# Business Logic — JKKWrisvcAutoAplyCCMapper.callDchskmTgSvcIcrnShokai() [210 LOC]

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

## 1. Role

### JKKWrisvcAutoAplyCCMapper.callDchskmTgSvcIcrnShokai()

This method serves as the data extraction target service inquiry bridge in the discount service auto-application (割引サービス自動適用) system. Its primary business role is to query the back-end Service Component (SC) for a list of eligible target services associated with a given data extraction item (データ抽出項目), so that the system can determine which discount services should be auto-applied to a customer's contract. Specifically, it receives a data extraction item code and a reference date (submitted year/month/day), constructs the SC query payload, invokes the `EKK1371B001` CBS (CallBack Service) to retrieve matching service records, and maps the results back into the working area map (`ccMapDchskm`). The method implements a request-response mapping pattern: it maps CC-side parameters to SC-side parameter keys, executes the SC via `ServiceComponentRequestInvoker`, then revers-maps the SC response into the CC-side data structures. It acts as a shared utility called by screen controllers during the data extraction item target service inquiry workflow — specifically called from `dslWribSvcTgKeiDchskmstTgKei` (for discount service target calculation statistics) and `searchWrisvcDchskmTgSvc` (for screen-based service list search).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callDchskmTgSvcIcrnShokai"])
    START --> S1["Build mapName from constants and renban"]
    S1 --> S2["Create new inMap"]
    S2 --> S3["Set inMap to cmnParam with mapName"]
    S3 --> S4["Put funcCd into inMap as FUNC_CODE"]
    S4 --> S5["Put MAX_SEARCH_NUM with default value 500"]
    S5 --> S6["Put KEY_DCHSKM_CD from ccMapDchskm.DCHSKM_CD"]
    S6 --> S7["Put KEY_KJN_YMD from ccMap.MSKM_YMD"]
    S7 --> S8["Create KKSV0313_EKK1371B001BSMapper"]
    S8 --> S9["mapper.editInMsg(cmnParam) -> paramMap"]
    S9 --> S10["scCall.run(paramMap, cmnHandle) -> result"]
    S10 --> S11["mapper.editResultRP(result, cmnParam)"]
    S11 --> S12["checkExecutionResult(result)"]
    S12 --> S13["outMap = cmnParam.getData(mapName)"]
    S13 --> S14["list = outMap.get EKK1371B001CBSMSG1LIST"]
    S14 --> S15["dchskmTgSvcList = ccMapDchskm.get DCHSKM_TG_SVC_LIST"]
    S15 --> S16{Is dchskmTgSvcList null?}
    S16 -- Yes --> S17["Create new ArrayList"]
    S17 --> S18["Put list into ccMapDchskm"]
    S16 -- No --> S19["Clear existing list"]
    S18 --> S20["Loop each item in list"]
    S19 --> S20
    S20 --> S21["Create ccMapDchskmTgSvc HashMap"]
    S21 --> S22["Copy 26 fields from service result"]
    S22 --> S23["Copy 5 additional fields"]
    S23 --> S24["Add to dchskmTgSvcList"]
    S24 --> S25{More items?}
    S25 -- Yes --> S21
    S25 -- No --> S26["Return dchskmTgSvcList"]
    S26 --> END(["Return"])
```

**Processing flow summary:**

1. **Parameter preparation (lines 5402–5426):** A unique map key (`mapName`) is constructed from the instance field `ccMapNm`, the SC key constant `KKSV031336SC`, and the sequence number `renban`. A new `inMap` is created and registered in the common parameter holder (`cmnParam`). Four keys are populated: the function code (`funcCd`), the maximum search count (default `"500"`), the data extraction item code from `ccMapDchskm`, and the application date from `ccMap`.

2. **Service Component invocation (lines 5431–5440):** An `EKK1371B001` BS mapper is instantiated. The input map is transformed via `editInMsg`, then executed through `ServiceComponentRequestInvoker.run()`. The result is mapped back via `editResultRP` and validated via `checkExecutionResult`.

3. **Result extraction and mapping (lines 5445–5587):** The SC response list (`EKK1371B001CBSMsg1List`) is extracted from `cmnParam`. For each record, 26 service detail fields are copied into a new target-service HashMap, which is then appended to the working area list. The list is returned to the caller.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `ccMap` | `HashMap<String, Object>` | The top-level working area (作業領域) map that holds the current processing context for the auto-application workflow. Contains `MSKM_YMD` (submitted year/month/day — 申込年月日) which serves as the reference date for querying eligible services. |
| 2 | `ccMapDchskm` | `HashMap<String, Object>` | A sub-map within `ccMap` representing a single data extraction item (データ抽出項目). Contains `DCHSKM_CD` (data extraction item code — データ抽出項目コード) used as the query key, and receives the result list `DCHSKM_TG_SVC_LIST` (data extraction target service list — データ抽出項目対象サービスリスト) after the method returns. |
| 3 | `funcCd` | `String` | The function code (機能コード) that identifies which business function is invoking this inquiry. Passed directly to the SC as `FUNC_CODE` to determine processing context. |
| 4 | `renban` | `String` | SC map sequence number (SCマップ連番) — a unique identifier used to distinguish multiple SC calls within a single screen flow. Incorporated into `mapName` to ensure each SC parameter map has a distinct key. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ccMapNm` | `String` | Base name prefix for SC parameter maps, used to construct the unique `mapName` key. |
| `cmnParam` | `JCCcomParam` | Common parameter holder — a shared state object that stores SC input/output maps keyed by `mapName`. |
| `cmnHandle` | Object | Common handle used by `ServiceComponentRequestInvoker` to execute the SC call. |

## 4. CRUD Operations / Called Services

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

The method primarily performs a **single Read (R)** operation against the back-end SC, with mapping/edit operations on the CC side.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `KKSV0313_KKSV0313OP_EKK1371B001BSMapper.editInMsg` | EKK1371B001 | - | Prepares the input message map for the SC call by transforming CC-side keys to SC-side keys. |
| R | `ServiceComponentRequestInvoker.run` | EKK1371B001 | Service component query (data extraction target service inquiry) | Executes the SC to retrieve the list of target services matching the data extraction item code and reference date. This is the primary data-read operation. |
| R | `KKSV0313_KKSV0313OP_EKK1371B001BSMapper.editResultRP` | EKK1371B001 | - | Maps the SC response back into CC-side data structures in `cmnParam`. |
| - | `JKKWrisvcAutoAplyCCMapper.checkExecutionResult` | - | - | Validates the SC execution result for errors/exceptions. |

**SC Details:**

The SC being invoked is **EKK1371B001** (part of the KKSV0313 screen module), which corresponds to the "Data Extraction Item Target Service Inquiry" (データ抽出項目対象サービス一覧照会) service. This CBS returns a list of service records (`EKK1371B001CBSMsg1List`), each containing service codes, pricing group codes, application conditions, and pre-change (before modification) service details.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | JKKWrisvcAutoAplyCC.dslWribSvcTgKeiDchskmstTgKei | `dslWribSvcTgKeiDchskmstTgKei()` -> `callDchskmTgSvcIcrnShokai` | `ServiceComponentRequestInvoker.run [R] EKK1371B001CBS` |
| 2 | JKKWrisvcAutoAplyCC.searchWrisvcDchskmTgSvc | `searchWrisvcDchskmTgSvc()` -> `callDchskmTgSvcIcrnShokai` | `ServiceComponentRequestInvoker.run [R] EKK1371B001CBS` |

**Downstream from this method:**

| # | Called Method | Terminal (SC / CRUD / Entity) |
|---|--------------|-------------------------------|
| 1 | `KKSV0313_KKSV0313OP_EKK1371B001BSMapper.editInMsg` | SC-side input mapping [-] |
| 2 | `ServiceComponentRequestInvoker.run` | EKK1371B001CBS [R] — data extraction target service list inquiry |
| 3 | `KKSV0313_KKSV0313OP_EKK1371B001BSMapper.editResultRP` | SC-side result mapping [-] |
| 4 | `JKKWrisvcAutoAplyCCMapper.checkExecutionResult` | Execution validation [-] |

## 6. Per-Branch Detail Blocks

**Block 1** — SET (Parameter preparation) (L5402)

> Constructs a unique map key and builds the SC input parameter map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapName = this.ccMapNm + "KKSV031336SC" + renban;` // Unique SC parameter map key [-> KKSV031336SC = "KKSV031336SC"] |
| 2 | SET | `inMap = new HashMap<String, Object>();` // New SC input map |
| 3 | EXEC | `this.cmnParam.setData(mapName, inMap);` // Register inMap in common parameter holder |
| 4 | SET | `inMap.put(FUNC_CODE, funcCd);` // Function code [-> FUNC_CODE = "func_code"] |
| 5 | SET | `inMap.put(MAX_SEARCH_NUM, MAX_SEARCH_NUM_DEFAULT);` // Max search count [-> MAX_SEARCH_NUM = "max_search_num", MAX_SEARCH_NUM_DEFAULT = "500"] |
| 6 | SET | `inMap.put(KEY_DCHSKM_CD, (String)ccMapDchskm.get(DCHSKM_CD));` // Data extraction item code [-> KEY_DCHSKM_CD = "key_dchskm_cd", DCHSKM_CD = "dchskm_cd"] |

**Block 2** — SET (Reference date for SC) (L5426)

> Sets the reference date used by the SC to filter eligible services. Originally used `opeDate` (online operation date) in pre-v3.00.00, but was changed to use the submitted application date (`MSKM_YMD`).

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(KEY_KJN_YMD, (String)ccMap.get(MSKM_YMD));` // Submitted date [-> KEY_KJN_YMD = "key_kjn_ymd", MSKM_YMD = "mskm_ymd"] |

**Block 3** — EXEC (Service Component invocation) (L5431–5440)

> Invokes the EKK1371B001 CBS (Data Extraction Item Target Service Inquiry) via the SC request infrastructure.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapper = new KKSV0313_KKSV0313OP_EKK1371B001BSMapper(mapName);` // Create SC mapper |
| 2 | CALL | `paramMap = mapper.editInMsg(this.cmnParam);` // Transform CC keys to SC keys |
| 3 | SET | `scCall = new ServiceComponentRequestInvoker();` // Create SC call handler |
| 4 | CALL | `result = scCall.run(paramMap, this.cmnHandle);` // Execute SC — primary data read [EKK1371B001] |
| 5 | SET | `this.cmnParam = mapper.editResultRP(result, this.cmnParam);` // Map SC result back to CC |
| 6 | CALL | `checkExecutionResult(result);` // Validate SC execution |

**Block 4** — SET (Result extraction) (L5445–5449)

> Extracts the SC response list from the common parameter holder and casts it to the expected type.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outMap = (HashMap<String, Object>)this.cmnParam.getData(mapName);` // Get SC response map |
| 2 | SET | `list = (ArrayList<HashMap<String, Object>>)outMap.get(EKK1371B001CBSMSG1LIST);` // Service list [-> EKK1371B001CBSMSG1LIST = "EKK1371B001CBSMsg1List"] |

**Block 5** — SET (Target service list preparation) (L5454–5459)

> Retrieves the target service list from the working area, creating it if null or clearing if it already exists.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dchskmTgSvcList = (ArrayList<HashMap<String, Object>>)ccMapDchskm.get(DCHSKM_TG_SVC_LIST);` // Get existing list [-> DCHSKM_TG_SVC_LIST = "dchskm_tg_svc_list"] |

**Block 5.1** — IF (Null check — create new list) (L5460)

| # | Type | Code |
|---|------|------|
| 1 | SET | `dchskmTgSvcList = new ArrayList<HashMap<String, Object>>();` // Create fresh list |
| 2 | SET | `ccMapDchskm.put(DCHSKM_TG_SVC_LIST, dchskmTgSvcList);` // Store in working area |

**Block 5.2** — ELSE (Clear existing list) (L5462)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `dchskmTgSvcList.clear();` // Clear previous results |

**Block 6** — FOR (Result field mapping loop) (L5461–5586)

> Iterates over each record from the SC response and copies all service detail fields into the target service HashMap. Each iteration creates one entry in `dchskmTgSvcList` representing a single eligible discount service.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMapDchskmTgSvc = new HashMap<String, Object>();` // New target service record |

**Block 6.1** — SET (Core service fields, L5467–L5496)

> Copies the primary service identification and pricing fields from the SC response.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMapDchskmTgSvc.put(DCHSKM_TG_SVC_CD, (String)outMapDchskmTgSvc.get(DCHSKM_TG_SVC_CD));` // [-> "dchskm_tg_svc_cd"] — Data extraction target service code |
| 2 | SET | `ccMapDchskmTgSvc.put(APLY_JOKEN_GRP, (String)outMapDchskmTgSvc.get(APLY_JOKEN_GRP));` // [-> "aply_joken_grp"] — Application condition group |
| 3 | SET | `ccMapDchskmTgSvc.put(SVC_CD, (String)outMapDchskmTgSvc.get(SVC_CD));` // [-> "svc_cd"] — Service code |
| 4 | SET | `ccMapDchskmTgSvc.put(PRC_GRP_CD, (String)outMapDchskmTgSvc.get(PRC_GRP_CD));` // [-> "prc_grp_cd"] — Pricing group code |
| 5 | SET | `ccMapDchskmTgSvc.put(PCRS_CD, (String)outMapDchskmTgSvc.get(PCRS_CD));` // [-> "pcrs_cd"] — Pricing code |
| 6 | SET | `ccMapDchskmTgSvc.put(PPLAN_CD, (String)outMapDchskmTgSvc.get(PPLAN_CD));` // [-> "pplan_cd"] — Pricing plan code |
| 7 | SET | `ccMapDchskmTgSvc.put(OP_SVC_CD, (String)outMapDchskmTgSvc.get(OP_SVC_CD));` // [-> "op_svc_cd"] — Option service code |
| 8 | SET | `ccMapDchskmTgSvc.put(SBOP_SVC_CD, (String)outMapDchskmTgSvc.get(SBOP_SVC_CD));` // [-> "sbop_svc_cd"] — Sub-option service code |
| 9 | SET | `ccMapDchskmTgSvc.put(KKTK_SVC_CD, (String)outMapDchskmTgSvc.get(KKTK_SVC_CD));` // [-> "kktk_svc_cd"] — Equipment provision service code |
| 10 | SET | `ccMapDchskmTgSvc.put(KKTK_SBT_CD, (String)outMapDchskmTgSvc.get(KKTK_SBT_CD));` // [-> "kktk_sbt_cd"] — Equipment provision type code |
| 11 | SET | `ccMapDchskmTgSvc.put(SEIOPSVC_CD, (String)outMapDchskmTgSvc.get(SEIOPSVC_CD));` // [-> "seiopsvc_cd"] — Billing option service code |

**Block 6.2** — SET (Pre-change service fields for modification scenarios, L5499–L5528)

> Copies the "before change" (変更前) variants of service codes, used when a service is being modified. These capture the original service state prior to the change.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMapDchskmTgSvc.put(CHGE_BF_SVC_CD, (String)outMapDchskmTgSvc.get(CHGE_BF_SVC_CD));` // [-> "chge_bf_svc_cd"] — Pre-change service code |
| 2 | SET | `ccMapDchskmTgSvc.put(CHGE_BF_PRC_GRP_CD, (String)outMapDchskmTgSvc.get(CHGE_BF_PRC_GRP_CD));` // [-> "chge_bf_prc_grp_cd"] — Pre-change pricing group code |
| 3 | SET | `ccMapDchskmTgSvc.put(CHGE_BF_PCRS_CD, (String)outMapDchskmTgSvc.get(CHGE_BF_PCRS_CD));` // [-> "chge_bf_pcrs_cd"] — Pre-change pricing code |
| 4 | SET | `ccMapDchskmTgSvc.put(CHGE_BF_PPLAN_CD, (String)outMapDchskmTgSvc.get(CHGE_BF_PPLAN_CD));` // [-> "chge_bf_pplan_cd"] — Pre-change pricing plan code |
| 5 | SET | `ccMapDchskmTgSvc.put(CHGE_BF_OP_SVC_CD, (String)outMapDchskmTgSvc.get(CHGE_BF_OP_SVC_CD));` // [-> "chge_bf_op_svc_cd"] — Pre-change option service code |
| 6 | SET | `ccMapDchskmTgSvc.put(CHGE_BF_SBOP_SVC_CD, (String)outMapDchskmTgSvc.get(CHGE_BF_SBOP_SVC_CD));` // [-> "chge_bf_sbop_svc_cd"] — Pre-change sub-option service code |
| 7 | SET | `ccMapDchskmTgSvc.put(CHGE_BF_KKTK_SVC_CD, (String)outMapDchskmTgSvc.get(CHGE_BF_KKTK_SVC_CD));` // [-> "chge_bf_kktk_svc_cd"] — Pre-change equipment provision service code |
| 8 | SET | `ccMapDchskmTgSvc.put(CHGE_BF_KKTK_SBT_CD, (String)outMapDchskmTgSvc.get(CHGE_BF_KKTK_SBT_CD));` // [-> "chge_bf_kktk_sbt_cd"] — Pre-change equipment provision type code |
| 9 | SET | `ccMapDchskmTgSvc.put(CHGE_BF_SEIOPSVC_CD, (String)outMapDchskmTgSvc.get(CHGE_BF_SEIOPSVC_CD));` // [-> "chge_bf_seiopsvc_cd"] — Pre-change billing option service code |

**Block 6.3** — REMOVED (v3.00.00) (L5531–L5535)

> The work task item code field (工事作業項目コード) was removed in v3.00.00. The corresponding `put` and `get` calls are commented out.

| # | Type | Code |
|---|------|------|
| 1 | SET | `// ccMapDchskmTgSvc.put(KOJI_WORK_KMK_CD, ...)` // Removed in v3.00.00 |

**Block 6.4** — SET (Service contract and eligibility fields, L5538–L5554)

> Copies contract duration, service count limits, and auto-application eligibility flags.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMapDchskmTgSvc.put(SVC_KEI_YEAR_CNT, (String)outMapDchskmTgSvc.get(SVC_KEI_YEAR_CNT));` // [-> "svc_kei_year_cnt"] — Service contract duration (years) |
| 2 | SET | `ccMapDchskmTgSvc.put(TRGT_KEI_SVC_CNT, (String)outMapDchskmTgSvc.get(TRGT_KEI_SVC_CNT));` // [-> "trgt_kei_svc_cnt"] — Target contract service count |
| 3 | SET | `ccMapDchskmTgSvc.put(TRGT_KEI_SVC_UPPL, (String)outMapDchskmTgSvc.get(TRGT_KEI_SVC_UPPL));` // [-> "trgt_kei_svc_uppl"] — Target contract service upper limit |
| 4 | SET | `ccMapDchskmTgSvc.put(TRGT_SVC_HAMBET_CD, (String)outMapDchskmTgSvc.get(TRGT_SVC_HAMBET_CD));` // [-> "trgt_svc_hambet_cd"] — Target service discrimination code |
| 5 | SET | `ccMapDchskmTgSvc.put(UPPL_AUTO_APLY_KH, (String)outMapDchskmTgSvc.get(UPPL_AUTO_APLY_KH));` // [-> "uppl_auto_aply_kh"] — Whether over-limit auto-application is permitted |

**Block 6.5** — SET (Add to result list) (L5557)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `dchskmTgSvcList.add(ccMapDchskmTgSvc);` // Append this target service record to the result list |

**Block 7** — RETURN (L5587)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return dchskmTgSvcList;` // Returns the populated list of target services |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `DCHSKM_CD` | Field | Data extraction item code — defines a set of query criteria for filtering discount services eligible for auto-application |
| `DCHSKM_TG_SVC_LIST` | Field | Data extraction target service list — the working area list that holds the query results after this method returns |
| `DCHSKM_TG_SVC_CD` | Field | Data extraction target service code — unique identifier for a service record in the query result |
| `APLY_JOKEN_GRP` | Field | Application condition group — groups services by the conditions under which they can be auto-applied |
| `SVC_CD` | Field | Service code — identifies a specific discount service type |
| `PRC_GRP_CD` | Field | Pricing group code — classifies the pricing structure for the service |
| `PCRS_CD` | Field | Pricing code — specifies the detailed pricing tier |
| `PPLAN_CD` | Field | Pricing plan code — identifies the billing plan associated with the service |
| `OP_SVC_CD` | Field | Option service code — identifies optional add-on services |
| `SBOP_SVC_CD` | Field | Sub-option service code — identifies sub-level optional services |
| `KKTK_SVC_CD` | Field | Equipment provision service code — identifies services involving equipment provision |
| `KKTK_SBT_CD` | Field | Equipment provision type code — classifies the type of equipment provision |
| `SEIOPSVC_CD` | Field | Billing option service code — identifies billing-related optional services |
| `MSKM_YMD` | Field | Submitted year/month/day (申込年月日) — the application date used as the reference date for SC queries |
| `KKSV031336SC` | Constant | HashMap key for "Data Extraction Item Target Service Inquiry" (データ抽出項目対象サービス一覧照会) — the SC mapping identifier |
| `EKK1371B001CBSMsg1List` | Constant | The SC response field name for the list of data extraction target service inquiry details |
| `FUNC_CODE` | Constant | Function code (機能コード) — identifies the invoking function context in the SC call |
| `MAX_SEARCH_NUM_DEFAULT` | Constant | Default value `"500"` for maximum search count parameter |
| KKSV0313 | Module | Discount service auto-application (割引サービス自動適用) screen module — part of the customer base system |
| EKK1371B001 | SC Code | Data Extraction Item Target Service Inquiry Service Component — queries the eligible service list for a given data extraction item |
| CC (Common Component) | Pattern | Shared utility class that handles SC parameter mapping and data transfer between screen and back-end |
| Data Extraction Item (データ抽出項目) | Domain | A query configuration entity that defines criteria for selecting eligible discount services from the customer database |
| Auto-application (自動適用) | Domain | The process of automatically applying discount services to a customer's contract based on eligibility criteria without manual intervention |
| Working Area (作業領域) | Domain | A HashMap-based temporary storage used to pass data between processing stages within a single screen flow |
| `mapName` | Field | Unique key constructed from `ccMapNm + "KKSV031336SC" + renban` to identify the SC parameter map in `cmnParam` |
| `renban` | Parameter | SC map sequence number (SCマップ連番) — ensures unique keys when multiple SC calls occur in the same flow |
