# Business Logic — JKKKikiKaifukuWrisvcCC.execWrisvcAutoAply() [71 LOC]

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

## 1. Role

### JKKKikiKaifukuWrisvcCC.execWrisvcAutoAply()

This method orchestrates the discount service auto-application process for equipment provider service contracts (機器提供サービス契約) during a contract recovery operation (契約回復). It is called from `execKktkSvcKeiInfoKaifuku()`, which handles equipment provider service detail information recovery. The method acts as an adapter and data-preparation layer: it extracts incoming request data from the session parameter map, assembles a structured service-contract data payload (including contract identification, status, pricing code, and service-type metadata), and then delegates to `JKKWrisvcAutoAplyCC.execute()` to perform the actual auto-application logic. The design pattern used is delegation with data assembly — this CC prepares the business envelope and hands it off to a specialized downstream CC. The method is a private shared utility, invoked only by `execKktkSvcKeiInfoKaifuku()` within the equipment provider service recovery flow, and it clears its intermediate working data from the request parameter before returning.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execWrisvcAutoAply entry"])
    STEP1["Set work key = WrisvcAutoAplyCC"]
    STEP2["Create empty HashMap, setData in param"]
    STEP3["Get ccMsg from param using dataMapKey"]
    STEP4["Get outMap from param using work key"]
    STEP5["Extract func_code from ccMsg"]
    STEP6["Extract ido_div from ccMsg"]
    STEP7["Set sysid on outMap from ekk0341a010Msg"]
    STEP8["Set add_chge_div on outMap from kobetsuData"]
    STEP9["Set mskm_no on outMap from mskmNo param"]
    STEP10["Set mskm_sbt_cd on outMap from ccMsg"]
    STEP11["Set ido_div on outMap"]
    STEP12["Set func_code on outMap"]
    STEP13["Create workSvcKeiArray"]
    STEP14["Create workSvcKeiMap, set grp_div = 00"]
    STEP15["Create workSvcKeiList"]
    STEP16["Create workSvcKeiData HashMap"]
    STEP17["Populate workSvcKeiData from kobetsuData"]
    STEP18["Add workSvcKeiData to workSvcKeiList"]
    STEP19["Add workSvcKeiList to workSvcKeiMap as svc_kei_list"]
    STEP20["Add workSvcKeiMap to workSvcKeiArray"]
    STEP21["Set svc_kei_grp_list on outMap"]
    STEP22["Create JKKWrisvcAutoAplyCC instance"]
    STEP23["Call wrisvcAutoAplyCC.execute(handle, param, workKey)"]
    STEP24["Remove work key data from param"]
    END(["Return / Next"])

    START --> STEP1 --> STEP2 --> STEP3 --> STEP4 --> STEP5 --> STEP6
    STEP6 --> STEP7 --> STEP8 --> STEP9 --> STEP10 --> STEP11 --> STEP12
    STEP12 --> STEP13 --> STEP14 --> STEP15 --> STEP16 --> STEP17
    STEP17 --> STEP18 --> STEP19 --> STEP20 --> STEP21
    STEP21 --> STEP22 --> STEP23 --> STEP24 --> END
```

**Note:** This method has no conditional branches (if/else, switch, loops). It executes a linear sequence of data extraction, payload assembly, delegation, and cleanup.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session handle carrying the application session context (transaction scope, user session data, and system date/time) used by downstream service components. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter carrier that stores and retrieves data maps by key across the service chain. Used to pass the assembled discount auto-application envelope to `JKKWrisvcAutoAplyCC.execute()`. |
| 3 | `ekk0341a010Msg` | `CAANMsg` | CBS message object from screen EKK0341A010 (equipment provider service contract recovery inquiry). Contains system-level data such as SYSID (system identifier) and other header fields required for the auto-application process. |
| 4 | `kobetsuData` | `HashMap<String, Object>` | Specific data map containing the targeted service contract details to be recovered — includes contract type codes, status flags, pricing codes, and provider service identifiers. This is the core business data payload. |
| 5 | `dataMapKey` | `String` | The key used to retrieve the caller's request parameter map (`ccMsg`) from `param`. This map contains incoming screen data like `func_code`, `mskm_sbt_cd`, and `ido_div`. |
| 6 | `mskmNo` | `String` | Application number (申請番号) — the unique identifier for the service contract application being processed during recovery. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKWrisvcAutoAplyCC.execute` | JKKWrisvcAutoAplyCC | — | Delegates to the discount service auto-application CC, which processes automatic discount application for the assembled service contract data envelope. |

**Note:** This method performs no direct database or entity CRUD operations itself. It assembles data structures and delegates to `JKKWrisvcAutoAplyCC.execute()`, which carries out the actual service-layer operations (the specific SC codes, CBS calls, and DB tables used within that downstream method are defined in its own documentation).

## 5. Dependency Trace

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

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKKikiKaifukuWrisvcCC.execKktkSvcKeiInfoKaifuku` | `execKktkSvcKeiInfoKaifuku` → `execWrisvcAutoAply` | `JKKWrisvcAutoAplyCC.execute` [delegation] |

## 6. Per-Branch Detail Blocks

**Block 1** — INITIALIZATION `(lines 310-315)`

> Prepare the working data envelope in the request parameter. Sets up the work key, creates an empty HashMap, and extracts incoming message data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workWrisvcAutoAplyDataKey = "WrisvcAutoAplyCC"` // Work data key constant |
| 2 | EXEC | `param.setData(workWrisvcAutoAplyDataKey, new HashMap<String, Object>())` // Create empty working map in param |
| 3 | SET | `ccMsg = (HashMap<String, Object>) param.getData(dataMapKey)` // Retrieve caller's request map (Request parameter data map obtained using dataMapKey) |
| 4 | SET | `outMap = (HashMap<String, Object>) param.getData(workWrisvcAutoAplyDataKey)` // Retrieve the working map (Working data map obtained using work key) |
| 5 | SET | `funcCode = (String) ccMsg.get("func_code")` // Extract function code (Function code) |
| 6 | SET | `ido_div = (String) ccMsg.get("ido_div")` // Extract change distinction (Change distinction) |

**Block 2** — OUTMAP POPULATION `(lines 317-328)`

> Populate the output map with system-level and identification fields sourced from the CBS message and caller parameters.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outMap.put("sysid", ekk0341a010Msg.getString(EKK0341A010CBSMsg1List.SYSID))` // Set system ID from CBS message (System ID) |
| 2 | SET | `outMap.put("add_chge_div", kobetsuData.get("add_chge_div"))` // Set add/change distinction (Add/Change distinction) |
| 3 | SET | `outMap.put("mskm_no", mskmNo)` // Set application number (Application number) |
| 4 | SET | `outMap.put("mskm_sbt_cd", (String) ccMsg.get("mskm_sbt_cd"))` // Set application type code (Application type code) |
| 5 | SET | `outMap.put("ido_div", ido_div)` // Set change distinction (Change distinction) |
| 6 | SET | `outMap.put("func_code", funcCode)` // Set function code (Function code) |

**Block 3** — SERVICE CONTRACT DATA ASSEMBLY `(lines 330-360)`

> Build a nested data structure representing the targeted service contract details. This includes contract identification, status codes, pricing information, and provider service metadata. The structure follows the hierarchy: array → group map → service list → service data items.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workSvcKeiArray = new ArrayList<HashMap<String, Object>>()` // Service contract group list (Service contract group list) |
| 2 | SET | `workSvcKeiMap = new HashMap<String, Object>()` // Service contract group map |
| 3 | SET | `workSvcKeiMap.put("grp_div", "00")` // Group distinction = "00" (Group distinction) |
| 4 | SET | `workSvcKeiList = new ArrayList<HashMap<String, Object>>()` // Service contract list |
| 5 | SET | `workSvcKeiData = new HashMap<String, Object>()` // Service contract data map |
| 6 | SET | `workSvcKeiData.put("tg_kei_skbt_cd", kobetsuData.get("tg_kei_skbt_cd"))` // Target contract type code (Target contract type code) |
| 7 | SET | `workSvcKeiData.put("kktk_svc_kei_no", kobetsuData.get("kktk_svc_kei_no"))` // Equipment provider service contract number (Equipment provider service contract number) |
| 8 | SET | `workSvcKeiData.put("kktk_svc_kei_stat", kobetsuData.get("kktk_svc_kei_stat"))` // Equipment provider service contract status (Equipment provider service contract status) |
| 9 | SET | `workSvcKeiData.put("svc_kei_ucwk_no", kobetsuData.get("svc_kei_ucwk_no"))` // Service contract work number (Service contract work number) |
| 10 | SET | `workSvcKeiData.put("svc_kei_ucwk_stat", kobetsuData.get("svc_kei_ucwk_stat"))` // Service contract work status (Service contract work status) |
| 11 | SET | `workSvcKeiData.put("pcrs_cd", kobetsuData.get("pcrs_cd"))` // Price code (Price code) |
| 12 | SET | `workSvcKeiData.put("pplan_cd", kobetsuData.get("pplan_cd"))` // Plan code (Plan code) |
| 13 | SET | `workSvcKeiData.put("kktk_svc_cd", kobetsuData.get("kktk_svc_cd"))` // Equipment provider service code (Equipment provider service code) |
| 14 | SET | `workSvcKeiData.put("kktk_sbt_cd", kobetsuData.get("kktk_sbt_cd"))` // Equipment provider type code (Equipment provider type code) |
| 15 | EXEC | `workSvcKeiList.add(workSvcKeiData)` // Add service data to list |
| 16 | SET | `workSvcKeiMap.put("svc_kei_list", workSvcKeiList)` // Set service list in group map |
| 17 | EXEC | `workSvcKeiArray.add(workSvcKeiMap)` // Add group map to array |
| 18 | SET | `outMap.put("svc_kei_grp_list", workSvcKeiArray)` // Set service contract group list in outMap |

**Block 4** — DELEGATION AND CLEANUP `(lines 362-366)`

> Create the discount auto-application CC instance, execute it with the assembled data envelope, and clean up the working data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wrisvcAutoAplyCC = new JKKWrisvcAutoAplyCC()` // Instantiate discount auto-application CC (Discount auto-application CC instance) |
| 2 | CALL | `wrisvcAutoAplyCC.execute(handle, param, workWrisvcAutoAplyDataKey)` // Execute discount auto-application processing |
| 3 | EXEC | `param.removeData(workWrisvcAutoAplyDataKey)` // Remove working data from param (Working data cleanup) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mskm_no` | Field | Application number — unique identifier for a service contract application |
| `mskm_sbt_cd` | Field | Application type code — classification code for the type of application |
| `ido_div` | Field | Change distinction — indicates the type of change (add, modify, delete) being performed on a contract |
| `func_code` | Field | Function code — identifies which business function is being invoked |
| `add_chge_div` | Field | Add/Change distinction — distinguishes between new additions and modifications to a contract |
| `svc_kei_ucwk_no` | Field | Service contract work number — internal tracking ID for a service contract detail line item |
| `svc_kei_ucwk_stat` | Field | Service contract work status — current processing status of a service contract work item |
| `kktk_svc_kei_no` | Field | Equipment provider service contract number — the contract number for equipment-provided services |
| `kktk_svc_kei_stat` | Field | Equipment provider service contract status — current status of the equipment provider service contract |
| `kktk_svc_cd` | Field | Equipment provider service code — code identifying the type of equipment provider service |
| `kktk_sbt_cd` | Field | Equipment provider type code — classification code for the kind of equipment provider |
| `tg_kei_skbt_cd` | Field | Target contract type code — code identifying the target service contract type for this operation |
| `pcrs_cd` | Field | Price code — pricing tier/code for the service contract |
| `pplan_cd` | Field | Plan code — service plan identification code |
| `grp_div` | Field | Group distinction — categorization field for grouping service contracts (value "00" = standard group) |
| `sysid` | Field | System identifier — system-level ID from the CBS message, identifying the originating system |
| `workWrisvcAutoAplyDataKey` | Constant | "WrisvcAutoAplyCC" — local key for the working data envelope in the request parameter |
| EKK0341A010CBSMsg1List | Class | CBS message constant definitions for screen EKK0341A010 (equipment provider service contract recovery) |
| SYSID | Constant | "sysid" — field name constant for the system ID in the CBS message |
| `workSvcKeiArray` | Variable | Service contract group list — top-level ArrayList containing service contract group maps |
| `workSvcKeiList` | Variable | Service contract list — ArrayList of service contract data maps within a group |
| `workSvcKeiData` | Variable | Service contract data — HashMap containing all fields for a single service contract detail |
| Kiki Kaifuku | Business term | Equipment provision recovery — the business domain of recovering/restoring equipment provider service contracts (typically after cancellation or error) |
| Wrisvc Auto Aply | Business term | Wireless service discount auto-application — automatic application of discounts to wireless/equipment provider service contracts |
| JKKWrisvcAutoAplyCC | Class | Discount service auto-application common component — downstream CC that performs the actual discount application logic |
| CC | Acronym | Common Component — a shared business logic component in the framework, typically a reusable service class |
| CBS | Acronym | Customer Business System — the telecom billing/customer management system |
| CAANMsg | Class | CBS message interface — the message object used for data exchange between CBS and application layer |
