# Business Logic — JKKUseStpRunCC.hakkoSodUcwk() [81 LOC]

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

## 1. Role

### JKKUseStpRunCC.hakkoSodUcwk()

This method determines whether a Service Order Data (SOD) issuance must be executed during a number change (番号切替 — "bangou setsubi") workflow, specifically when the service contract is already concluded (締結済) but a number change operation is in progress. It acts as a gatekeeper in the telecom service contract change system, ensuring that SOD is only issued when the customer's number portability (番ポ — "banpo") work status falls within an acceptable window: after SOD has already been issued (status 040) but before the number portability work has been cancelled (status 090). The method first validates that the processing group is a telecom service (`prc_grp_cd = "10"`), then verifies the service contract detail is in concluded status (`030`) and that the post-contract change flag is set to "in progress" (`1`). It queries the current number portability work state via a service component call and, if the conditions warrant SOD issuance, constructs an SOD data object containing system ID, service contract numbers, and generation timestamp, which is appended to the caller's data list. This routing/dispatch pattern ensures that already-concluded contracts undergoing number changes are correctly handled without duplicating or skipping required order processing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["hakkoSodUcwk params"])
    CHECK_TELECOM{prc_grp_cd equals PRC_GRP_CD_TEL?}
    GET_EKK0081A010["Get eKK0081A010Hash from resultHash"]
    EXTRACT_FIELDS["Extract fields from eKK0081A010Hash and eKK0161B004Hash"]
    SET_SVC_KEI_NO["Set svc_kei_no from eKK0081A010Hash"]
    SET_SVC_KEI_UCWK_NO["Set svc_kei_ucwk_no from eKK0161B004Hash"]
    SET_SVC_KEI_UCWK_STAT["Set svc_kei_ucwk_stat from eKK0161B004Hash"]
    SET_KZK_AF_KEI_CHG_FLG["Set kzkAfKeiChgFlg from eKK0161B004Hash"]
    CHECK_STAT{svc_kei_ucwk_stat equals 030?}
    CHECK_FLAG{KEIZK_AF_KEI_FLG_1 equals kzkAfKeiChgFlg?}
    CALL_ETU["callETU0011B018SC"]
    GET_RESULT["eTU0011B018HashList from resultHash"]
    CHECK_LIST{list not null and not empty?}
    GET_SVC_INFO["bmpHash = getSvcKeiUcwkInfo"]
    CHECK_BMP{bmpHash not null?}
    GET_BMP_STAT["bmpKojiStat from bmpHash"]
    CHECK_BMP_STAT{stat 040 <= bmpKojiStat < 090?}
    SET_HAKKO_SOD["hakkoSod = true"]
    CHECK_HAKKO{hakkoSod true?}
    CREATE_SOD_DATA["SODData = new HashMap"]
    SET_SYSID["SODData put INFO_SYSID"]
    SET_SVC_NO["SODData put INFO_SVC_KEI_NO"]
    SET_SVC_UCWK["SODData put INFO_SVC_KEI_UCWK_NO"]
    SET_GENE_DTM["SODData put INFO_CHAF_SVC_KEI_UCWK_GENE_ADD_DTM"]
    ADD_TO_LIST["hakkoSODDataList add SODData"]
    END_NODE(["Return void"])

    START --> CHECK_TELECOM
    CHECK_TELECOM -- No, return --> END_NODE
    CHECK_TELECOM -- Yes --> GET_EKK0081A010
    GET_EKK0081A010 --> EXTRACT_FIELDS
    EXTRACT_FIELDS --> SET_SVC_KEI_NO
    SET_SVC_KEI_NO --> SET_SVC_KEI_UCWK_NO
    SET_SVC_KEI_UCWK_NO --> SET_SVC_KEI_UCWK_STAT
    SET_SVC_KEI_UCWK_STAT --> SET_KZK_AF_KEI_CHG_FLG
    SET_KZK_AF_KEI_CHG_FLG --> CHECK_STAT
    CHECK_STAT -- No, return --> END_NODE
    CHECK_STAT -- Yes --> CHECK_FLAG
    CHECK_FLAG -- No, return --> END_NODE
    CHECK_FLAG -- Yes --> CALL_ETU
    CALL_ETU --> GET_RESULT
    GET_RESULT --> CHECK_LIST
    CHECK_LIST -- No --> END_NODE
    CHECK_LIST -- Yes --> GET_SVC_INFO
    GET_SVC_INFO --> CHECK_BMP
    CHECK_BMP -- No --> END_NODE
    CHECK_BMP -- Yes --> GET_BMP_STAT
    GET_BMP_STAT --> CHECK_BMP_STAT
    CHECK_BMP_STAT -- No --> END_NODE
    CHECK_BMP_STAT -- Yes --> SET_HAKKO_SOD
    SET_HAKKO_SOD --> CHECK_HAKKO
    CHECK_HAKKO -- No --> END_NODE
    CHECK_HAKKO -- Yes --> CREATE_SOD_DATA
    CREATE_SOD_DATA --> SET_SYSID
    SET_SYSID --> SET_SVC_NO
    SET_SVC_NO --> SET_SVC_UCWK
    SET_SVC_UCWK --> SET_GENE_DTM
    SET_GENE_DTM --> ADD_TO_LIST
    ADD_TO_LIST --> END_NODE
```

**Processing Flow Summary:**

1. **Telecom Filter:** Immediately returns if `prc_grp_cd` is not telecom (`"10"`). Non-telecom processing groups are irrelevant to this number change SOD logic.
2. **Data Extraction:** Retrieves the EKK0081A010 hash from `resultHash`, then extracts the service contract number, service contract detail number, service contract detail status, and post-contract change flag from the EKK0161B004 hash.
3. **Status Gate:** If `svc_kei_ucwk_stat` is not `"030"` (service contract detail status: concluded), the method returns — only concluded contracts are eligible.
4. **Change-in-Progress Gate:** If the post-contract change flag (`kzkAfKeiChgFlg`) is not `"1"` (change-in-progress), the method returns — only contracts actively undergoing change are processed.
5. **Number Portability Query:** Calls `callETU0011B018SC` with the service contract number and visit purpose codes for "list" (`"1"`) and "update" (`"2"`).
6. **Work Status Evaluation:** Retrieves the number portability work list from `resultHash`. For each work item found, gets the work status and checks if it falls within the acceptable range: >= `"040"` (SOD issued) AND < `"090"` (number portability work cancelled).
7. **SOD Data Assembly:** If `hakkoSod` is `true`, constructs an SOD data map with system ID, service contract number, service contract detail number, and generation/addition timestamp, then appends it to `hakkoSODDataList`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Request/response parameter interface used to read and write business data during processing. Carries the input request context and is passed to called service components. |
| 2 | `handle` | `SessionHandle` | Database session handle providing transaction and connection context. Passed through to service component calls for DB access. |
| 3 | `requestParam` | `HashMap<String, Object>` | Input parameters map carrying the originating request data. Extracted for context but primarily the EKK0081A010 data is pulled from `resultHash` instead. |
| 4 | `resultHash` | `HashMap<String, Object>` | Output results container populated by prior processing steps. Contains the EKK0081A010 service contract hash and is used to store the ETU0011B018 number portability work list after the service call. |
| 5 | `eKK0161B004Hash` | `HashMap<String, Object>` | Service contract detail hash containing the service contract detail number, status, and post-contract change flag. This is the primary source for determining the contract's current state. |
| 6 | `prc_grp_cd` | `String` | Processing group code that classifies the type of processing being performed. When equal to `"10"` (telecom, PRC_GRP_CD_TEL), the number change SOD logic applies; otherwise, the method returns immediately as non-telecom processing is out of scope. |
| 7 | `hakkoSODDataList` | `ArrayList<HashMap<String, Object>>` | Output list that accumulates SOD data objects to be issued. If the method determines SOD should be issued, a new map with system ID, service numbers, and timestamp is appended here for downstream processing. |

**External state accessed:**
- `resultHash` — also written to (populated with ETU0011B018 results by the called `callETU0011B018SC` method).

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callETU0011B018SC` | ETU0011B018SC | Number portability work tables (ETU0011B018) | Queries number portability work information for the given service contract number. Visit purpose codes are "list" (番_props 一覧) and "update" (番_props 更新). Results stored in `resultHash` under template ID `ETU0011B018`. |
| R | `getSvcKeiUcwkInfo` | JKKUseStpRunCC | - (in-memory search) | Searches within the `eTU0011B018HashList` for a matching record by `SVC_KEI_UCWK_NO`. Returns a `HashMap` with the number portability work details or `null` if not found. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKUseStpRunCC.svcKei_UseStp()` | `svcKei_UseStp` -> `hakkoSodUcwk` | `callETU0011B018SC [R] Number Portability Work`; `getSvcKeiUcwkInfo [R] In-memory List Search` |

**Caller Details:**
- **`JKKUseStpRunCC.svcKei_UseStp()`**: The primary caller. This method handles the "service contract use status" processing workflow and invokes `hakkoSodUcwk` to determine whether SOD issuance is required during number change operations. The `prc_grp_cd` parameter passed from the caller determines whether this method processes anything (must be telecom group `"10"`).

## 6. Per-Branch Detail Blocks

### Block 1 — IF (guard: non-telecom early return) (L1253)

> If `prc_grp_cd` does NOT equal the telecom processing group code, the method returns immediately. Non-telecom processing groups have no relevance to number portability SOD issuance.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!PRC_GRP_CD_TEL.equals(prc_grp_cd)` [-> PRC_GRP_CD_TEL="10"] |
| 2 | RETURN | `return;` // Non-telecom group — out of scope |

### Block 2 — Data Extraction (L1259–1267)

> Retrieves and extracts key fields from the result hash and service contract detail hash.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0081A010Hash = (HashMap)resultHash.get(TEMPLATE_ID_EKK0081A010)` [-> TEMPLATE_ID_EKK0081A010="EKK0081A010"] |
| 2 | SET | `svc_kei_no = (String)eKK0081A010Hash.get(EKK0081A010CBSMsg1List.SVC_KEI_NO)` // Service contract number |
| 3 | SET | `svc_kei_ucwk_no = (String)eKK0161B004Hash.get(EKK0161B004CBSMsg1List.SVC_KEI_UCWK_NO)` // Service contract detail number |
| 4 | SET | `svc_kei_ucwk_stat = (String)eKK0161B004Hash.get(EKK0161B004CBSMsg1List.SVC_KEI_UCWK_STAT)` // Service contract detail status |
| 5 | SET | `kzkAfKeiChgFlg = (String)eKK0161B004Hash.get(EKK0161B004CBSMsg1List.KEIZK_AF_KEI_CHGECHU_FLG)` // Post-contract change in-progress flag |

### Block 3 — IF (status gate: only concluded contracts) (L1270)

> If the service contract detail status is NOT `"030"` (concluded), the method returns. Only concluded service contracts are eligible for number change SOD processing.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!JKKSvcConst.SVC_KEI_STAT_030.equals(svc_kei_ucwk_stat)` [-> SVC_KEI_STAT_030="030"] |
| 2 | RETURN | `return;` // Status is not concluded — out of scope |

### Block 4 — IF (change-in-progress gate) (L1276)

> If the post-contract change flag is NOT `"1"` (change-in-progress), the method returns. Only contracts actively in the change process are processed.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!JKKSvcConst.KEIZK_AF_KEI_FLG_1.equals(kzkAfKeiChgFlg)` [-> KEIZK_AF_KEI_FLG_1="1"] |
| 2 | RETURN | `return;` // Not in change process — out of scope |

### Block 5 — EXEC (number portability work query) (L1283–1288)

> Calls the ETU0011B018 service component to retrieve number portability work information. The visit purpose code combines "list" (`"1"`) and "update" (`"2"`) to fetch all relevant work items for the service contract.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callETU0011B018SC(param, handle, svc_kei_no, JKKSvcConst.BMP_IRAI_NAIYO_CD_ITEN + "," + JKKSvcConst.BMP_IRAI_NAIYO_CD_UPD, resultHash)` |
|   |     | [-> BMP_IRAI_NAIYO_CD_ITEN="1" (list); BMP_IRAI_NAIYO_CD_UPD="2" (update)] |

### Block 6 — Data Extraction and Condition (L1291–1292)

> Retrieves the number portability work list from the result hash, which was populated by the previous service component call.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eTU0011B018HashList = (ArrayList)resultHash.get(TEMPLATE_ID_ETU0011B018)` [-> TEMPLATE_ID_ETU0011B018="ETU0011B018"] |

### Block 7 — IF (list check) (L1293)

> If the number portability work list is null or empty, no work items exist for this contract and the method returns without further processing.

| # | Type | Code |
|---|------|------|
| 1 | IF | `eTU0011B018HashList != null && !eTU0011B018HashList.isEmpty()` |
| 2 | EXEC | `bmpHash = getSvcKeiUcwkInfo(svc_kei_ucwk_no, eTU0011B018HashList, ETU0011B018CBSMsg1List.SVC_KEI_UCWK_NO)` |

#### Block 7.1 — IF (bmpHash not null) (L1296)

> LT-2013-0000645: System error prevention during number change (number present -> absent) processing in the usage suspension batch. If `bmpHash` is null, the method returns without issuing SOD.

| # | Type | Code |
|---|------|------|
| 1 | IF | `null != bmpHash` |
| 2 | SET | `bmpKojiStat = (String)bmpHash.get(ETU0011B018CBSMsg1List.BMP_KOJI_STAT)` // Number portability work status |

##### Block 7.1.1 — IF (SOD issuance condition) (L1302–1303)

> Checks if the number portability work status falls within the acceptable SOD issuance window. SOD should be issued when the status is >= `"040"` (SOD issued - SOD 発行済み) AND < `"090"` (number portability work cancelled - 番_props 工事取消). This ensures SOD is issued for concluded contracts that are actively undergoing number change but have not yet had their portability work cancelled.

| # | Type | Code |
|---|------|------|
| 1 | IF | `JKKSvcConst.BMP_KOJI_STAT_SOD_HAKKOZM.compareTo(bmpKojiStat) <= 0 && JKKSvcConst.BMP_KOJI_STAT_KOJICL.compareTo(bmpKojiStat) > 0` |
|   |     | [-> BMP_KOJI_STAT_SOD_HAKKOZM="040" (SOD issued); BMP_KOJI_STAT_KOJICL="090" (work cancelled)] |
| 2 | SET | `hakkoSod = true` // SOD issuance confirmed |

**LT Reference:** LT-2013-0000645 — System error prevention during number change (number present → absent) processing in the usage suspension batch. Date: 2013/07/26.

#### Block 7.2 — (else of bmpHash null check)

> If `bmpHash` is null, no further processing occurs within this block. The method proceeds to the SOD determination check below.

### Block 8 — IF (SOD determination) (L1309)

> If `hakkoSod` is `true`, constructs an SOD data object and adds it to the output list. This is the terminal action of the method — SOD data is prepared for downstream issuance.

| # | Type | Code |
|---|------|------|
| 1 | IF | `hakkoSod` |
| 2 | SET | `SODData = new HashMap<String, Object>()` |
| 3 | SET | `SODData.put(JKKHakkoSODConstCC.INFO_SYSID, eKK0081A010Hash.get(EKK0081A010CBSMsg1List.SYSID))` [-> INFO_SYSID="sysid"] |
| 4 | SET | `SODData.put(JKKHakkoSODConstCC.INFO_SVC_KEI_NO, eKK0081A010Hash.get(EKK0081A010CBSMsg1List.SVC_KEI_NO))` [-> INFO_SVC_KEI_NO="svc_kei_no"] |
| 5 | SET | `SODData.put(JKKHakkoSODConstCC.INFO_SVC_KEI_UCWK_NO, eKK0161B004Hash.get(EKK0161C040CBSMsg.SVC_KEI_UCWK_NO))` [-> INFO_SVC_KEI_UCWK_NO="svc_kei_ucwk_no"] |
| 6 | SET | `SODData.put(JKKHakkoSODConstCC.INFO_CHAF_SVC_KEI_UCWK_GENE_ADD_DTM, eKK0161B004Hash.get(EKK0161C040CBSMsg.GENE_ADD_DTM))` [-> INFO_CHAF_SVC_KEI_UCWK_GENE_ADD_DTM="gene_add_dtm"] |
| 7 | EXEC | `hakkoSODDataList.add(SODData)` |
| 8 | RETURN | `return;` // End of method |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `prc_grp_cd` | Field | Processing group code — classifies the type of processing. `"10"` represents telecom processing. |
| `svc_kei_no` | Field | Service contract number — the primary identifier for a service contract in the telecom system. |
| `svc_kei_ucwk_no` | Field | Service contract detail number — internal tracking ID for a specific service contract line item / detail. |
| `svc_kei_ucwk_stat` | Field | Service contract detail status — indicates the state of the service contract detail (e.g., `"030"` = concluded). |
| `kzkAfKeiChgFlg` | Field | Post-contract change in-progress flag — `"1"` indicates the contract is actively undergoing change after conclusion. |
| `hakkoSod` | Field | SOD issuance flag — internal boolean determining whether a Service Order Data should be issued. |
| `bmp_koji_stat` | Field | Number portability work status — status code for the number portability work item (e.g., `"040"` = SOD already issued, `"090"` = work cancelled). |
| SOD | Acronym | Service Order Data — telecom order fulfillment record generated when a service change is processed for a concluded contract. |
| 番号切替 | Business term | Bangou setsubi — "Number change/change" — the process of changing a customer's telephone number, often involving number portability. |
| 締結済 | Business term | Teikketsu-zumi — "Concluded" — indicates the service contract has been finalized/signed. |
| 番ポ | Business term | Banpo — shorthand for "number portability" — the process of porting a telephone number between carriers. |
| PRC_GRP_CD_TEL | Constant | Telecom processing group code — value `"10"`, filters processing to telecom-specific workflows only. |
| SVC_KEI_STAT_030 | Constant | Service contract detail concluded status — value `"030"`. Only contracts with this status proceed to SOD evaluation. |
| KEIZK_AF_KEI_FLG_1 | Constant | Post-contract change in-progress flag — value `"1"`. Indicates the contract is actively being modified post-conclusion. |
| BMP_KOJI_STAT_SOD_HAKKOZM | Constant | Number portability work status: SOD already issued — value `"040"`. Lower bound of acceptable SOD issuance window. |
| BMP_KOJI_STAT_KOJICL | Constant | Number portability work status: work cancelled — value `"090"`. Upper bound (exclusive) of acceptable SOD issuance window. |
| BMP_IRAI_NAIYO_CD_ITEN | Constant | Number portability visit purpose code: list — value `"1"`. Requests listing of number portability work items. |
| BMP_IRAI_NAIYO_CD_UPD | Constant | Number portability visit purpose code: update — value `"2"`. Requests update-related number portability work items. |
| ETU0011B018 | Screen/SC | Number portability work inquiry service component — retrieves and updates number portability work information. |
| EKK0081A010 | Screen/SC | Service contract information service component — provides service contract header data including system ID. |
| EKK0161B004 | Screen/SC | Service contract detail information — provides service contract detail data including status and change flags. |
| INFO_SYSID | Constant | System ID field key in SOD data — value `"sysid"`. Identifies the system of origin for the SOD record. |
| INFO_SVC_KEI_NO | Constant | Service contract number field key in SOD data — value `"svc_kei_no"`. |
| INFO_SVC_KEI_UCWK_NO | Constant | Service contract detail number field key in SOD data — value `"svc_kei_ucwk_no"`. |
| INFO_CHAF_SVC_KEI_UCWK_GENE_ADD_DTM | Constant | Generation/addition timestamp field key in SOD data — value `"gene_add_dtm"`. Records when the SOD data was generated. |
| LT-2013-0000645 | Change ticket | System error prevention during number change (number present → absent) processing in the usage suspension batch. Implemented 2013/07/26. |
