# Business Logic — JKKTVSvcKeiKaihukuCC.cancelRecoveryToCNC() [265 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKTVSvcKeiKaihukuCC` |
| Layer | Common Component (CC) — shared business logic across multiple screen handlers |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKTVSvcKeiKaihukuCC.cancelRecoveryToCNC()

This method performs **cancellation recovery for K-Opticom TV service contracts** (キャンセルからの回復処理). When a customer previously submitted a cancellation request that was processed (the cancellation recovery was executed), but the customer later requests to reverse that cancellation (e.g., they changed their mind), this method retracts every cancellation at every level of the service hierarchy. It operates as a **hierarchical cascade**: first recovering the root service contract, then iterating through each service detail (サービス契約内訳), each equipment service contract (機器提供サービス契約), each optional service contract (オプションサービス契約), and each contract cancellation detail (契約回線内訳) — calling the appropriate "cancellation recovery" CBS at each level. The method follows a **delegation pattern**, routing all actual data access and CBS invocation through its `callSC` helper, ensuring a consistent call interface. It is a **shared utility** called exclusively by `JKKTVSvcKeiKaihukuCC.kaihuku()`, serving as the core engine of the cancellation recovery workflow within the K-Opticom TV billing and contract management system.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["cancelRecoveryToCNC(params)"])

    START --> EXTRACT["Extract func_code, ido_div, lastUpdDtm, svc_kei_no from data map"]

    EXTRACT --> EKK0081IN["Build EKK0081C230IN (Service contract cancellation recovery input)"]
    EKK0081IN --> EKK0081CALL["callSC EKK0081C230 (Service contract cancellation recovery)"]
    EKK0081CALL --> EKK0081OUT["Get lastUpdDtm from EKK0081 output"]

    EKK0081OUT --> EKK0161IN["Build EKK0161B004IN (Service contract details list)"]
    EKK0161IN --> EKK0161CALL["callSC EKK0161B004 (Service contract details list)"]
    EKK0161CALL --> EKK0161OUT["Get ekk0161b004OUT list from response"]

    EKK0161OUT --> LOOP1START{"For each curSvcKeiUcwkInfo"}
    LOOP1START --> EKK0161C240IN["Build EKK0161C240IN (Detail cancellation recovery)"]
    EKK0161C240IN --> EKK0161C240CALL["callSC EKK0161C240 (Detail cancellation recovery)"]
    EKK0161C240CALL --> EKK0161C240OUT["Get lastUpdDtm from EKK0161C240 output"]

    EKK0161C240OUT --> EKK0341B501IN["Build EKK0341B501IN (Equipment service contract list)"]
    EKK0341B501IN --> EKK0341B501CALL["callSC EKK0341B501 (Equipment service contract list)"]
    EKK0341B501CALL --> EKK0341B501OUT["Get ekk0341b501OUT list from response"]

    EKK0341B501OUT --> LOOP2START{"For each curKktkSvcKeiInfo"}
    LOOP2START --> EKK0341C420IN1["Build EKK0341C420IN (Equipment contract cancellation recovery)"]
    EKK0341C420IN1 --> EKK0341C420CALL1["callSC EKK0341C420 (Equipment cancellation recovery)"]
    EKK0341C420CALL1 --> EKK0341C420OUT1["Get lastUpdDtm from EKK0341C420 output"]

    EKK0341C420OUT1 --> LOOP2END["Next curKktkSvcKeiInfo"]
    LOOP2END --> LOOP1B["Next curSvcKeiUcwkInfo"]

    LOOP1B --> EKK0351B002IN["Build EKK0351B002IN (Optional service contract list)"]
    EKK0351B002IN --> EKK0351B002CALL["callSC EKK0351B002 (Optional service contract list)"]
    EKK0351B002CALL --> EKK0351B002OUT["Get ekk0351b002OUT list from response"]

    EKK0351B002OUT --> LOOP3START{"For each curOpSvcKeiInfo"}
    LOOP3START --> EKK0351C300IN["Build EKK0351C300IN (Optional contract cancellation recovery)"]
    EKK0351C300IN --> EKK0351C300CALL["callSC EKK0351C300 (Optional cancellation recovery)"]
    EKK0351C300CALL --> EKK0351C300OUT["Get lastUpdDtm from EKK0351C300 output"]

    EKK0351C300OUT --> LOOP3END["Next curOpSvcKeiInfo"]
    LOOP3END --> LOOP1C["Next curSvcKeiUcwkInfo"]

    LOOP1C --> EKK0241B001IN["Build EKK0241B001IN (Contract cancellation details list)"]
    EKK0241B001IN --> EKK0241B001CALL["callSC EKK0241B001 (Cancellation details list)"]
    EKK0241B001CALL --> EKK0241B001OUT["Get ekk0241b001OUT list from response"]

    EKK0241B001OUT --> LOOP4START{"For each curKaiUcwkInfo"}
    LOOP4START --> EKK0251A010IN["Build EKK0251A010IN (Cancellation detail inquiry)"]
    EKK0251A010IN --> EKK0251A010CALL["callSC EKK0251A010 (Cancellation detail inquiry)"]
    EKK0251A010CALL --> EKK0251A010OUT["Get ekk0251a010OUT single message"]

    EKK0251A010OUT --> EKK0341B504IN["Build EKK0341B504IN (Equipment list by cancellation)"]
    EKK0341B504IN --> EKK0341B504CALL["callSC EKK0341B504 (Equipment list by cancellation)"]
    EKK0341B504CALL --> EKK0341B504OUT["Get ekk0341b504OUT list from response"]

    EKK0341B504OUT --> LOOP5START{"For each curKaisenKiki"}
    LOOP5START --> FILTER1{"KKTK_SVC_KEI_STAT = '920' AND KKTK_SVC_CD = 'C013'?"}
    FILTER1 -->|No| LOOP5SKIP["Skip (continue)"]
    FILTER1 -->|Yes| EKK0341C420IN2["Build EKK0341C420IN (Equipment cancellation recovery)"]
    EKK0341C420IN2 --> EKK0341C420CALL2["callSC EKK0341C420 (Equipment cancellation recovery)"]
    EKK0341C420CALL2 --> EKK0341C420OUT2["Get lastUpdDtm from EKK0341C420 output"]

    EKK0341C420OUT2 --> LOOP5END["Next curKaisenKiki"]
    LOOP5END --> FILTER2{"SVC_KEI_KAISEN_UCWK_STAT != '920'?"}
    FILTER2 -->|Yes| LOOP4SKIP["Skip (continue)"]
    FILTER2 -->|No| EKK0251C080IN["Build EKK0251C080IN (Cancellation detail recovery)"]
    EKK0251C080IN --> EKK0251C080CALL["callSC EKK0251C080 (Cancellation detail recovery)"]
    EKK0251C080CALL --> EKK0251C080OUT["Get lastUpdDtm from EKK0251C080 output"]

    EKK0251C080OUT --> LOOP4END["Next curKaiUcwkInfo"]
    LOOP4END --> LOOP1D["Next curSvcKeiUcwkInfo"]
    LOOP1D --> END_NODE["Return void"]

    LOOP5SKIP --> FILTER2
    LOOP4SKIP --> END_NODE
    LOOP2END --> LOOP1B
    LOOP3END --> LOOP1C

    style START fill:#f0f0f0,stroke:#333,stroke-width:2px
    style END_NODE fill:#f0f0f0,stroke:#333,stroke-width:2px
    style FILTER1 fill:#fff3cd,stroke:#f0ad4e
    style FILTER2 fill:#fff3cd,stroke:#f0ad4e
```

**CRITICAL — Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|-----------------|
| `TEMPLATE_ID_EKK0081C230` | `"EKK0081C230"` | Template for Service Contract Cancellation Recovery (確認後サービス契約キャンセル取消) |
| `TEMPLATE_ID_EKK0161B004` | `"EKK0161B004"` | Template for Service Contract Details List (サービス契約内訳照会) |
| `TEMPLATE_ID_EKK0161C240` | `"EKK0161C240"` | Template for Service Contract Detail Cancellation Recovery (確認後サービス契約内訳キャンセル取消) |
| `TEMPLATE_ID_EKK0341B501` | `"EKK0341B501"` | Template for Equipment Service Contract List (機器提供サービス契約一覧照会) |
| `TEMPLATE_ID_EKK0341C420` | `"EKK0341C420"` | Template for Equipment Contract Cancellation Recovery (確認後機器提供サービス契約キャンセル取消) |
| `TEMPLATE_ID_EKK0351B002` | `"EKK0351B002"` | Template for Optional Service Contract List (オプションサービス契約一覧照会) |
| `TEMPLATE_ID_EKK0351C300` | `"EKK0351C300"` | Template for Optional Contract Cancellation Recovery (確認後オプションサービス契約キャンセル取消) |
| `TEMPLATE_ID_EKK0241B001` | `"EKK0241B001"` | Template for Contract Cancellation Details List (サービス契約回線内訳一覧照会) |
| `TEMPLATE_ID_EKK0251C080` | `"EKK0251C080"` | Template for Cancellation Detail Recovery (サービス契約回線内訳キャンセル取消) |
| `TEMPLATE_ID_EKK0251A010` | `"EKK0251A010"` | Template for Cancellation Detail Inquiry (サービス契約回線内訳一致照会) |
| `TEMPLATE_ID_EKK0341B504` | `"EKK0341B504"` | Template for Equipment List by Cancellation (機器提供サービス契約一覧照会(サービス契約回線内訳)) |

**Status Code Constants (embedded literals, not extracted to class):**

| Literal | Business Meaning |
|---------|-----------------|
| `"920"` | Service status: "In Use" (使用中) — the item is currently active/operational |
| `"C013"` | Service code identifying a specific equipment type (e.g., set-top box / STB) |
| `"1"` | Fixed func_code value passed to list/query CBS calls |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transaction context and database connection for all CBS calls made within this method |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service Component invocation bridge used to dispatch requests to CBS (Business Support System) components and receive responses |
| 3 | `param` | `IRequestParameterReadWrite` | Request/response parameter container holding the data map, function code, and other screen-level parameters exchanged between the caller and CBS |
| 4 | `dataMapKey` | `String` | Key used to retrieve the HashMap containing cancel-recovery data from the `param` object (the data map holds `func_code`, `ido_div`, `lastUpdDtm`, `svc_kei_no`) |
| 5 | `mskmDtlNo` | `String` | Mailing detail number (請求明細番号) — the billing detail reference identifier used as a correlation key across all CBS cancellation recovery calls |

**External/Instance State Read:**

None — this method does not read any instance fields. All data is passed through parameters.

## 4. CRUD Operations / Called Services

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

The following CBS services are invoked by this method. All operations are Read (R) — the method queries for lists, then calls "cancellation recovery" operations which are logical retractions of previously confirmed cancellations.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0081C230 | Service contract table (KK_T_SVC_KEI) | Cancels recovery of a previously confirmed service contract cancellation (確認後サービス契約キャンセル取消) |
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0161B004 | Service contract detail table (KK_T_SVC_KEI_DETAIL) | Retrieves the list of service contract details for the given service number (サービス契約内訳照会) |
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0161C240 | Service contract detail table | Cancels recovery of a previously confirmed service contract detail cancellation (確認後サービス契約内訳キャンセル取消) |
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0341B501 | Equipment service contract table (KK_T_KKTK_SVC_KEI) | Retrieves equipment service contracts associated with a service detail work number (機器提供サービス契約一覧照会) |
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0341C420 | Equipment service contract table | Cancels recovery of a previously confirmed equipment service contract cancellation (確認後機器提供サービス契約キャンセル取消) |
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0351B002 | Optional service contract table (KK_T_OP_SVC_KEI) | Retrieves optional service contracts for a given service number (オプションサービス契約一覧照会) |
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0351C300 | Optional service contract table | Cancels recovery of a previously confirmed optional service contract cancellation (確認後オプションサービス契約キャンセル取消) |
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0241B001 | Cancellation detail table (KK_T_SVC_KEI_KAI_SEN) | Retrieves cancellation details for a given service number (サービス契約回線内訳一覧照会) |
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0251A010 | Cancellation detail work table (KK_T_SVC_KEI_KAI_SEN_UCWK) | Performs cancellation detail matching inquiry to check status (サービス契約回線内訳一致照会) |
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0341B504 | Equipment service contract table | Retrieves equipment service contracts associated with a cancellation detail work number (機器提供サービス契約一覧照会(サービス契約回線内訳)) |
| R | `JKKTVSvcKeiKaihukuCC.callSC` | EKK0251C080 | Cancellation detail work table | Cancels recovery of a previously confirmed cancellation detail cancellation (サービス契約回線内訳キャンセル取消) |

**Operation Classification:**

- The CBS codes ending in **B** (e.g., EKK0161B004, EKK0351B002, EKK0241B001, EKK0341B501, EKK0341B504, EKK0251A010) are **list/inquiry queries** — they read data from the database to build iteration collections.
- The CBS codes ending in **C** (e.g., EKK0081C230, EKK0161C240, EKK0341C420, EKK0351C300, EKK0251C080) are **cancellation recovery operations** — they perform logical retractions of previously confirmed cancellations, effectively restoring the records to their pre-cancellation state.

## 5. Dependency Trace

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

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC: `JKKTVSvcKeiKaihukuCC.kaihuku()` | `kaihuku()` → `cancelRecoveryToCNC()` | `callSC EKK0081C230 [R] KK_T_SVC_KEI`, `callSC EKK0161B004 [R] KK_T_SVC_KEI_DETAIL`, `callSC EKK0161C240 [R] KK_T_SVC_KEI_DETAIL`, `callSC EKK0341B501 [R] KK_T_KKTK_SVC_KEI`, `callSC EKK0341C420 [R] KK_T_KKTK_SVC_KEI`, `callSC EKK0351B002 [R] KK_T_OP_SVC_KEI`, `callSC EKK0351C300 [R] KK_T_OP_SVC_KEI`, `callSC EKK0241B001 [R] KK_T_SVC_KEI_KAI_SEN`, `callSC EKK0251A010 [R] KK_T_SVC_KEI_KAI_SEN_UCWK`, `callSC EKK0341B504 [R] KK_T_KKTK_SVC_KEI`, `callSC EKK0251C080 [R] KK_T_SVC_KEI_KAI_SEN_UCWK` |

## 6. Per-Branch Detail Blocks

**Block 1** — EXTRACT `(Extract data from map)` (L1206)

> Extract function code, movement division, last update timestamp, and service number from the data map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMsg = (HashMap<String, Object>) param.getData(dataMapKey)` — get the cancel-recovery data map [-> dataMapKey is the map key] |
| 2 | SET | `funcCode = (String) ccMsg.get("func_code")` — [-> "機能コード (Function Code)"] |
| 3 | SET | `idoDiv = (String) ccMsg.get("ido_div")` — [-> "異動区分 (Movement/Division Type)"] |
| 4 | SET | `lastUpdDtm = (String) ccMsg.get("lastUpdDtm")` — [-> "更新年月日時刻分秒 (Last Update DateTime)"] |
| 5 | SET | `opeDate` — commented out, previously obtained via `JPCCBCommon.getOpeDate(null)` [-> "運用日 (Operation Date)"] |

**Block 2** — EXEC `(EKK0081C230: Service contract cancellation recovery)` (L1255)

> Call CBS to recover the service contract cancellation. This is the root-level recovery — if a service contract was cancelled, this restores it.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `ekk0081c230IN = new CAANMsg(EKK0081C230CBSMsg.class.getName())` — create input message |
| 2 | SET | `ekk0081c230IN.set(TEMPLATEID, TEMPLATE_ID_EKK0081C230)` → `"EKK0081C230"` |
| 3 | SET | `ekk0081c230IN.set(FUNC_CODE, funcCode)` — function code from the data map |
| 4 | SET | `ekk0081c230IN.set(SVC_KEI_NO, ccMsg.get("svc_kei_no"))` — [-> "サービス契約番号 (Service Contract Number)"] |
| 5 | SET | `ekk0081c230IN.set(MSKM_DTL_NO, mskmDtlNo)` — billing detail number |
| 6 | SET | `ekk0081c230IN.set(IDO_DIV, ido_div)` — movement division type |
| 7 | SET | `ekk0081c230IN.set(UPD_DTM_BF, lastUpdDtm)` — last update timestamp before modification |
| 8 | CALL | `ekk0081c230OUT = callSC(handle, scCall, param, dataMapKey, ekk0081c230IN)` → EKK0081C230: 確認後サービス契約キャンセル取消 |
| 9 | EXEC | `lastUpdDtm = ekk0081c230OUT.getString(EKK0081C230CBSMsg.UPD_DTM)` — refresh timestamp for optimistic locking |

**Block 3** — FOR `(Iterate over service contract details — EKK0161B004 + EKK0161C240)` (L1269)

> Query all service contract details (内訳) and recover each one's cancellation. Also, for each detail, query and recover equipment service contracts.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `ekk0161b004IN = new CAANMsg(EKK0161B004CBSMsg.class.getName())` |
| 2 | SET | `ekk0161b004IN.set(TEMPLATEID, TEMPLATE_ID_EKK0161B004)` → `"EKK0161B004"` |
| 3 | SET | `ekk0161b004IN.set(FUNC_CODE, "1")` — [-> func code "1" for list query] |
| 4 | SET | `ekk0161b004IN.set(KEY_SVC_KEI_NO, ccMsg.get("svc_kei_no"))` — query by service contract number |
| 5 | CALL | `ekk0161b004OUT = callSC(...).getCAANMsgList(...)` → EKK0161B004: サービス契約内訳照会 |
| 6 | FOR | `for (CAANMsg curSvcKeiUcwkInfo : ekk0161b004OUT)` — iterate over each service detail |

  **Block 3.1** — EXEC `(EKK0161C240: Detail cancellation recovery inside FOR)` (L1281)

  > For each service detail, recover its cancellation.

  | # | Type | Code |
  |---|------|------|
  | 1 | EXEC | `ekk0161c240IN = new CAANMsg(EKK0161C240CBSMsg.class.getName())` |
  | 2 | SET | `ekk0161c240IN.set(TEMPLATEID, TEMPLATE_ID_EKK0161C240)` → `"EKK0161C240"` |
  | 3 | SET | `ekk0161c240IN.set(FUNC_CODE, funcCode)` |
  | 4 | SET | `ekk0161c240IN.set(SVC_KEI_UCWK_NO, curSvcKeiUcwkInfo.getString(EKK0161B004CBSMsg1List.SVC_KEI_UCWK_NO))` — [-> "サービス契約作業番号 (Service Contract Work Number)"] |
  | 5 | SET | `ekk0161c240IN.set(MSKM_DTL_NO, mskmDtlNo)` |
  | 6 | SET | `ekk0161c240IN.set(IDO_DIV, ido_div)` |
  | 7 | SET | `ekk0161c240IN.set(UPD_DTM_BF, lastUpdDtm)` |
  | 8 | CALL | `ekk0161c240OUT = callSC(...)` → EKK0161C240: 確認後サービス契約内訳キャンセル取消 |
  | 9 | EXEC | `lastUpdDtm = ekk0161c240OUT.getString(EKK0161C240CBSMsg.UPD_DTM)` |

  **Block 3.2** — EXEC `(EKK0341B501: Equipment service contract list + EKK0341C420 recovery inside FOR)` (L1295)

  > For each service detail, query associated equipment service contracts and recover each one's cancellation.

  | # | Type | Code |
  |---|------|------|
  | 1 | EXEC | `ekk0341b501IN = new CAANMsg(EKK0341B501CBSMsg.class.getName())` |
  | 2 | SET | `ekk0341b501IN.set(TEMPLATEID, TEMPLATE_ID_EKK0341B501)` → `"EKK0341B501"` |
  | 3 | SET | `ekk0341b501IN.set(FUNC_CODE, "1")` |
  | 4 | SET | `ekk0341b501IN.set(KEY_SVC_KEI_UCWK_NO, curSvcKeiUcwkInfo.getString(...SVC_KEI_UCWK_NO))` |
  | 5 | CALL | `ekk0341b501OUT = callSC(...).getCAANMsgList(...)` → EKK0341B501: 機器提供サービス契約一覧照会 |
  | 6 | FOR | `for (CAANMsg curKktkSvcKeiInfo : ekk0341b501OUT)` |

    **Block 3.2.1** — EXEC `(EKK0341C420: Equipment contract cancellation recovery inside nested FOR)` (L1307)

    > For each equipment service contract, recover its cancellation.

    | # | Type | Code |
    |---|------|------|
    | 1 | EXEC | `ekk0341c420IN = new CAANMsg(EKK0341C420CBSMsg.class.getName())` |
    | 2 | SET | `ekk0341c420IN.set(TEMPLATEID, TEMPLATE_ID_EKK0341C420)` → `"EKK0341C420"` |
    | 3 | SET | `ekk0341c420IN.set(FUNC_CODE, funcCode)` |
    | 4 | SET | `ekk0341c420IN.set(KKTK_SVC_KEI_NO, curKktkSvcKeiInfo.getString(EKK0341B501CBSMsg1List.KKTK_SVC_KEI_NO))` — [-> "機器提供サービス契約番号 (Equipment Service Contract Number)"] |
    | 5 | SET | `ekk0341c420IN.set(MSKM_DTL_NO, mskmDtlNo)` |
    | 6 | SET | `ekk0341c420IN.set(IDO_DIV, ido_div)` |
    | 7 | SET | `ekk0341c420IN.set(UPD_DTM_BF, lastUpdDtm)` |
    | 8 | CALL | `ekk0341c420OUT = callSC(...)` → EKK0341C420: 確認後機器提供サービス契約キャンセル取消 |
    | 9 | EXEC | `lastUpdDtm = ekk0341c420OUT.getString(EKK0341C420CBSMsg.UPD_DTM)` |

**Block 4** — FOR `(Iterate over optional service contracts — EKK0351B002 + EKK0351C300)` (L1329)

> After processing all service details and their equipment, query and recover optional service contracts (オプションサービス) for this service contract.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `ekk0351b002IN = new CAANMsg(EKK0351B002CBSMsg.class.getName())` |
| 2 | SET | `ekk0351b002IN.set(TEMPLATEID, TEMPLATE_ID_EKK0351B002)` → `"EKK0351B002"` |
| 3 | SET | `ekk0351b002IN.set(FUNC_CODE, "1")` |
| 4 | SET | `ekk0351b002IN.set(KEY_SVC_KEI_NO, ccMsg.get("svc_kei_no"))` — query by service contract number |
| 5 | CALL | `ekk0351b002OUT = callSC(...).getCAANMsgList(...)` → EKK0351B002: オプションサービス契約一覧照会 |
| 6 | FOR | `for (CAANMsg curOpSvcKeiInfo : ekk0351b002OUT)` — iterate over each optional service contract |

  **Block 4.1** — EXEC `(EKK0351C300: Optional contract cancellation recovery inside FOR)` (L1341)

  > For each optional service contract, recover its cancellation.

  | # | Type | Code |
  |---|------|------|
  | 1 | EXEC | `ekk0351c300IN = new CAANMsg(EKK0351C300CBSMsg.class.getName())` |
  | 2 | SET | `ekk0351c300IN.set(TEMPLATEID, TEMPLATE_ID_EKK0351C300)` → `"EKK0351C300"` |
  | 3 | SET | `ekk0351c300IN.set(FUNC_CODE, funcCode)` |
  | 4 | SET | `ekk0351c300IN.set(OP_SVC_KEI_NO, curOpSvcKeiInfo.getString(EKK0351B002CBSMsg1List.OP_SVC_KEI_NO))` — [-> "オプションサービス契約番号 (Optional Service Contract Number)"] |
  | 5 | SET | `ekk0351c300IN.set(MSKM_DTL_NO, mskmDtlNo)` |
  | 6 | SET | `ekk0351c300IN.set(IDO_DIV, ido_div)` |
  | 7 | SET | `ekk0351c300IN.set(UPD_DTM_BF, lastUpdDtm)` |
  | 8 | CALL | `ekk0351c300OUT = callSC(...)` → EKK0351C300: 確認後オプションサービス契約キャンセル取消 |
  | 9 | EXEC | `lastUpdDtm = ekk0351c300OUT.getString(EKK0351C300CBSMsg.UPD_DTM)` |

**Block 5** — FOR `(Iterate over cancellation details — EKK0241B001 + EKK0251A010 + EKK0341B504 + EKK0341C420 + EKK0251C080)` (L1359)

> The most complex section: query cancellation details (回線内訳), perform matching inquiry, check equipment, conditionally recover equipment contracts, and finally recover the cancellation detail itself — all within a nested loop.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `ekk0241b001IN = new CAANMsg(EKK0241B001CBSMsg.class.getName())` |
| 2 | SET | `ekk0241b001IN.set(TEMPLATEID, TEMPLATE_ID_EKK0241B001)` → `"EKK0241B001"` |
| 3 | SET | `ekk0241b001IN.set(FUNC_CODE, "1")` |
| 4 | SET | `ekk0241b001IN.set(KEY_SVC_KEI_NO, ccMsg.get("svc_kei_no"))` |
| 5 | CALL | `ekk0241b001OUT = callSC(...).getCAANMsgList(...)` → EKK0241B001: サービス契約回線内訳一覧照会 |
| 6 | FOR | `for (CAANMsg curKaiUcwkInfo : ekk0241b001OUT)` — iterate over each cancellation detail |

  **Block 5.1** — EXEC `(EKK0251A010: Cancellation detail inquiry + EKK0341B504: Equipment list)` (L1367)

  > Query cancellation detail matching info and equipment service contracts for this cancellation detail.

  | # | Type | Code |
  |---|------|------|
  | 1 | EXEC | `ekk0251a010IN = new CAANMsg(EKK0251A010CBSMsg.class.getName())` |
  | 2 | SET | `ekk0251a010IN.set(TEMPLATEID, TEMPLATE_ID_EKK0251A010)` → `"EKK0251A010"` |
  | 3 | SET | `ekk0251a010IN.set(FUNC_CODE, funcCode)` |
  | 4 | SET | `ekk0251a010IN.set(KEY_SVC_KEI_KAISEN_UCWK_NO, curKaiUcwkInfo.getString(EKK0241B001CBSMsg1List.SVC_KEI_KAISEN_UCWK_NO))` — [-> "サービス契約回線作業番号 (Service Contract Cancellation Work Number)"] |
  | 5 | SET | `ekk0251a010IN.set(KEY_GENE_ADD_DTM, curKaiUcwkInfo.getString(EKK0241B001CBSMsg1List.GENE_ADD_DTM))` — [-> "生成追加日時 (Generated/Addition DateTime)"] |
  | 6 | CALL | `ekk0251a010OUT = callSC(...).getCAANMsgList(...)[0]` → EKK0251A010: サービス契約回線内訳一致照会 (single result) |
  | 7 | EXEC | `ekk0341b504IN = new CAANMsg(EKK0341B504CBSMsg.class.getName())` |
  | 8 | SET | `ekk0341b504IN.set(TEMPLATEID, TEMPLATE_ID_EKK0341B504)` → `"EKK0341B504"` |
  | 9 | SET | `ekk0341b504IN.set(FUNC_CODE, funcCode)` |
  | 10 | SET | `ekk0341b504IN.set(KEY_SVC_KEI_KAISEN_UCWK_NO, ...)` |
  | 11 | CALL | `ekk0341b504OUTList = callSC(...).getCAANMsgList(...)` → EKK0341B504: 機器提供サービス契約一覧照会(サービス契約回線内訳) |
  | 12 | FOR | `for (CAANMsg curKaisenKiki : ekk0341b504OUTList)` — iterate over equipment records for this cancellation detail |

    **Block 5.1.1** — IF `(Filter: KKTK_SVC_KEI_STAT = '920' AND KKTK_SVC_CD = 'C013')` (L1385)

    > Only process equipment records that are "In Use" (status 920) AND are a specific equipment type (C013). If either condition fails, skip this equipment and continue to the next one.

    > **Business Meaning:** This filter ensures that only active set-top box type equipment (code C013) is recovered for cancellation retraction. Equipment that is already cancelled, inactive, or of a different type is left untouched.

    | # | Type | Code |
    |---|------|------|
    | 1 | IF | `! "920".equals(curKaisenKiki.getString(KKTK_SVC_KEI_STAT))` — [-> "920" = 使用中 (In Use)] |
    |   | OR | `! "C013".equals(curKaisenKiki.getString(KKTK_SVC_CD))` — [-> "C013" = 特定機器種別 (Specific Equipment Type)] |
    | 2 | EXEC | `continue;` — skip this equipment, move to next |
    | 3 | EXEC | `ekk0341c420IN = new CAANMsg(EKK0341C420CBSMsg.class.getName())` — only reached when both conditions pass |
    | 4 | SET | `ekk0341c420IN.set(TEMPLATEID, TEMPLATE_ID_EKK0341C420)` → `"EKK0341C420"` |
    | 5 | SET | `ekk0341c420IN.set(FUNC_CODE, funcCode)` |
    | 6 | SET | `ekk0341c420IN.set(KKTK_SVC_KEI_NO, curKaisenKiki.getString(EKK0341B504CBSMsg1List.KKTK_SVC_KEI_NO))` |
    | 7 | SET | `ekk0341c420IN.set(MSKM_DTL_NO, mskmDtlNo)` |
    | 8 | SET | `ekk0341c420IN.set(IDO_DIV, ido_div)` |
    | 9 | SET | `ekk0341c420IN.set(UPD_DTM_BF, lastUpdDtm)` |
    | 10 | CALL | `ekk0341c420OUT = callSC(...)` → EKK0341C420: 確認後サービス契約内訳キャンセル取消 |
    | 11 | EXEC | `lastUpdDtm = ekk0341c420OUT.getString(EKK0341C420CBSMsg.UPD_DTM)` |

  **Block 5.2** — IF `(Filter: SVC_KEI_KAISEN_UCWK_STAT != '920')` (L1445)

  > Skip this cancellation detail if the cancellation detail work status is not "In Use" (920).

  > **Business Meaning:** サービス回線内訳が使用中の場合のみ更新する。他のサービス（ネットや電話）が存在し、それらが無効である場合は回線が使用中となっているはず。(Only update if the cancellation detail is in use. If other services (network, phone) exist and are invalid, the line should show as in use.)

  | # | Type | Code |
  |---|------|------|
  | 1 | IF | `! "920".equals(ekk0251a010OUT.getString(EKK0251A010CBSMsg1List.SVC_KEI_KAISEN_UCWK_STAT))` — [-> "920" = 使用中 (In Use)] |
  | 2 | EXEC | `continue;` — skip this cancellation detail, move to next |

  **Block 5.3** — EXEC `(EKK0251C080: Cancellation detail recovery)` (L1455)

  > Called only when the cancellation detail is confirmed "In Use" (status 920) after the filter passes. Recovers the cancellation of the service contract cancellation detail.

  | # | Type | Code |
  |---|------|------|
  | 1 | EXEC | `ekk0251c080IN = new CAANMsg(EKK0251C080CBSMsg.class.getName())` |
  | 2 | SET | `ekk0251c080IN.set(TEMPLATEID, TEMPLATE_ID_EKK0251C080)` → `"EKK0251C080"` |
  | 3 | SET | `ekk0251c080IN.set(FUNC_CODE, funcCode)` |
  | 4 | SET | `ekk0251c080IN.set(SVC_KEI_KAISEN_UCWK_NO, curKaiUcwkInfo.getString(EKK0241B001CBSMsg1List.SVC_KEI_KAISEN_UCWK_NO))` |
  | 5 | SET | `ekk0251c080IN.set(MSKM_DTL_NO, mskmDtlNo)` |
  | 6 | SET | `ekk0251c080IN.set(UPD_DTM_BF, lastUpdDtm)` |
  | 7 | CALL | `ekk0251c080OUT = callSC(...)` → EKK0251C080: サービス契約回線内訳キャンセル取消 |
  | 8 | EXEC | `lastUpdDtm = ekk0251c080OUT.getString(EKK0251C080CBSMsg.UPD_DTM)` |

**Block 6** — RETURN `(Method completes)` (L1463)

> Return void — all cancellation recoveries are complete. The `lastUpdDtm` is not returned; it was refreshed after each CBS call for optimistic locking within each CBS transaction.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `void` — implicit return from method end |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `func_code` | Field | Function code — identifies the operation type being performed (e.g., cancellation, recovery, registration) |
| `ido_div` | Field | Movement division (異動区分) — classifies the type of service change/movement (e.g., new connection, transfer, cancellation) |
| `lastUpdDtm` | Field | Last update datetime (更新年月日時刻分秒) — optimistic locking timestamp to prevent concurrent modification conflicts |
| `svc_kei_no` | Field | Service contract number (サービス契約番号) — unique identifier for the top-level service contract |
| `svc_kei_ucwk_no` | Field | Service contract work number (サービス契約作業番号) — internal tracking ID for a service contract detail/work item |
| `mskmDtlNo` | Field | Billing detail number (請求明細番号) — correlation key linking all CBS calls to a specific billing detail record |
| `kktk_svc_kei_no` | Field | Equipment service contract number (機器提供サービス契約番号) — identifies a contract for equipment (e.g., set-top box) provided with the service |
| `kktk_svc_kei_stat` | Field | Equipment service contract status (機器提供サービス契約ステータス) — current state of the equipment contract |
| `kktk_svc_cd` | Field | Equipment service code (機器提供サービスコード) — type code identifying the kind of equipment/service |
| `op_svc_kei_no` | Field | Optional service contract number (オプションサービス契約番号) — identifies a contract for optional add-on services |
| `svc_kei_kaisen_ucwk_no` | Field | Service contract cancellation work number (サービス契約回線作業番号) — tracking ID for a line cancellation detail |
| `svc_kei_kaisen_ucwk_stat` | Field | Service contract cancellation work status (サービス契約回線作業ステータス) — current status of the cancellation work item |
| `gene_add_dtm` | Field | Generated/addition datetime (生成追加日時) — timestamp when the cancellation detail record was created |
| `mskm_dtl_staus` | Field | (Typo in source code — should be `mskm_dtl_status`) Billing detail status (請求明細ステータス) — status of the billing detail (commented-out v4.00 code path) |
| MSKM | Acronym | Mailing/detail billing entity (請求明細) — billing detail record in the K-Opticom system |
| KK | Acronym | K-Opticom — the internet service provider; prefix used in CBS code naming (e.g., EKK = Eo K-Opticom CBS) |
| EKK | Acronym | Eo K-Optikom CBS prefix — service component codes for Eo Hikari TV contract operations |
| CBS | Acronym | Core Business System — Fujitsu's middleware for invoking business logic components |
| CAANMsg | Type | CAAN message class — the standard request/response message container used for CBS communication (extends base message with set/get typed methods) |
| callSC | Method | Shared service component invocation method on `JKKTVSvcKeiKaihukuCC` — the single entry point for all CBS calls, handling message preparation, invocation via `scCall`, and result extraction |
| EKK0081C230 | CBS Code | 確認後サービス契約キャンセル取消 (Post-confirmation Service Contract Cancellation Retraction) — recovers a previously confirmed service contract cancellation |
| EKK0161B004 | CBS Code | サービス契約内訳照会 (Service Contract Details Inquiry) — lists all contract detail items under a service contract |
| EKK0161C240 | CBS Code | 確認後サービス契約内訳キャンセル取消 (Post-confirmation Service Contract Detail Cancellation Retraction) |
| EKK0341B501 | CBS Code | 機器提供サービス契約一覧照会 (Equipment Service Contract List Inquiry) — lists equipment contracts for a service detail |
| EKK0341C420 | CBS Code | 確認後機器提供サービス契約キャンセル取消 (Post-confirmation Equipment Service Contract Cancellation Retraction) |
| EKK0351B002 | CBS Code | オプションサービス契約一覧照会 (Optional Service Contract List Inquiry) — lists optional services for a service contract |
| EKK0351C300 | CBS Code | 確認後オプションサービス契約キャンセル取消 (Post-confirmation Optional Service Contract Cancellation Retraction) |
| EKK0241B001 | CBS Code | サービス契約回線内訳一覧照会 (Service Contract Line Detail List Inquiry) — lists line cancellation details for a service contract |
| EKK0251A010 | CBS Code | サービス契約回線内訳一致照会 (Service Contract Line Detail Matching Inquiry) — queries matching info for a cancellation detail |
| EKK0341B504 | CBS Code | 機器提供サービス契約一覧照会(サービス契約回線内訳) (Equipment Service Contract List Inquiry by Line Detail) |
| EKK0251C080 | CBS Code | サービス契約回線内訳キャンセル取消 (Service Contract Line Detail Cancellation Retraction) |
| "920" | Status Code | 使用中 (In Use) — the item is currently active/operational, not cancelled or retired |
| "C013" | Status Code | 特定機器種別 (Specific Equipment Type) — likely identifies a set-top box (STB) or similar customer premise equipment |
| "1" | Literal | Fixed function code used for list/query CBS calls (as opposed to transactional CBS which use the caller's func_code) |
| 回復処理 | Business term | Recovery processing — reverting a cancellation to restore the service to its pre-cancellation state |
| キャンセル取消 | Business term | Cancellation retraction — undoing a previously confirmed cancellation request |
| 照会 | Business term | Inquiry — data retrieval/listing operation |
| 内訳 | Business term | Detail/line item — breakdown of a contract into its constituent parts (services, equipment, optional add-ons, lines) |
| 回線 | Business term | Line — refers to the telephone/internet line as a physical service element |
| オプションサービス | Business term | Optional service — add-on services (e.g., security, email, storage) that can be added to a base service contract |
| 機器提供 | Business term | Equipment provision — provision of physical hardware (e.g., routers, set-top boxes) to the customer |