# Business Logic — JKKShkaFinJiKikiStaAddCC.callSod50() [397 LOC]

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

## 1. Role

### JKKShkaFinJiKikiStaAddCC.callSod50()

This method performs **SOD (Service Order Data) issuance for VA (Virtual Appliance) equipment** during the equipment launch-completion start registration process. It is the VA-specific SOD issuance handler within the broader equipment-launch-completion workflow. When the equipment provider's service contract is identified as a telephone service (`svcCd = "02"`), the method executes a multi-stage inquiry and registration sequence: it first confirms the service contract details via EKK0081A010CBS, then queries service contract line items via EKK0191B001CBS, checks for coexisting VA devices via EKK0341B002CBS, and finally registers the SOD via `addVaSodInfo`. The method supports two fee-course types (A31: No. 1 Course, A32: No. 2 Course) and two update operation types (47 and 48), applying different business rules depending on whether other VA devices are retained and whether the equipment change number matches. This method implements a **routing/dispatch pattern**: it reads incoming data, queries downstream services for context, evaluates branching conditions, and dispatches to the appropriate SOD registration path.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callSod50"])
    START --> READ_MSG["Read svcKeiKaisenUcwkNo and ksnGeneAddDtm from ksnMsg"]
    READ_MSG --> GET_SVC_KEI_NO["Get svcKeiNo from kikiMsg"]
    GET_SVC_KEI_NO --> CALL_EKK0081["Call SC: EKK0081A010CBS Service Contract Agreement Func=2"]
    CALL_EKK0081 --> EXTRACT_SVC["Extract svcKeiNo and svcCd from response"]
    EXTRACT_SVC --> CHECK_SVC_CD{svcCd equals 02 Telephone Service?}
    CHECK_SVC_CD -->|No| END_NODE(["Return (no action)"])
    CHECK_SVC_CD -->|Yes| CALL_EKK0191B["Call SC: EKK0191B001CBS Service Contract Detail List Func=8"]
    CALL_EKK0191B --> CHECK_LIST_OUT{ekk0191b001outMsg has results?}
    CHECK_LIST_OUT -->|No| END_RETURN["Return"]
    CHECK_LIST_OUT -->|Yes| CALL_EKK0341B["Call SC: EKK0341B002CBS Equipment-Provided Service List Func=1 KktkSvcCd=C004"]
    CALL_EKK0341B --> CHECK_OTHER_VA["Loop: check other VA device existence"]
    CHECK_OTHER_VA --> OTHER_VA_EXISTS{Other VA exists (valid stat and different svcKeiNo)?}
    OTHER_VA_EXISTS -->|Yes| SET_OTHER_FLAG["Set otherVaFlg = true"]
    OTHER_VA_EXISTS -->|No| NO_OTHER_FLAG["otherVaFlg = false"]
    SET_OTHER_FLAG --> LOOP_DETAILS["Loop ekk0191b001outMsg: process each service contract detail"]
    NO_OTHER_FLAG --> LOOP_DETAILS
    LOOP_DETAILS --> SKIP_CANCELLED{svcKeiUcwkStat is 910 (Released) or 920 (Cancelled)?}
    SKIP_CANCELLED -->|Yes| CONTINUE_LOOP["continue to next detail"]
    SKIP_CANCELLED -->|No| CALL_EKK0191A["Call SC: EKK0191A010CBS Service Contract Detail Agreement Func=2"]
    CALL_EKK0191A --> EXTRACT_UW["Extract svkeiuwGadtm from agreement response"]
    EXTRACT_UW --> SET_SVC_UW_NO["Set svcKeiUcwkNo = svcKeiUcwkNoTel"]
    SET_SVC_UW_NO --> CHECK_PCRS{PCRS_CD equals A31 No.1 Course?}
    CHECK_PCRS -->|No| CHECK_A32{PCRS_CD equals A32 No.2 Course?}
    CHECK_A32 -->|No| CONTINUE_LOOP
    CHECK_A32 -->|Yes| A32_BRANCH{otherVaFlg?}
    A32_BRANCH -->|No| A32_NO_OTHER{telnoJun = 1?}
    A32_NO_OTHER -->|Yes| SET_UCWK_MAP["If !addFlg: set ucwkMap with svcKeiUcwkNo; set addFlg=true"]
    A32_NO_OTHER -->|No| A32_TEL2["Set chgFlg = true if telnoJun = 2"]
    A32_BRANCH -->|Yes| A32_OTHER{vaKikiChgNo matches kikiMsg KIKI_CHG_NO?}
    A32_OTHER -->|Yes| A32_MATCH{telnoJun = 1?}
    A32_MATCH -->|Yes| SET_UCWK_MAP2["If !addFlg: set ucwkMap; set addFlg=true"]
    A32_MATCH -->|No| A32_TEL2_2["Set chgFlg = true if telnoJun = 2"]
    A32_OTHER -->|No| SET_HUITI["Set huittiFlg = true"]
    SET_UCWK_MAP --> NEXT_ITER
    SET_UCWK_MAP2 --> NEXT_ITER
    A32_TEL2 --> NEXT_ITER
    A32_TEL2_2 --> NEXT_ITER
    SET_HUITI --> NEXT_ITER
    NEXT_ITER --> SECOND_LOOP["Second loop: determine runNo for each detail"]
    SECOND_LOOP --> SKIP_CANCELLED_2{svcKeiUcwkStat is 910/920?}
    SKIP_CANCELLED_2 -->|Yes| CONTINUE_LOOP2["continue"]
    SKIP_CANCELLED_2 -->|No| CALL_EKK0191A_2["Call SC: EKK0191A010CBS Agreement"]
    CALL_EKK0191A_2 --> EXTRACT_UW_2["Extract svkeiuwGadtm; set svcKeiUcwkNo"]
    EXTRACT_UW_2 --> SET_RUN_A31{PCRS_CD = A31?}
    SET_RUN_A31 -->|Yes| SET_RUN_47_A31["runNo = 47 (No.1 Course update 47)"]
    SET_RUN_A31 -->|No| SET_RUN_A32{PCRS_CD = A32?}
    SET_RUN_A32 -->|No| CONTINUE_LOOP2
    SET_RUN_A32 -->|Yes| SET_RUN_A32_BRANCH{otherVaFlg?}
    SET_RUN_A32_BRANCH -->|No| SET_RUN_A32_NO_OTHER{telnoJun = 1?}
    SET_RUN_A32_NO_OTHER -->|Yes| SET_RUN_47["runNo = 47"]
    SET_RUN_A32_NO_OTHER -->|No| SET_RUN_48_2["runNo = 48 (No.2 Course update 48)"]
    SET_RUN_A32_BRANCH -->|Yes| CHECK_RELATION{vaKikiChgNo matches?}
    CHECK_RELATION -->|No| CONTINUE_LOOP2
    CHECK_RELATION -->|Yes| TEL1_REL{telnoJun = 1?}
    TEL1_REL -->|Yes| SET_RUN_47_REL["runNo = 47"]
    TEL1_REL -->|No| TEL2_REL{telnoJun = 2?}
    TEL2_REL -->|Yes| REL_HUITI{huittiFlg?}
    REL_HUITI -->|Yes| SET_RUN_47_HUITI["runNo = 47"]
    REL_HUITI -->|No| SET_RUN_48_REL["runNo = 48"]
    SET_RUN_47_A31 --> RUN_CHECK
    SET_RUN_47 --> RUN_CHECK
    SET_RUN_48_2 --> RUN_CHECK
    SET_RUN_47_REL --> RUN_CHECK
    SET_RUN_47_HUITI --> RUN_CHECK
    SET_RUN_48_REL --> RUN_CHECK
    RUN_CHECK --> EXEC_47{runNo = 47?}
    EXEC_47 -->|Yes| GET_UCWK["callSameTrnNo if trnNo empty; get ucwkMap values; addVaSodInfo(2/20/02)"]
    EXEC_47 -->|No| EXEC_48{runNo = 48?}
    EXEC_48 -->|Yes| ADD_48["callSameTrnNo if trnNo empty; addVaSodInfo(2/20/04)"]
    EXEC_48 -->|No| END_RETURN
    GET_UCWK --> END_RETURN
    ADD_48 --> END_RETURN
    CONTINUE_LOOP --> NEXT_ITER
    CONTINUE_LOOP2 --> END_RETURN
```

**Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `JKKStrConst.CD00130_02` | `"02"` | Service Code: Telephone Service |
| `PCRS_CD_A31` | `"A31"` | Fee Course Code: No. 1 Course |
| `PCRS_CD_A32` | `"A32"` | Fee Course Code: No. 2 Course |
| `KKTK_SVC_CD_C004` | `"C004"` | Equipment-Provided Service Code: VA (Virtual Appliance) |
| `KKTK_STAT_910` | `"910"` | Equipment-Provided Service Contract Status: Not in service / Inoperative |
| `KKTK_STAT_920` | `"920"` | Equipment-Provided Service Contract Status: Cancellation completed |
| `SVC_KEI_UCWK_STAT_DSL` | `"910"` | Service Contract Detail Status: Released |
| `SVC_KEI_UCWK_STAT_CANCEL` | `"920"` | Service Contract Detail Status: Cancellation completed |
| `FUC_CODE_2` | `2` | Function Code for Agreement (inquiry) |
| `FUC_CODE_8` | `8` | Function Code for Detail List (equipment-VA specific) |
| `FUC_CODE_1` | `1` | Function Code for List (standard list) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transactional context for all SC calls and data access |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service component invocation bridge used to call downstream SC (Service Component) methods such as EKK0081A010CBS, EKK0191B001CBS, EKK0341B002CBS, and EKK0191A010CBS |
| 3 | `param` | `IRequestParameterReadWrite` | Request parameter object used to read/write request-level data during SC invocations and internal processing |
| 4 | `fixedText` | `String` | Fixed text resource bundle reference for message localization |
| 5 | `funcCd` | `String` | Function code identifying the calling function/screen context; passed through to called methods for audit trail |
| 6 | `kikiMsg` | `CAANMsg` | Machine/equipment message containing the service contract number (`SVC_KEI_NO`), equipment service number (`KKTK_SVC_KEI_NO`), generation timestamp (`GENE_ADD_DTM`), and equipment change number (`KIKI_CHG_NO`) for the current VA device |
| 7 | `modelCd` | `String` | Equipment model code identifying the type of VA device being registered (e.g., STB, router, gateway model) |
| 8 | `kikiSeizoNo` | `String` | Equipment manufacturing serial number — unique identifier for the specific physical VA unit being launched |
| 9 | `ekk2811B504outMsg` | `CAANMsg[]` | Output message array placeholder for EKK2811B504 processing (used elsewhere, passed as-is for potential future extension) |
| 10 | `ksnMsg` | `CAANMsg` | KSN (likely a notification or supplementary message) containing the service contract line item number (`SVC_KEI_KAISEN_UCWK_NO`) and generation timestamp (`GENE_ADD_DTM`) |
| 11 | `baseYMD` | `String` | Base year-month-date string used as a reference date for service agreement inquiries (e.g., reservation application date for EKK0081A010CBS) |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callSC` (EKK0081A010CBS) | EKK0081A010CBS | KK_T_SVC_KEI (Service Contract) | Calls EKK0081A010CBS to retrieve service contract agreement details (svcKeiNo, svcCd, genTimestamp) using Func=2 (Agreement) |
| R | `callSC` (EKK0191B001CBS) | EKK0191B001CBS | KK_T_SVC_KEI_UCWK (Service Contract Detail) | Calls EKK0191B001CBS to list service contract line items for the service contract number using Func=8 (equipment-VA specific) |
| R | `callSC` (EKK0341B002CBS) | EKK0341B002CBS | KK_T_KKTK_SVC_KEI (Equipment-Provided Service Contract) | Calls EKK0341B002CBS to list equipment-provided service contracts filtered by KKTK_SVC_CD=C004 (VA) to check for other VA devices |
| R | `callSC` (EKK0191A010CBS) | EKK0191A010CBS | KK_T_SVC_KEI_UCWK (Service Contract Detail) | Calls EKK0191A010CBS to retrieve service contract line item agreement details for each valid contract detail (Func=2 Agreement) |
| C | `addVaSodInfo` | EKK1081D010CBS / EKK1551D010CBS | KK_T_ODR_HAKKO_JOKEN, KK_T_ODR_NAIYO_SAKUSEI | Registers SOD (Service Order Data) for VA equipment — Create operation for order release conditions and order detail registration |
| R | `callSameTrnNo` | - | - | Retrieves a same transaction number to maintain consistency across related SOD entries within this processing flow |
| R | `getMsgValue` | - | - | Utility method to safely extract a value from a CAANMsg, used for reading kikiMsg values with null safety |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKShkaFinJiKikiStaAddCC.addShkaFinJiKiStaAdd()` | `addShkaFinJiKiStaAdd` -> `callSod50` | `addVaSodInfo [C] KK_T_ODR_HAKKO_JOKEN`, `addVaSodInfo [C] KK_T_ODR_NAIYO_SAKUSEI`, `callSC EKK0081A010CBS [R] KK_T_SVC_KEI`, `callSC EKK0191B001CBS [R] KK_T_SVC_KEI_UCWK`, `callSC EKK0341B002CBS [R] KK_T_KKTK_SVC_KEI`, `callSC EKK0191A010CBS [R] KK_T_SVC_KEI_UCWK` |

No screen/batch entry points found within 8 hops. This method is called exclusively by `addShkaFinJiKiStaAdd()`, which is the main equipment launch-completion start registration handler in the same class.

## 6. Per-Branch Detail Blocks

**Block 1** — [VARIABLE DECLARATIONS] (L10839)

Initialization of all local variables and message arrays.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0081a010outMsg = null` |
| 2 | SET | `svcMsg = null` |
| 3 | SET | `svcUwMsg = null` |
| 4 | SET | `svcKeiNo = ""` // Service contract number |
| 5 | SET | `svkeiGadtmTel = ""` // Generation timestamp for service contract |
| 6 | SET | `svcKeiUcwkNo = ""` // Service contract detail number |
| 7 | SET | `svkeiuwGadtm = ""` // Generation timestamp for service contract detail |
| 8 | SET | `svcKeiUcwkNoTel = ""` // Service contract detail number (telephone) |
| 9 | SET | `telnoJun = ""` // Telephone number order sequence |
| 10 | SET | `svcKeiUcwkStat = ""` // Service contract detail status |
| 11 | SET | `svcCd = ""`, `svcKeiKaisenUcwkNo = ""`, `ksnGeneAddDtm = ""` |

**Block 2** — [SET] Read KSN message data (L10873)

Extracts service contract line item number and generation timestamp from ksnMsg.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiKaisenUcwkNo = ksnMsg.getString(EKK0251A010CBSMsg1List.SVC_KEI_KAISEN_UCWK_NO)` // Service contract line item number |
| 2 | SET | `ksnGeneAddDtm = ksnMsg.getString(EKK0251A010CBSMsg1List.GENE_ADD_DTM)` // Generation timestamp from KSN |

**Block 3** — [SET] Get service contract number from kikiMsg (L10880)

Retrieves the service contract number from the equipment message (v7.00.47 fix: simplified from a loop over a list to a single direct read).

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiNo_tmp = kikiMsg.getString(EKK0341B029CBSMsg1List.SVC_KEI_NO)` // Service contract number from equipment message |

**Block 4** — [SET] Build EKK0081A010CBS input message (L10883)

Prepares the service contract agreement inquiry message with funcCode=2 (agreement).

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0081a010InMsg = {{TEMPLATEID, TEMPLATE_ID_EKK0081A010}, {FUNC_CODE, FUC_CODE_2}, {KEY_SVC_KEI_NO, svcKeiNo_tmp}, {KEY_GENE_ADD_DTM, ""}, {KEY_RSV_APLY_YMD, baseYMD}}` |

**Block 5** — [CALL] Call EKK0081A010CBS service (L10892)

Invokes the service contract agreement SC to retrieve service contract details.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `ekk0081a010outMsg = callSC(handle, scCall, param, fixedText, ekk0081a010InMsg).getCAANMsgList(EKK0081A010CBSMsg.EKK0081A010CBSMSG1LIST)` |

**Block 6** — [SET] Extract service contract data (L10894)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcMsg = ekk0081a010outMsg[0]` |
| 2 | SET | `svcKeiNo = svcMsg.getString(EKK0081A010CBSMsg1List.SVC_KEI_NO)` |
| 3 | SET | `svcCd = svcMsg.getString(EKK0081A010CBSMsg1List.SVC_CD)` |

**Block 7** — [IF] Service code is telephone (CD00130_02 = "02") (L10907)

Checks if the service code is for telephone service. Only telephone services proceed to VA SOD issuance.

| # | Type | Code |
|---|------|------|
| 1 | SET | `chgFlg = false`, `trnNo = ""`, `ucwkMap = new HashMap()`, `addFlg = false`, `huittiFlg = false` |
| 2 | SET | `svkeiGadtmTel = svcMsg.getString(EKK0081A010CBSMsg1List.GENE_ADD_DTM)` |
| 3 | SET | `pcrsCd = svcMsg.getString(EKK0081A010CBSMsg1List.PCRS_CD)` |

**Block 7.1** — [IF] EKK0191B001CBS has results (L10944)

Calls EKK0191B001CBS (Service Contract Detail List, Func=8) and processes results if any.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0191b001InMsg = {{TEMPLATEID, TEMPLATE_ID_EKK0191B001}, {FUNC_CODE, FUC_CODE_8}, {KEY_SVC_KEI_NO, svcKeiNo}}` // v7.00.49: Func 8 (VA-specific) |
| 2 | CALL | `ekk0191b001outMsg = callSC(handle, scCall, param, fixedText, ekk0191b001InMsg).getCAANMsgList(EKK0191B001CBSMsg.EKK0191B001CBSMSG1LIST)` |

**Block 7.1.1** — [IF] Check other VA existence (L10955)

Calls EKK0341B002CBS to list equipment-provided service contracts for VA (C004) and checks if another VA device exists with a valid (non-910/920) status and a different service contract number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `otherVaFlg = false` |
| 2 | SET | `ekk0341B002InMsg = {{TEMPLATEID, TEMPLATE_ID_EKK0341B002}, {FUNC_CODE, FUC_CODE_1}, {KEY_SVC_KEI_NO, svcKeiNo}, {KEY_KKTK_SVC_CD, KKTK_SVC_CD_C004}, {KEY_SORT_KBN, "2"}}` |
| 3 | CALL | `ekk0341B002outMsg = callSC(handle, scCall, param, fixedText, ekk0341B002InMsg).getCAANMsgList(EKK0341B002CBSMsg.EKK0341B002CBSMSG1LIST)` |
| 4 | FOR | `j = 0; j < ekk0341B002outMsg.length; j++` |

**Block 7.1.1.1** — [IF] Other VA device found (L10969)

Iterates through equipment-provided service contract results. If a device has a valid status (not 910/920) and its service contract number differs from the current equipment's, another VA exists.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kktkSvcKeiNo = ekk0341B002outMsg[j].getString(EKK0341B002CBSMsg1List.KKTK_SVC_KEI_NO)` |
| 2 | SET | `kktkSvcKeiStat = ekk0341B002outMsg[j].getString(EKK0341B002CBSMsg1List.KKTK_SVC_KEI_STAT)` |
| 3 | IF | `kktkSvcKeiStat NOT equals "910" AND NOT equals "920"` // Valid (active) status |
| 4 | IF | `kktkSvcKeiNo NOT equals getMsgValue(kikiMsg, EKK0341B029CBSMsg1List.KKTK_SVC_KEI_NO)` // Different from current |
| 5 | SET | `otherVaFlg = true; break` |

**Block 7.1.2** — [FOR] First loop: process service contract details (L10993)

Iterates through service contract detail results to build the ucwkMap and set flags for later SOD registration.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `k = 0; k < ekk0191b001outMsg.length; k++` |

**Block 7.1.2.1** — [IF] Skip cancelled/released details (L10998)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiUcwkNoTel = ekk0191b001outMsg[k].getString(EKK0191B001CBSMsg1List.SVC_KEI_UCWK_NO)` |
| 2 | SET | `svcKeiUcwkStat = ekk0191b001outMsg[k].getString(EKK0191B001CBSMsg1List.SVC_KEI_UCWK_STAT)` |
| 3 | SET | `telnoJun = ekk0191b001outMsg[k].getString(EKK0191B001CBSMsg1List.TELNO_JUN)` |
| 4 | IF | `svcKeiUcwkStat equals "910" (Released) OR equals "920" (Cancelled)` |
| 5 | EXEC | `continue` |

**Block 7.1.2.2** — [SET] Build EKK0191A010CBS input (L11015)

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0191a010InMsg = {{TEMPLATEID, TEMPLATE_ID_EKK0191A010}, {FUNC_CODE, FUC_CODE_2}, {KEY_SVC_KEI_UCWK_NO, svcKeiUcwkNoTel}}` |
| 2 | CALL | `ekk0191a010outMsg = callSC(handle, scCall, param, fixedText, ekk0191a010InMsg).getCAANMsgList(EKK0191A010CBSMsg.EKK0191A010CBSMSG1LIST)` |

**Block 7.1.2.3** — [SET] Extract agreement data (L11021)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcUwMsg = ekk0191a010outMsg[0]` |
| 2 | SET | `svkeiuwGadtm = svcUwMsg.getString(EKK0191A010CBSMsg1List.GENE_ADD_DTM)` |
| 3 | SET | `svcKeiUcwkNo = svcKeiUcwkNoTel` |

**Block 7.1.2.4** — [IF/ELSE] PCRS_CD branch: A31 (Fee Course: No. 1 Course) (L11026)

When the fee course code is "A31", set the ucwkMap for update type 47 if telephone number order is "1".

| # | Type | Code |
|---|------|------|
| 1 | IF | `PCRS_CD_A31 ("A31") equals pcrsCd` |
| 2 | IF | `"1" equals telnoJun` |
| 3 | IF | `!addFlg` |
| 4 | SET | `ucwkMap.put("SVC_KEI_UCWK_NO", svcKeiUcwkNo); ucwkMap.put("GENE_ADD_DTM", svkeiuwGadtm)` |
| 5 | EXEC | `break` |

**Block 7.1.2.5** — [ELSE-IF] PCRS_CD branch: A32 (Fee Course: No. 2 Course) (L11035)

When fee course is "A32", the processing diverges based on whether another VA is retained.

| # | Type | Code |
|---|------|------|
| 1 | IF | `PCRS_CD_A32 ("A32") equals pcrsCd` |
| 2 | IF | `!otherVaFlg` // No other VA retained |
| 3 | IF | `"1" equals telnoJun` |
| 4 | IF | `!addFlg` |
| 5 | SET | `ucwkMap.put("SVC_KEI_UCWK_NO", svcKeiUcwkNo); ucwkMap.put("GENE_ADD_DTM", svkeiuwGadtm)` |
| 6 | SET | `addFlg = true` |
| 7 | IF | `"2" equals telnoJun` |
| 8 | SET | `chgFlg = true` |
| 9 | ELSE | `// otherVaFlg == true: other VA retained` |
| 10 | SET | `vaKikiChgNo = ekk0191b001outMsg[k].getString(EKK0191B001CBSMsg1List.VA_KIKI_CHG_NO)` |
| 11 | IF | `vaKikiChgNo equals getMsgValue(kikiMsg, EKK0341B029CBSMsg1List.KIKI_CHG_NO)` // Equipment change number matches |
| 12 | IF | `"1" equals telnoJun` |
| 13 | IF | `!addFlg` |
| 14 | SET | `ucwkMap.put("SVC_KEI_UCWK_NO", svcKeiUcwkNo); ucwkMap.put("GENE_ADD_DTM", svkeiuwGadtm)` |
| 15 | SET | `addFlg = true` |
| 16 | IF | `"2" equals telnoJun` |
| 17 | SET | `chgFlg = true` |
| 18 | ELSE | `huittiFlg = true` // Equipment change number does not match — equipment was replaced |

**Block 7.1.3** — [FOR] Second loop: determine runNo (L11086)

Second pass over service contract details to set the `runNo` value (47 or 48) which determines the SOD registration type.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `k = 0; k < ekk0191b001outMsg.length; k++` |
| 2 | SET | `runNo = ""` |
| 3 | SET | `svcKeiUcwkNoTel = ekk0191b001outMsg[k].getString(EKK0191B001CBSMsg1List.SVC_KEI_UCWK_NO)` |
| 4 | SET | `telnoJun = ekk0191b001outMsg[k].getString(EKK0191B001CBSMsg1List.TELNO_JUN)` |
| 5 | SET | `svcKeiUcwkStat = ekk0191b001outMsg[k].getString(EKK0191B001CBSMsg1List.SVC_KEI_UCWK_STAT)` |

**Block 7.1.3.1** — [IF] Skip cancelled/released (L11098)

| # | Type | Code |
|---|------|------|
| 1 | IF | `svcKeiUcwkStat equals "910" OR equals "920"` |
| 2 | EXEC | `continue` |

**Block 7.1.3.2** — [SET] Build EKK0191A010CBS input and call (L11113)

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0191a010InMsg = {{TEMPLATEID, TEMPLATE_ID_EKK0191A010}, {FUNC_CODE, FUC_CODE_2}, {KEY_SVC_KEI_UCWK_NO, svcKeiUcwkNoTel}}` |
| 2 | CALL | `ekk0191a010outMsg = callSC(handle, scCall, param, fixedText, ekk0191a010InMsg).getCAANMsgList(EKK0191A010CBSMsg.EKK0191A010CBSMSG1LIST)` |
| 3 | SET | `svcUwMsg = ekk0191a010outMsg[0]` |
| 4 | SET | `svkeiuwGadtm = svcUwMsg.getString(EKK0191A010CBSMsg1List.GENE_ADD_DTM)` |
| 5 | SET | `svcKeiUcwkNo = svcKeiUcwkNoTel` |

**Block 7.1.3.3** — [IF] PCRS_CD = A31, set runNo = 47 (L11127)

| # | Type | Code |
|---|------|------|
| 1 | IF | `PCRS_CD_A31 ("A31") equals pcrsCd` |
| 2 | SET | `runNo = "47"` // Update type 47: No. 1 Course |

**Block 7.1.3.4** — [IF] PCRS_CD = A32, determine runNo (L11134)

Complex branching based on otherVaFlg, telnoJun, vaKikiChgNo match, and huittiFlg.

| # | Type | Code |
|---|------|------|
| 1 | IF | `PCRS_CD_A32 ("A32") equals pcrsCd` |
| 2 | IF | `!otherVaFlg` // No other VA |
| 3 | IF | `"1" equals telnoJun` |
| 4 | SET | `runNo = "47"` // No. 1 Course |
| 5 | ELSE | `// telnoJun = "2"` |
| 6 | SET | `runNo = "48"` // No. 2 Course |
| 7 | ELSE | `// otherVaFlg == true: other VA retained` |
| 8 | SET | `relationFlg = false` |
| 9 | SET | `vaKikiChgNo = ekk0191b001outMsg[k].getString(EKK0191B001CBSMsg1List.VA_KIKI_CHG_NO)` |
| 10 | IF | `vaKikiChgNo equals getMsgValue(kikiMsg, EKK0341B029CBSMsg1List.KIKI_CHG_NO)` |
| 11 | SET | `relationFlg = true` |
| 12 | IF | `relationFlg` |
| 13 | IF | `"1" equals telnoJun` |
| 14 | SET | `runNo = "47"` |
| 15 | ELSE | `// telnoJun = "2"` |
| 16 | IF | `huittiFlg` |
| 17 | SET | `runNo = "47"` |
| 18 | ELSE | `runNo = "48"` |
| 19 | ELSE | `continue` // relationFlg false, skip this detail |

**Block 7.1.3.5** — [IF] runNo = "47", call addVaSodInfo (L11203)

Registers SOD for update type 47. Gets a same transaction number if needed, then calls addVaSodInfo with the stored ucwkMap values.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"47" equals runNo` |
| 2 | IF | `chgFlg && trnNo is empty` |
| 3 | CALL | `trnNo = callSameTrnNo(handle, scCall, param, fixedText, funcCd)` |
| 4 | SET | `ucwkNo = ucwkMap.get("SVC_KEI_UCWK_NO"); gadtm = ucwkMap.get("GENE_ADD_DTM")` |
| 5 | CALL | `addVaSodInfo(handle, scCall, param, fixedText, funcCd, svcKeiNo, modelCd, kikiSeizoNo, "2", "20", "02", trnNo, svcKeiKaisenUcwkNo, "207", kikiMsg, svkeiGadtmTel, gadtm, ucwkNo, svcKeiKaisenUcwkNo, ksnGeneAddDtm)` // updateType=2, orderType=20, yokyuSbtCd=02, serviceCd=207 |

**Block 7.1.3.6** — [IF] runNo = "48", call addVaSodInfo (L11214)

Registers SOD for update type 48.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"48" equals runNo` |
| 2 | IF | `trnNo is empty` |
| 3 | CALL | `trnNo = callSameTrnNo(handle, scCall, param, fixedText, funcCd)` |
| 4 | CALL | `addVaSodInfo(handle, scCall, param, fixedText, funcCd, svcKeiNo, modelCd, kikiSeizoNo, "2", "20", "04", trnNo, svcKeiKaisenUcwkNo, "208", kikiMsg, svkeiGadtmTel, svkeiuwGadtm, svcKeiUcwkNo, svcKeiKaisenUcwkNo, ksnGeneAddDtm)` // updateType=2, orderType=20, yokyuSbtCd=04, serviceCd=208 |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| SOD | Acronym | Service Order Data — telecom order fulfillment entity representing a service order to be issued |
| VA | Business term | Virtual Appliance — customer-provided or equipment-provided networking device (e.g., router, STB) leased to the subscriber |
| KKTK_SVC_KEI_NO | Field | Equipment-Provided Service Contract Number — links a specific VA device to a service contract |
| KKTK_SVC_CD | Field | Equipment-Provided Service Code — classifies device type (C004 = VA) |
| KKTK_STAT | Field | Equipment-Provided Service Contract Status — 910 = Not in service, 920 = Cancellation completed, other values = active |
| SVC_KEI_NO | Field | Service Contract Number — unique identifier for a service contract in the system |
| SVC_KEI_UCWK_NO | Field | Service Contract Line Item Number — identifies a specific line item within a service contract |
| SVC_KEI_UCWK_STAT | Field | Service Contract Line Item Status — 910 = Released, 920 = Cancellation completed |
| SVC_KEI_KAISEN_UCWK_NO | Field | Service Contract Line Item Number (Kaisen/Extension) — tracking ID for service contract extensions |
| GENE_ADD_DTM | Field | Generation Timestamp — date/time when a record was created or last generated |
| PCRS_CD | Field | Price Course Code — fee course classification (A31 = No. 1 Course, A32 = No. 2 Course) |
| TELNO_JUN | Field | Telephone Number Order Sequence — indicates the order of a telephone line (1 = No. 1, 2 = No. 2) |
| KIKI_CHG_NO | Field | Equipment Change Number — identifies a specific equipment change event |
| VA_KIKI_CHG_NO | Field | VA Equipment Change Number — equipment change number specific to VA devices |
| svcCd (CD00130_02) | Field | Service Code — 02 = Telephone Service |
| chgFlg | Field | Change Flag — indicates whether a change operation (telnoJun=2) has been detected |
| addFlg | Field | Add Flag — indicates whether SOD addition information has been recorded in this loop |
| huittiFlg | Field | Substitution Flag — indicates that an equipment change number mismatch was detected (replaced equipment) |
| otherVaFlg | Field | Other VA Flag — indicates whether another VA device with a valid status exists on a different service contract |
| relationFlg | Field | Relation Flag — indicates whether the VA equipment change number matches the kikiMsg KIKI_CHG_NO |
| runNo | Field | Run Number — processing type identifier (47 = No. 1 Course update, 48 = No. 2 Course update) |
| addVaSodInfo | Method | VA SOD Info Registration — registers Service Order Data for VA equipment |
| callSameTrnNo | Method | Same Transaction Number Retrieval — obtains a shared transaction number for consistency across related SOD entries |
| EKK0081A010CBS | CBS | Service Contract Agreement — retrieves service contract details (svcKeiNo, svcCd, genTimestamp) |
| EKK0191B001CBS | CBS | Service Contract Detail List — lists service contract line items |
| EKK0191A010CBS | CBS | Service Contract Detail Agreement — retrieves a specific service contract line item agreement |
| EKK0341B002CBS | CBS | Equipment-Provided Service Contract List — lists equipment-provided service contracts for a subscriber |
| FUC_CODE_2 | Constant | Function Code for Agreement (inquiry) |
| FUC_CODE_8 | Constant | Function Code for Detail List (VA-specific equipment query) |
| FUC_CODE_1 | Constant | Function Code for List (standard list query) |
| 47 | Constant | Update Type 47 — No. 1 Course update operation |
| 48 | Constant | Update Type 48 — No. 2 Course update operation |
| 207 | Constant | Service Code for No. 1 Course VA SOD registration |
| 208 | Constant | Service Code for No. 2 Course VA SOD registration |
| 02 | Constant | Yokyu Sbt Cd for No. 1 Course |
| 04 | Constant | Yokyu Sbt Cd for No. 2 Course |
| eo | Business term | eo — brand name for K-Opticom's fiber-optic broadband and bundled telephone services |
| K-Opticom | Business term | K-Opticom — Japanese broadband and telecommunications service provider |
