# (DD33) Business Logic — JDKCommon08CC.unlink() [310 LOC]

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

## 1. Role

### JDKCommon08CC.unlink()

The `unlink()` method orchestrates the **return product approval un-linking (アンリンク) process** for home equipment (STB Set-Top Box and C-CAS CAS Card) within a cable television service management system. When a customer returns their leased equipment and the return is approved (indicated by `updateStat` equaling "return product approval"), this method systematically disassociates the equipment from the customer's subscription by calling a chain of service interfaces.

The method handles two equipment types: **STB (Set-Top Box)** and **C-CAS (Conditional Access System Card)**. It follows a **gatekeeper and sequential orchestration pattern**: first performing a duplicate-processing check via `checkMap`, then executing a series of four service interface calls in strict order — (a-2) home equipment type agreement, (a-3) home equipment list agreement (3), (a-4) bureau list agreement, and (a-6) through (a-8) viewing control order reception, send, and result registration. Each service call is guarded by error checking, and certain error conditions cause early return with error flag codes instead of throwing exceptions.

The method plays a **shared utility role** within the product return/acceptance workflow (DKSV0081). It is called by `JDKCommon08CC.cc()` — a common processing method invoked during the return product approval flow — specifically when the equipment subtype is STB or C-CAS and the equipment update status is "return product approval."

Conditional branches handle three distinct outcomes: (1) **STB unlink impossible + C-CAS linkable** — returns with `key_unlink_unyo_hmpin_kiki_no` error code; (2) **STB linkable + C-CAS unlink impossible** — returns with `key_unlink_link_hmpin_kiki_no` error code; (3) **both equipment linkable for unlink** — proceeds through all service interface calls to complete the full un-linking process.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["unlink params"])
    
    START --> P1["paramMap = new HashMap<br/>paramMap: return holder"]
    P1 --> P2["tmpParamMap = new HashMap<br/>tmpParamMap: temp processing data"]
    P2 --> C1{checkMap is null<br/>or empty}
    
    C1 -->|yes| P3["tmpParamMap.put taknkiki_mdl_cd<br/>tmpParamMap.put kiki_seizo_no<br/>tmpParamMap.put svc_kei_no<br/>tmpParamMap.put operate_date_key<br/>tmpParamMap.put operate_datetime_key<br/>tmpParamMap.put operator_id"]
    
    C1 -->|no| C2{checkMap contains<br/>keyTkMdlCd + keyKkSeizoNo}
    C2 -->|yes| EARLY_RET1["return tmpParamMap<br/>already processed"]
    C2 -->|no| P3
    
    P3 --> P4["paramMap.put TRANZACTION_ID_KEY<br/>paramMap.put USECASE_ID_KEY<br/>paramMap.put OPERATION_ID_KEY<br/>paramMap.put CALL_TYPE_KEY"]
    P4 --> P5["paramMap.put CLIENT_HOST_NAME_KEY<br/>paramMap.put CLIENT_IP_ADDRESS_KEY<br/>paramMap.put INVOKE_GAMEN_ID_KEY<br/>paramMap.put OPERATOR_ID_KEY"]
    P5 --> P6["inMap = param.getData DKSV008101CC"]
    P6 --> P7["editTkniKikiMsg<br/>a-2 home equipment type info"]
    P7 --> P8["scCall.run editResultRrr<br/>SC Call home equipment type agreement"]
    P8 --> C3{hasError param}
    
    C3 -->|yes| ERR1["throw SCCallException<br/>home equipment type agreement failure"]
    C3 -->|no| P9["templates = result.get TEMPLATE_LIST_KEY<br/>msg = templates 0<br/>serchList = msg.getCAANMsgList<br/>EZM0411A010CBSMsg1List"]
    P9 --> C4{serchList null<br/>or empty}
    
    C4 -->|yes| FINAL_RET1["return tmpParamMap<br/>normal completion"]
    
    C4 -->|no| P10["tmpParamMap.put taknkiki_sbt_cd<br/>serchList 0 getString"]
    P10 --> P11["editTkniKiki3Msg<br/>a-3 home equipment list 3"]
    P11 --> P12["scCall.run editResultRrr<br/>SC Call home equipment list 3"]
    P12 --> C5{hasError param}
    
    C5 -->|yes| ERR2["throw SCCallException<br/>home equipment list 3 failure"]
    C5 -->|no| P13["templates = result.get TEMPLATE_LIST_KEY<br/>msg = templates 0<br/>serchList = msg.getCAANMsgList<br/>EWCA0010001CBSMsg1List"]
    P13 --> C6{serchList null<br/>or empty}
    
    C6 -->|yes| FINAL_RET1
    
    C6 -->|no| P14["tmpParamMap.put EWCA0010001CBSMSG1LIST<br/>msg = serchList 0"]
    P14 --> P15["stb_stat_cd = msg.getString STB_STAT_CD<br/>ccas_card_stat_cd = msg.getString CCAS_CARD_STAT_CD"]
    P15 --> P16["checkMap.add STB_TK_MDL_CD + STB_KK_SEIZO_NO<br/>checkMap.add CCAS_TK_MDL_CD + CCAS_KK_SEIZO_NO"]
    P16 --> C7{stb_stat_cd NOT IN<br/>011 012<br/>AND ccas_card_stat_cd EQ 012}
    
    C7 -->|yes| P18["tmpParamMap.put key_unlink_unyo_hmpin_kiki_no<br/>return tmpParamMap<br/>STB unlink impossible error"]
    
    C7 -->|no| C8{stb_stat_cd IN<br/>011 012<br/>AND ccas_card_stat_cd NOT EQ 012}
    
    C8 -->|yes| P19["tmpParamMap.put key_unlink_link_hmpin_kiki_no<br/>return tmpParamMap<br/>C-CAS unlink impossible error"]
    
    C8 -->|no| C9{stb_stat_cd IN<br/>011 012<br/>AND ccas_card_stat_cd EQ 012}
    
    C9 -->|yes| P20["template new CAANMsg EWC0151B010CBSMsg<br/>template.set TEMPLATEID EWC0151B010<br/>if inMap not null<br/>template.set FUNC_CODE 1<br/>template.set OPERATEDATE<br/>template.set OPERATEDATETIME<br/>template.set OPERATORID"]
    P20 --> P21["paramMap.put TEMPLATE_LIST_KEY<br/>scCall.run editResultRrr<br/>SC Call bureau list agreement"]
    P21 --> C10{hasError param}
    
    C10 -->|yes| ERR3["throw SCCallException<br/>bureau list agreement failure"]
    C10 -->|no| P22["templates = result.get TEMPLATE_LIST_KEY<br/>msg = templates 0<br/>serchList = msg.getCAANMsgList<br/>EWC0151B010CBSMsg1List"]
    P22 --> C11{serchList null<br/>or empty}
    
    C11 -->|yes| FINAL_RET2["return tmpParamMap"]
    
    C11 -->|no| P23["tmpParamMap.put kyoku_cd<br/>serchList 0 getString KYOKU_CD"]
    P23 --> P24["template new CAANMsg EWC0101B010CBSMsg<br/>template.set TEMPLATEID EWC0101B010<br/>if inMap not null<br/>template.set FUNC_CODE 1<br/>template.set KEY_KYOKU_CD<br/>template.set OPERATEDATE<br/>template.set OPERATEDATETIME<br/>template.set OPERATORID"]
    P24 --> P25["paramMap.put TEMPLATE_LIST_KEY<br/>scCall.run editResultRrr<br/>SC Call control area list agreement"]
    P25 --> C12{hasError param}
    
    C12 -->|yes| ERR4["throw SCCallException<br/>control area list failure"]
    C12 -->|no| P26["templates = result.get TEMPLATE_LIST_KEY<br/>msg = templates 0<br/>serchList = msg.getCAANMsgList<br/>EWC0101B010CBSMsg1List"]
    P26 --> C13{serchList null<br/>or empty}
    
    C13 -->|yes| FINAL_RET2
    
    C13 -->|no| P27["tmpParamMap.put ctrl_area_cd<br/>serchList 0 getString CTRL_AREA_CD"]
    P27 --> P28["editOrderUktkMsg<br/>a-6 viewing control order reception"]
    P28 --> P29["scCall.run editResultRrr<br/>SC Call viewing control order reception"]
    P29 --> C14{hasError param}
    
    C14 -->|yes| ERR5["throw SCCallException<br/>viewing control order reception failure"]
    C14 -->|no| P30["editResultUktk result tmpParamMap"]
    P30 --> P31["editOrderSendMsg<br/>a-7 viewing control order send"]
    P31 --> P32["scCall.run editResultRrr<br/>SC Call viewing control order send"]
    P32 --> C15{hasError param}
    
    C15 -->|yes| ERR6["throw SCCallException<br/>viewing control order send failure"]
    C15 -->|no| P33["tmpParamMap.put EWC0011C010CBSMSG1LIST<br/>msg"]
    P33 --> P34["editOrderResultRegistMsg<br/>a-8 viewing control order result regist"]
    P34 --> P35["scCall.run editResultRrr<br/>SC Call viewing control order result regist"]
    P35 --> C16{hasError param}
    
    C16 -->|yes| ERR7["throw SCCallException<br/>viewing control order result regist failure"]
    C16 -->|no| FINAL_RET3["return tmpParamMap<br/>normal completion"]
    
    C9 -->|no| P37["tmpParamMap.put key_not_unlink_flg<br/>return tmpParamMap<br/>unlink unnecessary status"]
    
    style START fill:#e1f5e1
    style ERR1 fill:#ffe1e1
    style ERR2 fill:#ffe1e1
    style ERR3 fill:#ffe1e1
    style ERR4 fill:#ffe1e1
    style ERR5 fill:#ffe1e1
    style ERR6 fill:#ffe1e1
    style ERR7 fill:#ffe1e1
    style EARLY_RET1 fill:#fff3cd
    style FINAL_RET1 fill:#e1f5e1
    style FINAL_RET2 fill:#e1f5e1
    style FINAL_RET3 fill:#e1f5e1
    style P37 fill:#fff3cd
    style P18 fill:#ffe1e1
    style P19 fill:#ffe1e1
```

**Processing flow summary:**
1. **Guard check**: If `checkMap` already contains the device key (`keyTkMdlCd + keyKkSeizoNo`), return early (device already processed).
2. **Parameter preparation**: Populate `tmpParamMap` with home equipment model code, serial number, service contract number, operate date/time, and operator ID. Populate `paramMap` with SC input common data from both telegram header and user control map.
3. **Step (a-2)**: Call `editTkniKikiMsg` to prepare home equipment type info, then execute the SC for home equipment type agreement. Check for errors.
4. **Step (a-3)**: From SC response, retrieve the search list and extract `taknkiki_sbt_cd`. Call `editTkniKiki3Msg` to prepare home equipment list(3) params, then execute the SC. Check for errors.
5. **Status evaluation**: From the SC(3) response, extract `stb_stat_cd` and `ccas_card_stat_cd`. Mark both devices in `checkMap`. Then evaluate equipment status:
   - If STB status is NOT "011" (provisional registration) or "012" (in operation) AND C-CAS status IS "012" (link in progress): **STB unlink impossible** -> error return.
   - If STB status IS "011" or "012" AND C-CAS status is NOT "012": **C-CAS unlink impossible** -> error return.
   - If both STB and C-CAS are in linkable status: proceed with un-linking.
6. **Steps (a-4) through (a-8)**: If unlinkable, execute a chain of 4 service interfaces — bureau list agreement, control area list agreement, viewing control order reception, viewing control order send, and viewing control order result registration. Each step follows the same pattern: prepare params, call SC, check error, extract response.
7. **IT1-2017-0000118 modification**: In the final else branch (status mismatch that is not explicitly unlinkable), set `key_not_unlink_flg` instead of proceeding.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying all input data, control map data (operating date, time, operator ID, hostname, IP, screen ID), and SC input common data (transaction ID, use case ID, operation ID, call type). Provides `getData(DKSV008101CC)` to retrieve the user data map containing return product approval context. |
| 2 | `keyTkMdlCd` | `String` | Home equipment model code — the type identifier for the piece of equipment being unlinked (STB or C-CAS). Combined with `keyKkSeizoNo` as a dedup key in `checkMap`. |
| 3 | `keyKkSeizoNo` | `String` | Equipment manufacturing serial number — the unique serial number assigned by the manufacturer to the physical device. Combined with `keyTkMdlCd` as a dedup key in `checkMap`. |
| 4 | `keySvcKeiNo` | `String` | Service contract line number — identifies the specific service contract line item associated with this equipment. Stored in `tmpParamMap` as `svc_kei_no`. |
| 5 | `checkMap` | `HashSet<String>` | Deduplication and status tracking set. Contains concatenated device keys (`modelCd + serialNo`) for both STB and C-CAS devices already processed. Used to skip duplicate processing at entry and to register devices after reading their status. |
| 6 | `scCall` | `ServiceComponentRequestInvoker` | Service component execution engine. Used to invoke remote service interface calls (`scCall.run(paramMap, handle)`) that perform the actual business operations against downstream CBS (CBS = Common Business Service) services. |
| 7 | `handle` | `SessionHandle` | Session handle providing context for SC invocations, carrying session state across service boundary calls. |
| 8 | `keyHmpinKikiNo` | `String` | Home equipment number — the internal identifier for the home equipment being processed. Used as the value in error flag maps (`key_unlink_unyo_hmpin_kiki_no`, `key_unlink_link_hmpin_kiki_no`, `key_not_unlink_flg`) to identify which equipment has the unlink status problem. |

**External state / constants referenced:**

| Constant | Value | Business Meaning |
|----------|-------|------------------|
| `DKSV008101CC` | `"DKSV008101CC"` [-> `DKSV0081_DKSV0081OP.java:39`] | Key to retrieve return product approval user data from the request parameter map |
| `JWCStrConst.CD_DIV_WATCH_KIKI_KANRI_STAT_KARITO` | `"011"` [-> `JWCStrConst.java:65`] | Home equipment management status code for provisional registration |
| `JWCStrConst.CD_DIV_WATCH_KIKI_KANRI_STAT_HONUNYO` | `"012"` [-> `JWCStrConst.java:70`] | Home equipment management status code for in operation |
| `JWCStrConst.CD_DIV_CCAS_CARD_KANRI_STAT_LINKCHU` | `"012"` [-> `JWCStrConst.java:116`] | C-CAS card management status code for link processing in progress |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JDKCommon08CC.editTkniKikiMsg` | - | - | Prepares home equipment type info parameters for the type agreement SC call |
| R | Home equipment type agreement SC | (inferred from EZM0411A010CBSMsg) | (home equipment type data) | SC Call retrieves home equipment type information |
| R | `JDKCommon08CC.editTkniKiki3Msg` | - | - | Prepares home equipment list(3) parameters to query device status |
| R | Home equipment list(3) SC | (inferred from EWCA0010001CBSMsg) | (home equipment status data) | SC Call retrieves STB status code and C-CAS card status code |
| R | Bureau list agreement SC | EWC0151B010SC (inferred) | (bureau information data) | SC Call retrieves bureau code for the equipment location |
| R | Control area list agreement SC | EWC0101B010SC (inferred) | (control area information data) | SC Call retrieves control area code based on bureau code |
| R | `JDKCommon08CC.editOrderUktkMsg` | - | - | Prepares viewing control order reception parameters |
| R | Viewing control order reception SC | (inferred from EWC0011C010CBSMsg template) | (viewing control order table) | SC Call registers viewing control order data to the table |
| R | Viewing control order send SC | (inferred from template) | (viewing control order data) | SC Call sends viewing control package with command issuance |
| R | `JDKCommon08CC.editOrderResultRegistMsg` | - | - | Prepares viewing control order result registration parameters |
| R | Viewing control order result registration SC | (inferred from template) | (viewing control order result table) | SC Call registers the viewing control order result |
| U | `JDKCommon08CC.editResultRrr` | - | - | Processes SC response and populates error status into param |
| R | `JDKBPCommon.hasError` | - | - | Checks whether error status is set in param after each SC call |
| R | `JDKCommon08CC.editResultUktk` | - | - | Extracts registration result from SC response into tmpParamMap |

**How to classify:**
- All `scCall.run()` invocations are **Read (R)** operations — they retrieve/query equipment status, bureau info, control area info, and register/send viewing control orders.
- `editResultRrr` is **Update (U)** — it processes the SC response and writes error status back into the param object.
- Helper methods (`editTkniKikiMsg`, `editTkniKiki3Msg`, `editOrderUktkMsg`, `editOrderSendMsg`, `editOrderResultRegistMsg`, `editResultUktk`) are **Read (R)** as they prepare and extract parameters from data structures.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | BPM:DKSV0081 (Return Product Approval) | `DKSV0081Flow` -> `DKSV0081OPOperation` -> `JDKCommon08CC.cc()` -> `JDKCommon08CC.unlink()` | Home equipment type agreement [R], Home equipment list(3) [R], Bureau list agreement [R], Control area list agreement [R], Viewing control order reception [R], Viewing control order send [R], Viewing control order result registration [R] |

**Call chain detail:**
- `DKSV0081Flow` is the BPM stateless session bean entry point for return product approval.
- `DKSV0081OPOperation` is the operation layer that coordinates processing steps.
- `JDKCommon08CC.cc()` is the common processing method called during return product approval. When equipment type is STB or C-CAS and update status is "return product approval" (`JDKStrConst.HMPIN_KIKI_STAT_SHONIN`), it calls `unlink()`.
- `unlink()` is invoked with equipment model code, serial number, service contract number, checkMap, scCall, handle, and home equipment number.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `checkMap != null && checkMap.size() > 0` (L1597)

> Duplicate processing guard: if checkMap is provided, skip processing if the device was already handled.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(checkMap != null && checkMap.size() > 0)` // L1597: dedup guard check |

**Block 1.1** — [IF] `checkMap.contains(keyTkMdlCd + keyKkSeizoNo)` (L1598)

> If this exact device (model + serial) is already tracked in checkMap, return immediately — this prevents re-processing the same equipment.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(checkMap.contains(keyTkMdlCd+keyKkSeizoNo))` // L1598: already processed device |
| 2 | RETURN | `return tmpParamMap` // L1599: early return for dedup |

**Block 2** — [SET] Parameter accumulation into tmpParamMap (L1603–L1611)

> Populate the temporary parameter map with core device and session metadata.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpParamMap.put("taknkiki_mdl_cd", keyTkMdlCd)` // L1604: home equipment model code |
| 2 | SET | `tmpParamMap.put("kiki_seizo_no", keyKkSeizoNo)` // L1606: equipment serial number |
| 3 | SET | `tmpParamMap.put("svc_kei_no", keySvcKeiNo)` // L1608: service contract number |
| 4 | SET | `tmpParamMap.put("operate_date_key", param.getControlMapData(SCControlMapKeys.OPE_DATE))` // L1610: operate date |
| 5 | SET | `tmpParamMap.put("operate_datetime_key", param.getControlMapData(SCControlMapKeys.OPE_TIME))` // L1612: operate datetime |
| 6 | SET | `tmpParamMap.put("operator_id", param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` // L1614: operator ID |

**Block 3** — [SET] SC Input common data from telegram header (L1619–L1624)

> Extract SC input common data from the telegram header — transaction ID, use case ID, operation ID, call type.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put(JCMConstants.TRANZACTION_ID_KEY, param.getTelegramID())` // L1621: transaction ID [-> JCMConstants.TRANZACTION_ID_KEY] |
| 2 | SET | `paramMap.put(JCMConstants.USECASE_ID_KEY, param.getUsecaseID())` // L1623: use case ID [-> JCMConstants.USECASE_ID_KEY] |
| 3 | SET | `paramMap.put(JCMConstants.OPERATION_ID_KEY, param.getOperationID())` // L1625: operation ID [-> JCMConstants.OPERATION_ID_KEY] |
| 4 | SET | `paramMap.put(JCMConstants.CALL_TYPE_KEY, param.getCallType())` // L1627: call type [-> JCMConstants.CALL_TYPE_KEY] |

**Block 4** — [SET] SC Input common data from user control map (L1632–L1638)

> Extract SC input common data from the user's control map — hostname, IP address, screen ID, operator ID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put(JCMConstants.CLIENT_HOST_NAME_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTNAME))` // L1634: client hostname |
| 2 | SET | `paramMap.put(JCMConstants.CLIENT_IP_ADDRESS_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTIP))` // L1636: client IP address |
| 3 | SET | `paramMap.put(JCMConstants.INVOKE_GAMEN_ID_KEY, param.getControlMapData(SCControlMapKeys.REQ_VIEWID))` // L1638: invoke screen ID |
| 4 | SET | `paramMap.put(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` // L1640: operator ID (overwritten) |

**Block 5** — [SET] Retrieve user data map (L1643)

> Get the user data HashMap from the request parameter using the DKSV008101CC key — this contains return product approval context data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = (HashMap)param.getData(DKSV008101CC)` // L1643: return product approval data |

**Block 6** — [CALL] Step (a-2): Home equipment type agreement (L1646–L1656)

> Prepare parameters for the home equipment type agreement and execute the SC call.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editTkniKikiMsg(paramMap, inMap, tmpParamMap)` // L1646: prepare home equipment type info params |
| 2 | EXEC | `JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), "home equipment type agreement processing (unlink)")` // L1650: debug log |
| 3 | CALL | `result = scCall.run(paramMap, handle)` // L1652: execute SC - home equipment type agreement |
| 4 | CALL | `editResultRrr(result, param)` // L1653: process SC result |
| 5 | IF | `if (JDKBPCommon.hasError(param))` // L1654: check for error |
| 6 | CALL | `throw new SCCallException("home equipment type agreement failure", "0", ...)` // L1655-1656: error throw |

**Block 7** — [SET] Extract SC(2) response (L1659–L1662)

> Retrieve the template list from the SC response and extract the search list for home equipment type info.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = (CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY)` // L1659: extract templates |
| 2 | SET | `msg = templates[0]` // L1660: first template |
| 3 | SET | `serchList = msg.getCAANMsgList(EZM0411A010CBSMsg.EZM0411A010CBSMSG1LIST)` // L1662: get search list |

**Block 8** — [IF] SC(2) search list exists (L1663)

> If the SC returned search results, proceed with device status retrieval. Otherwise, skip to final return.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(serchList != null && serchList.length > 0)` // L1663: search list guard |

**Block 8.1** — [SET] Store home equipment subtype code (L1666)

> Extract and store the home equipment subtype code (STB or C-CAS) from the SC response.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpParamMap.put("taknkiki_sbt_cd", serchList[0].getString(EZM0411A010CBSMsg1List.TAKNKIKI_SBT_CD))` // L1666: subtype code |

**Block 9** — [CALL] Step (a-3): Home equipment list agreement (3) (L1670–L1683)

> Prepare and execute the SC call to retrieve STB status code and C-CAS card status code.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editTkniKiki3Msg(paramMap, inMap, tmpParamMap)` // L1670: prepare home equipment list(3) params |
| 2 | EXEC | `JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), "home equipment list(3) processing")` // L1674: debug log |
| 3 | CALL | `result = scCall.run(paramMap, handle)` // L1676: execute SC - home equipment list(3) |
| 4 | CALL | `editResultRrr(result, param)` // L1677: process SC result |
| 5 | IF | `if (JDKBPCommon.hasError(param))` // L1678: check for error |
| 6 | CALL | `throw new SCCallException("home equipment list(3) failure", "0", ...)` // L1679-1680: error throw |

**Block 10** — [SET] Extract SC(3) response (L1683–L1686)

> Extract template list and search list from the home equipment list(3) SC response.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = (CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY)` // L1683: extract templates |
| 2 | SET | `msg = templates[0]` // L1684: first template |
| 3 | SET | `serchList = msg.getCAANMsgList(EWCA0010001CBSMsg.EWCA0010001CBSMSG1LIST)` // L1686: get search list |

**Block 11** — [IF] SC(3) search list exists (L1687)

> If the SC(3) returned results with STB/C-CAS status data, proceed with status evaluation.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(serchList != null && serchList.length > 0)` // L1687: search list guard |

**Block 11.1** — [SET] Store SC(3) list and read device status (L1690–L1696)

> Store the full SC(3) list and extract STB status code and C-CAS card status code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpParamMap.put("EWCA0010001CBSMSG1LIST", serchList[0])` // L1690: store SC(3) result list |
| 2 | SET | `msg = serchList[0]` // L1692: reference first entry |
| 3 | SET | `stb_stat_cd = msg.getString(EWCA0010001CBSMsg1List.STB_STAT_CD)` // L1693: STB status code |
| 4 | SET | `ccas_card_stat_cd = msg.getString(EWCA0010001CBSMsg1List.CCAS_CARD_STAT_CD)` // L1694: C-CAS card status code |

**Block 11.2** — [SET] Mark devices in checkMap (L1697–L1700)

> Register both the STB and C-CAS device keys in checkMap to mark them as processed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `checkMap.add(msg.getString(EWCA0010001CBSMsg1List.STB_TK_MDL_CD) + msg.getString(EWCA0010001CBSMsg1List.STB_KK_SEIZO_NO))` // L1697-1698: STB device key |
| 2 | SET | `checkMap.add(msg.getString(EWCA0010001CBSMsg1List.CCAS_TK_MDL_CD) + msg.getString(EWCA0010001CBSMsg1List.CCAS_KK_SEIZO_NO))` // L1699-1700: C-CAS device key |

**Block 12** — [IF] STB unlink impossible + C-CAS linkable (L1703–L1708) [CD_DIV_WATCH_KIKI_KANRI_STAT_KARITO="011" (JWCStrConst.java:65), CD_DIV_WATCH_KIKI_KANRI_STAT_HONUNYO="012" (JWCStrConst.java:70), CD_DIV_CCAS_CARD_KANRI_STAT_LINKCHU="012" (JWCStrConst.java:116)]

> **Error condition**: STB status is NOT "011" (provisional registration) or "012" (in operation) AND C-CAS status IS "012" (link in progress). The STB cannot be unlinked but the C-CAS is linkable — error out.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(!(JWCStrConst.CD_DIV_WATCH_KIKI_KANRI_STAT_KARITO.equals(stb_stat_cd) || JWCStrConst.CD_DIV_WATCH_KIKI_KANRI_STAT_HONUNYO.equals(stb_stat_cd)) && JWCStrConst.CD_DIV_CCAS_CARD_KANRI_STAT_LINKCHU.equals(ccas_card_stat_cd))` // L1703-1707 |
| 2 | SET | `tmpParamMap.put("key_unlink_unyo_hmpin_kiki_no", keyHmpinKikiNo)` // L1708: error flag for STB unlink impossible |
| 3 | RETURN | `return tmpParamMap` // L1709: return with error flag |

**Block 13** — [IF] STB linkable + C-CAS unlink impossible (L1715–L1722) [CD_DIV_WATCH_KIKI_KANRI_STAT_KARITO="011", CD_DIV_WATCH_KIKI_KANRI_STAT_HONUNYO="012", CD_DIV_CCAS_CARD_KANRI_STAT_LINKCHU="012"]

> **Error condition**: STB status IS "011" or "012" (linkable for unlink) AND C-CAS status is NOT "012" (unlink not possible). The STB is ready to unlink but the C-CAS is not in linkable state — error out.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if((JWCStrConst.CD_DIV_WATCH_KIKI_KANRI_STAT_KARITO.equals(stb_stat_cd) || JWCStrConst.CD_DIV_WATCH_KIKI_KANRI_STAT_HONUNYO.equals(stb_stat_cd)) && !JWCStrConst.CD_DIV_CCAS_CARD_KANRI_STAT_LINKCHU.equals(ccas_card_stat_cd))` // L1715-1721 |
| 2 | SET | `tmpParamMap.put("key_unlink_link_hmpin_kiki_no", keyHmpinKikiNo)` // L1722: error flag for C-CAS unlink impossible |
| 3 | RETURN | `return tmpParamMap` // L1723: return with error flag |

**Block 14** — [IF] Both STB and C-CAS linkable for unlink (L1726–L1729) [CD_DIV_WATCH_KIKI_KANRI_STAT_KARITO="011", CD_DIV_WATCH_KIKI_KANRI_STAT_HONUNYO="012", CD_DIV_CCAS_CARD_KANRI_STAT_LINKCHU="012"]

> **Unlink-able state**: STB status is "011" (provisional registration) or "012" (in operation) AND C-CAS status IS "012" (link in progress). All conditions met to proceed with full un-linking process.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if((JWCStrConst.CD_DIV_WATCH_KIKI_KANRI_STAT_KARITO.equals(stb_stat_cd) || JWCStrConst.CD_DIV_WATCH_KIKI_KANRI_STAT_HONUNYO.equals(stb_stat_cd)) && JWCStrConst.CD_DIV_CCAS_CARD_KANRI_STAT_LINKCHU.equals(ccas_card_stat_cd))` // L1726-1729 |

**Block 14.1** — [SET] Step (a-4): Prepare bureau list agreement params (L1732–L1745)

> Create a new CAANMsg template for the bureau list agreement SC (EWC0151B010). Set template ID, function code (default "1"), operate date, operate datetime, and operator ID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template = new CAANMsg(EWC0151B010CBSMsg.class.getName())` // L1734: create template |
| 2 | SET | `template.set(EWC0151B010CBSMsg.TEMPLATEID, "EWC0151B010")` // L1737: set template ID |
| 3 | IF | `if(inMap != null)` // L1739: conditional param population |
| 4 | SET | `template.set(EWC0151B010CBSMsg.FUNC_CODE, "1")` // L1741: function code (default: 1) |
| 5 | SET | `template.set(EWC0151B010CBSMsg.OPERATEDATE, tmpParamMap.get("operate_date_key"))` // L1743: operate date |
| 6 | SET | `template.set(EWC0151B010CBSMsg.OPERATEDATETIME, tmpParamMap.get("operate_datetime_key"))` // L1745: operate datetime |
| 7 | SET | `template.set(EWC0151B010CBSMsg.OPERATORID, tmpParamMap.get("operator_id"))` // L1747: operator ID |

**Block 14.2** — [CALL] Step (a-4): Execute bureau list agreement SC (L1750–L1763)

> Execute the SC call for bureau list agreement. EWC0151B010 retrieves bureau code from the system.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = new CAANMsg[1]` // L1750: create template array |
| 2 | SET | `templates[0] = template` // L1751: set template |
| 3 | SET | `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` // L1752: set template list in paramMap |
| 4 | EXEC | `JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), "bureau list agreement processing")` // L1755: debug log |
| 5 | CALL | `result = scCall.run(paramMap, handle)` // L1757: execute SC - bureau list agreement |
| 6 | CALL | `editResultRrr(result, param)` // L1758: process SC result |
| 7 | IF | `if (JDKBPCommon.hasError(param))` // L1759: check for error |
| 8 | CALL | `throw new SCCallException("bureau list agreement failure", "0", ...)` // L1760-1761: error throw |

**Block 14.3** — [SET] Extract bureau list SC response (L1764–L1767)

> Extract the bureau code from the SC(4) response.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = (CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY)` // L1764: extract templates |
| 2 | SET | `msg = templates[0]` // L1765: first template |
| 3 | SET | `serchList = msg.getCAANMsgList(EWC0151B010CBSMsg.EWC0151B010CBSMSG1LIST)` // L1767: get search list |

**Block 14.4** — [IF] Bureau list SC(4) search list exists (L1768)

> If bureau list SC returned results, extract the bureau code and proceed to control area lookup.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(serchList != null && serchList.length > 0)` // L1768: search list guard |

**Block 14.4.1** — [SET] Store bureau code (L1771)

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpParamMap.put("kyoku_cd", serchList[0].getString(EWC0151B010CBSMsg1List.KYOKU_CD))` // L1771: bureau code |

**Block 15** — [SET] Step (a-5): Prepare control area list agreement params (L1775–L1792)

> Create a new CAANMsg template for the control area list agreement SC (EWC0101B010). Set template ID, function code, bureau code, operate date, operate datetime, and operator ID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template = new CAANMsg(EWC0101B010CBSMsg.class.getName())` // L1777: create template |
| 2 | SET | `template.set(EWC0101B010CBSMsg.TEMPLATEID, "EWC0101B010")` // L1780: set template ID |
| 3 | IF | `if(inMap != null)` // L1782: conditional param population |
| 4 | SET | `template.set(EWC0101B010CBSMsg.FUNC_CODE, "1")` // L1784: function code (default: 1) |
| 5 | SET | `template.set(EWC0101B010CBSMsg.KEY_KYOKU_CD, tmpParamMap.get("kyoku_cd"))` // L1786: bureau code |
| 6 | SET | `template.set(EWC0101B010CBSMsg.OPERATEDATE, tmpParamMap.get("operate_date_key"))` // L1788: operate date |
| 7 | SET | `template.set(EWC0101B010CBSMsg.OPERATEDATETIME, tmpParamMap.get("operate_datetime_key"))` // L1790: operate datetime |
| 8 | SET | `template.set(EWC0101B010CBSMsg.OPERATORID, tmpParamMap.get("operator_id"))` // L1792: operator ID |

**Block 16** — [CALL] Step (a-5): Execute control area list agreement SC (L1795–L1809)

> Execute the SC call for control area list agreement. EWC0101B010 retrieves control area code from the system based on bureau code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = new CAANMsg[1]` // L1795: create template array |
| 2 | SET | `templates[0] = template` // L1796: set template |
| 3 | SET | `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` // L1797: set template list |
| 4 | EXEC | `JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), "control area list agreement processing")` // L1800: debug log |
| 5 | CALL | `result = scCall.run(paramMap, handle)` // L1802: execute SC - control area list agreement |
| 6 | CALL | `editResultRrr(result, param)` // L1803: process SC result |
| 7 | IF | `if (JDKBPCommon.hasError(param))` // L1804: check for error |
| 8 | CALL | `throw new SCCallException("control area list failure", "0", ...)` // L1805-1806: error throw |

**Block 17** — [SET] Extract control area list SC response (L1809–L1812)

> Extract the control area code from the SC(5) response.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = (CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY)` // L1809: extract templates |
| 2 | SET | `msg = templates[0]` // L1810: first template |
| 3 | SET | `serchList = msg.getCAANMsgList(EWC0101B010CBSMsg.EWC0101B010CBSMSG1LIST)` // L1812: get search list |

**Block 18** — [IF] Control area list SC(5) search list exists (L1813)

> If control area list SC returned results, extract the control area code and proceed with viewing control order processing.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(serchList != null && serchList.length > 0)` // L1813: search list guard |

**Block 18.1** — [SET] Store control area code (L1816)

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpParamMap.put("ctrl_area_cd", serchList[0].getString(EWC0101B010CBSMsg1List.CTRL_AREA_CD))` // L1816: control area code |

**Block 19** — [CALL] Step (a-6): Viewing control order reception (L1819–L1836)

> Prepare viewing control order reception parameters via `editOrderUktkMsg`, then execute the SC call.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editOrderUktkMsg(paramMap, inMap, tmpParamMap)` // L1820: prepare viewing control order reception params |
| 2 | EXEC | `JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), "viewing control order reception processing")` // L1824: debug log |
| 3 | CALL | `result = scCall.run(paramMap, handle)` // L1826: execute SC - viewing control order reception |
| 4 | CALL | `editResultRrr(result, param)` // L1827: process SC result |
| 5 | IF | `if (JDKBPCommon.hasError(param))` // L1828: check for error |
| 6 | CALL | `throw new SCCallException("viewing control order reception failure", "0", ...)` // L1829-1830: error throw |

**Block 19.1** — [CALL] Retrieve registration result (L1833)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editResultUktk(result, tmpParamMap)` // L1833: extract registration result |

**Block 20** — [CALL] Step (a-7): Viewing control order send (L1837–L1854)

> Prepare viewing control order send parameters via `editOrderSendMsg`, then execute the SC call. This sends the viewing control package and issues commands.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editOrderSendMsg(paramMap, inMap, tmpParamMap)` // L1838: prepare viewing control order send params |
| 2 | EXEC | `JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), "viewing control order send processing")` // L1842: debug log |
| 3 | CALL | `result = scCall.run(paramMap, handle)` // L1844: execute SC - viewing control order send |
| 4 | CALL | `editResultRrr(result, param)` // L1845: process SC result |
| 5 | IF | `if (JDKBPCommon.hasError(param))` // L1846: check for error |
| 6 | CALL | `throw new SCCallException("viewing control order send failure", "0", ...)` // L1847-1848: error throw |

**Block 20.1** — [SET] Store viewing control order send result (L1852)

> IT1-2017-0000118 MOD: Changed from calling `editResultSend` to directly storing the msg into tmpParamMap with key `EWC0011C010CBSMSG1LIST`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpParamMap.put("EWC0011C010CBSMSG1LIST", msg)` // L1852: store viewing control order send result list (IT1-2017-0000118 MOD) |

**Block 21** — [CALL] Step (a-8): Viewing control order result registration (L1857–L1874)

> Prepare viewing control order result registration parameters via `editOrderResultRegistMsg`, then execute the SC call. This is the final step that registers the viewing control order result.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editOrderResultRegistMsg(paramMap, inMap, tmpParamMap)` // L1858: prepare viewing control order result regist params |
| 2 | EXEC | `JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), "viewing control order result regist processing")` // L1862: debug log |
| 3 | CALL | `result = scCall.run(paramMap, handle)` // L1864: execute SC - viewing control order result regist |
| 4 | CALL | `editResultRrr(result, param)` // L1865: process SC result |
| 5 | IF | `if (JDKBPCommon.hasError(param))` // L1866: check for error |
| 6 | CALL | `throw new SCCallException("viewing control order result regist failure", "0", ...)` // L1867-1868: error throw |

**Block 21.1** — [SET] Extract final response (L1871–L1872)

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = (CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY)` // L1871: extract templates |
| 2 | SET | `msg = templates[0]` // L1872: first template |

**Block 22** — [ELSE] IT1-2017-0000118 modification: unlink unnecessary status (L1878–L1882)

> When the STB and C-CAS status combination is neither explicitly unlinkable nor explicitly error, set the "unlink unnecessary" flag and return early.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpParamMap.put("key_not_unlink_flg", keyHmpinKikiNo)` // L1880: set unlink unnecessary flag |
| 2 | RETURN | `return tmpParamMap` // L1881: return with flag |

**Block 23** — [RETURN] Normal completion (L1884)

> Final return of tmpParamMap when all processing is complete or when search lists are empty.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return tmpParamMap` // L1884: return result |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `unlink` | Method | Un-linking process — disassociating home equipment (STB/C-CAS) from a customer's service subscription when equipment is returned |
| `taknkiki_mdl_cd` | Field | Home equipment model code — identifies the type/model of the leased equipment |
| `kiki_seizo_no` | Field | Equipment manufacturing serial number — unique identifier assigned by the manufacturer to each physical device |
| `svc_kei_no` | Field | Service contract line number — identifies the specific service contract line item associated with this equipment |
| `taknkiki_sbt_cd` | Field | Home equipment subtype code — distinguishes between STB (Set-Top Box) and C-CAS (CAS Card) equipment types |
| `stb_stat_cd` | Field | STB status code — current management status of the Set-Top Box (e.g., "011" provisional registration, "012" in operation) |
| `ccas_card_stat_cd` | Field | C-CAS card status code — current management status of the CAS card (e.g., "012" link processing in progress) |
| `kyoku_cd` | Field | Bureau code — identifies the regional service bureau/office responsible for the equipment location |
| `ctrl_area_cd` | Field | Control area code — identifies the viewing control area for conditional access service management |
| `checkMap` | Parameter | Deduplication set tracking which devices have already been processed to prevent duplicate un-link operations |
| `SCControlMapKeys` | Constant class | Control map key constants for operating date, time, operator ID, hostname, IP, and screen ID |
| `JCMConstants` | Constant class | Common message constants for transaction ID, use case ID, operation ID, call type, client hostname, client IP, invoke screen ID, and template list key |
| `DKSV008101CC` | Constant | Key for retrieving return product approval user data from the request parameter map [-> "DKSV008101CC" (DKSV0081_DKSV0081OP.java:39)] |
| `CD_DIV_WATCH_KIKI_KANRI_STAT_KARITO` | Constant | Home equipment management status code "011" — provisional registration [-> "011" (JWCStrConst.java:65)] |
| `CD_DIV_WATCH_KIKI_KANRI_STAT_HONUNYO` | Constant | Home equipment management status code "012" — in operation [-> "012" (JWCStrConst.java:70)] |
| `CD_DIV_CCAS_CARD_KANRI_STAT_LINKCHU` | Constant | C-CAS card management status code "012" — link processing in progress [-> "012" (JWCStrConst.java:116)] |
| `key_unlink_unyo_hmpin_kiki_no` | Field | Error flag key — indicates STB unlink impossible condition; value contains the home equipment number |
| `key_unlink_link_hmpin_kiki_no` | Field | Error flag key — indicates C-CAS unlink impossible condition; value contains the home equipment number |
| `key_not_unlink_flg` | Field | Unlink unnecessary status flag — set when equipment status does not match any known unlinkable pattern |
| `key_hmpin_kiki_no` | Field | Home equipment number — internal identifier for the home equipment being processed |
| STB | Equipment | Set-Top Box — decoder equipment that receives and processes television signals for the customer |
| C-CAS | Equipment | Conditional Access System Card — smart card managing subscription access and viewing control for the STB |
| SC | Technical | Service Component — enterprise service layer component that handles business operations |
| CBS | Technical | Common Business Service — backend service component invoked by SCs for data operations |
| SC Call | Pattern | Service Component invocation pattern: `scCall.run(paramMap, handle)` executes remote SC processing |
| CAANMsg | Technical | Message container class used for SC input/output parameter passing |
| EWM0411A010CBS | SC Code | Home equipment type agreement SC — retrieves home equipment type information |
| EWCA0010001CBS | SC Code | Home equipment list agreement (3) SC — retrieves STB and C-CAS device status codes |
| EWC0151B010CBS | SC Code | Bureau list agreement SC — retrieves bureau code for the equipment location |
| EWC0101B010CBS | SC Code | Control area list agreement SC — retrieves control area code based on bureau code |
| EWC0011C010CBS | SC Code | Viewing control order reception/send/result SC — handles viewing control order lifecycle |
| DKSV0081 | Screen/BPM | Return Product Approval — BPM workflow for processing customer equipment returns and approvals |
| HMPIN_KIKI_STAT_SHONIN | Constant | Equipment update status "return product approval" — indicates the equipment return has been approved |
| TEMZAKION | Japanese term | Un-linking (アンリンク) — the process of disassociating leased equipment from a customer's service contract |
| TAKANKIKI | Japanese term | Home equipment (宅内機器) — customer-premises leased equipment such as STB and C-CAS cards |
| KIKI_SEIZO_NO | Japanese term | Equipment manufacturing number (機器製造番号) — serial number assigned by the equipment manufacturer |
| SYOKI_TEINYU_SYAKYAKU | Japanese term | Equipment provision service contract — the lease agreement between the operator and customer for home equipment |
| SHIKOMI_CHO | Japanese term | System provision — system-level service provisioning operations |
| UNYO_KBN | Japanese term | Operation type classification — used to determine the type of SC invocation |
| KYOKU_CD | Japanese term | Bureau code (局コード) — regional office identifier in the service management hierarchy |
| CTRL_AREA_CD | Japanese term | Control area code — geographic or logical area for viewing control operations |
