# Business Logic — JKKWrisvcAutoAplyCCMapper.callWribSvcIcrnShokai() [206 LOC]

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

## 1. Role

### JKKWrisvcAutoAplyCCMapper.callWribSvcIcrnShokai()

This method serves as the central **discount service auto-application candidate retrieval** entry point within K-Opticom's telecommunications customer management system. It orchestrates the complete lifecycle of querying available discount services that a customer is eligible for based on their subscription details and a specified reference date.

The method performs three distinct business phases: first, it maps CC (control component) domain parameters — including the reference date (基準年月日), the function code (機能コード), a hard-coded auto-application trigger code ("2"), and the subscription type code (申込種別コード) — into a standardized SC (service component) request payload. Second, it delegates to the underlying SC `EKK0841B003BSMapper` to invoke the discount service list inquiry service (割引サービス一覧照会サービスIF), which queries the database for all discount service records whose eligibility conditions are satisfied against the provided reference date and subscription type. Third, it retrieves the structured result list and transforms each SC-level discount service record into the CC-level work area format, extracting only the active fields (the removed v2.00–3.00 fields like discount type code, campaign codes, and agency codes are excluded per the v3.00.00 spec change).

This method implements the **mapper/delegation pattern**: it never contains business query logic itself but acts as a translation and orchestration layer between the caller (e.g., `JKKPrcSimulationCC.searchWribSvc`) and the SC `EKK0841B003BS`. Its role in the larger system is to populate the `wrib_svc_list` field in the shared work area (`ccMap`), which downstream auto-application logic then iterates to determine which discount services to apply to the customer's contract.

The method contains no conditional branching on the `funcCd` parameter or other multi-path logic — it is a single-path, linear orchestration with one data-iteration loop over the result list.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callWribSvcIcrnShokai ccMap, funcCd"])
    SETUP["Build mapName = ccMapNm + KKSV031301SC"]
    INMAP["Create inMap HashMap"]
    CMNSET["cmnParam.setData mapName, inMap"]
    FCODE["inMap.put FUNC_CODE = funcCd"]
    KJNYMD["inMap.put KEY_KJNYMD = ccMap.get MSKM_YMD"]
    APLY_OPTNTY["inMap.put KEY_WRIB_APLY_OPTNTY_CD = WRIB_APLY_OPTNTY_CD_AUTO_APLY = 2"]
    MSKM_SBT["inMap.put KEY_MSKM_SBT_CD = ccMap.get MSKM_SBT_CD"]
    MAPPER["Create KKSV0313_KKSV0313OP_EKK0841B003BSMapper mapName"]
    EDITIN["mapper.editInMsg cmnParam -> paramMap"]
    INVCALL["ServiceComponentRequestInvoker scCall = new"]
    RUN["scCall.run paramMap cmnHandle -> result"]
    EDITRP["cmnParam = mapper.editResultRP result cmnParam"]
    CHECK["checkExecutionResult result"]
    GETOUT["outMap = cmnParam.getData mapName"]
    GETLIST["list = outMap.get EKK0841B003CBSMSG1LIST"]
    GETWSRVLST["wribSvcList = ccMap.get WRIB_SVC_LIST"]
    WSRVLSTNULL{"wribSvcList == null?"}
    INITWSRV["wribSvcList = new ArrayList; ccMap.put WRIB_SVC_LIST"]
    CLEARWSRV["wribSvcList.clear"]
    FORSTART["for outMapWribSvc in list"]
    CCMAP["ccMapWribSvc = new HashMap"]
    PUT_SVC_CD["ccMapWribSvc.put WRIB_SVC_CD -> outMapWribSvc WRIB_SVC_CD"]
    PUT_TYPE_CD["ccMapWribSvc.put WRIB_TYPE_CD -> outMapWribSvc WRIB_TYPE_CD"]
    PUT_UPPL["ccMapWribSvc.put UPPL_APLY_CNT -> outMapWribSvc UPPL_APLY_CNT"]
    PUT_AGING["ccMapWribSvc.put WRIB_AGING_PRD -> outMapWribSvc WRIB_AGING_PRD"]
    PUT_KEI["ccMapWribSvc.put UPPL_KEI_CNT -> outMapWribSvc UPPL_KEI_CNT"]
    PUT_JUN["ccMapWribSvc.put DSP_JUN -> outMapWribSvc DSP_JUN"]
    PUT_YMDL["ccMapWribSvc.put YUSEN_JUN_MDL_CD -> outMapWribSvc YUSEN_JUN_MDL_CD"]
    PUT_YKND["ccMapWribSvc.put YUSEN_JUN_KIND_CD -> outMapWribSvc YUSEN_JUN_KIND_CD"]
    PUT_YTYP["ccMapWribSvc.put YUSEN_JUN_TYPE_CD -> outMapWribSvc YUSEN_JUN_TYPE_CD"]
    PUT_YJUN["ccMapWribSvc.put YUSEN_JUN_TYPE_JUN -> outMapWribSvc YUSEN_JUN_TYPE_JUN"]
    PUT_APLJ["ccMapWribSvc.put APLY_JOKEN_CD -> outMapWribSvc APLY_JOKEN_CD"]
    PUT_WRADJ["ccMapWribSvc.put WRIB_ADD_JOKEN_CD -> outMapWribSvc WRIB_ADD_JOKEN_CD"]
    PUT_SVCNM["ccMapWribSvc.put WRIB_SVC_NM -> outMapWribSvc WRIB_SVC_NM"]
    ADDLST["wribSvcList.add ccMapWribSvc"]
    RETLST["return wribSvcList"]

    START --> SETUP --> INMAP --> CMNSET --> FCODE --> KJNYMD --> APLY_OPTNTY --> MSKM_SBT --> MAPPER --> EDITIN --> INVCALL --> RUN --> EDITRP --> CHECK --> GETOUT --> GETLIST --> GETWSRVLST --> WSRVLSTNULL
    WSRVLSTNULL -- Yes --> INITWSRV --> FORSTART
    WSRVLSTNULL -- No --> CLEARWSRV --> FORSTART
    FORSTART --> CCMAP --> PUT_SVC_CD --> PUT_TYPE_CD --> PUT_UPPL --> PUT_AGING --> PUT_KEI --> PUT_JUN --> PUT_YMDL --> PUT_YKND --> PUT_YTYP --> PUT_YJUN --> PUT_APLJ --> PUT_WRADJ --> PUT_SVCNM --> ADDLST
    ADDLST --> FORSTART
    FORSTART --> RETLST
```

**Processing phases:**

**Phase 1 — CC-to-SC Upper Mapping (lines 343–373):** Constructs the input parameter map for the SC by extracting the reference date (`mskm_ymd`) and subscription type code (`mskm_sbt_cd`) from the caller's `ccMap`, hard-coding the auto-application opportunity code to `"2"`, and passing through the `funcCd`.

**Phase 2 — Service IF Execution (lines 379–392):** Instantiates the `KKSV0313_KKSV0313OP_EKK0841B003BSMapper`, maps the input parameters into the SC request format via `editInMsg`, executes the SC via `ServiceComponentRequestInvoker.run()`, maps the SC response back to the CC work area via `editResultRP`, and validates the result with `checkExecutionResult`.

**Phase 3 — SC-to-CC Lower Mapping (lines 397–539):** Extracts the result list from the work area, ensures the `wrib_svc_list` container exists in `ccMap`, and iterates over each SC discount service record to copy the active fields into the CC-level work map. Removed fields (discount type, campaign codes, agency codes) are excluded per v3.00.00 spec changes.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `ccMap` | `HashMap<String, Object>` | The shared work area (作業領域) used across the control component lifecycle. Contains business input data including `mskm_ymd` (申込年月日 — the contract application date used as the reference date for discount eligibility), `mskm_sbt_cd` (申込種別コード — the subscription type code that determines which discount service categories apply), and serves as both input source and output sink (the `wrib_svc_list` key is populated with the returned discount service candidates). |
| 2 | `funcCd` | `String` | Function code (機能コード) passed through to the SC layer. Identifies which functional context the SC inquiry is being made under. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ccMapNm` | `String` | The CC map name prefix used to construct the full SC work area name (`ccMapNm + KKSV031301SC`). Set by `setFixedText` during mapper initialization. |
| `cmnParam` | `IRequestParameterReadWrite` | The shared request parameter read/write interface that stores the work area data across the SC call. |
| `cmnHandle` | `Object` | The common handle used by `ServiceComponentRequestInvoker` to execute the SC. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| I | `KKSV0313_KKSV0313OP_EKK0841B003BSMapper.editInMsg` | EKK0841B003BS | — | Input message mapping — translates CC-level work area parameters into the SC request message format. Internally maps `func_code`, `key_kjnymd` (reference date), `key_wrib_aply_optnty_cd` = "2" (auto-application), and `key_mskm_sbt_cd` (subscription type code) to SC fields. |
| C | `ServiceComponentRequestInvoker.run` | EKK0841B003CBS | KK_T_WRIB_SVC (割引サービスマスタ), KK_T_WRIB_SVC_DCHSKM (割引サービス detail) | Service Component execution — queries the discount service master and detail tables to find all discount service records where the eligibility conditions match the reference date, auto-application opportunity code, and subscription type code. Returns a list of discount service records. |
| U | `KKSV0313_KKSV0313OP_EKK0841B003BSMapper.editResultRP` | EKK0841B003BS | — | Result response mapping — transforms the SC response into the CC work area format, populating the `EKK0841B003CBSMsg1List` key with the list of discount service records. |
| - | `JKKWrisvcAutoAplyCCMapper.checkExecutionResult` | — | — | Validates the SC execution result for errors/exceptions. Throws if the result indicates a failure condition. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKPrcSimulationCC.searchWribSvc` | `JKKPrcSimulationCC.searchWribSvc` -> `JKKWrisvcAutoAplyCCMapper.callWribSvcIcrnShokai` | `run [C] KK_T_WRIB_SVC`, `editInMsg [I] SC request`, `editResultRP [U] work area` |

**Terminal operations reached from this method:** `editInMsg` [I], `run` [C], `editResultRP` [U], `checkExecutionResult` [-].

## 6. Per-Branch Detail Blocks

**Block 1** — [SETUP / PARAMETER MAPPING] (L343)

> Constructs the SC input parameter map by mapping CC-level fields to SC-level field names. This is the "CC items → SC items upper mapping" phase.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapName = this.ccMapNm + KKSV0313_KKSV0313OP.KKSV031301SC` | [-> KKSV031301SC = "KKSV031301SC"] Builds the full SC work area name |
| 2 | SET | `inMap = new HashMap<String, Object>()` | Creates the SC input parameter map |
| 3 | EXEC | `this.cmnParam.setData(mapName, inMap)` | Stores inMap in cmnParam under mapName |
| 4 | SET | `inMap.put(FUNC_CODE, funcCd)` | [-> FUNC_CODE = "func_code"] Maps function code to SC |
| 5 | SET | `inMap.put(KEY_KJNYMD, (String) ccMap.get(MSKM_YMD))` | [-> KEY_KJNYMD = "key_kjnymd", MSKM_YMD = "mskm_ymd"] Reference date (基準年月日) from the work area. The original online operation date (`this.opeDate`) was replaced in v3.00.00 to use the contract application date instead. |
| 6 | SET | `inMap.put(KEY_WRIB_APLY_OPTNTY_CD, WRIB_APLY_OPTNTY_CD_AUTO_APLY)` | [-> KEY_WRIB_APLY_OPTNTY_CD = "key_wrib_aply_optnty_cd", WRIB_APLY_OPTNTY_CD_AUTO_APLY = "2"] Hard-coded auto-application opportunity code |
| 7 | SET | `inMap.put(KEY_MSKM_SBT_CD, (String) ccMap.get(MSKM_SBT_CD))` | [-> KEY_MSKM_SBT_CD = "key_mskm_sbt_cd", MSKM_SBT_CD = "mskm_sbt_cd"] Subscription type code from the work area |

**Block 2** — [SERVICE IF EXECUTION] (L379)

> Executes the SC `EKK0841B003BS` which performs the actual discount service eligibility query. This is the "Service IF execution" phase.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapper = new KKSV0313_KKSV0313OP_EKK0841B003BSMapper(mapName)` | Instantiates the SC mapper |
| 2 | SET | `paramMap = mapper.editInMsg(this.cmnParam)` | Maps CC params to SC request message |
| 3 | SET | `scCall = new ServiceComponentRequestInvoker()` | Creates the SC invocation handler |
| 4 | SET | `result = scCall.run(paramMap, this.cmnHandle)` | Executes the SC and retrieves the result |
| 5 | SET | `this.cmnParam = mapper.editResultRP(result, this.cmnParam)` | Maps SC result back to CC work area |
| 6 | EXEC | `checkExecutionResult(result)` | Validates execution result; throws on error |

**Block 3** — [SC-TO-CC LOWER MAPPING / RESULT TRANSFORMATION] (L397)

> Extracts the SC response list and transforms each record into CC-level format. This is the "CC items <- SC items lower mapping" phase.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outMap = (HashMap) this.cmnParam.getData(mapName)` | Retrieves the mapped SC result from cmnParam |
| 2 | SET | `list = (ArrayList) outMap.get(EKK0841B003CBSMSG1LIST)` | [-> EKK0841B003CBSMSG1LIST = "EKK0841B003CBSMsg1List"] Extracts the discount service result list |
| 3 | SET | `wribSvcList = (ArrayList) ccMap.get(WRIB_SVC_LIST)` | [-> WRIB_SVC_LIST = "wrib_svc_list"] Gets existing list from work area |

**Block 3.1** — [IF wribSvcList == null] (L415)

> Initialization branch: if no discount service list exists yet in the work area, create a new one.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wribSvcList = new ArrayList<HashMap<String, Object>>()` | Creates a new empty list |
| 2 | SET | `ccMap.put(WRIB_SVC_LIST, wribSvcList)` | Stores the new list in work area |

**Block 3.2** — [ELSE wribSvcList exists] (L419)

> Reuse branch: if a list already exists, clear it for reuse.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `wribSvcList.clear()` | Clears existing list contents |

**Block 4** — [FOR loop over list items] (L423)

> Iterates over each discount service record returned by the SC and maps its fields to the CC-level work map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMapWribSvc = new HashMap<String, Object>()` | Creates a new CC discount service map |
| 2 | SET | `ccMapWribSvc.put(WRIB_SVC_CD, outMapWribSvc.get(WRIB_SVC_CD))` | [-> WRIB_SVC_CD = "wrib_svc_cd"] Discount service code |
| 3 | SET | `ccMapWribSvc.put(WRIB_TYPE_CD, outMapWribSvc.get(WRIB_TYPE_CD))` | [-> WRIB_TYPE_CD = "wrib_type_cd"] Discount type code |
| 4 | SET | `ccMapWribSvc.put(UPPL_APLY_CNT, outMapWribSvc.get(UPPL_APLY_CNT))` | [-> UPPL_APLY_CNT = "uppl_aply_cnt"] Maximum application count |
| 5 | SET | `ccMapWribSvc.put(WRIB_AGING_PRD, outMapWribSvc.get(WRIB_AGING_PRD))` | [-> WRIB_AGING_PRD = "wrib_aging_prd"] Discount aging period |
| 6 | SET | `ccMapWribSvc.put(UPPL_KEI_CNT, outMapWribSvc.get(UPPL_KEI_CNT))` | [-> UPPL_KEI_CNT = "uppl_kei_cnt"] Maximum contract count |
| 7 | SET | `ccMapWribSvc.put(DSP_JUN, outMapWribSvc.get(DSP_JUN))` | [-> DSP_JUN = "dsp_jun"] Display order |
| 8 | SET | `ccMapWribSvc.put(YUSEN_JUN_MDL_CD, outMapWribSvc.get(YUSEN_JUN_MDL_CD))` | [-> YUSEN_JUN_MDL_CD = "yusen_jun_mdl_cd"] Priority ranking model code |
| 9 | SET | `ccMapWribSvc.put(YUSEN_JUN_KIND_CD, outMapWribSvc.get(YUSEN_JUN_KIND_CD))` | [-> YUSEN_JUN_KIND_CD = "yusen_jun_kind_cd"] Priority ranking type code |
| 10 | SET | `ccMapWribSvc.put(YUSEN_JUN_TYPE_CD, outMapWribSvc.get(YUSEN_JUN_TYPE_CD))` | [-> YUSEN_JUN_TYPE_CD = "yusen_jun_type_cd"] Priority ranking type code |
| 11 | SET | `ccMapWribSvc.put(YUSEN_JUN_TYPE_JUN, outMapWribSvc.get(YUSEN_JUN_TYPE_JUN))` | [-> YUSEN_JUN_TYPE_JUN = "yusen_jun_type_jun"] Priority ranking type order |
| 12 | SET | `ccMapWribSvc.put(APLY_JOKEN_CD, outMapWribSvc.get(APLY_JOKEN_CD))` | [-> APLY_JOKEN_CD = "aply_joken_cd"] Application condition code |
| 13 | SET | `ccMapWribSvc.put(WRIB_ADD_JOKEN_CD, outMapWribSvc.get(WRIB_ADD_JOKEN_CD))` | [-> WRIB_ADD_JOKEN_CD = "wrib_add_joken_cd"] Discount registration condition code |
| 14 | SET | `ccMapWribSvc.put(WRIB_SVC_NM, outMapWribSvc.get(WRIB_SVC_NM))` | [-> WRIB_SVC_NM = "wrib_svc_nm"] Discount service name (newly added in v3.00.00) |
| 15 | EXEC | `wribSvcList.add(ccMapWribSvc)` | Adds the mapped CC discount service to the result list |

**Removed fields (v3.00.00 deletion comments):** The following fields were stripped from the mapping in v3.00.00 per specification changes — they exist in the SC response but are no longer mapped to the CC work area:

| Field | Reason |
|-------|--------|
| `WRIB_SBT_CD` (割引種別コード) | Removed in v3.00.00 |
| `CAMPAIGN_STA_CD` (キャンペーン開始コード) | Removed in v3.00.00 |
| `STA_ADJ_CD` (開始調整コード) | Removed in v3.00.00 |
| `STA_ADJ` (開始調整期間) | Removed in v3.00.00 |
| `CAMPAIGN_END_CD` (キャンペーン終了コード) | Removed in v3.00.00 |
| `APLY_CNT_HAMBET_CD` (適用数判別コード) | Removed in v3.00.00 |
| `APLY_CNT` (適用数) | Removed in v3.00.00 |
| `AGNT_CD` (代理店コード) | Removed in v3.00.00 |
| `MSKM_FORM_CD` (申込形態コード) | Removed in v3.00.00 |
| `GRP_SBT_CD` (グルーポン種別コード) | Removed in v3.00.00 |
| `INTR_SBT_CD` (紹介種別コード) | Removed in v3.00.00 |

**Block 5** — [RETURN] (L541)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return wribSvcList` | Returns the populated discount service list to the caller |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mskm_ymd` | Field | Contract application date (申込年月日) — the date the customer submitted their contract application; used as the reference date for evaluating discount service eligibility |
| `mskm_sbt_cd` | Field | Subscription type code (申込種別コード) — classifies the type of contract application (e.g., new subscription, modification, renewal) |
| `wrib_svc_cd` | Field | Discount service code (割引サービスコード) — unique identifier for a discount service offering |
| `wrib_type_cd` | Field | Discount type code (割引タイプコード) — categorizes the type of discount (e.g., percentage-based, fixed-amount) |
| `wrib_svc_nm` | Field | Discount service name (割引サービス名) — human-readable name of the discount service; added in v3.00.00 |
| `uppl_aply_cnt` | Field | Maximum application count (上限適用回数) — the maximum number of times this discount can be applied |
| `wrib_aging_prd` | Field | Discount aging period (割引エイジング期間) — the aging/delay period for the discount |
| `uppl_kei_cnt` | Field | Maximum contract count (上限契約数) — the maximum number of contracts this discount can apply to |
| `dsp_jun` | Field | Display order (表示順) — the order in which discount services should be displayed to users |
| `yusen_jun_mdl_cd` | Field | Priority ranking model code (割引優先順位型コード) — the model used for ranking discount services by priority |
| `yusen_jun_kind_cd` | Field | Priority ranking type code (割引優先順位種類コード) — the type of priority ranking |
| `yusen_jun_type_cd` | Field | Priority ranking type code (割引優先順位タイプコード) — the detailed type of priority ranking |
| `yusen_jun_type_jun` | Field | Priority ranking type order (割引優先順位タイプ順位) — the sub-ordering within priority ranking types |
| `aply_joken_cd` | Field | Application condition code (適用条件コード) — the conditions under which the discount can be applied |
| `wrib_add_joken_cd` | Field | Discount registration condition code (割引登録条件コード) — conditions for registering the discount |
| `func_code` | Field | Function code (機能コード) — identifies the functional context of the operation |
| `wrib_svc_list` | Field | Discount service list (割引サービスリスト) — the CC work area container holding the list of eligible discount service candidates |
| KKSV031301SC | Constant | Discount service list inquiry (reference date) (割引サービス一覧照会（基準年月日）) — the SC identifier for the inquiry service |
| EKK0841B003BS / EKK0841B003CBS | SC/CBS | Discount service list inquiry service component — the backend service that queries discount service eligibility |
| WRIB_APLY_OPTNTY_CD_AUTO_APLY = "2" | Constant | Auto-application opportunity code (割引適用機会コード：自動適用) — hard-coded value indicating this inquiry is for automatic application candidate retrieval |
| CC | Acronym | Control Component (制御コンポーネント) — the Java EE component that orchestrates business logic and screens |
| SC | Acronym | Service Component (サービスコンポーネント) — the backend service component that handles business data operations and database access |
| CBS | Acronym | Common Business Service (共通ビジネスサービス) — the CBS-layer implementation that SC delegates to |
| Mapper | Pattern | Mapper (マッパ) — the translation layer that converts between CC and SC data formats (upper/lower mapping) |
| ccMap | Acronym | Control Component Map (CCマップ) — the shared work area used to pass data between components |
| cmnParam | Acronym | Common Parameter (共通パラメータ) — the request parameter read/write interface for the shared work area |
| cmnHandle | Acronym | Common Handle (共通ハンドル) — the handle used by the SC invocation framework |
| KK_T_WRIB_SVC | DB Table | Discount service master table (割引サービスマスタ) — stores all available discount service definitions |
| KK_T_WRIB_SVC_DCHSKM | DB Table | Discount service detail table (割引サービス詳細) — stores discount service eligibility and detail configurations |
| 基準年月日 | Japanese term | Reference date (基準年月日) — the date used as the basis for evaluating which discount services are eligible; in this method, it is taken from the contract application date (mskm_ymd) rather than the operation date |
| 割引サービス自動適用 | Japanese term | Discount service auto-application (割引サービス自動適用) — the business capability of automatically identifying and applying eligible discount services to a customer's contract |
| 作業領域 | Japanese term | Work area (作業領域) — the shared data area (ccMap) used across components for passing business data |
