# Business Logic — JKKKikiIchiranCancelCC.executeCancel() [140 LOC]

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

## 1. Role

### JKKKikiIchiranCancelCC.executeCancel()

This method implements the **device-provided service contract cancellation** workflow in a telecom billing/ordering system. It orchestrates the full cancellation lifecycle when a customer requests to cancel a device-provided service (e.g., set-top box, B-CAS smart card, or C-CAS module). The method acts as the central coordinator that dispatches cancellation processing to specialized service component calls based on the device type, service contract details, and return-device eligibility.

The method implements a **conditional dispatch pattern**: it branches by feature code (`func_code = "1"`), device type (STB vs non-STB via `judge_Stb`), and return-device eligibility (`judge_HmpinKikiUk`). For STB devices, it iterates over all B-CAS and C-CAS cards attached to the service contract and performs per-device cancellation. For non-STB devices, it processes the single-line contract record directly.

Additionally, it handles **multifunction router cancellation** (when `judgeTakinoRouter` is true), **service contract detail cancellation** (for STB with service detail work numbers), **return-device receipt processing** (when the device is eligible for return), **advance registration** (finalizing the cancellation registration), and **discount commission processing** (when a future date condition is met). This method is the core entry point for the device-provided service cancellation screen flow, called directly by `JKKKikiIchiranCancelCC.updKktkSvcCancel()`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeCancel()"])

    START --> GET_DATA["Get CAANMsg from temporaryData"]
    GET_DATA --> FUNC_CHECK{func_code equals 1?}

    FUNC_CHECK -- Yes --> CHECK_STB{judge_Stb?}
    FUNC_CHECK -- No --> SKIP_MAIN["Skip main block"]

    CHECK_STB -- Yes --> STB_LOOP["Loop over ekk0341b501cbsMsg entries"]
    CHECK_STB -- No --> SINGLE_CANCEL["execEKK0341C330 single device"]

    STB_LOOP --> SKIP_STATUS{KKTK_SVC_KEI_STAT 910 or 920?}
    SKIP_STATUS -- Yes --> LOOP_END
    SKIP_STATUS -- No --> STB_CANCEL["execEKK0341C330 device entry"]
    STB_CANCEL --> LOOP_END{More entries?}
    LOOP_END -- Yes --> STB_LOOP
    LOOP_END -- No --> CHECK_ROUTER{judgeTakinoRouter?}

    SINGLE_CANCEL --> CHECK_ROUTER
    CHECK_ROUTER -- Yes --> ROUTER_DEL["execKkopSvcKeiDel router"]
    CHECK_ROUTER -- No --> CHECK_HMPIN{judge_HmpinKikiUk?}

    CHECK_ROUTER --> CHECK_HMPIN
    CHECK_HMPIN -- No --> ADVANCE["execEKK1091D010 advance"]

    CHECK_HMPIN -- Yes --> CHECK_HMPIN_STB{judge_Stb?}
    CHECK_HMPIN -- No --> ADVANCE

    CHECK_HMPIN_STB -- Yes --> HMPIN_STB_LOOP["Loop over STB entries"]
    CHECK_HMPIN_STB -- No --> HMPIN_SINGLE["Check isCurHmpinKiki, then execEDK0301D010"]

    HMPIN_STB_LOOP --> HMPIN_SKIP_STATUS{KKTK_SVC_KEI_STAT 910 or 920?}
    HMPIN_SKIP_STATUS -- Yes --> HMPIN_LOOP_END
    HMPIN_SKIP_STATUS -- No --> HMPIN_CHECK{isCurHmpinKiki?}
    HMPIN_CHECK -- Yes --> HMPIN_RECV["execEDK0301D010stb return device"]
    HMPIN_CHECK -- No --> HMPIN_LOOP_END{More entries?}
    HMPIN_RECV --> HMPIN_LOOP_END
    HMPIN_LOOP_END -- Yes --> HMPIN_STB_LOOP
    HMPIN_LOOP_END -- No --> ADVANCE2["execEKK1091D010 advance"]

    HMPIN_SINGLE --> ADVANCE3["execEKK1091D010 advance"]
    ADVANCE --> FUTURE_CHECK{isFutureDateDsl?}
    ADVANCE2 --> FUTURE_CHECK
    ADVANCE3 --> FUTURE_CHECK
    FUTURE_CHECK -- Yes --> FUTURE_WARI["execKktkSvcKeiCancelWariCC discount"]
    FUTURE_CHECK -- No --> END_NODE(["Return"])
    FUTURE_WARI --> END_NODE

    SKIP_MAIN --> END_NODE
```

**Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|------------------|
| `TEMPLATE_ID_EKK0341A010` | `"EKK0341A010"` | Template ID for device-provided service contract single-line detail (service contract line info) |
| `TEMPLATE_ID_EKK0341B501` | `"EKK0341B501"` | Template ID for device-provided service contract list (circuit-level summary within a contract) |
| `func_code` | `"1"` | Feature code flag — the `func_code = "1"` condition gates the main cancellation block (v5.00.00 feature addition) |
| `KKTK_SVC_KEI_STAT` | N/A (field access) | Service contract status field — values `"910"` and `"920"` indicate already-cancelled/resolved status (v5.01.13 skip condition) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle representing the current user's database connection context. Used to establish transactions and session state for all downstream service component calls. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service Component invocation gateway. This is the middleware object used to dispatch calls to backend service components (SCs) such as `EKK0341C330`, `EKK0161C160`, etc. It abstracts the remote/remote-call mechanism. |
| 3 | `param` | `IRequestParameterReadWrite` | Request parameter object holding the screen input data and intermediate results. Provides `getData(dataMapKey)` to retrieve the cancellation request payload and holds mappings for downstream communication between CC methods. |
| 4 | `dataMapKey` | `String` | Key used to access the cancellation request data map from the `param` object. Acts as the namespace for the `ccMsg` HashMap containing screen-level fields like `func_code` and `ido_div`. |
| 5 | `temporaryData` | `HashMap<String, Object>` | Per-request temporary data store holding pre-fetched CBS messages and intermediate results. Contains `CAANMsg` objects retrieved from templates `EKK0341A010` (single-line detail) and `EKK0341B501` (list of circuits/B-CAS/C-CAS cards), used to avoid redundant database queries. |

**Instance fields / external state read:**
- None — the method is fully stateless, relying entirely on passed parameters and temporary data.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `execEKK0341C330` | EKK0341C330SC | KKTK_SVC_KEI (device-provided service contract) | Reads `TEMPLATE_ID_EKK0081A010` from temporaryData; retrieves service contract line detail for cancellation context. Invokes device-provided service cancellation SC. |
| R | `execEKK0161C160` | EKK0161C160SC | KK_T_SVC_KEI (service contract detail) | Reads `TEMPLATE_ID_EKK0081A010` and `TEMPLATE_ID_EKK0341A010` from temporaryData; processes service contract detail cancellation. |
| R | `execSvcKeiUcwRsvDel` | (internal) | - | Deletes service contract detail reservation (v7.00.10 addition). Called after `execEKK0161C160`. |
| R | `execKkopSvcKeiDel` | (internal) | - | Cancels device-provided service for multifunction router (v11.00.00 addition). Conditional on `judgeTakinoRouter`. |
| R | `execEDK0301D010` | EDK0301D010SC | Return device receipt table | Handles return-device receipt for non-STB devices (v6.00.01). Conditional on `isCurHmpinKiki`. |
| R | `execEDK0301D010stb` | EDK0301D010SC | Return device receipt table (STB) | Handles return-device receipt for STB devices (v6.00.01). Conditional on `isCurHmpinKiki`. |
| R | `execEKK1091D010` | EKK1091D010SC | Advance registration table | Registers advance/cancellation registration entry. Always executed at end of main flow. |
| R | `execKktkSvcKeiCancelWariCC` | (internal) | Discount/commission table | Processes discount commission for device-provided service cancellation (v4.01.00). Conditional on `isFutureDateDsl`. |
| R | `execEDK0301D010.getString` | - | - | Calls `getString` in `EDK0301D010` related service component. |
| R | `JBSbatDKNyukaFinAdd.getData` | - | - | Calls `getData` in `JBSbatDKNyukaFinAdd`. |
| R | `JBSbatFUCaseFileRnkData.getString` | - | - | Calls `getString` in `JBSbatFUCaseFileRnkData`. |
| R | `JBSbatFUMoveNaviData.getString` | - | - | Calls `getString` in `JBSbatFUMoveNaviData`. |
| R | `JBSbatZMAdDataSet.getString` | - | - | Calls `getString` in `JBSbatZMAdDataSet`. |
| R | `JFUeoTelOpTransferCC.getData` | - | - | Calls `getData` in `JFUeoTelOpTransferCC`. |
| R | `JFUTransferCC.getData` | - | - | Calls `getData` in `JFUTransferCC`. |
| R | `JFUTransferListToListCC.getData` | - | - | Calls `getData` in `JFUTransferListToListCC`. |
| R | `JESC0101B010TPMA.getString` | - | - | Calls `getString` in `JESC0101B010TPMA`. |
| R | `JESC0101B020TPMA.getString` | - | - | Calls `getString` in `JESC0101B020TPMA`. |
| R | `KKW12701SFLogic.getData` | - | - | Calls `getData` in `KKW12701SFLogic`. |

**How classified:**
- **R (Read)**: All called methods follow a read/invocation pattern — they retrieve data from temporary data maps, construct input CBS messages, invoke the service component, and store/update results. None of the methods in `executeCancel` directly perform create/delete SQL operations; those are delegated to backend SC/CBS layers.
- **SC Codes**: Inferred from method names (`execEKK0341C330` → `EKK0341C330SC`, `execEKK0161C160` → `EKK0161C160SC`, `execEKK1091D010` → `EKK1091D010SC`, `execEDK0301D010` → `EDK0301D010SC`).
- **Entity/DB tables**: Inferred from CBS message field names (`KKTK_SVC_KEI_NO` → `KKTK_SVC_KEI` table, `MSKM_DTL_NO` → `KK_T_MSKM_DTL`, etc.). The CBS message schemas (e.g., `EKK0341C330CBSMsg`, `EKK0341B501CBSMsg1List`) reference the domain entities directly.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Method: `JKKKikiIchiranCancelCC.updKktkSvcCancel` | `updKktkSvcCancel` → `executeCancel` | `execEKK0341C330 [R] KKTK_SVC_KEI`, `execEKK0161C160 [R] KK_T_SVC_KEI`, `execEKK1091D010 [R] ADVANCE_REG`, `execEDK0301D010 [R] HMPIN_RECEIPT`, `execKkopSvcKeiDel [R] ROUTER`, `execKktkSvcKeiCancelWariCC [R] DISCOUNT` |

**Notes:**
- No screen/batch entry points found within 8 hops. The direct caller is `JKKKikiIchiranCancelCC.updKktkSvcCancel()`, which is itself a CC-level method.
- Terminal operations from this method cover device-provided service cancellation (`EKK0341C330`), service contract detail cancellation (`EKK0161C160`), advance registration (`EKK1091D010`), return-device receipt (`EDK0301D010`), multifunction router cancellation (`KkopSvcKeiDel`), service contract detail reservation deletion (`SvcKeiUcwRsvDel`), and discount commission processing (`KktkSvcKeiCancelWariCC`).

## 6. Per-Branch Detail Blocks

**Block 1** — [GET] Retrieve CBS messages from temporaryData (L1074-1079)

> Retrieves the device-provided service contract cancellation data and list of circuits/B-CAS/C-CAS cards from the temporary data store. Also retrieves the request data map.

| # | Type | Code |
|---|------|------|
| 1 | GET | `ekk0341a010cbsMsg = (CAANMsg)temporaryData.get(TEMPLATE_ID_EKK0341A010)` // Get single-line detail (`TEMPLATE_ID_EKK0341A010 = "EKK0341A010"`) |
| 2 | GET | `ekk0341b501cbsMsg = (CAANMsg[])temporaryData.get(TEMPLATE_ID_EKK0341B501)` // Get circuit list (`TEMPLATE_ID_EKK0341B501 = "EKK0341B501"`) |
| 3 | EXEC | `ccMsg = (HashMap<String, Object>)param.getData(dataMapKey)` // Retrieve request data map |

---

**Block 2** — [IF] `func_code == "1"` feature gate (L1082)

> Gates the main cancellation block. This was added in v5.00.00 as a feature-code-based conditional. Only executed when the screen's `func_code` is `"1"`.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if ("1".equals((String)ccMsg.get("func_code")))` |

---

**Block 2.1** — [IF] `judge_Stb(temporaryData)` — STB device path (L1089)

> For STB (Set-Top Box) devices, iterates over all B-CAS and C-CAS cards attached to the service contract. Processes each device record individually.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (judge_Stb(temporaryData))` |
| 2 | INIT | `for (int i = 0; i < ekk0341b501cbsMsg.length; i++)` // Loop over circuit entries |

---

**Block 2.1.1** — [IF] Skip already-cancelled cards (L1094-1098)

> If a B-CAS card's status is `"910"` (cancellation complete) or `"920"` (resolved), skip processing it. This was added in v5.01.13 to prevent reprocessing.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if ("910".equals(ekk0341b501cbsMsg[i].getString(EKK0341B501CBSMsg1List.KKTK_SVC_KEI_STAT))` |
| 2 | COND | `|| "920".equals(ekk0341b501cbsMsg[i].getString(EKK0341B501CBSMsg1List.KKTK_SVC_KEI_STAT)))` |
| 3 | EXEC | `continue` // Skip already-cancelled/resolved card |

---

**Block 2.1.2** — [EXEC] Device-provided service cancellation for each STB card (L1105)

> Calls `execEKK0341C330` for each B-CAS/C-CAS card entry. This performs the device-provided service cancellation (STB, B-CAS, C-CAS) at the per-device-record level.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `execEKK0341C330(handle, scCall, param, dataMapKey, temporaryData, ekk0341b501cbsMsg[i])` // Device-provided service cancellation (STB/B-CAS/C-CAS) per card |

---

**Block 2.2** — [ELSE] Non-STB single device path (L1110)

> For non-STB devices, processes the single-line contract record directly (no loop needed).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `execEKK0341C330(handle, scCall, param, dataMapKey, temporaryData, ekk0341a010cbsMsg)` // Device-provided service cancellation (single device, non-STB) |

---

**Block 2.3** — [IF] `judgeTakinoRouter(temporaryData)` — Multifunction router cancellation (L1118)

> If the device is a multifunction router (judgeTakinoRouter), cancel the device option. Added in v11.00.00.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (judgeTakinoRouter(temporaryData))` |
| 2 | CALL | `execKkopSvcKeiDel(handle, scCall, param, dataMapKey, temporaryData)` // Cancel device option for multifunction router |

---

**Block 2.4** — [IF] `judge_Stb && judge_SvcKeiUcwkNo` — Service contract detail cancellation (L1124)

> If the device is STB AND has a service detail work number, execute service contract detail cancellation. Also deletes service contract detail reservation (v7.00.10).

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (judge_Stb(temporaryData) && judge_SvcKeiUcwkNo(temporaryData))` |
| 2 | CALL | `execEKK0161C160(handle, scCall, param, dataMapKey, temporaryData)` // Service contract detail cancellation |
| 3 | CALL | `execSvcKeiUcwRsvDel(handle, scCall, param, dataMapKey, temporaryData)` // Delete service contract detail reservation (v7.00.10) |

---

**Block 3** — [IF] `judge_HmpinKikiUk(temporaryData, ccMsg)` — Return-device eligibility (L1137)

> Checks whether the device is eligible for return (hmpin = 返品). If eligible, processes return-device receipt for each card/line.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (judge_HmpinKikiUk(temporaryData, ccMsg))` // Return-device eligibility check |

---

**Block 3.1** — [IF] `judge_Stb` return-device path (L1140)

> For STB devices eligible for return, iterates over all B-CAS/C-CAS entries and processes return-device receipt per card.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (judge_Stb(temporaryData))` |
| 2 | INIT | `for (int i = 0; i < ekk0341b501cbsMsg.length; i++)` // Loop over STB circuit entries |

---

**Block 3.1.1** — [IF] Skip already-cancelled cards (L1144-1148)

> Same skip logic as Block 2.1.1 — skip B-CAS cards with status `"910"` or `"920"`.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if ("910".equals(ekk0341b501cbsMsg[i].getString(EKK0341B501CBSMsg1List.KKTK_SVC_KEI_STAT))` |
| 2 | COND | `|| "920".equals(ekk0341b501cbsMsg[i].getString(EKK0341B501CBSMsg1List.KKTK_SVC_KEI_STAT)))` |
| 3 | EXEC | `continue` |

---

**Block 3.1.2** — [IF] `isCurHmpinKiki` return-device receipt (L1153-1157)

> For each STB card, checks if the current device is eligible for return receipt via `isCurHmpinKiki`. If true, processes the return-device receipt (STB variant). Added in v6.00.01 (replacing unconditional call).

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (isCurHmpinKiki(handle, scCall, param, dataMapKey, temporaryData, ekk0341b501cbsMsg[i]))` |
| 2 | CALL | `execEDK0301D010stb(handle, scCall, param, dataMapKey, temporaryData, ekk0341b501cbsMsg[i])` // Return-device receipt (STB variant) |

---

**Block 3.2** — [ELSE] Non-STB return-device path (L1160-1167)

> For non-STB devices eligible for return, checks `isCurHmpinKiki` and processes return-device receipt. Added in v6.00.01.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (isCurHmpinKiki(handle, scCall, param, dataMapKey, temporaryData, ekk0341a010cbsMsg))` |
| 2 | CALL | `execEDK0301D010(handle, scCall, param, dataMapKey, temporaryData)` // Return-device receipt (non-STB) |

---

**Block 4** — [EXEC] Advance registration (L1170)

> Always executed after the main cancellation block. Registers the advance/cancellation entry in the system.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `execEKK1091D010(handle, scCall, param, dataMapKey, temporaryData)` // Advance registration |

---

**Block 5** — [IF] `isFutureDateDsl(ccMsg)` — Discount commission processing (L1175-1178)

> Processes discount commission for device-provided service cancellation. Previously always executed (commented out at L1176), but modified in v4.01.00 to be conditional on a future date check.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (isFutureDateDsl(ccMsg))` // Future date DSL check |
| 2 | CALL | `execKktkSvcKeiCancelWariCC(handle, scCall, param, dataMapKey, temporaryData)` // Discount commission CC (device-provided service cancellation) |

---

**Block 6** — [ELSE / FALL-THROUGH] `func_code != "1"` (L1133)

> When `func_code` is not `"1"`, the entire main cancellation block (v5.00.00 addition) is skipped. The method proceeds directly to return-device eligibility check (Block 3), advance registration (Block 4), and discount processing (Block 5).

| # | Type | Code |
|---|------|------|
| 1 | PASS | (Main cancellation block skipped; falls through to `judge_HmpinKikiUk` check) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kktk_svc_kei_no` | Field | Device-provided service contract number — unique identifier for a device service contract line |
| `kktk_svc_kei_stat` | Field | Device-provided service contract status — `"910"` = cancellation complete, `"920"` = resolved, other values = active/processing |
| `mskm_dtl_no` | Field | Equipment detail number — identifies specific equipment detail within a service contract |
| `svc_cancel_rsn_cd` | Field | Service cancellation reason code — reason classification for the cancellation (value `"00"` used in EKK0341C330) |
| `ido_div` | Field | Movement division — indicates the type of service change/movement (e.g., new installation, transfer, cancellation) |
| `upd_dtm_bf` | Field | Update timestamp before — the service contract's last update timestamp prior to this operation |
| `func_code` | Field | Feature code — screen feature identifier (`"1"` enables the main cancellation block) |
| `hmpin` | Field | Return device (short for 返品 — henpin) — indicates whether the device is eligible for physical return to the supplier |
| STB | Acronym | Set-Top Box — set-top box device provided as part of cable/broadcast service |
| B-CAS | Business term | B-CAS smart card — conditional access smart card used for broadcast decryption in Japan |
| C-CAS | Business term | C-CAS module — conditional access module (alternative to B-CAS smart card) |
| EKK0341C330 | SC Code | Device-provided service cancellation SC — cancells a device-provided service contract line (STB/B-CAS/C-CAS) |
| EKK0161C160 | SC Code | Service contract detail cancellation SC — cancels the service contract line detail |
| EKK1091D010 | SC Code | Advance registration SC — registers the advance/cancellation entry in the system |
| EDK0301D010 | SC Code | Return-device receipt SC — processes the receipt of a returned device |
| `kko_svc_kei_del` | SC Code | Device option cancellation SC — cancels device option for multifunction routers |
| `kktk_svc_kei_cancel_wari` | SC Code | Discount commission SC — processes discount/commission adjustments for cancellations |
| `svc_kei_ucwk_no` | Field | Service detail work number — internal tracking ID for service contract line items/work |
| TAKNKIKI_SBT_CD | Field | Device type code — classifies the device type (e.g., `"A0"`, `"B0"`, `"C0"` for different device categories) |
| KIKI_SEIZO_NO | Field | Device serial number — unique serial number of the device |
| v4.01.00 | Version | Version tag — modified discount CC to be conditional on `isFutureDateDsl` check |
| v5.00.00 | Version | Version tag — added `func_code` feature gate around main cancellation block |
| v5.01.08 | Version | Version tag — fixed cancellation reason code from hardcoded `"00"` to `SVC_CANCEL_RSN_CD` constant |
| v5.01.13 | Version | Version tag — added skip condition for already-cancelled/resolved B-CAS cards |
| v6.00.01 | Version | Version tag — added `isCurHmpinKiki` pre-check before return-device receipt calls |
| v7.00.10 | Version | Version tag — added service contract detail reservation deletion (`execSvcKeiUcwRsvDel`) |
| v9.00.01 | Version | Version tag — updated `getMskmDtlNo` call to accept additional `ccMsg` parameter |
| v11.00.00 | Version | Version tag — added multifunction router (Takino Router) cancellation logic |
| CAANMsg | Type | CAN API message object — structured message container used for CBS (Call Back System) communication |
| CBS | Acronym | Call Back System — Fujitsu's backend service component invocation framework |
| SC | Acronym | Service Component — backend business logic module invoked via CBS |
| DCBS / DBS | Acronym | Data Call Back System / Database Service — database access service layer |
