# Business Logic — JKKCallWrisvcAutoAplyCC.editInMsg() [65 LOC]

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

## 1. Role

### JKKCallWrisvcAutoAplyCC.editInMsg()

This method constructs the inbound parameter map (`paramMap`) that is sent to the discount automatic application service (`JKKWrisvcAutoAplyCC.execute()`). It translates UI-level contract data into a structured message format expected by the downstream discount application engine.

It handles **two business integration scenarios** based on whether a billing contract number (`seikyKeiNo`) is provided:

- **Contract integration** (seikyKeiNo is null): The `add_chge_div` flag is set to "11" and the original system ID (`old_sysid`) is carried over, indicating that existing service contracts are being merged under a new contract. This is used when a customer consolidates multiple contracts.

- **Billing integration** (seikyKeiNo has value): The `add_chge_div` flag is set to "13" and the old billing contract number (`old_seiky_kei_no`) is carried over, indicating that service contract changes are being synchronized with an existing billing contract. This supports simultaneous changes across billing and service contract lines.

The method implements a **map-building pattern** with conditional dispatch and iterative child-object construction. It iterates over the provided service contract list (`svcList`), filters for selected services (`isSelect == true`), and assembles a nested service contract list structure (`svc_kei_grp_list`) containing per-service identifiers (service contract number, status, code, pricing group, pricing cost, pricing plan).

Its **role in the larger system** is as a shared message-assembler called exclusively by `callWrisvcAutoAply()` within the same class. The resulting map is set back onto the `IRequestParameterReadWrite` object so that the discount application component (`JKKWrisvcAutoAplyCC`) can process it. This is a pure data-transform method — it does not perform database access, invoke SC/CBS layers, or produce side effects beyond constructing the return map.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editInMsg called by callWrisvcAutoAply"])
    INIT["Initialize paramMap, childMap, childMap2, svcMap, list"]
    SET_SYSID["Set paramMap.sysid from dataMap.sk_sysid"]
    COND1{"isNull(seikyKeiNo)?"}
    BRANCH_CONTRACT["add_chge_div = 11<br/>Contract Integration<br/>old_sysid from dataMap.mt_sysid"]
    BRANCH_BILLING["add_chge_div = 13<br/>Billing Integration<br/>old_seiky_kei_no = seikyKeiNo"]
    SET_MSKM_NO["Set paramMap.mskm_no from workDataMap.mskm_no"]
    SET_MSKM_SBT["Set paramMap.mskm_sbt_cd = 00011<br/>Application type code"]
    SET_IDO_DIV["Set paramMap.ido_div from dataMap.ido_div"]
    SET_FUNC_CODE["Set paramMap.func_code = 1<br/>Function code"]
    INIT_CHILD["Set childMap.grp_div = 00<br/>Group division"]
    INIT_LIST2["Initialize list2 = new ArrayList"]
    LOOP_START{"i < svcList.size()?"}
    GET_SVC_MAP["svcMap = svcList.get(i)"]
    COND_SELECT{"svcMap.isSelect == true?"}
    INIT_CHILD2["childMap2 = new HashMap"]
    SET_TG_KEYS["Set childMap2: tg_kei_skbt_cd, svc_kei_no, svc_kei_stat, svc_cd, prc_grp_cd, pcrs_cd, pplan_cd"]
    ADD_TO_LIST2["list2.add(childMap2)"]
    INC_I["i++"]
    SET_SVC_LIST["childMap.svc_kei_list = list2"]
    ADD_TO_LIST["list.add(childMap)"]
    SET_GRP_LIST["paramMap.svc_kei_grp_list = list"]
    RETURN["Return paramMap"]

    START --> INIT
    INIT --> SET_SYSID
    SET_SYSID --> COND1
    COND1 -->|seikyKeiNo is null| BRANCH_CONTRACT
    COND1 -->|seikyKeiNo has value| BRANCH_BILLING
    BRANCH_CONTRACT --> SET_MSKM_NO
    BRANCH_BILLING --> SET_MSKM_NO
    SET_MSKM_NO --> SET_MSKM_SBT
    SET_MSKM_SBT --> SET_IDO_DIV
    SET_IDO_DIV --> SET_FUNC_CODE
    SET_FUNC_CODE --> INIT_CHILD
    INIT_CHILD --> INIT_LIST2
    INIT_LIST2 --> LOOP_START
    LOOP_START -->|true| GET_SVC_MAP
    LOOP_START -->|false| SET_SVC_LIST
    GET_SVC_MAP --> COND_SELECT
    COND_SELECT -->|true| INIT_CHILD2
    COND_SELECT -->|false| INC_I
    INIT_CHILD2 --> SET_TG_KEYS
    SET_TG_KEYS --> ADD_TO_LIST2
    ADD_TO_LIST2 --> INC_I
    INC_I --> LOOP_START
    SET_SVC_LIST --> ADD_TO_LIST
    ADD_TO_LIST --> SET_GRP_LIST
    SET_GRP_LIST --> RETURN
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying the overall request context. Used only to call `isNull()` as a utility — the map values are derived from `dataMap`, `workDataMap`, and `svcList`. |
| 2 | `dataMap` | `HashMap<String, Object>` | The user data map extracted from the request (via `param.getData(fixedText)` in the caller). Contains system identifiers (`sk_sysid` — integration source SYSID, `mt_sysid` — contract source SYSID, `ido_div` — migration/change division indicator). |
| 3 | `svcList` | `ArrayList<Object>` | The list of service contract objects displayed on the UI. Each entry is a `HashMap<String, String>` containing service contract details (number, status, code, pricing group, pricing cost, pricing plan) and an `isSelect` flag indicating whether the service was checked by the user. |
| 4 | `workDataMap` | `HashMap<String, Object>` | The work area map extracted from the request's mapping work area (`param.getMappingWorkArea()` -> `"WORK"` key). Contains the application number (`mskm_no`) submitted by the user. |
| 5 | `seikyKeiNo` | `String` | The old billing contract number, or `null`. When `null`, this is a **contract integration** operation (contract consolidation — 契約者融合). When non-null, this is a **billing integration** operation (simultaneous billing change — 請求同時融合). This parameter determines the `add_chge_div` value and how the "old contract" reference is set. |

**External state / instance fields read:** None. This method has no dependency on instance fields or external state. It is stateless and deterministic.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKCallWrisvcAutoAplyCC.isNull` | - | - | Reads null-check utility; inherited from `AbstractCommonComponent` |

**CRUD Classification:**

This method performs **no Create, Update, or Delete operations** against any database or external service. It is a pure data-transformation method that reads from input maps and constructs a new parameter map.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKCallWrisvcAutoAplyCC.isNull` | - | - | Null-check utility (inherited from `AbstractCommonComponent`). Used to determine the integration scenario branch (contract vs. billing). |

**Summary:** Zero database or SC/CBS calls. The method reads exclusively from in-memory HashMap and ArrayList parameters and writes to a newly constructed HashMap. It is a side-effect-free mapper.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `isNull` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0360 | `JKKCallWrisvcAutoAplyCC.callWrisvcAutoAply` -> `JKKCallWrisvcAutoAplyCC.editInMsg` | `isNull` [-] |

**Call chain detail (from caller `callWrisvcAutoAply`):**

The caller `callWrisvcAutoAply(SessionHandle handle, IRequestParameterReadWrite param, String fixedText)` is a public method that orchestrates the discount automatic application flow:

1. Creates a new `JKKWrisvcAutoAplyCC` instance.
2. Extracts `dataMap` from the parameter, `workDataMap` from the work area, and `svcList` from the UI work map (`KKSV0360WORK01`).
3. **First call:** Invokes `editInMsg(param, dataMap, svcList, workDataMap, null)` — this is the **contract integration** path (seikyKeiNo = null). The returned map is set back into `param` and then `wrisvcAutoAplyCC.execute()` is invoked.
4. **Optional second phase:** If `work01Map.seiky_doji` == "ON" (simultaneous billing integration), it retrieves the list of billing contract numbers via `getSeikyKeiNoList(svcList)` and iterates over them, calling `editInMsg` **once per billing contract** with each `seikyKeiNo` value (billing integration path). Each iteration also calls `execute()`.

The screen entry point `KKSV0360` is the contract change registration screen. The `fixedText` parameter is a user-chosen string key used to store/retrieve data in the request parameter map.

**Terminal operations from this method:** Only the utility `isNull()` call, which has no database or side-effect impact.

## 6. Per-Branch Detail Blocks

**Block 1** — INIT (variable declarations) `(L140)`

Initialize local variables for building the parameter map and child structures.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = new HashMap<String, Object>();` // Parameter map to return |
| 2 | SET | `childMap = new HashMap<String, Object>();` // Child map for service contract group |
| 3 | SET | `childMap2 = new HashMap<String, String>();` // Map for individual service contract entries |
| 4 | SET | `svcMap = null;` // Temp variable for iterating svcList entries |
| 5 | SET | `list = new ArrayList<Object>();` // List to hold childMap entries |

**Block 2** — SYSID SETUP `(L146)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put("sysid", dataMap.get("sk_sysid"));` // Integration source SYSID [-> "sk_sysid"] |

**Block 3** — INTEGRATION SCENARIO BRANCH (if/else on `seikyKeiNo`) `(L148)`

Determines the integration type and sets the corresponding flag and old-contract reference.

| # | Type | Code |
|---|------|------|
| 1 | COND | `isNull(seikyKeiNo)` — [seikyKeiNo is null = Contract Integration / 契約者融合] |

**Block 3.1** — [IF] Contract Integration `isNull(seikyKeiNo) == true` `(L150)`

When the billing contract number is null, this is a contract consolidation (customer-level integration). Set registration/change division to "11" and carry over the original system ID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put("add_chge_div", "11");` // Registration/Change division [-> "11"] |
| 2 | SET | `paramMap.put("old_sysid", dataMap.get("mt_sysid"));` // Original contract SYSID [-> "mt_sysid"] |

**Block 3.2** — [ELSE] Billing Integration `isNull(seikyKeiNo) == false` `(L156)`

When the billing contract number is provided, this is a simultaneous billing change (billing-level integration). Set registration/change division to "13" and carry over the old billing contract number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put("add_chge_div", "13");` // Registration/Change division [-> "13"] |
| 2 | SET | `paramMap.put("old_seiky_kei_no", seikyKeiNo);` // Old billing contract number [-> seikyKeiNo parameter value] |

**Block 4** — COMMON PARAMETER SETUP `(L161)`

Set fields shared across both integration scenarios.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put("mskm_no", (String)workDataMap.get("mskm_no"));` // Application number [-> "mskm_no"] |
| 2 | SET | `paramMap.put("mskm_sbt_cd", "00011");` // Application type code [-> "00011"] |
| 3 | SET | `paramMap.put("ido_div", dataMap.get("ido_div"));` // Migration/change division [-> "ido_div"] |
| 4 | SET | `paramMap.put("func_code", "1");` // Function code [-> "1"] |

**Block 5** — CHILD GROUP SETUP `(L166)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `childMap.put("grp_div", "00");` // Group division [-> "00"] |

**Block 6** — SERVICE CONTRACT LIST ITERATION `(L169)`

Iterate through all service contracts in `svcList` and collect only those that the user selected (`isSelect == true`).

| # | Type | Code |
|---|------|------|
| 1 | SET | `list2 = new ArrayList<Object>();` // Initialize list for selected service entries |
| 2 | LOOP | `for(int i=0; i<svcList.size(); i++)` — [for-loop over svcList] |

**Block 6.1** — [LOOP BODY] `(L172)`

Get the current service contract entry from the list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcMap = (HashMap<String, String>)svcList.get(i);` // Cast to typed map |

**Block 6.2** — [NESTED IF] Selection check `svcMap.get("isSelect") == true` `(L174)`

Only process service contracts that were checked on the UI.

| # | Type | Code |
|---|------|------|
| 1 | COND | `(Boolean.valueOf(svcMap.get("isSelect")))` — [isSelect flag is true] |

**Block 6.2.1** — [IF TRUE] Selected service: extract all contract detail fields `(L176)`

Re-initialize childMap2 (one per selected service) and populate it with service contract identifiers.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childMap2 = new HashMap<String, String>();` // Re-initialize for each selected service |
| 2 | SET | `childMap2.put("tg_kei_skbt_cd", "01");` // Target contract identification code [-> "01"] |
| 3 | SET | `childMap2.put("svc_kei_no", svcMap.get("svc_kei_no"));` // Service contract number [-> "svc_kei_no"] |
| 4 | SET | `childMap2.put("svc_kei_stat", svcMap.get("svc_kei_stat"));` // Service contract status [-> "svc_kei_stat"] |
| 5 | SET | `childMap2.put("svc_cd", svcMap.get("svc_cd_KK0081"));` // Service code [-> "svc_cd_KK0081"] |
| 6 | SET | `childMap2.put("prc_grp_cd", svcMap.get("prc_grp_cd_KK0081"));` // Pricing group code [-> "prc_grp_cd_KK0081"] |
| 7 | SET | `childMap2.put("pcrs_cd", svcMap.get("pcrs_cd_KK0081"));` // Pricing cost code [-> "pcrs_cd_KK0081"] |
| 8 | SET | `childMap2.put("pplan_cd", svcMap.get("pplan_cd"));` // Pricing plan code [-> "pplan_cd"] |
| 9 | EXEC | `list2.add(childMap2);` // Add selected service entry to list2 |

**Block 7** — CONSTRUCT NESTED MAP STRUCTURE `(L186)`

Assemble the child map with the service contract list, then the outer list with the child map, and finally set it all on the parameter map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childMap.put("svc_kei_list", list2);` // Service contract list [-> list2] |
| 2 | SET | `list.add(childMap);` // Add childMap to outer list |
| 3 | SET | `paramMap.put("svc_kei_grp_list", list);` // Service contract group list [-> list] |

**Block 8** — RETURN `(L189)`

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return paramMap;` // Return constructed parameter map |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `seikyKeiNo` | Field | Old billing contract number — the contract line number of the billing contract. Null for contract-level integration; set for billing-synchronized changes. |
| `sk_sysid` | Field | Integration source SYSID — the system identifier of the integration source (new contract). |
| `mt_sysid` | Field | Contract source SYSID — the original system ID of the contract before integration. |
| `ido_div` | Field | Migration/change division — indicates the type of contract change operation (e.g., new, modify, terminate). |
| `mskm_no` | Field | Application number — the submission/application number for the change request. |
| `mskm_sbt_cd` | Field | Application type code — classifies the type of application. "00011" identifies this as a discount automatic application request. |
| `add_chge_div` | Field | Registration/Change division — distinguishes between integration scenarios. "11" = contract integration (契約者融合); "13" = billing integration (請求同時融合). |
| `old_sysid` | Field | Original contract SYSID — the system ID before integration, used in contract integration scenarios. |
| `old_seiky_kei_no` | Field | Old billing contract number — carried over in billing integration to link the new service contract to the existing billing contract. |
| `func_code` | Field | Function code — "1" indicates this is a discount automatic application function call. |
| `grp_div` | Field | Group division — "00" indicates the top-level service contract group. |
| `tg_kei_skbt_cd` | Field | Target contract identification code — "01" identifies the target contract type (standard service contract). |
| `svc_kei_no` | Field | Service contract number — unique identifier for a service contract line item. |
| `svc_kei_stat` | Field | Service contract status — current status of the service contract (e.g., active, terminated). |
| `svc_cd_KK0081` | Field | Service code — the code identifying the type of service (e.g., FTTH, mail, ENUM). Suffix "_KK0081" indicates the source data structure from screen KKSV0081. |
| `prc_grp_cd_KK0081` | Field | Pricing group code — groups pricing rules for the service. Suffix "_KK0081" indicates the source. |
| `pcrs_cd_KK0081` | Field | Pricing cost code — identifies the cost structure for the service. Suffix "_KK0081" indicates the source. |
| `pplan_cd` | Field | Pricing plan code — identifies the pricing plan applied to the service contract. |
| `svc_kei_grp_list` | Field | Service contract group list — the top-level map key containing the nested service contract structure sent to the discount application service. |
| `svc_kei_list` | Field | Service contract list — the child map key containing the list of selected service contract entries. |
| `isSelect` | Field | Selection flag — boolean indicator set by the UI to show which service contracts the user has checked/selected. |
| `isNull` | Method | Null-check utility — inherited from `AbstractCommonComponent`. Returns true if the given String parameter is null or empty. |
| `callWrisvcAutoAply` | Method | Discount automatic application entry point — orchestrates the full flow: calls `editInMsg` to build the message, then delegates to `JKKWrisvcAutoAplyCC.execute()` to process discount application. |
| `JKKWrisvcAutoAplyCC` | Class | Discount automatic application CC — the downstream component that receives the message built by `editInMsg` and performs the actual discount application logic. |
| `KKSV0360` | Screen | Contract change registration screen — the UI screen where users select service contracts for change and initiate the discount automatic application process. |
| `KKSV0360WORK01` | Data key | UI work area data key — stores `svc_kei_list` (the service contract list) from the screen. |
| 契約者融合 | Japanese business term | Contract integration (customer-level consolidation) — merging multiple service contracts under a single customer. add_chge_div = "11". |
| 請求同時融合 | Japanese business term | Billing simultaneous integration — synchronizing service contract changes with an existing billing contract. add_chge_div = "13". |
| 割引自動適用 | Japanese business term | Discount automatic application — the business process of automatically applying eligible discounts to service contracts based on bundle/pack rules. |
| AbstractCommonComponent | Class | Base common component class — provides shared utilities including the `isNull()` method, used as the parent of `JKKCallWrisvcAutoAplyCC`. |
