# Business Logic — JKKWrisvcAutoAplyCCMapper.callDchskmIcrnShokai() [207 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKWrisvcAutoAplyCCMapper` |
| Layer | CC / Common Component |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKWrisvcAutoAplyCCMapper.callDchskmIcrnShokai()

This method is the **data extraction item inquiry entry point** for the discount service automatic application workflow. Its primary business purpose is to call the "Data Extraction Item List Inquiry (Subscription Type Code)" service IF (EKK1351B003SC) and retrieve all data extraction item records whose conditions are satisfied at the base date, meaning the records qualify as candidates for automatic discount application.

The method follows a **map-mapping-delegate-mapping** design pattern: it first maps working-area parameters (ccMap) into service-component-format input, delegates to the SC-level CBS via a ServiceComponentRequestInvoker, then maps the SC response back into the working area's data extraction item list structure. This bidirectional mapping ensures loose coupling between the common component (CC) layer and the service component (SC) layer.

Its role in the larger system is as a **shared utility** consumed by the discount service automatic application control class (`JKKWrisvcAutoAplyCC.searchWrisvcDchskm()`). When the system determines that the inquiry target is a data extraction item (as opposed to a discount service), it dispatches to this method to populate the `dchskm_list` working area with all eligible data extraction items for the given subscription type, base date, and auto-apply context.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callDchskmIcrnShokai"])
    STEP1["Get mapName from ccMapNm + KKSV031331SC"]
    STEP2["Create inMap HashMap"]
    STEP3["cmnParam.setData mapName inMap"]
    STEP4["Common Info Mapping"]
    STEP4A["inMap.put FUNC_CODE funcCd"]
    STEP4B["inMap.put KEY_MSKM_SBT_CD ccMap.get MSKM_SBT_CD"]
    STEP4C["inMap.put KEY_BASE_YMD ccMap.get MSKM_YMD"]
    STEP4D["inMap.put KEY_DCHS_APLY_OPTNTY_CD 2"]
    STEP5["ServiceIF Execution"]
    STEP5A["Create EKK1351B003BSMapper"]
    STEP5B["paramMap mapper.editInMsg cmnParam"]
    STEP5C["scCall.run paramMap cmnHandle"]
    STEP5D["mapper.editResultRP result cmnParam"]
    STEP5E["checkExecutionResult result"]
    STEP6["CC Items Down Mapping"]
    STEP6A["outMap cmnParam.getData mapName"]
    STEP6B["list outMap.get EKK1351B003CBSMSG1LIST"]
    STEP6C["dchskmList ccMap.get DCHSKM_LIST"]
    COND1{"dchskmList is null"}
    STEP6D["dchskmList = new ArrayList"]
    STEP6E["dchskmList.clear"]
    LOOP1["For each outMapDchskm in list"]
    STEP7["ccMapDchskm = new HashMap"]
    STEP8["Map all data extraction fields"]
    STEP9["dchskmList.add ccMapDchskm"]
    RETURN(["return dchskmList"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP4A
    STEP4A --> STEP4B
    STEP4B --> STEP4C
    STEP4C --> STEP4D
    STEP4D --> STEP5
    STEP5 --> STEP5A
    STEP5A --> STEP5B
    STEP5B --> STEP5C
    STEP5C --> STEP5D
    STEP5D --> STEP5E
    STEP5E --> STEP6
    STEP6 --> STEP6A
    STEP6A --> STEP6B
    STEP6B --> STEP6C
    STEP6C --> COND1
    COND1 -- Yes --> STEP6D
    COND1 -- No --> STEP6E
    STEP6D --> LOOP1
    STEP6E --> LOOP1
    LOOP1 --> STEP7
    STEP7 --> STEP8
    STEP8 --> STEP9
    STEP9 --> RETURN
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `ccMap` | `HashMap<String, Object>` | Working area (作業領域) — the central shared data store passed across all CC methods. It contains subscription type code (`mskm_sbt_cd`), base year/month/day (`mskm_ymd`), and the target data extraction item list (`dchskm_list`). Values are read from this map as input and populated as output. |
| 2 | `funcCd` | `String` | Function code (機能コード) — identifies the calling business context. Passed through to the SC as `func_code` so the SC can apply function-specific logic. In the caller context, this is `DCHSKM_ICRN_FUNC_CD` (data extraction item inquiry function code). |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `this.ccMapNm` | `String` | Common parameter map name prefix — used as a namespace key for storing/retrieving data from the common parameter map |
| `this.cmnParam` | `CommonParameter` | Common parameter object — shared data container holding all mapped input/output data for SC calls |
| `this.cmnHandle` | `CommonHandle` | Common handle — system-level context handle passed to the SC for logging and transaction management |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C/R | `KKSV0313_KKSV0313OP_EKK1351B003BSMapper.editInMsg` | EKK1351B003SC | Data Extraction Item List Inquiry (Subscription Type Code) | Calls `editInMsg` to prepare service input parameters from common parameter map; triggers the SC query for eligible data extraction items |
| C/R | `ServiceComponentRequestInvoker.run` | EKK1351B003CBS | Data Extraction Item List Inquiry (Subscription Type Code) | Invokes the SC CBS to retrieve matching data extraction item records based on subscription type code, base date, and auto-apply priority code |
| U | `KKSV0313_KKSV0313OP_EKK1351B003BSMapper.editResultRP` | EKK1351B003SC | Data Extraction Item List Inquiry (Subscription Type Code) | Calls `editResultRP` to map SC response into common parameter map; populates the output data extraction item detail list |
| - | `JKKWrisvcAutoAplyCCMapper.checkExecutionResult` | - | - | Calls `checkExecutionResult` to validate SC execution results and throw exceptions if processing failed |

### Method Call Classification

| CRUD | Method | SC Code | Entity / DB | Description |
|------|--------|---------|-------------|-------------|
| R | `mapper.editInMsg(this.cmnParam)` | EKK1351B003SC | KK_T_DCHSKM (Data Extraction Items) | SC input preparation — maps CC working area params to SC input format for querying data extraction items |
| R | `scCall.run(paramMap, this.cmnHandle)` | EKK1351B003CBS | KK_T_DCHSKM | Core SC invocation — queries the data extraction items table for records matching subscription type code, base date, and auto-apply priority code "2" |
| U | `mapper.editResultRP(result, this.cmnParam)` | EKK1351B003SC | - | SC result mapping — transforms SC response into CC working area format |
| - | `checkExecutionResult(result)` | - | - | Validation — throws if the SC call encountered errors |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Controller:JKKWrisvcAutoAplyCC.searchWrisvcDchskm() | `searchWrisvcDchskm(ccMap, wribDchsSkbtFlag)` -> `getMapper().callDchskmIcrnShokai(ccMap, DCHSKM_ICRN_FUNC_CD)` | `EKK1351B003CBS [R] KK_T_DCHSKM` |

**Notes:**
- This method is called exclusively from `JKKWrisvcAutoAplyCC.searchWrisvcDchskm()`, which is the central search method for the discount service automatic application data extraction item screen.
- The caller determines the inquiry target type: when `wribDchsSkbtFlag` equals `WRIB_DCHS_SKBT_FLAG_DCHS`, it dispatches to `callDchskmIcrnShokai` to fetch data extraction item candidates.
- Terminal operations from this method: `editInMsg [R] KK_T_DCHSKM`, `run [R] KK_T_DCHSKM`, `editResultRP [U] -`, `checkExecutionResult [-]`, `getData [R] -`, `clear [-]`, `setData [-]`.

## 6. Per-Branch Detail Blocks

### Block 1 — INITIALIZATION (L4805)

> Initialize the common parameter map for the SC call. This prepares the input container that will be mapped to and from the service component.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapName = this.ccMapNm + KKSV031331_KKSV0313OP.KKSV031331SC` [-> "KKSV031331SC"] |
| 2 | SET | `inMap = new HashMap<String, Object>()` |
| 3 | EXEC | `this.cmnParam.setData(mapName, inMap)` // Store input map in common parameter |

### Block 2 — CC ITEMS TO SC ITEMS UPWARD MAPPING (L4813-4831)

> Maps common component working area values into the service component input parameter format. The comment reads: "CC items -> SC items upward mapping" (CC項目 -> SC項目 上げマッピング).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `inMap.put(FUNC_CODE, funcCd)` // [-> "func_code"] Function code passed to SC |
| 2 | EXEC | `inMap.put(KKSV031331SC.KEY_MSKM_SBT_CD, (String)ccMap.get(KKSV031331OP_WORK.MSKM_SBT_CD))` // [-> "key_mskm_sbt_cd"] Subscription type code from working area [-> "mskm_sbt_cd"] |
| 3 | EXEC | `inMap.put(KKSV031331SC.KEY_BASE_YMD, (String)ccMap.get(KKSV031331OP_WORK.MSKM_YMD))` // [-> "key_base_ymd"] Base year/month/day from working area [-> "mskm_ymd"] |
| 4 | SET | `/* v3.00.00 Change Start */` // Replaced `this.opeDate` with `ccMap.get(MSKM_YMD)` for online operation support |
| 5 | SET | `/* v3.00.00 Change End */` |
| 6 | EXEC | `inMap.put(KKSV031331SC.KEY_DCHS_APLY_OPTNTY_CD, KKSV031331OP_WRISVC_AUTO_APLY_CC.WRIB_APLY_OPTNTY_CD_AUTO_APLY)` // [-> "key_dchs_aply_optnty_cd"] Hardcoded to "2" (Auto Apply) [-> "WRIB_APLY_OPTNTY_CD_AUTO_APLY" = "2"] |

### Block 3 — SERVICE IF EXECUTION (L4833-4846)

> Executes the SC-level service. This is the core data retrieval step. The comment reads: "ServiceIF execution" (サービスIF実行).

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapper = new KKSV0313_KKSV0313OP_EKK1351B003BSMapper(mapName)` |
| 2 | SET | `paramMap = mapper.editInMsg(this.cmnParam)` // SC input mapping |
| 3 | SET | `scCall = new ServiceComponentRequestInvoker()` |
| 4 | SET | `result = scCall.run(paramMap, this.cmnHandle)` // SC CBS execution |
| 5 | SET | `this.cmnParam = mapper.editResultRP(result, this.cmnParam)` // SC response mapping |
| 6 | EXEC | `checkExecutionResult(result)` // Error validation |

### Block 4 — CC ITEMS TO SC ITEMS DOWNWARD MAPPING (L4848-4989)

> Maps SC output back into the CC working area data extraction item list. The comment reads: "CC items <- SC items downward mapping" (CC項目 <- SC項目 下げマッピング).

| # | Type | Code |
|---|------|------|
| 1 | SET | `outMap = (HashMap<String, Object>)this.cmnParam.getData(mapName)` |
| 2 | SET | `list = (ArrayList<HashMap<String, Object>>)outMap.get(KKSV031331SC_EKK1351B003CBSMsg1List.EKK1351B003CBSMSG1LIST)` |
| 3 | SET | `dchskmList = (ArrayList<HashMap<String, Object>>)ccMap.get(KKSV031331OP_WORK.DCHSKM_LIST)` // [-> "dchskm_list"] |
| 4 | COND | `if (dchskmList == null)` // Initialize list if not present in working area |
| 5 | SET | `dchskmList = new ArrayList<HashMap<String, Object>>(); ccMap.put(KKSV031331OP_WORK.DCHSKM_LIST, dchskmList)` |
| 6 | ELSE | `dchskmList.clear()` // Reuse existing list |

### Block 5 — FOR LOOP: Field Mapping (L4892-4989)

> Iterates over each data extraction item record returned by the SC and maps every field from the SC output format to the CC working area format. The comment reads: "Add to working area data extraction item list" (作業領域.データ抽出項目リストに追加).

**Block 5** — FOR loop `(for (HashMap<String, Object> outMapDchskm : list))` (L4892)

> Create a new CC-format HashMap for each SC record and map all data extraction item fields.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMapDchskm = new HashMap<String, Object>()` |
| 2 | SET | `ccMapDchskm.put(DCHSKM_CD, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.DCHSKM_CD))` // [-> "DCHSKM_CD" = "dchskm_cd"] [-> "dchskm_cd"] Data extraction item code |
| 3 | SET | `ccMapDchskm.put(DCHS_TYPE_CD, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.DCHS_TYPE_CD))` // [-> "DCHS_TYPE_CD" = "dchs_type_cd"] [-> "dchs_type_cd"] Data extraction type code |
| 4 | SET | `ccMapDchskm.put(DCHS_SBT_CD, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.DCHS_SBT_CD))` // [-> "DCHS_SBT_CD" = "dchs_sbt_cd"] [-> "dchs_sbt_cd"] Data extraction subtype code |
| 5 | SET | `ccMapDchskm.put(DCHSKM_STA_CD, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.DCHSKM_STA_CD))` // [-> "DCHSKM_STA_CD" = "dchskm_sta_cd"] [-> "dchskm_sta_cd"] Data extraction item start code |
| 6 | SET | `ccMapDchskm.put(STA_ADJ_CD, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.STA_ADJ_CD))` // [-> "STA_ADJ_CD" = "sta_adj_cd"] [-> "sta_adj_cd"] Start adjustment code |
| 7 | SET | `ccMapDchskm.put(STA_ADJ, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.STA_ADJ_PRD))` // [-> "STA_ADJ" = "sta_adj"] [-> "sta_adj_prd"] Start adjustment period (v3.00.00: changed from STA_ADJ to STA_ADJ_PRD) |
| 8 | SET | `/* v3.00.00 Change: removed unused priority type model/category/type/type order fields */` |
| 9 | SET | `ccMapDchskm.put(DCHSKM_END_CD, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.DCHSKM_END_CD))` // [-> "DCHSKM_END_CD" = "dchskm_end_cd"] [-> "dchskm_end_cd"] Data extraction item end code |
| 10 | SET | `ccMapDchskm.put(UPPL_APLY_CNT, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.UPPL_APLY_CNT))` // [-> "UPPL_APLY_CNT" = "uppl_aply_cnt"] [-> "uppl_aply_cnt"] Upper limit application count |
| 11 | SET | `ccMapDchskm.put(DCHSKM_AGING_PRD, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.DCHSKM_AGING_PRD))` // [-> "DCHSKM_AGING_PRD" = "dchskm_aging_prd"] [-> "dchskm_aging_prd"] Data extraction aging period |
| 12 | SET | `ccMapDchskm.put(UPPL_KEI_CNT, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.UPPL_KEI_CNT))` // [-> "UPPL_KEI_CNT" = "uppl_kei_cnt"] [-> "uppl_kei_cnt"] Upper limit contract count |
| 13 | SET | `ccMapDchskm.put(DSP_JUN, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.DSP_JUN))` // [-> "DSP_JUN" = "dsp_jun"] [-> "dsp_jun"] Display order |
| 14 | SET | `ccMapDchskm.put(APLY_CNT_HAMBET_CD, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.APLY_CNT_HAMBET_CD))` // [-> "APLY_CNT_HAMBET_CD" = "aply_cnt_hambet_cd"] [-> "aply_cnt_hambet_cd"] Application count discrimination code |
| 15 | SET | `ccMapDchskm.put(APLY_CNT, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.APLY_CNT))` // [-> "APLY_CNT" = "aply_cnt"] [-> "aply_cnt"] Application count |
| 16 | SET | `ccMapDchskm.put(APLY_JOKEN_CD, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.APLY_JOKEN_CD))` // [-> "APLY_JOKEN_CD" = "aply_joken_cd"] [-> "aply_joken_cd"] Application condition code |
| 17 | SET | `ccMapDchskm.put(DCHS_ADD_JOKEN_CD, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.DCHS_ADD_JOKEN_CD))` // [-> "DCHS_ADD_JOKEN_CD" = "dchs_add_joken_cd"] [-> "dchs_add_joken_cd"] Data extraction registration condition code |
| 18 | SET | `ccMapDchskm.put(DCHSKM_NM, (String)outMapDchskm.get(EKK1351B003CBSMsg1List.DCHSKM_NM))` // [-> "DCHSKM_NM" = "dchskm_nm"] [-> "dchskm_nm"] Data extraction item name (v3.00.00: new field) |
| 19 | EXEC | `dchskmList.add(ccMapDchskm)` // Add mapped item to output list |

### Block 6 — RETURN (L4989)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return dchskmList` // Returns the populated data extraction item list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `dchskm` | Field Prefix | Data Extraction Item (データ抽出項目) — a record defining a candidate for automatic discount application, with its own attributes and conditions |
| `mskm_sbt_cd` | Field | Subscription Type Code (申込種別コード) — classifies the type of service subscription (e.g., new contract, renewal, modification) |
| `mskm_ymd` | Field | Subscription Year/Month/Day (申込年月日) — the reference date used to determine which data extraction item records are valid at that point in time |
| `dchskm_cd` | Field | Data Extraction Item Code (データ抽出項目コード) — unique identifier for a data extraction item record |
| `dchs_type_cd` | Field | Data Extraction Type Code (データ抽出タイプコード) — categorizes the type of data extraction item |
| `dchs_sbt_cd` | Field | Data Extraction Subtype Code (データ抽出種別コード) — further classifies the data extraction item |
| `dchskm_sta_cd` | Field | Data Extraction Item Start Code (データ抽出項目開始コード) — indicates the start status of a data extraction item |
| `sta_adj_cd` | Field | Start Adjustment Code (開始調整コード) — code for adjusting the effective start timing of a data extraction item |
| `sta_adj_prd` | Field | Start Adjustment Period (開始調整期間) — the time period of start adjustment |
| `dchskm_end_cd` | Field | Data Extraction Item End Code (データ抽出項目終了コード) — indicates the end/discontinuation status |
| `uppl_aply_cnt` | Field | Upper Limit Application Count (上限適用回数) — maximum number of times this item can be applied |
| `dchskm_aging_prd` | Field | Data Extraction Aging Period (データ抽出項目エイジング期間) — aging period threshold for the data extraction item |
| `uppl_kei_cnt` | Field | Upper Limit Contract Count (上限契約数) — maximum number of contracts this item can be applied to |
| `dsp_jun` | Field | Display Order (表示順) — sort order for displaying data extraction items on screens |
| `aply_cnt_hambet_cd` | Field | Application Count Discrimination Code (適用数判別コード) — code determining how application count is evaluated |
| `aply_cnt` | Field | Application Count (適用数) — current number of times this item has been applied |
| `aply_joken_cd` | Field | Application Condition Code (適用条件コード) — conditions under which this item can be applied |
| `dchs_add_joken_cd` | Field | Data Extraction Registration Condition Code (データ抽出登録条件コード) — conditions for registering this data extraction item |
| `dchskm_nm` | Field | Data Extraction Item Name (データ抽出項目名) — human-readable name of the data extraction item (v3.00.00 addition) |
| `WRIB_APLY_OPTNTY_CD_AUTO_APLY` | Constant | Discount Application Priority Code: Auto Apply (割引適用契機コード（自動適用）) = "2" — indicates automatic application priority |
| `KKSV031331SC` | Constant | Data Extraction Item List Inquiry (Subscription Type Code) (データ抽出項目一覧照会（申込種別コード）) — SC identifier |
| `EKK1351B003SC` | SC Code | Data Extraction Item List Inquiry (Subscription Type Code) Service Component |
| `EKK1351B003CBS` | CBS Code | Data Extraction Item List Inquiry (Subscription Type Code) Common Business Service |
| `EKK1351B003CBSMSG1LIST` | Constant | Data Extraction Item List Inquiry (Subscription Type Code) Detail (データ抽出項目一覧照会（申込種別コード）詳細) — output key for the item detail list |
| `FUNC_CODE` | Constant | "func_code" — map key for the function code parameter |
| `dchskm_list` | Field | Data Extraction Item List (データ抽出項目リスト) — working area list holding all qualifying data extraction items |
| KKSV0313 | Module | Discount Service Automatic Application (割引サービス自動適用) — system module for automatic discount application to K-Opticom subscriber contracts |
| CC | Acronym | Common Component — the shared controller/common layer in the Fujitsu Futurity framework |
| SC | Acronym | Service Component — a reusable business logic component with standardized input/output |
| CBS | Acronym | Common Business Service — the service-level execution layer that processes SC requests |
| ICRN | Acronym | Introduction/Registration (紹介) — part of the service IF naming, indicating inquiry/registration operations |
| WRIB | Acronym | Discount/Reduction (割引) — domain prefix for discount-related items |
| Auto Apply | Business term | Automatic discount application — the system automatically selects and applies discount conditions that match customer criteria without manual intervention |
