# Business Logic — JKKTvSvcKeiCancelCC.execWrisvcAutoAply() [70 LOC]

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

## 1. Role

### JKKTvSvcKeiCancelCC.execWrisvcAutoAply()

This method orchestrates the preparation and delegation of discount service cancellation data to the auto-application subsystem. In K-Opticom's fiber-to-the-home (FTTH) telecom service platform, when a customer's TV or bundled discount contract is cancelled, the system must feed the relevant service contract details into the auto-application CC (`JKKWrisvcAutoAplyCC`) which then decides whether pricing discounts, installation charges, or other contract-line-item adjustments should be automatically applied or reversed.

The method operates as a **data-mapping and delegation pattern**: it reads the caller's input data map and the current service contract header information, constructs a structured service contract data object (including system ID, contract number, status, service code, pricing details, and end dates), wraps it in a work map keyed by `"WrisvcAutoAplyCC"`, and delegates to `JKKWrisvcAutoAplyCC.execute()` to perform the actual auto-application logic. There are no conditional branches — the method unconditionally populates the work structure and always delegates.

The method serves as a shared common component called by the main TV contract cancellation processing (`cancel()`) specifically when handling discount service line items during a TV contract cancellation flow. The hardcoded cancellation reason code `"10"` indicates a standard service cancellation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execWrisvcAutoAply handle, param, curSvcKeiInfo, dataMapKey, mskmNo"])
    STEP1["SET workWrisvcAutoAplyDataKey = WrisvcAutoAplyCC"]
    STEP2["EXEC param.setData workWrisvcAutoAplyDataKey, new HashMap"]
    STEP3["SET ccMsg = HashMap param.getData dataMapKey"]
    STEP4["SET outMap = HashMap param.getData workWrisvcAutoAplyDataKey"]
    STEP5["SET funcCode = ccMsg.get func_code<br/>SET ido_div = ccMsg.get ido_div"]
    STEP6["outMap.put sysid<br/>outMap.put add_chge_div = 05 Change<br/>outMap.put mskm_no<br/>outMap.put mskm_sbt_cd = 00020 Contract<br/>outMap.put ido_div<br/>outMap.put func_code<br/>outMap.put svc_cancel_rsn_cd = 10 Cancellation"]
    STEP7["SET workSvcKeiArray = new ArrayList<br/>SET workSvcKeiMap = new HashMap<br/>SET workSvcKeiList = new ArrayList<br/>SET workSvcKeiData = new HashMap"]
    STEP8["workSvcKeiData.put sysid from curSvcKeiInfo<br/>workSvcKeiData.put tg_kei_skbt_cd = 01 Target<br/>workSvcKeiData.put svc_kei_no<br/>workSvcKeiData.put svc_kei_stat<br/>workSvcKeiData.put svc_cd<br/>workSvcKeiData.put prc_grp_cd<br/>workSvcKeiData.put pcrs_cd<br/>workSvcKeiData.put pplan_cd<br/>workSvcKeiData.put svc_endymd<br/>workSvcKeiData.put svc_chrg_endymd<br/>workSvcKeiMap.put svc_kei_list<br/>outMap.put svc_kei_grp_list"]
    STEP9["JKKWrisvcAutoAplyCC execute handle, param, workWrisvcAutoAplyDataKey<br/>Delegate to auto-application CC"]
    END_NODE(["Return void"])

    START --> STEP1 --> STEP2 --> STEP3 --> STEP4 --> STEP5 --> STEP6 --> STEP7 --> STEP8 --> STEP9 --> END_NODE
```

**CRITICAL -- Constant Resolution:**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `add_chge_div` | `"05"` | Registration/Change Division — `05` means "Change" (modification operation) |
| `mskm_sbt_cd` | `"00020"` | Application Type Code — `00020` means "Contract" |
| `svc_cancel_rsn_cd` | `"10"` | Cancellation Reason Code — `10` means "Service Cancellation" |
| `tg_kei_skbt_cd` | `"01"` | Target Contract ID — `01` means "Target (the contract being operated on)" |
| `grp_div` | `"00"` | Group Division — `00` means "Default group" |
| `workWrisvcAutoAplyDataKey` | `"WrisvcAutoAplyCC"` | Data map key for the work output of the Wrisvc Auto-Apply component |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transaction context and connection to the enterprise DB. Used to pass to `JKKWrisvcAutoAplyCC.execute()` for DB-level operations during auto-application. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object that carries bidirectional data between components. Used as a shared map to store the initialized work output data under the key `"WrisvcAutoAplyCC"`, and to read caller input data via `dataMapKey`. |
| 3 | `curSvcKeiInfo` | `CAANMsg` | Current service contract header message object carrying live service contract details — system ID, contract number, status, service code, pricing group code, pricing course code, pricing plan code, and end dates. Read via field constants from `EKK0081A010CBSMsg1List`. |
| 4 | `dataMapKey` | `String` | Key into the `param` map pointing to the caller's input data (a HashMap) that contains the functional code and operation division. This is the bridge from the calling context to this method's work map. |
| 5 | `mskmNo` | `String` | Application detail number (申請番号) — the unique identifier for the specific application line item being processed. Stored directly into the work output map as `mskm_no`. |

**External state read:**
- `EKK0081A010CBSMsg1List` constants — field position constants for `SYSID`, `SVC_KEI_NO`, `SVC_KEI_STAT`, `SVC_CD`, `PRC_GRP_CD`, `PCRS_CD`, `PPLAN_CD`, `SVC_ENDYMD`, `SVC_CHRG_ENDYMD` used to extract values from `curSvcKeiInfo`.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `param.setData(workWrisvcAutoAplyDataKey, new HashMap)` | - | - | Sets a new empty HashMap as work output data in the param map under key `"WrisvcAutoAplyCC"` |
| R | `param.getData(dataMapKey)` | - | - | Retrieves caller input data map (HashMap) from the param using the provided `dataMapKey` |
| R | `param.getData(workWrisvcAutoAplyDataKey)` | - | - | Retrieves the work output map that was just initialized, to populate with cancellation data |
| R | `curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SYSID)` | - | - | Reads system ID from the current service contract info message |
| R | `curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_KEI_NO)` | - | - | Reads service contract number |
| R | `curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_KEI_STAT)` | - | - | Reads service contract status |
| R | `curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_CD)` | - | - | Reads service code |
| R | `curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.PRC_GRP_CD)` | - | - | Reads pricing group code |
| R | `curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.PCRS_CD)` | - | - | Reads pricing course code |
| R | `curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.PPLAN_CD)` | - | - | Reads pricing plan code |
| R | `curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_ENDYMD)` | - | - | Reads service end date (YYYYMMDD) |
| R | `curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_CHRG_ENDYMD)` | - | - | Reads service charge end date (YYYYMMDD) |
| C | `JKKWrisvcAutoAplyCC.execute(handle, param, workWrisvcAutoAplyDataKey)` | JKKWrisvcAutoAplyCC | Auto-application tables (pricing/discount adjustments) | Delegates to the Wrisvc Auto-Apply Common Component which processes automatic discount/service contract application adjustments. Performs CRUD on auto-application-related entities (pricing plans, discount rates, contract line items). |

**How to classify:**
- **R (Read)**: Methods with `getString()` on `CAANMsg` objects — these extract field values from in-memory message objects.
- **C (Create)**: `JKKWrisvcAutoAplyCC.execute()` — the execute prefix combined with its business purpose (auto-application of discounts and pricing adjustments) indicates creation/registration of auto-application records.

## 5. Dependency Trace

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKTvSvcKeiCancelCC.cancel()` | `cancel()` -> `execWrisvcAutoAply(handle, param, curSvcKeiInfo, dataMapKey, mskmNo)` | `JKKWrisvcAutoAplyCC.execute` [C] auto-application entities; `getString` [R] service contract info fields |

## 6. Per-Branch Detail Blocks

This method has no conditional branches (no if/else, switch, or loop). It follows a single straight-line execution path.

**Block 1** — [TOP-LEVEL SEQUENTIAL] `(no condition)` (L257)

> Prepare the work output data structure and populate it with cancellation header data.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `workWrisvcAutoAplyDataKey = "WrisvcAutoAplyCC"` | Define the work data map key for Wrisvc Auto-Apply (割引サービスの自動適用CC実行処理 — Discount service auto-apply CC execution processing) |
| 2 | EXEC | `param.setData(workWrisvcAutoAplyDataKey, new HashMap<String, Object>())` | Initialize an empty HashMap as the work output data under the key `WrisvcAutoAplyCC` |

**Block 2** — [DATA RETRIEVAL] `(no condition)` (L261)

> Retrieve both the caller input map and the work output map from the param.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ccMsg = (HashMap<String, Object>)param.getData(dataMapKey)` | Get caller input data map — contains the functional code and operation division from the calling context (呼出元のデータマップ取得) |
| 2 | SET | `outMap = (HashMap<String, Object>)param.getData(workWrisvcAutoAplyDataKey)` | Get the work output map that was just initialized to populate |

**Block 3** — [METADATA EXTRACTION] `(no condition)` (L264)

> Extract functional code and operation division from caller input data.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `funcCode = (String) ccMsg.get("func_code")` | Extract functional code from caller input (機能コード) |
| 2 | SET | `ido_div = (String) ccMsg.get("ido_div")` | Extract operation division — indicates whether this is registration, change, or cancellation (移動区分) |
| 3 | EXEC | `outMap.put("sysid", ccMsg.get("sysid"))` | Pass through the system ID from caller input (SYSID) |

**Block 4** — [HEADER DATA POPULATION] `[add_chge_div="05"]` `[mskm_sbt_cd="00020"]` `[svc_cancel_rsn_cd="10"]` (L266)

> Populate the work output map with standard header data for the cancellation request. These are all hardcoded business constants:
> - `add_chge_div = "05"` means "Change" operation (登録/変更区分 — Registration/Change Division)
> - `mskm_sbt_cd = "00020"` means "Contract" type (申請種別コード — Application Type Code)
> - `svc_cancel_rsn_cd = "10"` means "Service Cancellation" reason (キャンセル理由コード — Cancellation Reason Code)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `outMap.put("add_chge_div", "05")` | Set registration/change division to "05" (Change) (登録/変更区分) |
| 2 | SET | `outMap.put("mskm_no", mskmNo)` | Set the application detail number passed as parameter (申請番号) |
| 3 | SET | `outMap.put("mskm_sbt_cd", "00020")` | Set application type code to "00020" (Contract) (申請種別コード) |
| 4 | SET | `outMap.put("ido_div", ido_div)` | Pass through operation division from caller input (移動区分) |
| 5 | SET | `outMap.put("func_code", funcCode)` | Pass through functional code from caller input (機能コード) |
| 6 | SET | `outMap.put("svc_cancel_rsn_cd", "10")` | Set cancellation reason code to "10" (Service Cancellation) (キャンセル理由コード) |

**Block 5** — [SERVICE CONTRACT DATA STRUCTURE INITIALIZATION] (L270)

> Initialize nested data structures to hold the service contract group and line-item details.
> - `workSvcKeiArray` — Array of service contract groups (サービス契約グループリスト)
> - `workSvcKeiMap` — Map representing one group with `grp_div` and `svc_kei_list`
> - `workSvcKeiList` — List of individual service contract line items (サービス契約リスト)
> - `workSvcKeiData` — Map representing one service contract line item with all field data

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `workSvcKeiArray = new ArrayList<HashMap<String, Object>>()` | Initialize service contract group array (サービス契約グループリスト) |
| 2 | SET | `workSvcKeiMap = new HashMap<String, Object>()` | Initialize one group map (グループ区分) |
| 3 | SET | `workSvcKeiMap.put("grp_div", "00")` | Set group division to "00" (default group) (グループ区分) |
| 4 | SET | `workSvcKeiList = new ArrayList<HashMap<String, Object>>()` | Initialize service contract line items list (サービス契約リスト) |
| 5 | SET | `workSvcKeiData = new HashMap<String, Object>()` | Initialize one service contract data map (サービス契約データ) |

**Block 6** — [SERVICE CONTRACT LINE-ITEM POPULATION] `[tg_kei_skbt_cd="01"]` (L273)

> Populate the service contract line item with all field values extracted from `curSvcKeiInfo`. This is the core data mapping — converting the flat CAANMsg into a structured HashMap for the auto-application subsystem. All field references use constants from `EKK0081A010CBSMsg1List`:
> - `tg_kei_skbt_cd = "01"` means "Target (the contract being operated on)" (対象契約識別コード — Target Contract Identification Code)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `workSvcKeiData.put("sysid", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SYSID))` | Read system ID from service contract info (SYSID) |
| 2 | SET | `workSvcKeiData.put("tg_kei_skbt_cd", "01")` | Set target contract identification code to "01" (Target) (対象契約識別コード) |
| 3 | SET | `workSvcKeiData.put("svc_kei_no", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_KEI_NO))` | Read service contract number (サービス契約番号) |
| 4 | SET | `workSvcKeiData.put("svc_kei_stat", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_KEI_STAT))` | Read service contract status (サービス契約ステータス) |
| 5 | SET | `workSvcKeiData.put("svc_cd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_CD))` | Read service code (サービスコード) |
| 6 | SET | `workSvcKeiData.put("prc_grp_cd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.PRC_GRP_CD))` | Read pricing group code (料金グループコード) |
| 7 | SET | `workSvcKeiData.put("pcrs_cd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.PCRS_CD))` | Read pricing course code (料金コースコード) |
| 8 | SET | `workSvcKeiData.put("pplan_cd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.PPLAN_CD))` | Read pricing plan code (料金プランコード) |
| 9 | SET | `workSvcKeiData.put("svc_endymd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_ENDYMD))` | Read service end date (サービス終了年月日) |
| 10 | SET | `workSvcKeiData.put("svc_chrg_endymd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_CHRG_ENDYMD))` | Read service charge end date (サービス課金終了年月日) |
| 11 | EXEC | `workSvcKeiList.add(workSvcKeiData)` | Add the line item to the contract list |
| 12 | EXEC | `workSvcKeiMap.put("svc_kei_list", workSvcKeiList)` | Set the contract list in the group map |
| 13 | EXEC | `workSvcKeiArray.add(workSvcKeiMap)` | Add the group map to the group array |
| 14 | EXEC | `outMap.put("svc_kei_grp_list", workSvcKeiArray)` | Set the service contract group list in the work output map |

**Block 7** — [DELEGATION TO AUTO-APPLICATION CC] (L309)

> Instantiate and execute the Wrisvc Auto-Apply common component, passing the fully populated work map.
> - Creates a new `JKKWrisvcAutoAplyCC` instance
> - Calls `execute(handle, param, workWrisvcAutoAplyDataKey)` to process the cancellation data

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `JKKWrisvcAutoAplyCC wrisvcAutoAplyCC = new JKKWrisvcAutoAplyCC()` | Instantiate the Wrisvc Auto-Apply common component (割引サービス契約自動適用CC) |
| 2 | CALL | `wrisvcAutoAplyCC.execute(handle, param, workWrisvcAutoAplyDataKey)` | Execute the auto-application logic — this performs the actual discount/pricing adjustments based on the prepared work data |

**Block 8** — [RETURN] (L313)

> The method ends here. The output data remains in the param map for downstream consumers. The commented-out code indicates a historical cleanup step that was removed (コメントアウト — commented out):

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `// param.removeData(workWrisvcAutoAplyDataKey);` | Historically removed the work data from param after getting return messages (戻り値のメッセージを取得するためコメントアウト — Commented out to retrieve return value messages) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `execWrisvcAutoAply` | Method | Execute Wrisvc (Wireless/Remote) Service Auto-Apply — prepares and delegates discount service cancellation data for automatic pricing adjustments |
| `cancel()` | Method | Main TV service contract cancellation processing entry point that calls `execWrisvcAutoAply` |
| `workWrisvcAutoAplyDataKey` | Field | Work data map key `"WrisvcAutoAplyCC"` — identifies the work output data in the param map for the Wrisvc Auto-Apply component |
| `add_chge_div` | Field | Registration/Change Division — distinguishes between new registration and modification operations; `05` = Change |
| `mskm_sbt_cd` | Field | Application Type Code (申請種別コード) — classifies the type of application; `00020` = Contract |
| `mskm_no` | Field | Application Detail Number (申請番号) — unique identifier for a specific application line item |
| `ido_div` | Field | Operation Division (移動区分) — indicates the type of operation (registration, change, cancellation) |
| `func_code` | Field | Functional Code (機能コード) — identifies which business function is being invoked |
| `svc_cancel_rsn_cd` | Field | Cancellation Reason Code (キャンセル理由コード) — why the service is being cancelled; `10` = Service Cancellation |
| `grp_div` | Field | Group Division (グループ区分) — group classification within the service contract data structure; `00` = Default |
| `tg_kei_skbt_cd` | Field | Target Contract Identification Code (対象契約識別コード) — identifies whether this contract is the target of the operation; `01` = Target |
| `svc_kei_no` | Field | Service Contract Number (サービス契約番号) — unique identifier for a service contract |
| `svc_kei_stat` | Field | Service Contract Status (サービス契約ステータス) — current lifecycle status of the contract |
| `svc_cd` | Field | Service Code (サービスコード) — identifies the type of telecom service (e.g., FTTH TV, broadband) |
| `prc_grp_cd` | Field | Pricing Group Code (料金グループコード) — group classification for pricing tiers |
| `pcrs_cd` | Field | Pricing Course Code (料金コースコード) — specific pricing course/plan tier |
| `pplan_cd` | Field | Pricing Plan Code (料金プランコード) — the pricing plan associated with the contract |
| `svc_endymd` | Field | Service End Date (サービス終了年月日) — when the service itself terminates (YYYYMMDD) |
| `svc_chrg_endymd` | Field | Service Charge End Date (サービス課金終了年月日) — when billing for the service stops (YYYYMMDD) |
| `EKK0081A010CBSMsg1List` | Constant Class | Schema constants for service contract header message fields — defines field position keys for SYSID, SVC_KEI_NO, SVC_CD, etc. |
| `JKKWrisvcAutoAplyCC` | Component | Wrisvc Auto-Apply Common Component — processes automatic discount and pricing adjustments for service contracts |
| `CAANMsg` | Type | Fujitsu CAAN (Component Architecture for Application Networking) message object — generic typed message container for field access via `getString()` |
| `SessionHandle` | Type | Database session handle — provides transaction context and DB connection for CBS/SC calls |
| `IRequestParameterReadWrite` | Type | Bidirectional request parameter interface — shared map for inter-component data exchange |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service delivered by K-Opticom |
| K-Opticom | Business term | Japanese telecommunications provider offering FTTH broadband, IPTV, and bundled services |
| CC | Acronym | Common Component — reusable shared business logic component in the K-Opticom platform architecture |
| CBS | Acronym | Core Business System — the enterprise system housing telecom service processing |
| SC | Acronym | Service Component — granular business logic units invoked by CBS |
| SYSID | Field | System ID — identifies which subsystem/system context the data belongs to |
| 割引 | Business term | Discount — refers to promotional pricing or contract discounts applied to telecom services |
| 自動適用 | Business term | Auto-Apply — automatic application of discount/pricing adjustments without manual intervention |
| サービス契約取消 | Business term | Service Contract Cancellation — the business process of terminating a service contract and its associated discounts |
