# Business Logic — JKKCourseRkWrisvcCallCC.execute() [74 LOC]

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

## 1. Role

### JKKCourseRkWrisvcCallCC.execute()

This method executes the **discount service automatic application** processing for K-Opticom's telecom customer base system. It orchestrates the preparation of service item data required to automatically apply discounted-rate services during contract modification flows, specifically within the service course change (Ko) workflow. The method implements a **data assembly and delegation pattern**: it extracts application-level metadata (from the `ccMsg` map keyed by `fixedText`), pulls service DSL fix item lists from the work area, and assembles them into a nested structure that the downstream `JKKWrisvcAutoAplyCC` component consumes to determine which services qualify for discount application.

The method handles a single processing path — it iterates over all DSL-fix service items (contract lines subject to modification) and, for each one, populates a shared outbound map (`outMap`) with billing, contract, and service classification data before delegating to `JKKWrisvcAutoAplyCC.execute()`. This CC (Common Component) serves as a **shared utility called by BPM operations**, notably from `KKSV0396OPOperation`, which acts as the screen-level orchestrator for the service course change screen (KKSV0396).

The method is invoked during the service contract determination phase of a course change operation, where existing optional service contracts are analyzed and auto-applied discount services are registered without manual user intervention.

## 2. Processing Pattern (Detailed Business Logic)

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

    START --> STEP1["Set dataMapKey = fixedText"]
    STEP1 --> STEP2["Create outMap param.setData WrisvcAutoAplyCC"]
    STEP2 --> STEP3["Get ccMsg from param using dataMapKey"]
    STEP3 --> STEP4["Get outMap from param using WrisvcAutoAplyCC"]
    STEP4 --> STEP5["Instantiate JKKWrisvcAutoAplyCC"]
    STEP5 --> STEP6["Get workMap from param"]
    STEP6 --> STEP7["Get opsvkeiDslFixList and mskmNo from workMap"]
    STEP7 --> LOOP{Loop opsvkeiDslFixList}
    LOOP -- i lt size --> MAPDATA["Populate outMap with service item data"]
    MAPDATA --> BUILDSVC["Build nested workSvcKeiMap grp_div svc_kei_list"]
    BUILDSVC --> BUILDSVCDATA["Build workSvcKeiData sysid tg_kei_skbt_cd op_svc_kei_no pcrs_cd pplan_cd op_svc_cd"]
    BUILDSVCDATA --> NESTING["Nest svc_kei_list into svc_kei_grp_list in outMap"]
    NESTING --> CALLEXEC["Call wrisvcAutoAplyCC.execute handle param WrisvcAutoAplyCC"]
    CALLEXEC --> LOOP
    LOOP -- i gte size --> CLEANUP["param.removeData WrisvcAutoAplyCC"]
    CLEANUP --> RETURN["Return param"]
    RETURN --> END(["End"])
```

**Processing overview:**

1. **Data Map Key Setup** — The `fixedText` parameter (e.g., `"KKSV039605CC"`) is assigned to `dataMapKey` and used as the key to retrieve pre-populated `ccMsg` data from the parameter object.
2. **Outbound Map Initialization** — A new `HashMap<String, Object>` is created under the key `"WrisvcAutoAplyCC"` in the parameter data store. This map serves as the shared work area passed to `JKKWrisvcAutoAplyCC`.
3. **Data Extraction** — Both the inbound `ccMsg` (contract metadata) and the outbound `outMap` (discount application work data) are retrieved from `param`.
4. **Work Area Access** — The method pulls `opsvkeiDslFixList` (the list of service DSL fix items) and `mskmNo` (application number) from the mapping work area.
5. **Iteration Loop** — For each item in `opsvkeiDslFixList`, the method populates `outMap` with service item fields, builds nested service contract group structures, and delegates to `JKKWrisvcAutoAplyCC.execute()`.
6. **Cleanup** — After the loop, the temporary `WrisvcAutoAplyCC` data is removed from `param` and the modified `param` is returned.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session management handle carrying the database connection, transaction context, and user session information for the current request. Used when delegating to `JKKWrisvcAutoAplyCC.execute()`. |
| 2 | `param` | `IRequestParameterReadWrite` | The master parameter object carrying the model group and control map. It holds pre-populated `ccMsg` data (keyed by `fixedText`), the work mapping area (`opsvkeiDslFixList`, `mskm_no`), and is modified in-place with the outbound `WrisvcAutoAplyCC` map. Returned as the final result. |
| 3 | `fixedText` | `String` | A user-defined string identifier used as the data map key to retrieve `ccMsg` from `param`. In practice, this is a screen/action identifier such as `"KKSV039605CC"`, which links this CC invocation to the calling BPM screen's data preparation. |

**Work area data accessed from `param.getMappingWorkArea()`:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `opsvkeiDslFixList` | `ArrayList<Map<String, Object>>` | List of optional service item records subject to DSL (Dedicated Line / Service) fix — each map represents a service contract line item being modified during the course change, containing fields like `sysid`, `add_chge_div`, `op_svc_kei_no`, `op_svc_kei_stat`, `pcrs_cd`, `pplan_cd`, `op_svc_cd`, `svc_dlre_cd`, `svc_cancel_rsn_cd`. |
| `mskm_no` | `String` | Application number — the unique identifier for the current service change application/request. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKWrisvcAutoAplyCC.execute` | - | - | Delegates to the discount service automatic application CC to process which services qualify for automatic discount application. This CC likely performs internal SC/BBS calls (not visible at this level). |

**Analysis:**

This method is a **pure orchestrator** — it does not directly perform any database CRUD operations itself. Instead, it:

- **Reads** data from `param` (the inbound `ccMsg` and `opsvkeiDslFixList` work area data)
- **Writes** (updates) data into the outbound `outMap` under the `WrisvcAutoAplyCC` key
- **Delegates** all actual service-level operations to `JKKWrisvcAutoAplyCC.execute()`

The `JKKWrisvcAutoAplyCC` component (whose detailed implementation is outside the scope of this method's source) is responsible for the actual discount service determination logic, which would involve database queries to determine eligibility and potentially create/update service registration records.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0396 | `KKSV0396OPOperation.target1b.execute` -> `CCRequestBroker.invoke` -> `JKKCourseRkWrisvcCallCC.execute` | `JKKWrisvcAutoAplyCC.execute` (delegated) |
| 2 | Screen:KKSV0395 (commented out) | `KKSV0395_KKSV0395OPBPCheck` -> `JKKCourseRkWrisvcCallCC.getInvokeCBS` (disabled code path) | — |
| 3 | Screen:KKSV0396 (commented out) | `KKSV0396_KKSV0396OPBPCheck` -> `JKKCourseRkWrisvcCallCC.getInvokeCBS` (disabled code path) | — |

**Notes on call chains:**

- **Primary caller**: `KKSV0396OPOperation` defines a `CCRequestBroker` instance (`target1b`) that invokes `JKKCourseRkWrisvcCallCC.execute` with the parameter `"KKSV039605CC"`. This is the active, production call path.
- **Disabled callers**: `KKSV0395_KKSV0395OPBPCheck` and `KKSV0396_KKSV0396OPBPCheck` contain commented-out references to this class, indicating historical or planned integration that is currently inactive.
- The `KKSV0396` screen is the **Service Course Change** screen in K-Opticom's customer base system, where operators modify existing service contracts and the automatic discount application is triggered as part of the post-change processing.

## 6. Per-Branch Detail Blocks

### Block 1 — ASSIGNMENT (setup) (L48)

> Initialize the data map key and create the outbound work map for the automatic application CC.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dataMapKey = fixedText` // Copy the fixedText parameter as the data map key [-> "KKSV039605CC"] |
| 2 | SET | `workWrisvcAutoAplyDataKey = "WrisvcAutoAplyCC"` // Constant key for the auto-apply work area [-> "WrisvcAutoAplyCC"] |
| 3 | EXEC | `param.setData(workWrisvcAutoAplyDataKey, new HashMap<String, Object>())` // Create outbound map for WrisvcAutoAplyCC (Discount service auto-apply CC execution processing / 割引サービス自動適用CC実行処理) |
| 4 | SET | `ccMsg = (HashMap<String, Object>)param.getData(dataMapKey)` // Retrieve inbound contract metadata from param [-> ccMsg] |
| 5 | SET | `outMap = (HashMap<String, Object>)param.getData(workWrisvcAutoAplyDataKey)` // Retrieve the outbound map for population |
| 6 | SET | `wrisvcAutoAplyCC = new JKKWrisvcAutoAplyCC()` // Instantiate the discount service auto-apply component |

### Block 2 — ASSIGNMENT (work area extraction) (L58)

> Extract the work mapping area and the service DSL fix item list from param.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap = param.getMappingWorkArea()` // Get the work mapping area (work領域の取得 / 作業領域の取得) |
| 2 | SET | `opsvkeiDslFixList = (ArrayList)workMap.get("opsvkeiDslFixList")` // Get the list of optional service DSL fix items |
| 3 | SET | `mskmNo = (String)workMap.get("mskm_no")` // Get the application number (申請番号) |

### Block 3 — FOR LOOP (iteration over service items) (L60)

> For each service DSL fix item, populate the outbound map with contract/billing data, build nested service structures, and delegate to the auto-apply CC. Loop iterates over `opsvkeiDslFixList.size()` items.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` // Loop counter initialization |
| 2 | COND | `i < opsvkeiDslFixList.size()` // Loop condition — iterate over all service DSL fix items |

**Block 3.1 — IF [loop body] (L61)**

> (Loop body — executed for each item in opsvkeiDslFixList)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outMap.put("sysid", (String)opsvkeiDslFixList.get(i).get("sysid"))` // Set SYSID from the service item (SYSID) |
| 2 | EXEC | `outMap.put("add_chge_div", (String)opsvkeiDslFixList.get(i).get("add_chge_div"))` // Set registration/change classification from service item (登録/変更区分 / tonroku/henkun kubun) |
| 3 | EXEC | `outMap.put("mskm_no", mskmNo)` // Set the application number (申請番号 / shinbai bangou) |
| 4 | EXEC | `outMap.put("mskm_sbt_cd", (String)ccMsg.get("mskm_sbt_cd"))` // Set the application type code (申請種別コード / shinbai shubetsu koodo) |
| 5 | EXEC | `outMap.put("ido_div", (String)ccMsg.get("ido_div"))` // Set the change type classification (異動区分 / idou kubun) |
| 6 | EXEC | `outMap.put("func_code", (String)ccMsg.get("func_code"))` // Set the function code (機能コード / kinou koodo) |
| 7 | EXEC | `outMap.put("svc_dlre_cd", (String)opsvkeiDslFixList.get(i).get("svc_dlre_cd"))` // Set the service cancellation reason code (サービス解約理由コード / saabisu kaiyaku riyuu koodo) |
| 8 | EXEC | `outMap.put("svc_cancel_rsn_cd", (String)opsvkeiDslFixList.get(i).get("svc_cancel_rsn_cd"))` // Set the service cancellation reason code (サービスキャンセル理由コード / saabisu kyanaseru riyuu koodo) |
| 9 | SET | `workSvcKeiArray = new ArrayList<HashMap<String, Object>>()` // Create service contract group list (サービス契約グループリスト / saabisu keiyaku guruupu risuto) |
| 10 | SET | `workSvcKeiMap = new HashMap<String, Object>()` // Create a service contract map (サービス契約マップ / saabisu keiyaku mappu) |
| 11 | EXEC | `workSvcKeiMap.put("grp_div", (String)ccMsg.get("grp_div"))` // Set the group classification (グループ区分 / guruupu kubun) |
| 12 | SET | `workSvcKeiList = new ArrayList<HashMap<String, Object>>()` // Create the service contract detail list (サービス契約リスト / saabisu keiyaku risuto) |
| 13 | SET | `workSvcKeiData = new HashMap<String, Object>()` // Create a service contract detail map |
| 14 | EXEC | `workSvcKeiData.put("sysid", "")` // Set empty SYSID for the detail item (SYSID) |
| 15 | EXEC | `workSvcKeiData.put("tg_kei_skbt_cd", (String)ccMsg.get("tg_kei_skbt_cd"))` // Set the target contract identification code (対象契約識別コード / taishou keiyaku shikibetsu koodo) |
| 16 | EXEC | `workSvcKeiData.put("op_svc_kei_no", (String)opsvkeiDslFixList.get(i).get("op_svc_kei_no"))` // Set the optional service contract number (オプションサービス契約番号 / opushon saabisu keiyaku bangou) |
| 17 | EXEC | `workSvcKeiData.put("op_svc_kei_stat", (String)opsvkeiDslFixList.get(i).get("op_svc_kei_stat"))` // Set the optional service contract status (オプションサービス契約ステータス / opushon saabisu keiyaku suteetasu) |
| 18 | EXEC | `workSvcKeiData.put("pcrs_cd", (String)opsvkeiDslFixList.get(i).get("pcrs_cd"))` // Set the price course code (料金コースコード / ryoukin koodo) |
| 19 | EXEC | `workSvcKeiData.put("pplan_cd", (String)opsvkeiDslFixList.get(i).get("pplan_cd"))` // Set the price plan code (料金プランコード / ryoukin purankooodo) |
| 20 | EXEC | `workSvcKeiData.put("op_svc_cd", (String)opsvkeiDslFixList.get(i).get("op_svc_cd"))` // Set the optional service code (オプションサービスコード / opushon saabisu koodo) |
| 21 | EXEC | `workSvcKeiList.add(workSvcKeiData)` // Add the service detail to the list |
| 22 | EXEC | `workSvcKeiMap.put("svc_kei_list", workSvcKeiList)` // Set the service detail list in the map |
| 23 | EXEC | `workSvcKeiArray.add(workSvcKeiMap)` // Add the group map to the array |
| 24 | EXEC | `outMap.put("svc_kei_grp_list", workSvcKeiArray)` // Set the nested service contract group list in outMap |
| 25 | CALL | `wrisvcAutoAplyCC.execute(handle, param, workWrisvcAutoAplyDataKey)` // Delegate to the discount service auto-apply CC to process automatic discount application (割引サービス自動適用 / waribiki saabisujidou tekiyou) |

### Block 4 — ASSIGNMENT (cleanup) (L97)

> Remove the temporary work data and return the modified parameter.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.removeData(workWrisvcAutoAplyDataKey)` // Remove the temporary WrisvcAutoAplyCC work data from param (WrisvcAutoAplyCCデータを削除 / WrisvcAutoAplyCC deeta wo sajou) |
| 2 | RETURN | `return param` // Return the modified parameter object (サービコン実行用CAANMsg / saabisu konpokou ka ANMsg) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `fixedText` | Parameter | User-defined string identifier used as the data map key to retrieve `ccMsg` from param. In practice, this is a screen/action identifier (e.g., `"KKSV039605CC"`). |
| `dataMapKey` | Field | Internal variable — alias for `fixedText`, used as the key to look up `ccMsg` in the parameter data store. |
| `workWrisvcAutoAplyDataKey` | Field | Internal constant — the key `"WrisvcAutoAplyCC"` under which the outbound work map is stored in param. |
| `ccMsg` | Field | Inbound contract metadata map, pre-populated by the calling screen/BPM. Contains application-level data such as `mskm_sbt_cd`, `ido_div`, `func_code`, `grp_div`, `tg_kei_skbt_cd`. |
| `outMap` | Field | Outbound work map for `JKKWrisvcAutoAplyCC`. Populated with service item data during iteration, then consumed by the auto-apply CC. |
| `workMap` | Field | The mapping work area from param, containing lists and data passed between BPM processing stages. |
| `opsvkeiDslFixList` | Field | List of optional service DSL fix items — each represents a service contract line being modified during the course change. Contains: `sysid`, `add_chge_div`, `op_svc_kei_no`, `op_svc_kei_stat`, `pcrs_cd`, `pplan_cd`, `op_svc_cd`, `svc_dlre_cd`, `svc_cancel_rsn_cd`. |
| `mskmNo` | Field | Application number (申請番号 / shinbai bangou) — unique identifier for the current service change application. |
| `add_chge_div` | Field | Registration/change classification (登録/変更区分) — indicates whether the service item is being newly registered or modified. |
| `mskm_sbt_cd` | Field | Application type code (申請種別コード) — classifies the type of application (e.g., new registration, modification, cancellation). |
| `ido_div` | Field | Change/movement classification (異動区分) — indicates the type of change being made (add, modify, remove). |
| `func_code` | Field | Function code (機能コード) — identifies the functional area or operation type. |
| `grp_div` | Field | Group classification (グループ区分) — categorizes service items into logical groups. |
| `svc_dlre_cd` | Field | Service cancellation reason code (サービス解約理由コード) — reason code for service termination. |
| `svc_cancel_rsn_cd` | Field | Service cancellation reason code (サービスキャンセル理由コード) — reason code for service cancellation. |
| `tg_kei_skbt_cd` | Field | Target contract identification code (対象契約識別コード) — identifies the type of target contract. |
| `op_svc_kei_no` | Field | Optional service contract number (オプションサービス契約番号) — unique number for an optional service contract line. |
| `op_svc_kei_stat` | Field | Optional service contract status (オプションサービス契約ステータス) — current status of the optional service contract. |
| `pcrs_cd` | Field | Price course code (料金コースコード) — pricing course/course plan code for the service item. |
| `pplan_cd` | Field | Price plan code (料金プランコード) — pricing plan code associated with the service item. |
| `op_svc_cd` | Field | Optional service code (オプションサービスコード) — code identifying the optional service type. |
| `svc_kei_grp_list` | Field | Service contract group list — nested structure in outMap containing grouped optional service contract data. |
| `svc_kei_list` | Field | Service contract detail list — nested within `svc_kei_grp_list`, contains individual service detail records. |
| `JKKWrisvcAutoAplyCC` | Class | Discount service automatic application CC (割引サービス自動適用CC) — component that processes automatic application of discounted-rate services based on prepared service item data. |
| `KKSV0396` | Screen | Service Course Change screen (コース変更画面) — the BPM screen where operators modify customer service contracts and trigger the discount auto-apply workflow. |
| `KKSV039605CC` | Constant | Screen CC identifier — the specific CC invocation key for the KKSV0396 course change operation. |
| `KKSV0395` | Screen | Related BPM screen (commented-out code path only) — appears in disabled check processing. |
| `CCRequestBroker` | Class | CC request routing broker — handles dispatch of CC invocations from BPM operations to the correct Common Component class and method. |
| `SessionHandle` | Class | Session management handle — carries DB connection, transaction, and user session context. |
| `IRequestParameterReadWrite` | Interface | Master parameter interface — carries model groups and control maps between BPM components. |
| `AbstractCommonComponent` | Class | Base class for Common Components — provides shared utilities for BPM CC implementations. |
