# (DD34) Business Logic — JDKCommon08CC.editOrderUktkMsg() [224 LOC]

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

## 1. Role

### JDKCommon08CC.editOrderUktkMsg()

This method assembles a **Watching Control (Viewing Restriction) Order Reception** message (視聴制御オーダ受付) for a cable/broadband set-top box (STB) service. It is a message-building utility that prepares a `CAANMsg` template (`EWC0011D010CBSMsg`) with all the fields required to register or cancel a watching-control order — specifically, the temporary registration (アンリンク, unlink) and its cancellation via STB direct control (STB直接制御).

The method implements the **Builder pattern**: it creates a new message template, populates a series of fields from three input maps (`paramMap`, `inMap`, `tmpParamMap`), and injects STB device identifiers from a pre-fetched message list (`EWCA0010001CBSMsg1List`). It then packages the completed message into a `CAANMsg[]` array and stores it in `paramMap` under `JCMConstants.TEMPLATE_LIST_KEY` so that the caller can invoke the corresponding CBS (EWC0011D010) via `ServiceComponentRequestInvoker`.

In the larger system, this method is a shared component used within the `unlink()` business flow (ANK-3080-00-00), which handles STB/C-CAS unlink processing — i.e., removing a set-top box from a customer's service contract. The method's role is to translate gathered STB device data into a format the watching-control order reception CBS can consume.

The method has two conditional branches: (1) the `inMap != null` block, which enriches the template with operational metadata (date, operator, control codes), and (2) a series of STB-field null-check blocks that copy device data from the message list or null out fields when data is missing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editOrderUktkMsg(paramMap, inMap, tmpParamMap)"])

    START --> INIT_MSG["Initialize CAANMsg<br/>EWC0011D010CBSMsg"]
    INIT_MSG --> SET_TEMPLATE["Set TEMPLATEID = EWC0011D010"]
    SET_TEMPLATE --> CHECK_INMAP{inMap != null?}

    CHECK_INMAP -->|No| SKIP_INIT["Skip init block<br/>param defaults remain null"]
    CHECK_INMAP -->|Yes| SET_FUNC_CODE["Set FUNC_CODE = 1<br/>Function Code default"]

    SET_FUNC_CODE --> SET_OPERATE_DATE["Set OPERATEDATE<br/>tmpParamMap[operate_date_key]"]
    SET_OPERATE_DATE --> SET_OPERATE_TIME["Set OPERATEDATETIME<br/>tmpParamMap[operate_datetime_key]"]
    SET_OPERATE_TIME --> SET_OPERATOR_ID["Set OPERATORID<br/>tmpParamMap[operator_id]"]
    SET_OPERATOR_ID --> SET_WCTRL_STAT["Set WCTRL_ORDER_STAT = 000<br/>Normal"]
    SET_WCTRL_STAT --> SET_WCTRL_CD["Set WCTRL_ORDER_CD = 02<br/>CD_DIV_WCTRL_ORDER_UNSET TempRegCancel"]
    SET_WCTRL_CD --> SET_WCTRL_REQ["Set WCTRL_REQ_TRN_CD = 88<br/>CD_DIV_WCTRL_REQ_TRN_CD_STBCTRL_UNSET STB Direct Ctrl Cancel"]
    SET_WCTRL_REQ --> SET_SYSID_NULL["SetNull SYSID"]
    SET_SYSID_NULL --> SET_SVC_KEI_NULL["SetNull SVC_KEI_UCWK_NO"]
    SET_SVC_KEI_NULL --> SET_CTRL_TYPE["Set CTRL_TYPE_CD = 0<br/>Real"]
    SET_CTRL_TYPE --> SET_CTRL_MODE["Set CTRL_MODE_CD = 1"]
    SET_CTRL_MODE --> SET_CHRG_NULL["SetNull CHRG_FLG"]
    SET_CHRG_NULL --> SET_STB7_NULL["SetNull STB_GRP_ID_7"]
    SET_STB7_NULL --> SET_RST_NULL["SetNull RE_SETTE_FLG"]
    SET_RST_NULL --> SET_RUN_NULL["SetNull RUN_RSLT_CD"]
    SET_RUN_NULL --> SET_CMD_FLG["Set CTRL_CMD_HAKKO_ZUMI_FLG = 1<br/>Not Issued"]
    SET_CMD_FLG --> SET_RSLT_FLG["Set RSLT_RCV_FLG = 1<br/>Not Received"]
    SET_RSLT_FLG --> SET_DLYD_FLG["Set DLYD_FLG = 1<br/>CD_DIV_DLYD_FLG_TAISYOGAI NotDelivered"]
    SET_DLYD_FLG --> SET_CCAS_NULL["SetNull CCAS_SHKKA_CMD_HAK_FLG"]
    SET_CCAS_NULL --> SET_ORDER_DTM["Set ORDER_UK_DTM<br/>getSysDateTimeStamp()"]
    SET_ORDER_DTM --> SKIP_INIT

    SKIP_INIT --> CHECK_KYOKU{kyoku_cd<br/>empty or null?}
    CHECK_KYOKU -->|Yes| SET_KYOKU_NULL["SetNull KYOKU_CD"]
    CHECK_KYOKU -->|No| SET_KYOKU["Set KYOKU_CD<br/>tmpParamMap[kyoku_cd]"]

    SET_KYOKU_NULL --> CHECK_CTRL_AREA{ctrl_area_cd<br/>empty or null?}
    SET_KYOKU --> CHECK_CTRL_AREA
    CHECK_CTRL_AREA -->|Yes| SET_CTRL_AREA_NULL["SetNull CTRL_AREA_CD"]
    CHECK_CTRL_AREA -->|No| SET_CTRL_AREA["Set CTRL_AREA_CD<br/>tmpParamMap[ctrl_area_cd]"]

    SET_CTRL_AREA_NULL --> GET_MSG_LIST["Get EWCA0010001CBSMSG1LIST<br/>from tmpParamMap"]
    SET_CTRL_AREA --> GET_MSG_LIST

    GET_MSG_LIST --> CHECK_STB_MDL{STB_TK_MDL_CD<br/>empty?}
    CHECK_STB_MDL -->|Yes| STB_MDL_NULL["SetNull STB_TAKNKIKI_MODEL_CD"]
    CHECK_STB_MDL -->|No| STB_MDL_VAL["Set STB_TAKNKIKI_MODEL_CD<br/>from msgList"]

    STB_MDL_NULL --> CHECK_STB_SEIZO{STB_KK_SEIZO_NO<br/>empty?}
    STB_MDL_VAL --> CHECK_STB_SEIZO
    CHECK_STB_SEIZO -->|Yes| STB_SEIZO_NULL["SetNull STB_KIKI_SEIZO_NO"]
    CHECK_STB_SEIZO -->|No| STB_SEIZO_VAL["Set STB_KIKI_SEIZO_NO<br/>from msgList"]

    STB_SEIZO_NULL --> CHECK_CTL_MDL{STB_MAKER_KOYU_CTL_MDL_CD<br/>empty?}
    STB_SEIZO_VAL --> CHECK_CTL_MDL
    CHECK_CTL_MDL -->|Yes| CTL_MDL_NULL["SetNull STB_CTRL_MODEL_CD"]
    CHECK_CTL_MDL -->|No| CTL_MDL_VAL["Set STB_CTRL_MODEL_CD<br/>from msgList"]

    CTL_MDL_NULL --> CHECK_STB_ID{STBID<br/>empty?}
    CTL_MDL_VAL --> CHECK_STB_ID
    CHECK_STB_ID -->|Yes| STB_ID_NULL["SetNull STB_ID"]
    CHECK_STB_ID -->|No| STB_ID_VAL["Set STB_ID<br/>from msgList"]

    STB_ID_NULL --> CHECK_CAS_FLG{STB_NAIZOCAS_CD<br/>empty?}
    STB_ID_VAL --> CHECK_CAS_FLG
    CHECK_CAS_FLG -->|Yes| CAS_FLG_NULL["SetNull STB_CAS_NAIZO_FLG"]
    CHECK_CAS_FLG -->|No| CAS_FLG_VAL["Set STB_CAS_NAIZO_FLG<br/>from msgList"]

    CAS_FLG_NULL --> CHECK_CCAS_CARD{CCAS_KK_SEIZO_NO<br/>empty?}
    CAS_FLG_VAL --> CHECK_CCAS_CARD
    CHECK_CCAS_CARD -->|Yes| CCAS_CARD_NULL["SetNull CCAS_CARD_NO"]
    CHECK_CCAS_CARD -->|No| CCAS_CARD_VAL["Set CCAS_CARD_NO<br/>from msgList"]

    CCAS_CARD_NULL --> CHECK_BCAS_CARD{BCAS_KK_SEIZO_NO<br/>empty?}
    CCAS_CARD_VAL --> CHECK_BCAS_CARD
    CHECK_BCAS_CARD -->|Yes| BCAS_CARD_NULL["SetNull BCAS_CARD_NO"]
    CHECK_BCAS_CARD -->|No| BCAS_CARD_VAL["Set BCAS_CARD_NO<br/>from msgList"]

    BCAS_CARD_NULL --> CHECK_GRP1{STB_MATSU_YO_GRPID1<br/>empty?}
    BCAS_CARD_VAL --> CHECK_GRP1
    CHECK_GRP1 -->|Yes| GRP1_NULL["SetNull STB_GRP_ID_1"]
    CHECK_GRP1 -->|No| GRP1_VAL["Set STB_GRP_ID_1<br/>from msgList"]

    GRP1_NULL --> CHECK_GRP2{STB_MATSU_YO_GRPID2<br/>empty?}
    GRP1_VAL --> CHECK_GRP2
    CHECK_GRP2 -->|Yes| GRP2_NULL["SetNull STB_GRP_ID_2"]
    CHECK_GRP2 -->|No| GRP2_VAL["Set STB_GRP_ID_2<br/>from msgList"]

    GRP2_NULL --> CHECK_GRP3{STB_MATSU_YO_GRPID3<br/>empty?}
    GRP2_VAL --> CHECK_GRP3
    CHECK_GRP3 -->|Yes| GRP3_NULL["SetNull STB_GRP_ID_3"]
    CHECK_GRP3 -->|No| GRP3_VAL["Set STB_GRP_ID_3<br/>from msgList"]

    GRP3_NULL --> CHECK_GRP4{STB_MATSU_YO_GRPID4<br/>empty?}
    GRP3_VAL --> CHECK_GRP4
    CHECK_GRP4 -->|Yes| GRP4_NULL["SetNull STB_GRP_ID_4"]
    CHECK_GRP4 -->|No| GRP4_VAL["Set STB_GRP_ID_4<br/>from msgList"]

    GRP4_NULL --> CHECK_GRP5{STB_MATSU_YO_GRPID5<br/>empty?}
    GRP4_VAL --> CHECK_GRP5
    CHECK_GRP5 -->|Yes| GRP5_NULL["SetNull STB_GRP_ID_5"]
    CHECK_GRP5 -->|No| GRP5_VAL["Set STB_GRP_ID_5<br/>from msgList"]

    GRP5_NULL --> CHECK_GRP6{STB_MATSU_YO_GRPID6<br/>empty?}
    GRP5_VAL --> CHECK_GRP6
    CHECK_GRP6 -->|Yes| GRP6_NULL["SetNull STB_GRP_ID_6"]
    CHECK_GRP6 -->|No| GRP6_VAL["Set STB_GRP_ID_6<br/>from msgList"]

    GRP6_NULL --> WRAP_TEMPLATES["Create CAANMsg array<br/>templates[0] = template"]
    GRP6_VAL --> WRAP_TEMPLATES

    WRAP_TEMPLATES --> SET_TEMPLATE_LIST["Set paramMap[TEMPLATE_LIST_KEY] = templates"]
    SET_TEMPLATE_LIST --> RETURN["Return paramMap"]
    RETURN --> END(["END"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `paramMap` | `HashMap<String, Object>` | Output parameter map that holds the assembled `CAANMsg[]` array under the key `JCMConstants.TEMPLATE_LIST_KEY`. Also carries transaction-level metadata (transaction ID, use case ID, operation ID, call type, client host/IP, invoke screen ID) set by the caller in `unlink()`. |
| 2 | `inMap` | `HashMap` | Functional presence flag. If non-null, the method populates the template with operational metadata (function code, operation date/time, operator ID, and all watching-control-specific fields). If null, the template fields default to null/empty values. |
| 3 | `tmpParamMap` | `HashMap<String, Object>` | Intermediate parameter map carrying operational data (operate_date_key, operate_datetime_key, operator_id), branch/area codes (kyoku_cd, ctrl_area_cd), and the STB device message list (`EWCA0010001CBSMSG1LIST`) fetched from a prior SC call. |

**Instance fields / external state read:**

| Field/External | Source | Business Meaning |
|---------------|--------|-----------------|
| `JCCBPCommon.getSysDateTimeStamp()` | Utility call | System date-time stamp used as the order receipt timestamp |
| `JWCStrConst.CD_DIV_WCTRL_ORDER_UNSET` = `"02"` | `JWCStrConst.java:441` | Watching-control order code: Temp Registration / Cancel |
| `JWCStrConst.CD_DIV_WCTRL_REQ_TRN_CD_STBCTRL_UNSET` = `"88"` | `JWCStrConst.java:296` | Watching-control request code: STB Direct Control, Registration Removal (Cancel) |
| `JWCStrConst.CD_DIV_DLYD_FLG_TAISYOGAI` = `"1"` | `JWCStrConst.java:656` | Delivery flag: Not a Delivery-Target |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCBPCommon.getSysDateTimeStamp` | JCCBPCommon | - | Calls `getSysDateTimeStamp` to obtain the system date-time stamp for ORDER_UK_DTM |

**Additional method calls found in source:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `CAANMsg.set(EWC0011D010CBSMsg.TEMPLATEID, ...)` | EWC0011D010CBS | - | Sets the template ID on the CAANMsg instance (field population) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.FUNC_CODE, ...)` | EWC0011D010CBS | - | Sets the function code to "1" (default) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.OPERATEDATE, ...)` | EWC0011D010CBS | - | Sets the operation date from tmpParamMap |
| R | `CAANMsg.set(EWC0011D010CBSMsg.OPERATEDATETIME, ...)` | EWC0011D010CBS | - | Sets the operation date-time from tmpParamMap |
| R | `CAANMsg.set(EWC0011D010CBSMsg.OPERATORID, ...)` | EWC0011D010CBS | - | Sets the operator ID from tmpParamMap |
| R | `CAANMsg.set(EWC0011D010CBSMsg.WCTRL_ORDER_STAT, "000")` | EWC0011D010CBS | - | Sets watching-control order status to "000" (Normal) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.WCTRL_ORDER_CD, "02")` | EWC0011D010CBS | - | Sets watching-control order code to "02" (Temp Registration / Cancel) [-> CD_DIV_WCTRL_ORDER_UNSET="02" (JWCStrConst.java:441)] |
| R | `CAANMsg.set(EWC0011D010CBSMsg.WCTRL_REQ_TRN_CD, "88")` | EWC0011D010CBS | - | Sets watching-control request code to "88" (STB Direct Control: Registration Removal) [-> CD_DIV_WCTRL_REQ_TRN_CD_STBCTRL_UNSET="88" (JWCStrConst.java:296)] |
| R | `CAANMsg.setNull(EWC0011D010CBSMsg.SYSID)` | EWC0011D010CBS | - | Clears the SYSID field (null) |
| R | `CAANMsg.setNull(EWC0011D010CBSMsg.SVC_KEI_UCWK_NO)` | EWC0011D010CBS | - | Clears the service detail work number |
| R | `CAANMsg.set(EWC0011D010CBSMsg.CTRL_TYPE_CD, "0")` | EWC0011D010CBS | - | Sets control type code to "0" (Real type) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.CTRL_MODE_CD, "1")` | EWC0011D010CBS | - | Sets control mode code to "1" |
| R | `CAANMsg.setNull(EWC0011D010CBSMsg.CHRG_FLG)` | EWC0011D010CBS | - | Clears the charge flag (null) |
| R | `CAANMsg.setNull(EWC0011D010CBSMsg.STB_GRP_ID_7)` | EWC0011D010CBS | - | Clears STB Group ID 7 (null) |
| R | `CAANMsg.setNull(EWC0011D010CBSMsg.RE_SETTE_FLG)` | EWC0011D010CBS | - | Clears the re-set flag (null) |
| R | `CAANMsg.setNull(EWC0011D010CBSMsg.RUN_RSLT_CD)` | EWC0011D010CBS | - | Clears the execution result code (null) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.CTRL_CMD_HAKKO_ZUMI_FLG, "1")` | EWC0011D010CBS | - | Sets control command issuance flag to "1" (Not Issued) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.RSLT_RCV_FLG, "1")` | EWC0011D010CBS | - | Sets control result receipt flag to "1" (Not Received) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.DLYD_FLG, "1")` | EWC0011D010CBS | - | Sets delivery flag to "1" (Not Delivered-Target) [-> CD_DIV_DLYD_FLG_TAISYOGAI="1" (JWCStrConst.java:656)] |
| R | `CAANMsg.setNull(EWC0011D010CBSMsg.CCAS_SHKKA_CMD_HAK_FLG)` | EWC0011D010CBS | - | Clears C-CAS initial command issuance flag (null) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.ORDER_UK_DTM, ...)` | EWC0011D010CBS | - | Sets order receipt date-time via `JCCBPCommon.getSysDateTimeStamp()` |
| R | `CAANMsg.set(EWC0011D010CBSMsg.KYOKU_CD, ...)` | EWC0011D010CBS | - | Sets branch office code from tmpParamMap (or null if absent) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.CTRL_AREA_CD, ...)` | EWC0011D010CBS | - | Sets control area code from tmpParamMap (or null if absent) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.STB_TAKNKIKI_MODEL_CD, ...)` | EWC0011D010CBS | - | Sets STB home equipment model code from msgList (or null if absent) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.STB_KIKI_SEIZO_NO, ...)` | EWC0011D010CBS | - | Sets STB equipment serial number from msgList (or null if absent) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.STB_CTRL_MODEL_CD, ...)` | EWC0011D010CBS | - | Sets STB control-special model code from msgList (or null if absent) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.STB_ID, ...)` | EWC0011D010CBS | - | Sets STB ID from msgList (or null if absent) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.STB_CAS_NAIZO_FLG, ...)` | EWC0011D010CBS | - | Sets STB built-in CAS flag from msgList (or null if absent) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.CCAS_CARD_NO, ...)` | EWC0011D010CBS | - | Sets C-CAS card number from msgList (or null if absent) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.BCAS_CARD_NO, ...)` | EWC0011D010CBS | - | Sets B-CAS card number from msgList (or null if absent) |
| R | `CAANMsg.set(EWC0011D010CBSMsg.STB_GRP_ID_1..6, ...)` | EWC0011D010CBS | - | Sets STB Group IDs 1-6 from msgList (or null if absent) |
| R | `HashMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` | JCMConstants | - | Stores the CAANMsg array into the paramMap for the caller to invoke the CBS |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC:JDKCommon08CC.unlink | `JDKCommon08CC.unlink` (a-6) -> `JDKCommon08CC.editOrderUktkMsg` | `getSysDateTimeStamp [R]`, `CAANMsg.set [R]`, `CAANMsg.setNull [R]`, `HashMap.put [R]` |

**Caller details:**
- The method is called once within `JDKCommon08CC.unlink()` at line ~1823.
- The `unlink()` method (comment: アンリンク処理を行う "Perform unlink processing") is part of ANK-3080-00-00, handling the un-linking of STB/C-CAS equipment from a service contract.
- Within the `unlink()` flow, after gathering branch info, control area info, and STB device info via prior SC calls, `editOrderUktkMsg` is invoked to prepare the watching-control order reception message, which is then sent to the CBS via `scCall.run(paramMap, handle)`.

## 6. Per-Branch Detail Blocks

### Block 1 — INITIALIZATION (L2641)

> Initialize the CAANMsg template for the Watching Control Order Reception CBS (EWC0011D010CBS)

| # | Type | Code |
|---|------|------|
| 1 | SET | `template = new CAANMsg(EWC0011D010CBSMsg.class.getName())` |
| 2 | SET | `template.set(EWC0011D010CBSMsg.TEMPLATEID, "EWC0011D010")` // Template ID |

### Block 2 — [IF] Operational Metadata Block `(inMap != null)` (L2651)

> When `inMap` is non-null, the template is enriched with operational metadata (function code, date/time, operator, watching-control specific codes). This block configures the message for a real (live) watching-control order with STB direct control cancel semantics.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EWC0011D010CBSMsg.FUNC_CODE, "1")` // Function Code (default: 1) |
| 2 | SET | `template.set(EWC0011D010CBSMsg.OPERATEDATE, tmpParamMap.get("operate_date_key"))` // Operation Date |
| 3 | SET | `template.set(EWC0011D010CBSMsg.OPERATEDATETIME, tmpParamMap.get("operate_datetime_key"))` // Operation Date-Time |
| 4 | SET | `template.set(EWC0011D010CBSMsg.OPERATORID, tmpParamMap.get("operator_id"))` // Operator ID |
| 5 | SET | `template.set(EWC0011D010CBSMsg.WCTRL_ORDER_STAT, "000")` // Watching Control Order Status: Normal |
| 6 | SET | `template.set(EWC0011D010CBSMsg.WCTRL_ORDER_CD, JWCStrConst.CD_DIV_WCTRL_ORDER_UNSET)` // Watching Control Order Code: Temp Registration / Cancel [-> CD_DIV_WCTRL_ORDER_UNSET="02" (JWCStrConst.java:441)] |
| 7 | SET | `template.set(EWC0011D010CBSMsg.WCTRL_REQ_TRN_CD, JWCStrConst.CD_DIV_WCTRL_REQ_TRN_CD_STBCTRL_UNSET)` // Watching Control Request Code: STB Direct Control Registration Removal [-> CD_DIV_WCTRL_REQ_TRN_CD_STBCTRL_UNSET="88" (JWCStrConst.java:296)] |
| 8 | SET | `template.setNull(EWC0011D010CBSMsg.SYSID)` // SYSID (null) |
| 9 | SET | `template.setNull(EWC0011D010CBSMsg.SVC_KEI_UCWK_NO)` // Service Contract Detail Number (null) |
| 10 | SET | `template.set(EWC0011D010CBSMsg.CTRL_TYPE_CD, "0")` // Control Type Code: Real |
| 11 | SET | `template.set(EWC0011D010CBSMsg.CTRL_MODE_CD, "1")` // Control Mode Code: 1 |
| 12 | SET | `template.setNull(EWC0011D010CBSMsg.CHRG_FLG)` // Charge Flag (null) |
| 13 | SET | `template.setNull(EWC0011D010CBSMsg.STB_GRP_ID_7)` // STB Group ID 7 (null) |
| 14 | SET | `template.setNull(EWC0011D010CBSMsg.RE_SETTE_FLG)` // Re-set Flag (null) |
| 15 | SET | `template.setNull(EWC0011D010CBSMsg.RUN_RSLT_CD)` // Execution Result Code (null) |
| 16 | SET | `template.set(EWC0011D010CBSMsg.CTRL_CMD_HAKKO_ZUMI_FLG, "1")` // Control Command Issuance Flag: Not Issued |
| 17 | SET | `template.set(EWC0011D010CBSMsg.RSLT_RCV_FLG, "1")` // Control Result Receipt Flag: Not Received |
| 18 | SET | `template.set(EWC0011D010CBSMsg.DLYD_FLG, JWCStrConst.CD_DIV_DLYD_FLG_TAISYOGAI)` // Delivery Flag: Not Delivered-Target [-> CD_DIV_DLYD_FLG_TAISYOGAI="1" (JWCStrConst.java:656)] |
| 19 | SET | `template.setNull(EWC0011D010CBSMsg.CCAS_SHKKA_CMD_HAK_FLG)` // C-CAS Initial Command Issuance Flag (null) |
| 20 | SET | `template.set(EWC0011D010CBSMsg.ORDER_UK_DTM, JCCBPCommon.getSysDateTimeStamp())` // Order Receipt Date-Time (current system time) |

### Block 3 — [IF/ELSE] Branch Office Code `(kyoku_cd null or empty)` (L2699)

> Set the branch office code (局コード) from tmpParamMap if present; otherwise null it out. A commented-out block (OM-2017-0001015 DEL) previously handled the service contract number but was removed.

| # | Type | Code |
|---|------|------|
| 1 | IF | `tmpParamMap.get("kyoku_cd") == null || "".equals(tmpParamMap.get("kyoku_cd"))` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.KYOKU_CD)` // Branch Office Code (null) |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.KYOKU_CD, tmpParamMap.get("kyoku_cd"))` // Branch Office Code from tmpParamMap |

### Block 4 — [IF/ELSE] Control Area Code `(ctrl_area_cd null or empty)` (L2708)

> Set the control area code from tmpParamMap if present; otherwise null it out.

| # | Type | Code |
|---|------|------|
| 1 | IF | `tmpParamMap.get("ctrl_area_cd") == null || "".equals(tmpParamMap.get("ctrl_area_cd"))` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.CTRL_AREA_CD)` // Control Area Code (null) |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.CTRL_AREA_CD, tmpParamMap.get("ctrl_area_cd"))` // Control Area Code from tmpParamMap |

### Block 5 — MESSAGE LIST RETRIEVAL (L2715)

> Retrieve the STB device message list from tmpParamMap. This list was populated by a prior SC call (`EWCA0010001` — STB device master inquiry) in the calling `unlink()` method.

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgList = (CAANMsg)tmpParamMap.get("EWCA0010001CBSMSG1LIST")` |

### Block 6 — [IF/ELSE] STB Home Equipment Model Code `(STB_TK_MDL_CD empty)` (L2718)

> Copy STB home equipment model code from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STB_TK_MDL_CD) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_TAKNKIKI_MODEL_CD)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_TAKNKIKI_MODEL_CD, msgList.getString(EWCA0010001CBSMsg1List.STB_TK_MDL_CD))` |

### Block 7 — [IF/ELSE] STB Equipment Serial Number `(STB_KK_SEIZO_NO empty)` (L2727)

> Copy STB equipment serial number from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STB_KK_SEIZO_NO) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_KIKI_SEIZO_NO)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_KIKI_SEIZO_NO, msgList.getString(EWCA0010001CBSMsg1List.STB_KK_SEIZO_NO))` |

### Block 8 — [IF/ELSE] STB Control Special Model Code `(STB_MAKER_KOYU_CTL_MDL_CD empty)` (L2736)

> Copy STB control special model code from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STB_MAKER_KOYU_CTL_MDL_CD) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_CTRL_MODEL_CD)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_CTRL_MODEL_CD, msgList.getString(EWCA0010001CBSMsg1List.STB_MAKER_KOYU_CTL_MDL_CD))` |

### Block 9 — [IF/ELSE] STB ID `(STBID empty)` (L2745)

> Copy STB ID from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STBID) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_ID)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_ID, msgList.getString(EWCA0010001CBSMsg1List.STBID))` |

### Block 10 — [IF/ELSE] STB Built-in CAS Flag `(STB_NAIZOCAS_CD empty)` (L2754)

> Copy the STB built-in CAS flag from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STB_NAIZOCAS_CD) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_CAS_NAIZO_FLG)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_CAS_NAIZO_FLG, msgList.getString(EWCA0010001CBSMsg1List.STB_NAIZOCAS_CD))` |

### Block 11 — [IF/ELSE] C-CAS Card Number `(CCAS_KK_SEIZO_NO empty)` (L2763)

> Copy C-CAS card number from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.CCAS_KK_SEIZO_NO) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.CCAS_CARD_NO)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.CCAS_CARD_NO, msgList.getString(EWCA0010001CBSMsg1List.CCAS_KK_SEIZO_NO))` |

### Block 12 — [IF/ELSE] B-CAS Card Number `(BCAS_KK_SEIZO_NO empty)` (L2772)

> Copy B-CAS card number from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.BCAS_KK_SEIZO_NO) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.BCAS_CARD_NO)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.BCAS_CARD_NO, msgList.getString(EWCA0010001CBSMsg1List.BCAS_KK_SEIZO_NO))` |

### Block 13 — [IF/ELSE] STB Group ID 1 `(STB_MATSU_YO_GRPID1 empty)` (L2781)

> Copy STB Group ID 1 from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID1) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_GRP_ID_1)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_GRP_ID_1, msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID1))` |

### Block 14 — [IF/ELSE] STB Group ID 2 `(STB_MATSU_YO_GRPID2 empty)` (L2790)

> Copy STB Group ID 2 from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID2) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_GRP_ID_2)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_GRP_ID_2, msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID2))` |

### Block 15 — [IF/ELSE] STB Group ID 3 `(STB_MATSU_YO_GRPID3 empty)` (L2799)

> Copy STB Group ID 3 from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID3) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_GRP_ID_3)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_GRP_ID_3, msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID3))` |

### Block 16 — [IF/ELSE] STB Group ID 4 `(STB_MATSU_YO_GRPID4 empty)` (L2808)

> Copy STB Group ID 4 from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID4) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_GRP_ID_4)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_GRP_ID_4, msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID4))` |

### Block 17 — [IF/ELSE] STB Group ID 5 `(STB_MATSU_YO_GRPID5 empty)` (L2817)

> Copy STB Group ID 5 from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID5) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_GRP_ID_5)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_GRP_ID_5, msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID5))` |

### Block 18 — [IF/ELSE] STB Group ID 6 `(STB_MATSU_YO_GRPID6 empty)` (L2826)

> Copy STB Group ID 6 from the message list, or null out if absent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID6) == null || "".equals(...)` |
| 2 | SET | `template.setNull(EWC0011D010CBSMsg.STB_GRP_ID_6)` |
| 3 | ELSE | — |
| 4 | SET | `template.set(EWC0011D010CBSMsg.STB_GRP_ID_6, msgList.getString(EWCA0010001CBSMsg1List.STB_MATSU_YO_GRPID6))` |

### Block 19 — TEMPLATE PACKAGING (L2833)

> Wrap the single template into a `CAANMsg[]` array and store it in paramMap under the template list key. This is the final step — the array is consumed by the caller's `scCall.run(paramMap, handle)` to invoke the CBS.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = new CAANMsg[1]` |
| 2 | SET | `templates[0] = template` |
| 3 | SET | `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` |
| 4 | RETURN | `return paramMap` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `EWC0011D010CBSMsg` | CBS Class | Watching Control Order Reception CBS message class — handles order registration/cancellation for watching-control services |
| `WCTRL_ORDER_STAT` | Field | Watching Control Order Status — "000" means Normal (active); controls whether the watching restriction is enabled |
| `WCTRL_ORDER_CD` | Field | Watching Control Order Code — classifies the type of watching control action; "02" means Temp Registration / Cancel (アンリンク) [-> CD_DIV_WCTRL_ORDER_UNSET="02" (JWCStrConst.java:441)] |
| `WCTRL_REQ_TRN_CD` | Field | Watching Control Request/Processing Code — "88" means STB Direct Control, Registration Removal (登録解除: アンリンク) [-> CD_DIV_WCTRL_REQ_TRN_CD_STBCTRL_UNSET="88" (JWCStrConst.java:296)] |
| `STB` | Acronym | Set-Top Box — the subscriber's cable/broadband decoder box in the home |
| `C-CAS` | Acronym | Conditional Access System Card (built-in) — smart card embedded in the STB for content decryption |
| `B-CAS` | Acronym | Broadband CAS — a standard Japanese digital broadcast content protection smart card |
| `STB_TK_MDL_CD` | Field | STB Home Equipment Model Code — identifies the STB model type |
| `STB_KK_SEIZO_NO` | Field | STB Equipment Serial Number (KK = 内蔵, built-in) — unique hardware serial of the STB |
| `STB_MAKER_KOYU_CTL_MDL_CD` | Field | STB Maker-Private Control Model Code — manufacturer-specific model code used for STB control commands |
| `STB_NAIZOCAS_CD` | Field | STB Built-in CAS Flag — indicates whether the STB has a built-in CAS card |
| `CCAS_CARD_NO` | Field | C-CAS Card Number — serial number of the C-CAS card |
| `BCAS_CARD_NO` | Field | B-CAS Card Number — serial number of the B-CAS card |
| `STB_GRP_ID_1` through `STB_GRP_ID_6` | Field | STB Group IDs 1-6 — grouping identifiers for STB management (MATSU_YO = 待機用, standby grouping) |
| `STB_TAKNKIKI_MODEL_CD` | Field | STB Home Equipment Model Code — target field in the output template |
| `STB_KIKI_SEIZO_NO` | Field | STB Equipment Serial Number — target field in the output template |
| `STB_CTRL_MODEL_CD` | Field | STB Control Special Model Code — target field in the output template |
| `STB_ID` | Field | STB Identifier — unique STB ID in the system |
| `STB_CAS_NAIZO_FLG` | Field | STB Built-in CAS Flag — target field in the output template |
| `KYOKU_CD` | Field | Branch Office Code (局コード) — identifies the branch office responsible for the service |
| `CTRL_AREA_CD` | Field | Control Area Code — geographic or logical area for control operations |
| `DLYD_FLG` | Field | Delivery Flag — "1" means Not Delivered-Target (配信対象外); indicates the order is not for delivery to a specific terminal |
| `CTRL_CMD_HAKKO_ZUMI_FLG` | Field | Control Command Issuance Flag — "1" means Not Yet Issued (未発行) |
| `RSLT_RCV_FLG` | Field | Control Result Receipt Flag — "1" means Not Yet Received (未受信) |
| `UNLINK` | Business term | アンリンク — removing an STB or C-CAS from a service contract; the watching control order is set to cancel/unset mode |
| `VIEWING CONTROL` | Business term | 視聴制御 — watching/restriction control for cable TV or broadband content (e.g., blocking or enabling channels) |
| `ORDRE_UK` | Business term | オーダ受付 — Order Reception; the service that registers watching-control orders in the system |
| `CAANMsg` | Class | Common Application AN message wrapper — Fujitsu's internal message container for CBS request/response exchange |
| `EWC0011D010` | CBS ID | Watching Control Order Reception CBS — the back-end service component that processes watching-control order registration/cancellation |
| `EWCA0010001` | CBS ID | STB Device Master Inquiry CBS — the back-end service component that returns STB device information |
| `FUNC_CODE` | Field | Function Code — "1" is the default function code for this CBS |
| `ORDER_UK_DTM` | Field | Order Receipt Date-Time — timestamp when the order was received, set to current system time |
| `TEMPLATE_LIST_KEY` | Constant | Key used to store the CAANMsg array in paramMap for CBS invocation |
| `OPERATEDATE` | Field | Operation Date — the date of the operation |
| `OPERATEDATETIME` | Field | Operation Date-Time — the date and time of the operation |
| `OPERATORID` | Field | Operator ID — the ID of the user performing the operation |
| `SVC_KEI_UCWK_NO` | Field | Service Detail Work Number — internal tracking ID for service contract line items (null in this method) |
| `SYSID` | Field | System ID — system identifier (null in this method) |
| `CHRG_FLG` | Field | Charge Flag — billing/charge indicator (null in this method) |
| `RE_SETTE_FLG` | Field | Re-set Flag — indicates if a re-configuration is needed (null in this method) |
| `RUN_RSLT_CD` | Field | Execution Result Code — result code from a previous execution (null in this method) |
| `CCAS_SHKKA_CMD_HAK_FLG` | Field | C-CAS Initial Command Issuance Flag — indicates if a C-CAS initialization command has been issued (null in this method) |
| `STB_GRP_ID_7` | Field | STB Group ID 7 — reserved group identifier (null in this method) |
