# (DD31) Business Logic — JDKCommon08CC.addHmpinSodHakko() [605 LOC]

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

## 1. Role

### JDKCommon08CC.addHmpinSodHakko()

This method performs **Return SOD (Service Order Data) issuance processing** during the return device approval workflow in the telecom customer backbone system. It is invoked by `addHmpinSodShinsei` (lines 753-759) after a return device has been approved (`HMPIN_KIKI_STAT_SHONIN`) — specifically after the device return information update step completes, ensuring that all eligible return devices trigger the creation of corresponding SOD records for downstream fulfillment.

The method implements a **routing/dispatch pattern** that iterates over a list of approved devices (`approveDatas`) and, for each device, performs a chain of read-only service component calls to retrieve device provision service contract details, domestic device type agreement, and return SOD target service contract look-up. Based on the device's domestic device subtype code (e.g., "50" = Optical Phone TA, "F0" = BB Phone, "J0" = UQ, "R0"/"S0" = Multi-function Router / HGW), it dispatches to device-specific SOD creation branches that register cancellation and deletion conditions via `insertOdrHakkoJoken` and `insertOdrInfSksiWk`.

The method also supports a **model change** scenario (OM-2020-0000461): when `key_hmpin_kbn` equals `MODEL_CHANGE = "5"`, the device is immediately flagged as a return SOD target without needing to check service contract status codes, enabling faster processing for equipment swap events.

Its role in the larger system is as a **shared CC (Common Component) utility** called during the return approval process. It bridges device-level return decisions with order-level SOD issuance, ensuring that every returned piece of equipment triggers the appropriate order condition and order information creation workflows.

## 2. Processing Pattern (Detailed Business Logic)

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

    GET_WORKMAP["Get workMap from param"]
    CHECK_WORKMAP{"workMap == null?"}
    CREATE_WORKMAP["workMap = new HashMap"]
    SET_WORKMAP["param.setMappingWorkArea"]
    CHECK_SOD{"workMap contains SOD_WORKAREA_KEY?"}
    CREATE_SOD["sodWorkMap = new HashMap"]
    PUT_SOD["workMap.put SOD_WORKAREA_KEY sodWorkMap"]
    GET_SOD["sodWorkMap = getSodWorkMap"]
    GET_INMAP["inMap = param.getData DKSV008101CC"]
    LOOP_START["Iterate approveDatas"]
    GET_MAP["map = ite.next"]
    CHECK_ERR1{checkErrList stat}
    CHECK_ERR2{checkErrList hen}
    CHECK_ERR3{checkErrList son}
    GET_SEIZO_NO["Get kikiSeizoNo from map"]
    CHECK_SEIZO{kikiSeizoNo null or empty?}
    PUT_SEIZO["ekk0341B001InMap put KIKI_SEIZO_NO"]
    CALL_EKK0341B001["scCall.run EKK0341B001CBS"]
    EDIT_EKK0341B001["EKK0341B001BSMapper editResultRP"]
    CHECK_ERR_B001{hasError?}
    GET_EKK0341B001_OUT["Get EKK0341B001CBSMSG1LIST"]
    GET_SVC_KEY["Get keyKktkSvcKeiNo from map"]
    CHECK_SVC_KEY{svcKey null or empty?}
    MATCH_SVC_KEY["Match service key from EKK0341B001 list"]
    GET_GENE_DTM["Get geneAddDtm"]
    CALL_EKK0341A010["scCall.run EKK0341A010_02CBS"]
    EDIT_EKK0341A010["EKK0341A010_02BSMapper editResultRP"]
    CHECK_ERR_A010{hasError?}
    GET_EKK0341A010_OUT["Get ekk0341A010CbsMsg1List"]
    CHECK_LIST_01{size == 0?}
    GET_TMP_MAP["tmpKK0341A001Map = first record"]
    GET_TK_MDL_CD["Get tkMdlCd from map"]
    CALL_EZM0411A010["scCall.run EZM0411A010CBS"]
    EDIT_EZM0411A010["EZM0411A010BSMapper editResultRP"]
    CHECK_ERR_ZM{hasError?}
    GET_EZM_OUT["Get ezm0411A010CbsMsg1List"]
    CHECK_LIST_02{size == 0?}
    GET_TKNI_SBT_CD["Get tkniKikiSbtCd"]
    CHECK_TKNI_SBT{checkTkniKikiSbtCd?}
    CALL_EKK0341B034["scCall.run EKK0341B034CBS"]
    EDIT_EKK0341B034["EKK0341B034BSMapper editResultRP"]
    CHECK_ERR_B034{hasError?}
    GET_EKK0341B034_OUT["Get kk0341B034CbsMsg1List"]
    CHECK_LIST_03{size == 0?}
    CHECK_IS_SOD{isSod target?}
    BRANCH_IS_SOD["isSod == true - Return SOD processing"]
    BRANCH_NOT_SOD["isSod == false - skip"]
    CLEAR_SOD["sodWorkMap.clear"]
    REMOVE_SOD["workMap.remove sodWorkMap"]
    END_NODE(["Return / Next"])
    CONTINUE["continue"]

    START --> GET_WORKMAP
    GET_WORKMAP --> CHECK_WORKMAP
    CHECK_WORKMAP -- Yes --> CREATE_WORKMAP --> SET_WORKMAP --> CHECK_SOD
    CHECK_WORKMAP -- No --> CHECK_SOD
    CHECK_SOD -- No --> CREATE_SOD --> PUT_SOD --> GET_SOD
    CHECK_SOD -- Yes --> GET_SOD
    GET_SOD --> GET_INMAP
    GET_INMAP --> LOOP_START
    LOOP_START --> GET_MAP
    GET_MAP --> CHECK_ERR1
    CHECK_ERR1 -- Yes --> CONTINUE
    CHECK_ERR1 -- No --> CHECK_ERR2
    CHECK_ERR2 -- Yes --> CONTINUE
    CHECK_ERR2 -- No --> CHECK_ERR3
    CHECK_ERR3 -- Yes --> CONTINUE
    CHECK_ERR3 -- No --> GET_SEIZO_NO
    GET_SEIZO_NO --> CHECK_SEIZO
    CHECK_SEIZO -- Yes --> CONTINUE
    CHECK_SEIZO -- No --> PUT_SEIZO --> CALL_EKK0341B001
    CALL_EKK0341B001 --> EDIT_EKK0341B001
    EDIT_EKK0341B001 --> CHECK_ERR_B001
    CHECK_ERR_B001 -- Yes --> CONTINUE
    CHECK_ERR_B001 -- No --> GET_EKK0341B001_OUT
    GET_EKK0341B001_OUT --> GET_SVC_KEY
    GET_SVC_KEY --> CHECK_SVC_KEY
    CHECK_SVC_KEY -- Yes --> CONTINUE
    CHECK_SVC_KEY -- No --> MATCH_SVC_KEY --> GET_GENE_DTM
    GET_GENE_DTM --> CALL_EKK0341A010
    CALL_EKK0341A010 --> EDIT_EKK0341A010
    EDIT_EKK0341A010 --> CHECK_ERR_A010
    CHECK_ERR_A010 -- Yes --> CONTINUE
    CHECK_ERR_A010 -- No --> GET_EKK0341A010_OUT
    GET_EKK0341A010_OUT --> CHECK_LIST_01
    CHECK_LIST_01 -- Yes --> CONTINUE
    CHECK_LIST_01 -- No --> GET_TMP_MAP
    GET_TMP_MAP --> GET_TK_MDL_CD
    GET_TK_MDL_CD --> CALL_EZM0411A010
    CALL_EZM0411A010 --> EDIT_EZM0411A010
    EDIT_EZM0411A010 --> CHECK_ERR_ZM
    CHECK_ERR_ZM -- Yes --> CONTINUE
    CHECK_ERR_ZM -- No --> GET_EZM_OUT
    GET_EZM_OUT --> CHECK_LIST_02
    CHECK_LIST_02 -- Yes --> CONTINUE
    CHECK_LIST_02 -- No --> GET_TKNI_SBT_CD
    GET_TKNI_SBT_CD --> CHECK_TKNI_SBT
    CHECK_TKNI_SBT -- No --> CONTINUE
    CHECK_TKNI_SBT -- Yes --> CALL_EKK0341B034
    CALL_EKK0341B034 --> EDIT_EKK0341B034
    EDIT_EKK0341B034 --> CHECK_ERR_B034
    CHECK_ERR_B034 -- Yes --> CONTINUE
    CHECK_ERR_B034 -- No --> GET_EKK0341B034_OUT
    GET_EKK0341B034_OUT --> CHECK_LIST_03
    CHECK_LIST_03 -- Yes --> CONTINUE
    CHECK_LIST_03 -- No --> CHECK_IS_SOD
    CHECK_IS_SOD -- Yes --> BRANCH_IS_SOD --> CLEAR_SOD
    CHECK_IS_SOD -- No --> BRANCH_NOT_SOD --> CLEAR_SOD
    CLEAR_SOD --> REMOVE_SOD
    REMOVE_SOD --> END_NODE
    CONTINUE --> LOOP_START
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `approveDatas` | `List<Map>` | List of approved return device records. Each map contains device-level data including `key_kk_seizo_no` (device manufacturing serial number), `key_kktk_svc_kei_no` (device provision service contract number), `key_hmpin_kbn` (return type flag), and `key_tk_mdl_cd` (take-home device model code). These are devices that have passed the return approval step and need SOD issuance check. |
| 2 | `handle` | `SessionHandle` | Database session handle used for all service component invocations within this method. Provides the database connection context for CBS (CBS = Component Business Service) calls like `scCall.run()`. |
| 3 | `param` | `IRequestParameterReadWrite` | Request parameter object carrying the mapping work area (`getMappingWorkArea`/`setMappingWorkArea`), SOD work area state, DKSV008101CC data (error lists for device status/hen/son), and control map data (`returnCode`). It is the primary data exchange vehicle between the method and called services. |
| 4 | `scCall` | `ServiceComponentRequestInvoker` | Service Component request invoker used to execute CBS calls (`scCall.run()`). Dispatches service component requests to the backend service layer (e.g., EKK0341B001CBS, EZM0411A010CBS). |

**Key instance fields / external state:**
- `SOD_WORKAREA_KEY` = `"SODWORK"` — Key used to store and retrieve the SOD work area map within the param's mapping work area [-> SOD_WORKAREA_KEY="SODWORK" (JDKCommon08CC.java:198)]

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `getSodWorkMap` | - | - | Retrieves the SOD work area map from param's mapping work area |
| R | `checkErrList` | - | - | Checks if the current device's contract number is in an error list (to be skipped) |
| R | `checkTkniKikiSbtCd` | - | - | Validates if the domestic device subtype code is eligible for return SOD issuance |
| R | `EKK0341B001BSMapper.editInMsg` | - | - | Prepares input message for device provision service contract look-up (serial number) |
| C/R | `scCall.run (EKK0341B001CBS)` | EKK0341B001CBS | Device provision service contract look-up | Calls look-up of device provision service contract details by manufacturing serial number |
| R | `EKK0341B001BSMapper.editResultRP` | - | - | Extracts output from EKK0341B001CBS response |
| R | `EKK0341A010_02BSMapper.editInMsg` | - | - | Prepares input for device provision service contract agreement look-up |
| C/R | `scCall.run (EKK0341A010_02CBS)` | EKK0341A010_02CBS | Device provision service contract agreement | Calls agreement look-up for the device provision service contract number |
| R | `EKK0341A010_02BSMapper.editResultRP` | - | - | Extracts output from EKK0341A010_02CBS response |
| R | `EZM0411A010BSMapper.editInMsg` | - | - | Prepares input for take-home device type agreement |
| C/R | `scCall.run (EZM0411A010CBS)` | EZM0411A010CBS | Take-home device type | Calls agreement look-up for the domestic device model code |
| R | `EZM0411A010BSMapper.editResultRP` | - | - | Extracts output from EZM0411A010CBS response |
| R | `EKK0341B034BSMapper.editInMsg` | - | - | Prepares input for device provision service contract look-up (return SOD target) |
| C/R | `scCall.run (EKK0341B034CBS)` | EKK0341B034CBS | Device provision service contract (return SOD) | Calls look-up of service contract details for return SOD target |
| R | `EKK0341B034BSMapper.editResultRP` | - | - | Extracts output from EKK0341B034CBS response |
| C/R | `scCall.run (EKK0081B034CBS)` | EKK0081B034CBS | Service contract number (R0/S0 path) | For multi-function router/HGW devices, calls service contract number look-up via service improvement work number |
| R | `EKK0081B034BSMapper.editResultRP` | - | - | Extracts output from EKK0081B034CBS response |
| C/R | `scCall.run (EKK0081A010CBS)` | EKK0081A010CBS | Service contract agreement | Calls service contract agreement look-up for the service contract number |
| R | `EKK0081A010BSMapper.editResultRP` | - | - | Extracts output from EKK0081A010CBS response |
| R | `EKK1081C011BSMapper.editInMsg` | - | - | Prepares input for same transaction number acquisition |
| C/R | `scCall.run (EKK1081C011CBS)` | EKK1081C011CBS | Same transaction number | Acquires the same transaction number for order issuance |
| R | `EKK1081C011BSMapper.editResultRP` | - | - | Extracts output from EKK1081C011CBS response |
| C | `this.insertOdrHakkoJoken` | - | KK_T_ODR_HAKKO_JOKEN | Creates return SOD order issuance conditions (cancellation/deletion) |
| C | `this.insertOdrInfSksiWk` | - | KK_T_ODR_INF_SKSI_WK | Creates return SOD order information creation work records |
| R | `EKK0161B004BSMapper.editInMsg` | - | - | Prepares input for service contract detail list look-up (used in J0 and R0/S0 branches) |
| C/R | `scCall.run (EKK0161B004CBS)` | EKK0161B004CBS | Service contract detail list | Calls service contract detail list look-up |
| R | `EKK0161B004BSMapper.editResultRP` | - | - | Extracts output from EKK0161B004CBS response |
| R | `EKK2811B010BSMapper.editInMsg` | - | - | Prepares input for device option service contract list look-up (R0/S0 path) |
| C/R | `scCall.run (EKK2811B010CBS)` | EKK2811B010CBS | Device option service contract | Calls device option service contract list look-up |
| R | `EKK2811B010BSMapper.editResultRP` | - | - | Extracts output from EKK2811B010CBS response |
| - | `JDKBPCommon.hasError` | - | - | Checks param for error status after service calls |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC: JDKCommon08CC | `addHmpinSodShinsei` (line 759) -> `this.addHmpinSodHakko(approveDatas, handle, param, scCall)` | `insertOdrInfSksiWk [C]`, `insertOdrHakkoJoken [C]`, `hasError [-]`, `editResultRP [U]`, `editInMsg [U]`, `run [-]`, `clear [-]` |

**Explanation:** The method is called directly from `addHmpinSodShinsei` (the same class) at line 759, within the approval path (`updateStat == HMPIN_KIKI_STAT_SHONIN`) after return device information update. The caller flow is:
1. `addHmpinSodShinsei` - Main return approval entry point
2. Calls device agreement, approval, and update CBS operations
3. Then invokes `addHmpinSodHakko` to create return SODs for all approved devices

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `workMap == null` (L977)

> If the work area does not exist, create a new HashMap and set it in param.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap = new HashMap()` // Create work area |
| 2 | EXEC | `param.setMappingWorkArea(workMap)` // Store in param |

**Block 2** — [IF] `!workMap.containsKey(SOD_WORKAREA_KEY)` (L983) [-> SOD_WORKAREA_KEY="SODWORK" (JDKCommon08CC.java:198)]

> If the SOD work area does not exist within the work area, create it.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sodWorkMap = new HashMap()` // Create SOD work area |
| 2 | SET | `workMap.put(SOD_WORKAREA_KEY, sodWorkMap)` // Store in work area |

**Block 3** — [EXEC] Retrieve SOD work area and error list data (L989-L992)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `sodWorkMap = this.getSodWorkMap(param)` // Get SOD work area |
| 2 | SET | `inMap = (HashMap) param.getData(DKSV008101CC)` // Get screen data |

**Block 4** — [WHILE] Iterate `approveDatas` (L994)

> Loop through each approved return device record and process SOD issuance.

**Block 4.1** — [IF] `checkErrList(inMap, "kktk_svc_kiy_stat_err_list", map)` (L999)

> Skip this device if it is in the device status error list.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `checkErrList(inMap, "kktk_svc_kiy_stat_err_list", map)` // Check error list |
| 2 | RETURN | `continue` // Skip to next device |

**Block 4.2** — [IF] `checkErrList(inMap, "kktk_svc_kiy_hen_err_list", map)` (L1003)

> Skip this device if it is in the device change error list.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `checkErrList(inMap, "kktk_svc_kiy_hen_err_list", map)` // Check error list |
| 2 | RETURN | `continue` // Skip to next device |

**Block 4.3** — [IF] `checkErrList(inMap, "kktk_svc_kiy_son_err_list", map)` (L1010)

> Skip this device if it is in the device damage error list.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `checkErrList(inMap, "kktk_svc_kiy_son_err_list", map)` // Check error list |
| 2 | RETURN | `continue` // Skip to next device |

**Block 5** — [IF] `map.containsKey("key_kk_seizo_no")` (L1018) [IT1-2014-0000368 ADD]

> Retrieve the device manufacturing serial number. This is used to look up device provision service contract details.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kikiSeizoNo = (String) map.get("key_kk_seizo_no")` // Device serial number |

**Block 5.1** — [IF] `null == kikiSeizoNo || 0 == kikiSeizoNo.length()` (L1027) [OM-2014-0003844 ADD]

> If the serial number cannot be obtained, skip return SOD issuance.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `continue` // Skip — cannot process without serial number |

**Block 6** — [EXEC] Call device provision service contract look-up (serial number) (L1033-L1050)

> Sets up and calls EKK0341B001CBS to look up device provision service contract details by manufacturing serial number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0341B001InMap = new HashMap()` // Create input map |
| 2 | SET | `ekk0341B001InMap.put(EKK0341B001CBSMsg.KEY_KIKI_SEIZO_NO, kikiSeizoNo)` |
| 3 | SET | `sodWorkMap.put(DKSV0081_DKSV0081OP_EKK0341B001BSMapper.TEMPLATEID, ekk0341B001InMap)` |
| 4 | SET | `ekk0341B001ParamMap = EKK0341B001BSMapper.editInMsg(param)` |
| 5 | CALL | `ekk0341B001ResultMap = scCall.run(ekk0341B001ParamMap, handle)` |
| 6 | SET | `param = EKK0341B001BSMapper.editResultRP(ekk0341B001ResultMap, param)` |
| 7 | - | `// JSYejbLog: Device provision service contract look-up (serial number) processing` |

**Block 7** — [IF] `JDKBPCommon.hasError(param)` (L1044)

> If the serial number look-up failed, throw an exception.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `throw new SCCallException("Device provision service contract look-up (serial number) failed", ...)` |

**Block 8** — [EXEC] Retrieve EKK0341B001 output and match service contract number (L1051-L1075)

> Gets the service contract agreement list from EKK0341B001 output and finds the matching service contract number (`keyKktkSvcKeiNo`) to extract the generation add timestamp.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0341B001OutMap = (HashMap) sodWorkMap.get(DKSV0081_DKSV0081OP_EKK0341B001BSMapper.TEMPLATEID)` |
| 2 | SET | `ekk0341B001CbsMsg1List = (List) ekk0341B001OutMap.get(EKK0341B001CBSMsg.EKK0341B001CBSMSG1LIST)` |
| 3 | SET | `keyKktkSvcKeiNo = (String) map.get("key_kktk_svc_kei_no")` // Service contract number |
| 4 | WHILE | `Iterate ekk0341B001CbsMsg1List to find matching service key` |
| 5 | SET | `geneAddDtm = (String) ...get(GENE_ADD_DTM)` // Generation add timestamp |

**Block 9** — [IF] `null == keyKktkSvcKeiNo || 0 == keyKktkSvcKeiNo.length()` (L1065) [OM-2015-0000671 ADD]

> If the service contract number cannot be obtained, skip return SOD issuance.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `continue` // Skip — cannot process without service contract number |

**Block 10** — [EXEC] Call device provision service contract agreement look-up (L1082-L1099)

> Calls EKK0341A010_02CBS to look up the device provision service contract agreement.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0341A010_02InMap = new HashMap()` |
| 2 | SET | `ekk0341A010_02InMap.put(EKK0341A010CBSMsg.KEY_KKTK_SVC_KEI_NO, keyKktkSvcKeiNo)` |
| 3 | SET | `ekk0341A010_02InMap.put(EKK0341A010CBSMsg.KEY_GENE_ADD_DTM, geneAddDtm)` [IT1-2014-0000368 ADD] |
| 4 | SET | `sodWorkMap.put(DKSV0081_DKSV0081OP_EKK0341A010_02BSMapper.TEMPLATEID, ekk0341A010_02InMap)` |
| 5 | SET | `ekk0341A010_02ParamMap = EKK0341A010_02BSMapper.editInMsg(param)` |
| 6 | CALL | `ekk0341A010_02ResultMap = scCall.run(ekk0341A010_02ParamMap, handle)` |
| 7 | SET | `param = EKK0341A010_02BSMapper.editResultRP(ekk0341A010_02ResultMap, param)` |

**Block 11** — [IF] `JDKBPCommon.hasError(param)` (L1092)

> If the agreement look-up failed, throw an exception.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `throw new SCCallException("Device provision service contract agreement look-up failed", ...)` |

**Block 12** — [EXEC] Retrieve EKK0341A010 output and check record count (L1100-L1112)

> Gets the service contract agreement list. If no records were obtained, skip processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0341A010_02OutMap = (HashMap) sodWorkMap.get(DKSV0081_DKSV0081OP_EKK0341A010_02BSMapper.TEMPLATEID)` |
| 2 | SET | `ekk0341A010CbsMsg1List = (List) ekk0341A010_02OutMap.get(EKK0341A010CBSMsg.EKK0341A010CBSMSG1LIST)` |
| 3 | SET | `tmpKK0341A001Map = (HashMap) ekk0341A010CbsMsg1List.get(0)` // First record |

**Block 13** — [IF] `ekk0341A010CbsMsg1List.size() == 0` (L1108)

> If no agreement records were obtained, skip return SOD issuance.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `continue` // No records — skip |

**Block 14** — [IF] `map.containsKey("key_tk_mdl_cd")` (L1116) [IT1-2014-0000348 ADD]

> Retrieve the take-home device model code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tkMdlCd = (String) map.get("key_tk_mdl_cd")` // Take-home device model code |

**Block 15** — [EXEC] Call take-home device type agreement (L1122-L1140) [IT1-2014-0000348 MOD]

> Calls EZM0411A010CBS to agree on the take-home device type. Note: IT1-2014-0000348 MOD changed to use `tkMdlCd` from map directly instead of from tmpKK0341A001Map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ezm0411A010InMap = new HashMap()` |
| 2 | SET | `ezm0411A010InMap.put(EZM0411A010CBSMsg.KEY_TAKNKIKI_MODEL_CD, tkMdlCd)` [IT1-2014-0000348 MOD] |
| 3 | SET | `sodWorkMap.put(DKSV0081_DKSV0081OP_EZM0411A010BSMapper.TEMPLATEID, ezm0411A010InMap)` |
| 4 | SET | `ezm0411A010ParamMap = EZM0411A010BSMapper.editInMsg(param)` |
| 5 | CALL | `ezm0411A010ResultMap = scCall.run(ezm0411A010ParamMap, handle)` |
| 6 | SET | `param = EZM0411A010BSMapper.editResultRP(ezm0411A010ResultMap, param)` |

**Block 16** — [IF] `JDKBPCommon.hasError(param)` (L1133)

> If the device type agreement failed, throw an exception.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `throw new SCCallException("Take-home device type agreement failed", ...)` |

**Block 17** — [EXEC] Retrieve EZM0411A010 output and get domestic device subtype code (L1140-L1152)

> Gets the EZM0411A010 output. If no records or if the device subtype is not eligible for return SOD, skip.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ezm0411A010CbsMsg1List = (ArrayList) ezm0411A010OutMap.get(EZM0411A010CBSMsg.EZM0411A010CBSMSG1LIST)` |
| 2 | SET | `ezm0411A010CbsMsg = (HashMap) ezm0411A010CbsMsg1List.get(0)` |
| 3 | SET | `tkniKikiSbtCd = (String) ezm0411A010CbsMsg.get(EZM0411A010CBSMsg1List.TAKNKIKI_SBT_CD)` |

**Block 18** — [IF] `!this.checkTkniKikiSbtCd(tkniKikiSbtCd)` (L1155)

> If the domestic device subtype code is not a valid return SOD target, skip.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `continue` // Not eligible for return SOD |

**Block 19** — [EXEC] Call device provision service contract look-up (return SOD target) (L1162-L1186) [OM-2016-0000175 ADD]

> Calls EKK0341B034CBS to look up service contract details for return SOD targets. OM-2016-0000175 added the serial number to the input map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0341B034InMap = new HashMap()` |
| 2 | SET | `ekk0341B034InMap.put(EKK0341B034CBSMsg.KEY_KKTK_SVC_KEI_NO, keyKktkSvcKeiNo)` |
| 3 | SET | `ekk0341B034InMap.put(EKK0341B034CBSMsg.KEY_KK_SEIZO_NO, map.get("key_kk_seizo_no"))` [OM-2016-0000175 ADD] |
| 4 | SET | `sodWorkMap.put(DKSV0081_DKSV0081OP_EKK0341B034BSMapper.TEMPLATEID, ekk0341B034InMap)` |
| 5 | SET | `ekk0341B034ParamMap = EKK0341B034BSMapper.editInMsg(param)` |
| 6 | CALL | `ekk0341B034ResultMap = scCall.run(ekk0341B034ParamMap, handle)` |
| 7 | SET | `param = EKK0341B034BSMapper.editResultRP(ekk0341B034ResultMap, param)` |

**Block 20** — [IF] `JDKBPCommon.hasError(param)` (L1179)

> If the look-up failed, throw an exception.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `throw new SCCallException("Device provision service contract look-up (return SOD) failed", ...)` |

**Block 21** — [EXEC] Retrieve EKK0341B034 output and check record count (L1186-L1197)

| # | Type | Code |
|---|------|------|
| 1 | SET | `kk0341B034CbsMsg1List = (List) ekk0341B034OutMap.get(EKK0341B034CBSMsg.EKK0341B034CBSMSG1LIST)` |

**Block 22** — [IF] `kk0341B034CbsMsg1List.size() == 0` (L1193)

> If no records were obtained, skip.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `continue` // No records — skip |

**Block 23** — [WHILE] Check if this device is a return SOD target (L1202-L1236)

> Iterates through EKK0341B034 results to determine if the device qualifies as a return SOD target. Sets `isSod = true` if any of the following conditions match:
> - Device change number was changed (device swap has been performed and return approved)
> - Service contract is cancelled (contract status "910" or "920" = 解約 or キャンセル)
> - Model change scenario (OM-2020-0000461)

| # | Type | Code |
|---|------|------|
| 1 | SET | `isSod = false` |
| 2 | SET | `kktkSvcKeiNo = kk0341B034Map.get(KKTK_SVC_KEI_NO)` |
| 3 | SET | `kikiChgNo = kk0341B034Map.get(KIKI_CHG_NO)` |

**Block 23.1** — [IF] Device change detected (L1212)

> Same service key, but different device change number — indicates device swap was performed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `isSod = true` |
| 2 | RETURN | `break` |

**Block 23.2** — [ELSE IF] Service contract cancelled (L1219)

> Same service key AND same change number, but contract status is "910" (解約) or "920" (キャンセル).

| # | Type | Code |
|---|------|------|
| 1 | SET | `isSod = true` |
| 2 | RETURN | `break` |

**Block 23.3** — [ELSE IF] Model change scenario (L1225) [OM-2020-0000461 ADD]

> If `key_hmpin_kbn` equals `MODEL_CHANGE = "5"`, it is a model change scenario. [-> MODEL_CHANGE="5" (JDKStrConst.java:301)]

| # | Type | Code |
|---|------|------|
| 1 | SET | `isSod = true` |
| 2 | RETURN | `break` |

**Block 24** — [IF] `isSod` (L1231)

> This device IS a return SOD target. Proceed with return SOD issuance.

**Block 24.1** — [IF/ELSE] Branch by device subtype code to determine service contract number (L1241-L1382)

> **IF `tkniKikiSbtCd == "R0"` or `"S0"`** (Multi-function Router / HGW): [ANK-4315-00-00 MOD]
> - Calls EKK0081B034CBS to look up service contract number via service improvement work number [IT1-2014-0000341 ADD]
> - Selects service CD "01" (NET priority) [-> CD00130_01="01" (JKKStrConst.java:347)], or defaults to "02" (CD00130_02="02") [-> CD00130_02="02" (JKKStrConst.java:350)]
> - Extracts `svcKeiNo` from the selected service contract

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0081B034InMap = new HashMap()` |
| 2 | SET | `ekk0081B034InMap.put(EKK0081B034CBSMsg.KEY_SVC_KEI_KAISEN_UCWK_NO, tmpKK0341A001Map.get(SVC_KEI_KAISEN_UCWK_NO))` |
| 3 | CALL | `scCall.run(ekk0081B034ParamMap, handle)` // EKK0081B034CBS |
| 4 | IF | `CD00130_01 = "01"` (NET priority) — select it; else if null or `CD00130_02 = "02"`, select as fallback |
| 5 | SET | `svcKeiNo = ekk0081B034CbsMsg.get(SVC_KEI_NO)` |

> **ELSE** (Non R0/S0 devices — BB Phone, UQ, Optical Phone TA, etc.):
> - Directly extract `svcKeiNo` from `tmpKK0341A001Map` [IT1-2014-0000341]

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiNo = tmpKK0341A001Map.get(SVC_KEI_NO)` |

**Block 24.2** — [EXEC] Call service contract agreement (L1384-L1403)

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0081A010InMap = new HashMap()` |
| 2 | SET | `ekk0081A010InMap.put(EKK0081A010CBSMsg.KEY_SVC_KEI_NO, svcKeiNo)` |
| 3 | CALL | `scCall.run(ekk0081A010ParamMap, handle)` // EKK0081A010CBS |
| 4 | SET | `param = EKK0081A010BSMapper.editResultRP(...)` |

**Block 24.3** — [IF] `JDKBPCommon.hasError(param)` (L1396)

> If service contract agreement failed, throw an exception.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `throw new SCCallException("Service contract agreement failed", ...)` |

**Block 24.4** — [IF] `ekk0081A010CbsMsg1List.size() == 0` (L1413)

> If no agreement records were obtained, skip.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `continue` // No records — skip |

**Block 24.5** — [EXEC] Call same transaction number acquisition (L1423-L1438)

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk1081C011InMap = new HashMap()` |
| 2 | SET | `sodWorkMap.put(DKSV0081_DKSV0081OP_EKK1081C011BSMapper.TEMPLATEID, ekk1081C011InMap)` |
| 3 | CALL | `scCall.run(ekk1081C011ParamMap, handle)` // EKK1081C011CBS |
| 4 | SET | `sameTrnNo = (String) sodWorkMap.get(...).get(SAME_TRN_NO)` |

**Block 25** — [IF] `tkniKikiSbtCd == "50"` (Optical Phone TA) (L1442)

> Register TA cancellation and deletion conditions for Optical Phone TA devices.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `this.insertOdrHakkoJoken(map, tmpKK0341A001Map, "2", "20", "03", sameTrnNo, ...)` // TA cancellation condition |
| 2 | CALL | `this.insertOdrInfSksiWk("215", handle, param, scCall)` // TA cancellation work record |
| 3 | CALL | `this.insertOdrHakkoJoken(map, tmpKK0341A001Map, "2", "20", "08", sameTrnNo, ...)` // TA deletion condition |
| 4 | CALL | `this.insertOdrInfSksiWk("216", handle, param, scCall)` // TA deletion work record |

**Block 26** — [ELSE IF] `tkniKikiSbtCd == "F0"` (BB Phone) (L1454)

> Register BB Phone cancellation and deletion conditions.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `this.insertOdrHakkoJoken(map, tmpKK0341A001Map, "1", "0A", "03", sameTrnNo, ...)` // BB Phone cancellation |
| 2 | CALL | `this.insertOdrInfSksiWk("149", handle, param, scCall)` // BB Phone cancellation work |
| 3 | CALL | `this.insertOdrHakkoJoken(map, tmpKK0341A001Map, "1", "0A", "08", sameTrnNo, ...)` // BB Phone deletion |
| 4 | CALL | `this.insertOdrInfSksiWk("150", handle, param, scCall)` // BB Phone deletion work |

**Block 27** — [ELSE IF] `tkniKikiSbtCd == "J0"` (UQ) (L1466)

> Call service contract detail list look-up (new in IT1-2014-0000368 ADD), then register UQ cancellation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0161B004InMap = new HashMap()` [IT1-2014-0000368 ADD] |
| 2 | SET | `ekk0161B004InMap.put(EKK0161B004CBSMsg.KEY_SVC_KEI_NO, svcKeiNo)` |
| 3 | CALL | `scCall.run(ekk0161B004ParamMap, handle)` // EKK0161B004CBS — Service contract detail list |
| 4 | CALL | `this.insertOdrHakkoJoken(map, tmpKK0341A001Map, "3", "02", "03", sameTrnNo, ...)` // UQ cancellation |
| 5 | CALL | `this.insertOdrInfSksiWk("309", handle, param, scCall)` // UQ cancellation work |

**Block 28** — [ELSE IF] `tkniKikiSbtCd == "R0"` or `"S0"` (Multi-function Router / HGW) [ANK-4315-00-00 MOD]

> **IF R0 (Multi-function Router) or S0 (HGW)**: [-> TAKNKIKI_SBT_CD_TAKINORT="R0" (JKKStrConst.java:2980)] [-> TAKNKIKI_SBT_CD_HGW="S0" (JKKStrConst.java:2616)]

> Call service contract detail list look-up, then call device option service contract list look-up, and register multi-function router cancellation/deletion.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0161B004InMap = new HashMap()` [IT1-2014-0000368 ADD] |
| 2 | CALL | `scCall.run(ekk0161B004ParamMap, handle)` // Service contract detail list |
| 3 | SET | `ekk2811B010InMap = new HashMap()` |
| 4 | SET | `ekk2811B010InMap.put(EKK2811B010CBSMsg.KEY_KKTK_SVC_KEI_NO, tmpKK0341A001Map.get(KKTK_SVC_KEI_NO))` |
| 5 | CALL | `scCall.run(ekk2811B010ParamMap, handle)` // Device option service contract list |
| 6 | CALL | `this.insertOdrHakkoJoken(map, tmpKK0341A001Map, "2", "26", "03", sameTrnNo, ...)` // MFR cancellation |
| 7 | CALL | `this.insertOdrInfSksiWk("423", handle, param, scCall)` // MFR cancellation work |
| 8 | CALL | `this.insertOdrHakkoJoken(map, tmpKK0341A001Map, "2", "26", "08", sameTrnNo, ...)` // MFR deletion |
| 9 | CALL | `this.insertOdrInfSksiWk("424", handle, param, scCall)` // MFR deletion work |

**Block 29** — [EXEC] Clear SOD work area after each device processing (L1572)

> After processing each device (whether it was a return SOD target or not), clear the SOD work area to prepare for the next device.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `sodWorkMap.clear()` // Clear SOD work area |

**Block 30** — [EXEC] Remove SOD work area from work map (L1574)

> After all devices are processed, remove the SOD work area from the work map.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `workMap.remove(sodWorkMap)` // Remove SOD work area |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| SOD | Acronym | Service Order Data — a telecom order fulfillment entity that tracks device return processing |
| Return SOD | Business term | Service Order Data issued specifically for returned equipment, triggering downstream cancellation workflows |
| `kikiSeizoNo` | Field | Device manufacturing serial number — unique hardware identifier for each piece of equipment |
| `key_kktk_svc_kei_no` | Field | Device provision service contract number — links a device to its service contract |
| `tkniKikiSbtCd` | Field | Take-home device subtype code — classifies the type of returned equipment (50=Optical Phone TA, F0=BB Phone, J0=UQ, R0=Multi-function Router, S0=HGW) |
| `geneAddDtm` | Field | Generation add timestamp — timestamp used to match current service contract state against historical changes |
| `sameTrnNo` | Field | Same transaction number — a shared transaction ID used across related order issuance operations |
| `svcKeiNo` | Field | Service contract number — the primary identifier for a customer's service contract |
| `svc_kei_kaisen_ucwk_no` | Field | Service detail improvement work number — internal tracking ID for service contract improvement/change processing |
| `kiki_chg_no` | Field | Device change number — tracks when a device has been swapped (different value = device was changed) |
| `kktk_svc_kei_stat` | Field | Device provision service contract status — e.g., "910" = 解約 (cancelled), "920" = キャンセル (cancellation) |
| `key_hmpin_kbn` | Field | Return type classification — "5" (MODEL_CHANGE) indicates a model change/swap scenario |
| `tkMdlCd` | Field | Take-home device model code — model identifier for take-home equipment |
| CD00130_01 | Constant | "01" — NET priority service code used when selecting service contract number for R0/S0 devices |
| CD00130_02 | Constant | "02" — Fallback service code when NET priority is not available |
| TAKNKIKI_SBT_CD_TAKINORT | Constant | "R0" — Multi-function Router (multifunction router with take-home function) |
| TAKNKIKI_SBT_CD_HGW | Constant | "S0" — HGW (Home Gateway) device subtype |
| MODEL_CHANGE | Constant | "5" — Model change return classification flag (OM-2020-0000461) |
| SOD_WORKAREA_KEY | Constant | "SODWORK" — Key used to store the SOD work area within the param mapping work area |
| DKSV008101CC | Constant | CC class identifier for screen DKSV0081 data |
| KKTK_SVC_KEI_NO | Constant | "kktk_svc_kei_no" — Map key for device provision service contract number |
| KIKI_CHG_NO | Constant | "kiki_chg_no" — Map key for device change number |
| SOD | Acronym | Service Order Data — Fujitsu's internal term for telecom order fulfillment records |
| EKK | Acronym | Entity Key (prefix for Service Component class names, e.g., EKK0341B001CBS) |
| EZM | Acronym | Entity prefix (prefix for EZM-type Service Component class names) |
| CBS | Acronym | Component Business Service — backend service component executed via `scCall.run()` |
| BSMapper | Acronym | Business Service Mapper — class that maps between param and CBS input/output |
| insertOdrHakkoJoken | Method | Creates order issuance condition records in the order condition table |
| insertOdrInfSksiWk | Method | Creates order information creation work records in the order information work table |
| 解約 | Japanese term | Contract cancellation — customer has cancelled their service contract |
| キャンセル | Japanese term | Cancellation — pending or processed cancellation status |
