# Business Logic — JKKWribSvcKeiOperateCC.deleteContents() [307 LOC]

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

## 1. Role

### JKKWribSvcKeiOperateCC.deleteContents()

The `deleteContents()` method performs the core **cancellation and contract termination** processing for the K-Opticom e- Customer Foundation System — a Japanese telecommunications operator's billing and contract management platform. This method is invoked as the `delete` action within the `execute()` dispatch pattern, and it processes a batch of service contract lines selected on the "Discounted Service Contract Screen" (割引サービス契約画面) for cancellation or content removal.

The method handles **two contract categories** determined by `keiKind` (contract category): **HNSOKU** (Data Extraction Item — データ抽出項目, representing bundled data extraction configurations) and **WRIB** (Discounted Service — 割引サービス, representing subscription-based discount service agreements such as line discount, family pack, and long-term discount contracts). For each contract line in the target list, it performs contract deletion via the `deleteContent()` sub-component, creates progress tracking records (`createPrg()`), and handles post-cancellation side effects specific to service type (e.g., auto-creating replacement long-term discount contracts for immediate discounts, validating jurisdiction special coupons, updating family pack records, and notifying contract details for confirmed cancellations).

It implements a **routing/dispatch pattern** (via a Java `switch` on `KeiKind` enum) combined with **delegation** to internal service methods. Its role in the larger system is that of the central business coordination component for the cancel operation — it orchestrates the cascade of database updates, service component calls, and status transitions required to cleanly terminate one or more service contracts in a single batch operation.

After all contract lines are processed, it updates introduction codes (`exeJKKIntrInfoChgCfmCC()`) and returns the modified parameter object. Error determination data (`rslErrHantei`) is initialized and cleaned up via ThreadLocal storage to support warning message output during penalty generation scenarios.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["deleteContents(param)"])
    INIT(["Initialize rslErrHantei with empty ArrayList"])

    INIT --> GET_TARGET["Get targetInfo from param (KKSV024001CC)"]
    GET_TARGET --> GET_FUNC["Extract funcCd (function code) from targetInfo"]

    GET_FUNC --> GET_ADDITION["Get additionInfo from param (KKSV024002CC)"]
    GET_ADDITION --> EXTRACT_FIELDS["Extract: mskmYmd, sysid, idoDiv, idoRsnCdList, idoRsnMemo"]
    EXTRACT_FIELDS --> BUILD_WRI["Create wriMap (empty HashMap)"]
    BUILD_WRI --> GET_JCT["getJctWribSvcCdList(param) — retrieve jurisdiction special service code list"]

    GET_JCT --> GET_TARGET_LIST["Extract targetList from targetInfo"]
    GET_TARGET_LIST --> LOOP_START{"targetList empty?"}

    LOOP_START -->|No| SET_CURRENT["setCurrentTarget(target)"]
    SET_CURRENT --> EXTRACT_TARGET["Extract: no, keiKind, kakinYohi, pnlty_cd, wrib_svc_kei_zengetu_kaiyaku"]
    EXTRACT_TARGET --> RESOLVE_KIND["KeiKind.resolve(keiKind)"]

    RESOLVE_KIND --> MSKM_DTL["createAndFixMskmMskmDtl(...) — register application details"]
    MSKM_DTL --> GET_DTL_NO["Extract mskmDtlNo"]

    GET_DTL_NO --> SWITCH{"keiKindEnum"}

    SWITCH -->|HNSOKU| HNSOKU_BLOCK["Block: Data Extraction Item (HNSOKU)"]
    HNSOKU_BLOCK --> RES_DCH["resolveDchskmst(keiNo) — get data extraction settings agreement"]
    RES_DCH --> RES_DCH_SBT["resolveDchskm(dchskmCd) + resolveDchskmstTrgtKeis(keiNo)"]
    RES_DCH_SBT --> DEL_CONTENT_H["deleteContent(..., dchsTypeCd) — delete data extraction contract"]

    DEL_CONTENT_H --> LOOP_TARGET_H["Loop: trgtKeis (target contracts)"]
    LOOP_TARGET_H --> CREATE_PRG_H["createPrg(..., PRG_STAT_DCHSKM_DEL_FIN=F061, ...)"]

    CREATE_PRG_H --> NEXT_H["removeCurrentTarget() -> next target"]

    SWITCH -->|WRIB| WRIB_BLOCK["Block: Discounted Service (WRIB)"]
    WRIB_BLOCK --> RES_WRI["resolveWribSvcKei(keiNo) — get discounted service contract"]
    RES_WRI --> RES_WRI_TYPE["resolveWribSvc(wribSvcCd) — get service type code"]

    RES_WRI_TYPE --> PUT_WRI_MAP["wriMap.put(keiNo) — track contracted services"]
    PUT_WRI_MAP --> RES_TRGT["resolveWribSvcTrgtKeis(keiNo) — get target contracts"]
    RES_TRGT --> DEL_CONTENT_W["deleteContent(..., wribTypeCd) — delete discounted service contract"]

    DEL_CONTENT_W --> CHECK_SOK{"WRIB_SVC_CD_SOK_WRI (W00000021 = Immediate)?"}

    CHECK_SOK -->|Yes| AUTO_CREATE["autoCreateWribSvcKei(WRIB_SVC_CD_CHO_WRI=W00000011) — create long-term discount contract"]
    CHECK_SOK -->|No| CHECK_JCT

    AUTO_CREATE --> CHECK_JCT{"jctWribSvcCdList contains wribSvcCd?"}

    CHECK_JCT -->|Yes| JCT_CHECK["checkJctSpclCp — validate jurisdiction special coupon"]

    JCT_CHECK --> CHECK_FAMILY{"WRIB_SVC_CD_FAMILY_P (W00000006 = Family Pack)?"}

    CHECK_FAMILY -->|Yes| FAMIPA["updFamipaKeiUm(param, svcKeiNo, funcCd) — update family pack contract"]
    CHECK_FAMILY -->|No| CHECK_CHOKI

    CHECK_JCT -->|No| CHECK_FAMILY

    CHECK_SOK -->|No| CHECK_JCT

    CHECK_CHOKI{"WRIB_SVC_CD_CHOKI_KEIZOKU_WRI (W00000041 = Long-term)?"}

    CHECK_CHOKI -->|Yes| CHECK_APLY_GAI{"chokiKeizokuRiyoWribAplyGaiFlg set?"}
    CHECK_APLY_GAI -->|Yes| SET_FLAG_LIST["targetInfo.put(choki_keizoku_riyo_wrib_aply_gai_list, new ArrayList())"]
    CHECK_APLY_GAI -->|No| CREATE_PRG_W

    CHECK_APLY_GAI -->|Yes| CREATE_PRG_W
    CHECK_APLY_GAI -->|No| CREATE_PRG_W

    CHECK_CHOKI -->|No| CREATE_PRG_W

    FAMIPA --> CREATE_PRG_W["createPrg(..., retPrgStatToFamilyPack(prgStat), idoRsnMemo, ...)"]
    CREATE_PRG_W --> CHECK_SOK2{"WRIB_SVC_CD_SOK_WRI (W00000021 = Immediate)?"}

    CHECK_SOK2 -->|Yes| CHECK_FUNC1{"funcCd = 1 (Check & Update)?"}
    CHECK_FUNC1 -->|Yes| EXEC_KNY["executeKeiyakuNaiyoTuchi(param, sysid, svcKeiNo, mskmDtlNo, idoDiv) — notify contract details"]
    CHECK_FUNC1 -->|No| NEXT_W
    CHECK_SOK2 -->|No| NEXT_W
    EXEC_KNY --> NEXT_W

    NEXT_W["removeCurrentTarget() -> next target"] --> LOOP_END{"More targets?"}
    NEXT_H --> LOOP_END

    LOOP_END -->|Yes| SET_CURRENT
    LOOP_END -->|No| FINALIZE["rslErrHantei.remove()"]

    FINALIZE --> EXE_INTR["exeJKKIntrInfoChgCfmCC(funcCd, svcKeiNo, idoDiv, TRN_DIV_DEL=1, wriMap) — update introduction code"]
    EXE_INTR --> RETURN["return param"]
    RETURN --> END(["END"])

    START --> INIT
    LOOP_START -->|Yes| FINALIZE

    style START fill:#e1f5e1
    style END fill:#e1f5e1
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying all screen input data and context for the cancellation operation. It contains two key data blocks: `KKSV024001CC` (the screen's target list and function code) and `KKSV024002CC` (addition data including application date, system ID, move reason codes and memo). The `func_code` value determines processing mode ("1" = Check & Update — triggers contract detail notification; other values skip notification). |

**Instance fields / external state read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `rslErrHantei` | `ThreadLocal<ArrayList<HashMap<String, String>>>` | Error determination result storage — initialized with empty list for warning message output during penalty generation (違約金発生時のワーニングメッセージ出力対応). Removed at method end. |
| `chokiKeizokuRiyoWribAplyGaiFlg` | `Boolean` | Long-term discount contract application-outside flag — set to `true` when a long-term discount cancellation is occurring outside its automatic continuation period (長期継続利用割引の適用外フラグ). |
| `wrib_svc_kei_zengetu_kaiyaku` | `String` | Previous month cancellation indicator for BS Option Chansnel "Star Channel" (前月解約). |
| `pnlty_cd` | `Boolean` | Penalty code flag extracted from target data — tracks whether a penalty applies to the service detail (利用開始年月日保持 / penalty_cd target field). |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKWribSvcKeiOperateCC.getJctWribSvcCdList` | EKK0451B006 | KK_T_WRIB_SVC_KEI | Reads jurisdiction special service code list — retrieves discount service contract codes eligible for jurisdiction special coupon checks |
| C | `JKKWribSvcKeiOperateCC.createAndFixMskmMskmDtl` | EKK0021D020 / EKK0021C060 | KK_T_MSKM / KK_T_MSKM_DTL | Registers and fixes application details (申請内容承認登録 / 申請明細照会・後続業務依頼) — creates mskm header and detail records |
| R | `JKKWribSvcKeiOperateCC.resolveDchskmst` | EKK1351A010 | KK_T_DCHSKMST | Reads data extraction settings agreement (データ抽出項目設定照会) — retrieves the last update datetime and settings code |
| R | `JKKWribSvcKeiOperateCC.resolveDchskm` | EKK1391A010 | KK_T_DCHSKM | Reads data extraction settings (データ抽出項目設定照会) — retrieves the service type code (dchs_type_cd) |
| R | `JKKWribSvcKeiOperateCC.resolveDchskmstTrgtKeis` | EKK1401B001 | KK_T_DCHSKMST_TRGT_KEI | Reads data extraction settings target contracts (データ抽出項目設定対象契約一覧照会) |
| D | `JKKWribSvcKeiOperateCC.deleteContent` | EKK0451C020 / EKK1091D010 | KK_T_WRIB_SVC_KEI / KK_T_PROGRESS | Deletes discounted service contract (割引サービス契約解約) and creates progress records for data extraction cancellation |
| C | `JKKWribSvcKeiOperateCC.createPrg` | EKK1091D010 | KK_T_PROGRESS | Creates progress tracking records (進捗登録) for each target contract line — stores processing state (F051/F061) |
| R | `JKKWribSvcKeiOperateCC.resolveWribSvcKei` | EKK0451A010 | KK_T_WRIB_SVC_KEI | Reads discounted service contract (割引サービス契約照会) — retrieves update datetime, status, and service code |
| R | `JKKWribSvcKeiOperateCC.resolveWribSvc` | EKK0451A010 | KK_T_WRIB_SVC | Reads discount service master (割引サービス照会) — retrieves service type code (wrib_type_cd) |
| C | `JKKWribSvcKeiOperateCC.autoCreateWribSvcKei` | EKK0451D010 | KK_T_WRIB_SVC_KEI | Auto-creates long-term discount service contract (長期利用割引契約情報・対象契約情報作成) when immediate discount is cancelled — registers replacement contract |
| - | `JKKWribSvcKeiOperateCC.checkJctSpclCp` | EKK0841C011 | KK_T_WRIB_SVC_CP | Checks jurisdiction special coupon validity (自治体特別キャンペーン照会) — validates coupon for local government special offers |
| - | `JKKWribSvcKeiOperateCC.executeKeiyakuNaiyoTuchi` | EKK0451B010 | KK_T_WRIB_SVC_KEI | Calls contract detail notification CC (契約内容通知書CC) — only when funcCd = "1" (Check & Update) |
| U | `JKKWribSvcKeiOperateCC.updFamipaKeiUm` | EKU0021C010 / EKU0061C010 | KK_T_EKU_WORK_*, KK_T_WORK_* | Updates family pack contract (ファミリーパックの場合) — writes to work tables for HPW (Hard Wire) compliance |
| R | `JKKWribSvcKeiOperateCC.exeJKKIntrInfoChgCfmCC` | EKK0081B039 | KK_T_INTR_INFO | Updates introduction code (紹介コード更新CC) — marks the service as cancelled (TRN_DIV_DEL = "1") |
| - | `JKKStringUtil.isNullEmpty` | - | - | Utility method — checks if a String is null or empty |
| - | `JKKStringUtil.isNullBlank` | - | - | Utility method — checks if a String is null, empty, or blank |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Method: `JKKWribSvcKeiOperateCC.execute()` (Action.delete case) | `execute()` (Action dispatch) -> `deleteContents(param)` | `deleteContent [D] KK_T_WRIB_SVC_KEI`, `createPrg [C] KK_T_PROGRESS`, `createAndFixMskmMskmDtl [C] KK_T_MSKM`, `autoCreateWribSvcKei [C] KK_T_WRIB_SVC_KEI`, `executeKeiyakuNaiyoTuchi [-] KK_T_WRIB_SVC_KEI`, `updFamipaKeiUm [U] KK_T_EKU_WORK_*`, `exeJKKIntrInfoChgCfmCC [R] KK_T_INTR_INFO`, `isNullBlank [-]`, `isNullEmpty [-]`, `removeCurrentTarget [D]` |

**Direct caller:** `JKKWribSvcKeiOperateCC.execute()` — This method is the central action dispatcher for the discounted service contract operation screen. When the `Action.delete` enum value is passed (via the screen's cancel button), `execute()` delegates to `deleteContents()`. No separate screen-level entry point exists — this CC component directly handles the action.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialize rslErrHantei ThreadLocal (L5940)

> Initializes the error determination result list for warning message output during penalty generation scenarios (違約金発生時のワーニングメッセージ出力対応).

| # | Type | Code |
|---|------|------|
| 1 | SET | `this.rslErrHantei.set(new ArrayList<HashMap<String, String>>())` // Error determination result initialization |

**Block 2** — [SET] Extract screen data (L5945–5957)

> Retrieves the target list and function code from the screen parameter block KKSV024001CC.

| # | Type | Code |
|---|------|------|
| 1 | SET | `targetInfo = (HashMap<String, Object>) param.getData("KKSV024001CC")` // Target info block |
| 2 | SET | `funcCd = (String) targetInfo.get("func_code")` // Function code — "1" = Check & Update, other values skip certain post-processing |

**Block 3** — [SET] Extract addition data (L5962–5969)

> Retrieves the application date, system ID, move reason codes and memo from the KKSV024002CC block.

| # | Type | Code |
|---|------|------|
| 1 | SET | `additionInfo = (HashMap<String, Object>) param.getData("KKSV024002CC")` // Addition info block |
| 2 | SET | `mskmYmd = (String) additionInfo.get("mskm_ymd")` // Application date (申請日) |
| 3 | SET | `sysid = (String) additionInfo.get("sysid")` // System ID |
| 4 | SET | `idoDiv = (String) additionInfo.get("ido_div")` // Move reason classification (異動区分別) — IDO_DIV_WRIB="00049" for discounts, IDO_DIV_DCHSKM="00050" for data extraction |
| 5 | SET | `idoRsnCdList = (ArrayList<HashMap<String, Object>>) additionInfo.get("ido_rsn_cd_list")` // Move reason code list |
| 6 | EXEC | `idoRsnCds = translateIdoRsnCdsFromArrayList(idoRsnCdList)` // Convert list to String array |
| 7 | SET | `idoRsnMemo = (String) additionInfo.get("ido_rsn_memo")` // Move reason memo (異動理由メモ) — added in v3.01.00 |

**Block 4** — [SET] Create wriMap and get jurisdiction special codes (L5972–5980)

> Creates a HashMap to track contracted services, and retrieves the list of jurisdiction special service codes for later coupon validation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wriMap = new HashMap<String, String>()` // Tracks contracted services for introduction code update |
| 2 | CALL | `jctWribSvcCdList = getJctWribSvcCdList(param)` // Retrieves jurisdiction special discount service codes (自治体特別割引サービスコードリスト) — ANK-3383-09-00 |

**Block 5** — [FOR] Process each target contract line (L5985–L6228)

> Iterates over all contract lines selected on the cancellation screen. For each line, sets it as the current target (thread-local), extracts fields, resolves the kind enum, registers application details, and dispatches to the appropriate processing block.

| # | Type | Code |
|---|------|------|
| 1 | SET | `targetList = (ArrayList<HashMap<String, Object>>) targetInfo.get("target_list")` // List of target contracts from screen |
| 2 | FOR | `for (HashMap<String, Object> target : targetList)` // Process each selected contract |
| 3 | EXEC | `setCurrentTarget(target)` // Store in ThreadLocal for downstream processing |
| 4 | SET | `keiNo = (String) target.get("no")` // Contract number (契約番号) |
| 5 | SET | `keiKind = (String) target.get("kei_kind")` // Contract category — "HNSOKU" or "WRIB" |
| 6 | SET | `kakinYohi = (String) target.get("kakin_yohi")` // Overprint attachment (上付余技) |
| 7 | SET | `keiKindEnum = KeiKind.resolve(keiKind)` // Resolve string to enum (HNSOKU / WRIB) |
| 8 | SET | `pnltyCd = (Boolean) target.get("pnlty_cd")` // Penalty code flag (v10.00.00) |
| 9 | SET | `wrib_svc_kei_zengetu_kaiyaku = String.valueOf(target.get("wrib_svc_kei_zengetu_kaiyaku"))` // Previous month cancellation indicator (v10.00.07) |
| 10 | CALL | `mskmDtl = createAndFixMskmMskmDtl(param, funcCd, sysid, mskmYmd, idoDiv, keiKindEnum, "")` // v7.00.00 — Registers application details and fixes detail records |
| 11 | SET | `mskmDtlNo = mskmDtl.getString("mskm_dtl_no")` // Extracts the created detail number |

**Block 5.1** — [SWITCH] keiKindEnum dispatch — case HNSOKU: Data Extraction Item (L5993–L6048)

> Handles the "Data Extraction Item" (データ抽出項目) contract category. Deletes the data extraction settings, creates progress records with status F061 (Data Extraction Item Cancellation Complete), and processes all target contracts.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dchskmst = resolveDchskmst(keiNo)` // Read data extraction settings agreement |
| 2 | SET | `updDtmBf = dchskmst.getString(EKK1351A010CBSMsg1List.LAST_UPD_DTM)` // Last update datetime before deletion |
| 3 | SET | `dchskmCd = dchskmst.getString("dchskm_cd")` // Data extraction settings code (v4.01.00 — long-term discount contract system) |
| 4 | SET | `dchskm = resolveDchskm(dchskmCd)` // Read data extraction settings |
| 5 | SET | `dchsTypeCd = dchskm.getString("dchs_type_cd")` // Data extraction service type code (v4.01.00) |
| 6 | SET | `trgtKeis = resolveDchskmstTrgtKeis(keiNo)` // Get all target contracts for this data extraction settings |
| 7 | CALL | `deleteContent(param, funcCd, keiKind, keiNo, updDtmBf, mskmDtlNo, mskmYmd, idoDiv, WRIB_DSL_CNCL_OPTY_CD_MAN_APLY="2", null, dchsTypeCd)` // Delete data extraction contract with manual apply reason code (v4.01.00) |
| 8 | SET | `prgStat = PRG_STAT_DCHSKM_DEL_FIN` → **"F061"** // Progress status: Data Extraction Item Cancellation Complete (v4.04.00) |
| 9 | FOR | `for (CAANMsg trgtKei : trgtKeis)` // Process each target contract |
| 10 | SET | `svcKeiNo = trgtKei.getString("svc_kei_no")` |
| 11 | CALL | `createPrg(param, funcCd, mskmDtlNo, svcKeiNo, null, idoDiv, prgStat="F061", idoRsnCds, idoRsnMemo, keiKindEnum)` // v3.01.00 — Register progress with reason memo |

**Block 5.2** — [SWITCH] case WRIB: Discounted Service (L6053–L6215)

> Handles the "Discounted Service" (割引サービス) contract category. Performs service deletion, auto-creates replacement long-term contracts for immediate discounts, validates jurisdiction special coupons, updates family pack records, and processes all target contracts.

| # | Type | Code |
|---|------|------|
| 1 | SET | `this.pnltyCd = (Boolean) target.get("pnlty_cd")` // v10.00.00 — Store penalty flag |
| 2 | SET | `this.wrib_svc_kei_zengetu_kaiyaku = String.valueOf(target.get("wrib_svc_kei_zengetu_kaiyaku"))` // v10.00.07 — Previous month cancellation |
| 3 | SET | `wribSvcKei = resolveWribSvcKei(keiNo)` // Read discounted service contract |
| 4 | SET | `updDtmBf = wribSvcKei.getString("last_upd_dtm")` // Last update datetime |
| 5 | SET | `wribSvcKeiStat = wribSvcKei.getString("wrib_svc_kei_stat")` // Contract status |
| 6 | SET | `wribSvcCd = wribSvcKei.getString("wrib_svc_cd")` // Service code |
| 7 | SET | `wribSvc = resolveWribSvc(wribSvcCd)` // Read discount service master |
| 8 | SET | `wribTypeCd = wribSvc.getString("wrib_type_cd")` // Service type code (v4.01.00) |
| 9 | EXEC | `wriMap.put(String.valueOf(wriMap.size()), keiNo)` // Track this contracted service |
| 10 | SET | `trgtKeis = resolveWribSvcTrgtKeis(keiNo)` // Get target contracts |
| 11 | CALL | `deleteContent(param, funcCd, keiKind, keiNo, updDtmBf, mskmDtlNo, mskmYmd, idoDiv, WRIB_DSL_CNCL_OPTY_CD_MAN_APLY="2", kakinYohi, wribTypeCd)` // Delete discounted service contract with manual apply reason and overprint attachment |

**Block 5.2.1** — [IF] Immediate discount: create long-term replacement (L6090–L6099) `[WRIB_SVC_CD_SOK_WRI = "W00000021"]`

> When the cancelled service is an "Immediate" discount (即時割引), automatically create a "Long-term" discount contract (長期利用割引) as a replacement. The long-term service code is `WRIB_SVC_CD_CHO_WRI = "W00000011"`.

| # | Type | Code |
|---|------|------|
| 1 | IF | `WRIB_SVC_CD_SOK_WRI.equals(wribSvcCd)` → "W00000021" (Immediate discount) |
| 2 | CALL | `autoCreateWribSvcKei(param, WRIB_SVC_CD_CHO_WRI="W00000011", funcCd, idoDiv, sysid, mskmDtlNo, mskmYmd, keiNo)` // v6.00.00 — Create long-term discount contract as replacement |

**Block 5.2.2** — [IF] Jurisdiction special coupon validation (L6102–L6120) `[jctWribSvcCdList]`

> When the cancelled service code is in the jurisdiction special service code list, validate each target contract's special coupon. Only applies when funcCd = "2" (Check only), in which case a check error is triggered.

| # | Type | Code |
|---|------|------|
| 1 | IF | `jctWribSvcCdList.contains(wribSvcCd)` — service is a jurisdiction special (自治体特別) contract |
| 2 | FOR | `for (CAANMsg trgtKei : trgtKeis)` // Validate each target contract |
| 3 | SET | `tgKeiSvcKeiNo = trgtKei.getString("svc_kei_no")` |
| 4 | IF | `JKKStringUtil.isNullEmpty(tgKeiSvcKeiNo)` → skip (OM-2019-0000910) |
| 5 | IF | `!checkJctSpclCp(tgKeiSvcKeiNo, (String) additionInfo.get("svc_kei_no"))` — coupon check fails |
| 6 | EXEC | `targetInfo.put("jct_spcl_cp_check_list", new ArrayList())` // Trigger check error |

**Block 5.2.3** — [IF] Family Pack handling (L6124–L6135) `[WRIB_SVC_CD_FAMILY_P = "W00000006"]`

> When the cancelled service is a Family Pack (ファミリーパック), update the HPW (Hard Wire) compliant family pack contract data. Extracts the service number from target contracts.

| # | Type | Code |
|---|------|------|
| 1 | IF | `WRIB_SVC_CD_FAMILY_P.equals(wribSvcCd)` → "W00000006" (Family Pack) |
| 2 | SET | `svcKeiNo = ""` // Initialize |
| 3 | FOR | `for (CAANMsg trgtKei : trgtKeis)` |
| 4 | IF | `!JKKStringUtil.isNullBlank(trgtKei.getString("svc_kei_no"))` |
| 5 | SET | `svcKeiNo = trgtKei.getString("svc_kei_no")` |
| 6 | CALL | `updFamipaKeiUm(param, svcKeiNo, funcCd)` // v31.00.00 — Update family pack contract for OPMS hard wire compliance |

**Block 5.2.4** — [SET] Progress status for WRIB (L6143–L6146)

> Sets the progress tracking status code for discounted service cancellation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `prgStat = PRG_STAT_WRIB_DEL_FIN` → **"F051"** // Progress status: Discount/Coupon Cancellation Complete (v4.04.00) |

**Block 5.2.5** — [FOR] Create progress records for WRIB target contracts (L6152–L6172)

> Creates progress records for all target contracts with the appropriate progress status. For Family Pack, the status is converted via `retPrgStatToFamilyPack()`.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (CAANMsg trgtKei : trgtKeis)` |
| 2 | SET | `svcKeiNo = trgtKei.getString("svc_kei_no")` |
| 3 | CALL | `createPrg(param, funcCd, mskmDtlNo, svcKeiNo, keiNo, idoDiv, retPrgStatToFamilyPack(prgStat, wribSvcCd), idoRsnCds, idoRsnMemo, keiKindEnum)` // v4.09.00 — Register progress with Family Pack status conversion and reason memo |

**Block 5.2.6** — [IF] Immediate discount: send contract detail notification (L6176–L6192) `[WRIB_SVC_CD_SOK_WRI = "W00000021"]`

> After progress records are created, if the service was an immediate discount and the function code is "1" (Check & Update), call the contract detail notification CC to generate a notification document.

| # | Type | Code |
|---|------|------|
| 1 | IF | `WRIB_SVC_CD_SOK_WRI.equals(wribSvcCd)` → "W00000021" (Immediate discount) |
| 2 | SET | `svcKeiNo = ""` // Extract first non-blank svcKeiNo |
| 3 | FOR | `for (CAANMsg trgtKei : trgtKeis)` |
| 4 | IF | `!JKKStringUtil.isNullBlank(trgtKei.getString("svc_kei_no"))` |
| 5 | SET | `svcKeiNo = trgtKei.getString("svc_kei_no")` |
| 6 | IF | `"1".equals(funcCd)` → funcCd is "Check & Update" |
| 7 | CALL | `executeKeiyakuNaiyoTuchi(param, sysid, svcKeiNo, mskmDtlNo, idoDiv)` // v26.00.01 — Notify contract details |

**Block 5.2.7** — [IF] Long-term discount: set application-outside flag (L6197–L6213) `[WRIB_SVC_CD_CHOKI_KEIZOKU_WRI = "W00000041"]`

> When the cancelled service is a long-term discount contract (長期継続利用割引) and the cancellation is occurring outside the automatic continuation period, set a flag indicating the application is outside the valid period.

| # | Type | Code |
|---|------|------|
| 1 | IF | `WRIB_SVC_CD_CHOKI_KEIZOKU_WRI.equals(wribSvcCd)` → "W00000041" (Long-term discount) |
| 2 | IF | `chokiKeizokuRiyoWribAplyGaiFlg == true` — cancellation outside automatic continuation period |
| 3 | EXEC | `targetInfo.put("choki_keizoku_riyo_wrib_aply_gai_list", new ArrayList())` // Set flag for application-outside processing |

**Block 6** — [SET] Cleanup and finalize (L6231–L6234)

> After all target contracts are processed, remove the error determination result ThreadLocal.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `this.rslErrHantei.remove()` // v5.00.07 — Clean up error determination data |

**Block 7** — [CALL] Update introduction code (L6237–L6241)

> After processing all contract lines, update the introduction code for contracted services that have been cancelled.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `exeJKKIntrInfoChgCfmCC(funcCd, svcKeiNo (from additionInfo), idoDiv, TRN_DIV_DEL="1", wriMap)` // v7.00.05 — Update introduction code for cancelled contracted services |

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

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return the modified parameter object |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `keiKind` | Field | Contract category — classifies a service line item as either "HNSOKU" (Data Extraction Item / データ抽出項目) or "WRIB" (Discounted Service / 割引サービス) |
| `keiNo` | Field | Contract number (契約番号) — unique identifier for a service contract line |
| `mskmYmd` | Field | Application date (申請年月日) — the date the application was submitted |
| `mskmDtlNo` | Field | Application detail number (申請明細番号) — identifier for the application detail record created during cancellation |
| `idoDiv` | Field | Move reason classification (異動区分別) — distinguishes between "IDO_DIV_WRIB"="00049" (discount service operations) and "IDO_DIV_DCHSKM"="00050" (data extraction operations) |
| `idoRsnCds` | Field | Move reason codes (異動理由コード) — array of codes explaining why the contract was cancelled/moved |
| `idoRsnMemo` | Field | Move reason memo (異動理由メモ) — free-text explanation for the cancellation reason |
| `funcCd` | Field | Function code (機能コード) — "1" = Check & Update (チェック＆更新), "2" = Check only (チェックのみ) |
| `kakinYohi` | Field | Overprint attachment (上付余技) — attachment flag for the cancellation operation |
| `pnltyCd` | Field | Penalty code flag — indicates whether a penalty applies (利用開始年月日保持) |
| `wrib_svc_kei_zengetu_kaiyaku` | Field | Previous month cancellation indicator (前月解約) — tracks if the service was cancelled the previous month (for BS Option Chansnel "Star Channel" / BSオプションチャンネル「スターチャンネル」) |
| `rslErrHantei` | Field | Error determination result (エラー判定) — ThreadLocal storage for error/warning messages during penalty generation (違約金発生時のワーニングメッセージ出力対応) |
| `chokiKeizokuRiyoWribAplyGaiFlg` | Field | Long-term discount contract application-outside flag (長期継続利用割引適用外フラグ) — true when cancellation occurs outside the automatic continuation period |
| `wriMap` | Field | Contracted services tracking map (契約サービスマップ) — tracks which service contract numbers were cancelled, used for introduction code updates |
| `jctWribSvcCdList` | Field | Jurisdiction special service code list (自治体特別割引サービスコードリスト) — list of service codes eligible for local government special coupon checks |
| `DCHSKU` | Acronym | Data Extraction Item (データ抽出項目) — a contract category representing bundled data extraction settings |
| `WRIB` | Acronym | Discounted Service (割引サービス) — subscription-based discount service agreements |
| `PRG_STAT_WRIB_DEL_FIN` | Constant | **"F051"** — Progress status: Discount/Coupon Cancellation Complete (割引・キャンペーン取消完了) |
| `PRG_STAT_DCHSKM_DEL_FIN` | Constant | **"F061"** — Progress status: Data Extraction Item Cancellation Complete (データ抽出項目取消完了) |
| `WRIB_SVC_CD_SOK_WRI` | Constant | **"W00000021"** — Service code: Immediate Discount (即時割引) — effective immediately |
| `WRIB_SVC_CD_CHO_WRI` | Constant | **"W00000011"** — Service code: Long-term Discount (長期利用割引) — replacement contract created when immediate discount is cancelled |
| `WRIB_SVC_CD_FAMILY_P` | Constant | **"W00000006"** — Service code: Family Pack (ファミリーパック) — bundled service package |
| `WRIB_SVC_CD_CHOKI_KEIZOKU_WRI` | Constant | **"W00000041"** — Service code: Long-term Continuation Discount (長期継続利用割引) |
| `WRIB_SVC_CD_KOSOKU_WRI` | Constant | **"W00000022"** — Service code: High-Speed Discount (高速割) |
| `WRIB_SVC_CD_NET_MBL_SET` | Constant | **"W00000005"** — Service code: Internet/Mobile Set Discount (インターネット・モバイルセット割引) |
| `WRIB_DSL_CNCL_OPTY_CD_MAN_APLY` | Constant | **"2"** — Discount cancellation opportunity code: Manual Apply (手動設定) |
| `TRN_DIV_DEL` | Constant | **"1"** — Transaction division: Delete (削除) |
| `TRN_DIV_ADD` | Constant | **"0"** — Transaction division: Add (登録) |
| `KeiKind.HNSOKU` | Enum | Data Extraction Item (データ抽出項目) — contract category for data extraction settings |
| `KeiKind.WRIB` | Enum | Discounted Service (割引サービス) — contract category for discount service agreements |
| `autoCreateWribSvcKei` | Method | Auto-create replacement long-term discount contract when an immediate discount is cancelled |
| `updFamipaKeiUm` | Method | Update family pack contract data for HPW (Hard Wire) compliance — writes to work tables for eo光ネット (eo Hikari Net) |
| `executeKeiyakuNaiyoTuchi` | Method | Contract detail notification CC (契約内容通知書CC) — generates and sends notification documents for confirmed cancellations |
| `exeJKKIntrInfoChgCfmCC` | Method | Introduction code update CC (紹介コード更新CC) — updates introduction/referral tracking when contracted services are cancelled |
| `checkJctSpclCp` | Method | Jurisdiction special coupon check (自治体特別キャンペーンチェック) — validates local government special offer coupons |
| SC Code EKK0451C020 | SC | Discounted Service Contract Cancellation (割引サービス契約解約) |
| SC Code EKK0451D010 | SC | Discounted Service Contract Registration (割引サービス契約登録) |
| SC Code EKK1091D010 | SC | Progress Registration (進捗登録) |
| SC Code EKK0021D020 | SC | Application Content Approval Registration (申請内容承認登録) |
| SC Code EKK0021C060 | SC | Application Detail Inquiry / Follow-up Task (申請明細照会・後続業務依頼) |
| SC Code EKK1351A010 | SC | Data Extraction Item Agreement Inquiry (データ抽出項目照会) |
| SC Code EKK1391A010 | SC | Data Extraction Settings Inquiry (データ抽出項目設定照会) |
| SC Code EKK1401B001 | SC | Data Extraction Settings Target Contract List (データ抽出項目設定対象契約一覧照会) |
| SC Code EKK0451A010 | SC | Discounted Service Contract Inquiry (割引サービス契約照会) |
| SC Code EKK0481B001 | SC | Discounted Service Target Contract List (割引サービス対象契約一覧照会) |
| SC Code EKK0841C011 | SC | Discount/Coupon Coexistence Availability (割引・キャンペーン併用可否取得) |
| SC Code EKK0081B039 | SC | Introduction Code Inquiry (紹介コード照会) |
| eo光 (eo Hikari) | Business term | K-Opticom's fiber-optic broadband internet service (Fiber To The Home) |
| 割引サービス (Waribiki Service) | Business term | Discounted service — subscription-based price reduction agreements (e.g., line discount, family pack, long-term discount) |
| データ抽出項目 (Data Extraction Item) | Business term | Data extraction settings — configurations for extracting specific service data for reporting or processing |
| 契約内容通知書 (Contract Detail Notification) | Business term | Document notifying customers of contract changes, sent for confirmed cancellations |
| 自治体特別キャンペーン (Jurisdiction Special Campaign) | Business term | Local government special coupon/discount programs — regional promotional campaigns for telecommunications services |
| ファミリーパック (Family Pack) | Business term | Bundled service package — multiple services offered together at a discounted rate |
| 長期利用割引 (Long-term Discount) | Business term | Discount applied over a long-term contract period (24-month commitment) |
| 即時割引 (Immediate Discount) | Business term | Discount effective immediately upon contract registration |
| 長期継続利用割引 (Long-term Continuation Discount) | Business term | Long-term continuation discount — auto-renewing discount beyond initial commitment period |
| 高速割 (High-Speed Discount) | Business term | High-speed plan discount — price reduction for high-speed internet plans (e.g., 10G Fiber) |
| 違約金 (Penalty Fee) | Business term | Early termination penalty — fees charged for cancelling contracts before the commitment period ends |
