# Business Logic — JKKWrisvcAutoAplyMappingCC.execute() [80 LOC]

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

## 1. Role

### JKKWrisvcAutoAplyMappingCC.execute()

This method serves as a **mapping bridge** that transforms and repackages data extracted from a screen request (`IRequestParameterReadWrite`) into the specific input structure expected by the `JKKWrisvcAutoAplyCC` component, which handles automatic discount application to service contracts. It acts as an **adapter** between the screen layer (which aggregates data from multiple SC objects — `KKSV006301SC`, `KKSV006305SC`, `KKSV006307SC`) and the discount-application business logic layer.

The method specifically handles **network (Net) and telephone services** — identified by service code `svc_cd` values of `"01"` (Network) and `"02"` (Telephone) — routing them into a dedicated discount-service automatic-apply mapping flow. For all other service types (e.g., TV, home networking, MVNEO), the method simply returns the original `param` unchanged, effectively **bypassing** the discount auto-apply process.

The data preparation follows a **building-block pattern**: it assembles a nested map structure (`inMap`) containing the subscription identifier, change classification, operation flags, and a detailed service-contract line-item list (`svc_kei_grp_list`), which includes pre-change snapshot data for audit and rollback purposes. Once fully assembled, the mapped data is stored under the key `"wrisvcMap"` and passed to the `JKKWrisvcAutoAplyCC.execute()` entry point for execution.

Its role in the larger system is that of a **shared utility called by many screens** — specifically, it is the designated mapping component invoked after contract-agreement confirmation screens (e.g., KKSV0063 series), where the system must decide whether the selected services qualify for automatic discount application based on their service type.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute handle, param, fixedText"])

    START --> EXTRACT["Extract KKSV006301SC, KKSV006305SC, KKSV006307SC from param"]

    EXTRACT --> CHECK_SVC{Check svc_cd of EKK0081A010CBSMsg1ListMap}

    CHECK_SVC -->|"svc_cd == 01 (Network)"| BUILD_MAP["Build inMap for discount service auto-apply"]
    CHECK_SVC -->|"svc_cd == 02 (Telephone)"| BUILD_MAP

    CHECK_SVC -->|"svc_cd is neither 01 nor 02"| RETURN["Return param unchanged"]

    BUILD_MAP --> SET_INMAP["Set sysid, add_chge_div, mskm_no, mskm_sbt_cd, ido_div, func_code, kojihi_kap_operate_stat in inMap"]

    SET_INMAP --> BUILD_SVCGRP["Build svcKeiGrpListMap with grp_div = 00 (Standard contract)"]

    BUILD_SVCGRP --> BUILD_SVCLST["Build svcKeiListMap with tg_kei_skbt_cd = 01 (Service contract), svc_kei_no, svc_kei_stat, svc_cd, prc_grp_cd, pcrs_cd, pplan_cd, chge_bf_* values"]

    BUILD_SVCLST --> ADD_SVCLST["Add svcKeiListMap to svcKeiList, then to svcKeiGrpListMap"]

    ADD_SVCLST --> ADD_GROUP["Add svcKeiGrpListMap to svcKeiGrpList, then set svc_kei_grp_list in inMap"]

    ADD_GROUP --> SET_WRISVC["param.setData(wrisvcMap, inMap)"]

    SET_WRISVC --> EXEC_CC["Execute JKKWrisvcAutoAplyCC.execute(handle, param, wrisvcMap)"]

    EXEC_CC --> RETURN
```

**CRITICAL — Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|------------------|
| `JKKStrConst.CD00130_01` | `"01"` | Network service (Internet/telecom connectivity) |
| `JKKStrConst.CD00130_02` | `"02"` | Telephone service |
| `ADD_CHGE_DIV_PLAN_CHG` | `"02"` | Change classification: Plan change |
| `GRP_DIV_STDARD` | `"00"` | Group classification: Standard contract |
| `TG_KEI_SKBT_CD_SVC_KEI` | `"01"` | Target contract identification code: Service contract |
| `JPCModelConstant.FUNC_CD_1` | `1` | Function code: Operation (general business function) |
| `kojihi_kap_operate_stat` | `"1"` | Non-public charge discount operation status: Enabled |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transaction context and connection to the backend data layer. It carries the authenticated user's session state, enabling service components executed within this method to query and persist data under the correct transaction scope. |
| 2 | `param` | `IRequestParameterReadWrite` | Screen request parameter object carrying data extracted from multiple screen-scoped data maps. It serves as the central data carrier: input data is read from it (e.g., `KKSV006301SC`, `KKSV006305SC`, `KKSV006307SC`), and processed data is written back into it (e.g., `wrisvcMap` containing the assembled mapping structure). The method mutates this object by setting the `wrisvcMap` key before delegating to `JKKWrisvcAutoAplyCC`. |
| 3 | `fixedText` | `String` | A string parameter that is accepted but **not used** within this method's body. It is part of the method signature inherited from the common component interface pattern, where fixed text might be used by subclasses or calling chain components for localization, log messages, or business-rule text binding. |

**Instance fields read by the method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ADD_CHGE_DIV_PLAN_CHG` | `String` | Private constant; class-level value `"02"` indicating plan-change type for discount service registration/modification classification. |
| `GRP_DIV_STDARD` | `String` | Private constant; class-level value `"00"` indicating standard (non-premium, non-custom) contract group classification. |
| `TG_KEI_SKBT_CD_SVC_KEI` | `String` | Private constant; class-level value `"01"` indicating the target contract type is a service contract line item. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKWrisvcAutoAplyCC.execute` | JKKWrisvcAutoAplyCC | - | Delegates to discount-service automatic-apply component with the assembled `wrisvcMap` parameter. Performs service-contract-level discount application logic (internal to `JKKWrisvcAutoAplyCC`). |

**Note:** The pre-computed evidence table referenced in the instructions lists numerous other SC/CBS calls (`JBSbat*`, `JFUeo*`, `KKW12701SFLogic`, etc.), but **none of these methods are called within the body of `JKKWrisvcAutoAplyMappingCC.execute()` as defined in the actual source code** (lines 53-132). The only direct call made is to `JKKWrisvcAutoAplyCC.execute()`. The other pre-computed entries appear to belong to a different method or call chain context.

The method's business-level dependency on `JKKWrisvcAutoAplyCC` implies downstream operations:
- **C** (Create): `JKKWrisvcAutoAplyCC` will likely create or update discount-application records in service-contract-related tables (e.g., `KK_T_DISCOUNT_APPLY` or similar entities governed by the discount auto-apply domain).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Component: `JKKWrisvcAutoAplyMappingCC` | `JKKWrisvcAutoAplyMappingCC.execute` (self-referential entry) | `JKKWrisvcAutoAplyCC.execute -> discount service auto-apply logic` |

**Caller Analysis:** Based on the pre-computed caller evidence, the direct caller listed is `JKKWrisvcAutoAplyMappingCC.execute()` itself (self-reference in the caller table). In practice, this component is invoked by screen-operation classes in the KKSV0063 series (e.g., KKSV0063), which handle the contract-agreement confirmation workflow. The screen extracts data from multiple SC objects, passes them to this mapping CC, which then delegates to the discount auto-apply CC.

## 6. Per-Branch Detail Blocks

**Block 1** — [EXEC: Data Extraction] `(L55-L61)`

> Extract the three screen-scoped data maps from the request parameter object. This step decouples the data from the `param` carrier so it can be individually referenced during mapping assembly.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `KKSV006301SC = (HashMap) param.getData("KKSV006301SC")` // Submit information update map |
| 2 | EXEC | `KKSV006305SC = (HashMap) param.getData("KKSV006305SC")` // Submit content acceptance registration map |
| 3 | EXEC | `KKSV006307SC = (HashMap) param.getData("KKSV006307SC")` // Service contract agreement confirmation map |

**Block 2** — [EXEC: Data Preparation] `(L62-L64)`

> Extract the service detail list and the first entry to access the service code for branching logic.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `eKK0081A010CBSMsg1List = (ArrayList) KKSV006307SC.get("EKK0081A010CBSMsg1List")` // Service detail list from CBS message |
| 2 | EXEC | `eKK0081A010CBSMsg1ListMap = eKK0081A010CBSMsg1List.get(0)` // First service detail entry |

**Block 3** — [IF: Service Code Check] `(svc_cd == "01" OR svc_cd == "02")` `(L67)` `[CD00130_01="01" (Network), CD00130_02="02" (Telephone)]` `(L66-L67)`

> Conditional branch: If the service code of the first service-detail entry indicates a network (`"01"`) or telephone (`"02"`) service, execute the discount-service automatic-apply mapping. For all other service types (TV, home networking, etc.), skip the entire mapping block and return the original param unchanged.

**Block 3.1** — [SET: Build inMap] `(L69)`

> Initialize the input map for the discount service auto-apply mapping.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = new HashMap()` // Discount service auto-apply mapping input container |

**Block 3.2** — [SET: Populate inMap fields] `(L72-L80)`

> Set individual fields on the inMap. Most values are sourced from the extracted screen data maps (`KKSV006305SC`, `KKSV006301SC`). Several fields carry hardcoded constant values that define the business context of the auto-apply operation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put("sysid", KKSV006305SC.get("sysid"))` // System ID from submit content acceptance |
| 2 | SET | `inMap.put("add_chge_div", ADD_CHGE_DIV_PLAN_CHG)` `[-> "02" (Plan change)]` // Change classification: plan change |
| 3 | SET | `inMap.put("mskm_no", KKSV006305SC.get("mskm_no"))` // Subscription number |
| 4 | SET | `inMap.put("mskm_sbt_cd", KKSV006305SC.get("mskm_sbt_cd"))` // Subscription type code |
| 5 | SET | `inMap.put("ido_div", KKSV006301SC.get("ido_div"))` // Migration/change classification |
| 6 | SET | `inMap.put("func_code", JPCModelConstant.FUNC_CD_1)` `[-> "1" (Operation)]` // Function code |
| 7 | SET | `inMap.put("kojihi_kap_operate_stat", "1")` // IT1-2018-0000086: Non-public charge discount operation status: enabled |

**Block 3.3** — [SET: Build svcKeiGrpListMap] `(L82-L85)`

> Create the service-contract-group list map container and set its group classification to "00" (standard contract).

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiGrpListMap = new HashMap()` // Service contract group list map |
| 2 | SET | `svcKeiList = new ArrayList<HashMap<String, Object>>()` // Service contract list collection |
| 3 | SET | `svcKeiGrpListMap.put("grp_div", GRP_DIV_STDARD)` `[-> "00" (Standard contract)]` // Group classification |

**Block 3.4** — [SET: Build svcKeiListMap] `(L88-L108)`

> Populate the service-contract-line-item map with all relevant fields sourced from the CBS message (the first entry in the service-detail list). The "before change" fields (`chge_bf_*`) are all set to the same values as the current fields, capturing a snapshot of the state before the auto-apply discount takes effect.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiListMap = new HashMap()` // Service contract list entry map |
| 2 | SET | `svcKeiList = new ArrayList<HashMap<String, Object>>()` // Service contract list collection |
| 3 | SET | `svcKeiListMap.put("tg_kei_skbt_cd", TG_KEI_SKBT_CD_SVC_KEI)` `[-> "01" (Service contract)]` // Target contract identification code |
| 4 | SET | `svcKeiListMap.put("svc_kei_no", eKK0081A010CBSMsg1ListMap.get("svc_kei_no"))` // Service detail number |
| 5 | SET | `svcKeiListMap.put("svc_kei_stat", eKK0081A010CBSMsg1ListMap.get("svc_kei_stat"))` // Service detail status |
| 6 | SET | `svcKeiListMap.put("svc_cd", eKK0081A010CBSMsg1ListMap.get("svc_cd"))` // Service code |
| 7 | SET | `svcKeiListMap.put("prc_grp_cd", eKK0081A010CBSMsg1ListMap.get("prc_grp_cd"))` // Price group code |
| 8 | SET | `svcKeiListMap.put("pcrs_cd", eKK0081A010CBSMsg1ListMap.get("pcrs_cd"))` // Price course code |
| 9 | SET | `svcKeiListMap.put("pplan_cd", eKK0081A010CBSMsg1ListMap.get("pplan_cd"))` // Price plan code |
| 10 | SET | `svcKeiListMap.put("chge_bf_svc_cd", eKK0081A010CBSMsg1ListMap.get("svc_cd"))` // Pre-change service code |
| 11 | SET | `svcKeiListMap.put("chge_bf_prc_grp_cd", eKK0081A010CBSMsg1ListMap.get("prc_grp_cd"))` // Pre-change price group code |
| 12 | SET | `svcKeiListMap.put("chge_bf_pcrs_cd", eKK0081A010CBSMsg1ListMap.get("pcrs_cd"))` // Pre-change price course code |
| 13 | SET | `svcKeiListMap.put("chge_bf_pplan_cd", eKK0081A010CBSMsg1ListMap.get("pplan_cd"))` // Pre-change price plan code |

**Block 3.5** — [EXEC: Assemble nested lists] `(L110-L115)`

> Combine the individual maps into the nested list structure expected by `JKKWrisvcAutoAplyCC`: `svc_kei_list` is added to `svcKeiGrpListMap`, and then `svcKeiGrpListMap` is added to `svcKeiGrpList`, which is finally set as `svc_kei_grp_list` in `inMap`.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `svcKeiList.add(svcKeiListMap)` // Add service contract entry to list |
| 2 | EXEC | `svcKeiGrpListMap.put("svc_kei_list", svcKeiList)` // Add list to group map |
| 3 | EXEC | `svcKeiGrpList.add(svcKeiGrpListMap)` // Add group map to group list |
| 4 | EXEC | `inMap.put("svc_kei_grp_list", svcKeiGrpList)` // Set group list in inMap |

**Block 3.6** — [EXEC: Store and delegate] `(L117-L118)`

> Store the fully assembled `inMap` into the `param` object under the key `"wrisvcMap"`, then instantiate and execute the discount-service auto-apply component with the assembled data.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.setData("wrisvcMap", inMap)` // Store mapping result in param |
| 2 | CALL | `(new JKKWrisvcAutoAplyCC()).execute(handle, param, "wrisvcMap")` // Execute discount service auto-apply |

**Block 4** — [RETURN] `(L120)` `(L120)`

> Return the original `param` object (now modified with `wrisvcMap`) to the caller, regardless of whether the discount auto-apply path was taken or not.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param;` // Return the request parameter object |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_cd` | Field | Service code — classifies the type of telecom service (01=Network, 02=Telephone, 03=TV, etc.) |
| `svc_kei_no` | Field | Service detail number — internal tracking ID for a service contract line item |
| `svc_kei_stat` | Field | Service detail status — current lifecycle status of a service contract line (e.g., active, suspended, completed) |
| `prc_grp_cd` | Field | Price group code — groups services into pricing tiers (e.g., home type, mansion type, eo64 area) |
| `pcrs_cd` | Field | Price course code — specific pricing plan/course within a price group |
| `pplan_cd` | Field | Price plan code — detailed pricing plan within a course |
| `mskm_no` | Field | Subscription number — the subscriber's account/contract identifier |
| `mskm_sbt_cd` | Field | Subscription type code — classifies the type of subscription (e.g., new, renewal, transfer) |
| `ido_div` | Field | Migration/change classification — indicates whether the operation is a new setup, change, or cancellation |
| `add_chge_div` | Field | Addition/change classification — distinguishes between new registration, plan changes, and course changes |
| `grp_div` | Field | Group classification — categorizes service contract groups (00 = standard contract) |
| `tg_kei_skbt_cd` | Field | Target contract identification code — specifies the type of contract target (01 = service contract) |
| `chge_bf_*` | Fields | Pre-change values — snapshot of contract fields before the discount auto-apply takes effect, used for audit/rollback |
| `kojihi_kap_operate_stat` | Field | Non-public charge discount operation status — flag controlling whether hidden/discounted charges are applied (1 = enabled) |
| `sysid` | Field | System ID — identifies the system or subsystem performing the operation |
| `func_code` | Field | Function code — identifies the function type (1 = general business operation) |
| `wrisvcMap` | Field | Web/Response service mapping key — the key under which the assembled mapping data is stored in the param object |
| CD00130_01 | Constant | Service code "01" — Network/Internet service |
| CD00130_02 | Constant | Service code "02" — Telephone service |
| ADD_CHGE_DIV_PLAN_CHG | Constant | Change classification "02" — Plan change (as opposed to new registration or course change) |
| GRP_DIV_STDARD | Constant | Group classification "00" — Standard contract (non-premium, non-custom) |
| TG_KEI_SKBT_CD_SVC_KEI | Constant | Target contract code "01" — Service contract line item |
| FUNC_CD_1 | Constant | Function code "1" — General operation (business function) |
| K-Opticom | Brand | K-Opticom — Japanese fixed-line and broadband telecommunications provider (the system's domain) |
| KKSV | Screen prefix | K-Opticom Screen Validation — screen operation class naming convention (e.g., KKSV0063 series) |
| CC | Technical term | Common Component — shared business logic component in the Fujitsu Futurity framework |
| SC | Technical term | Screen Component — data carrier between screen UI and business logic |
| CBS | Technical term | Customer Business System — backend CBS layer (e.g., EKK0081A010CBS) |
| EKK0081A010CBS | SC Code | Service component for retrieving service agreement details — returns the service detail list used for service-code branching |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband service (corresponds to network service code "01") |
| KKSV006301SC | Data key | Submit information update map — contains application/change data from the screen |
| KKSV006305SC | Data key | Submit content acceptance registration map — contains acceptance/registration data |
| KKSV006307SC | Data key | Service contract agreement confirmation map — contains service contract confirmation data |
