# Business Logic — JKKOrsjgsUseStpRunCC.hakkoSodUcwk() [79 LOC]

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

## 1. Role

### JKKOrsjgsUseStpRunCC.hakkoSodUcwk()

This method determines whether a Service Order Data (SOD) document must be issued during a post-continuity contract number change (番号切替 — bangou settei) operation. In the Japanese telecom order fulfillment domain, when a customer's contract is transferred (e.g., from one entity to another or from a reseller to the main carrier) while retaining the original phone number (number porting), the system needs to decide whether a new SOD should be generated. The method first checks that the processing group is telecom (`prc_grp_cd = "10"`), that the service contract status is "completed" (`svc_kei_ucwk_stat = "030"`), and that the post-continuity contract change-in-progress flag is set (`kzkAfKeiChgFlg = "1"`). If these preconditions hold, it queries the number porting work list via `callETU0011B018SC` and inspects the porting work status (`bmp_koji_stat`). If the porting status falls between "SOD issued" (`"040"`) and "work cancelled" (`"090"`), meaning the porting is in-flight but has not yet produced an SOD, the method sets a flag and assembles a basic SOD data record — containing the system ID, service contract number, service contract line item number, and generation timestamp — appending it to the caller's `hakkoSODDataList`. This is a routing/dispatch method that implements a gate-and-collect pattern: gate decisions based on business rules, then collect SOD issuance candidates for downstream batch processing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["hakkoSodUcwk params"])
    
    START --> L955{prc_grp_cd check}
    L955 -->|No| L957_RETURN1[return - Non telecom exit]
    L955 -->|Yes| L960[Extract eKK0081A010Hash from resultHash]
    
    L960 --> L962[Extract svc_kei_no from eKK0081A010Hash]
    L962 --> L964[Extract svc_kei_ucwk_no from eKK0161B004Hash]
    L964 --> L966[Extract svc_kei_ucwk_stat from eKK0161B004Hash]
    L966 --> L968[Extract kzkAfKeiChgFlg from eKK0161B004Hash]
    
    L968 --> L973{svc_kei_ucwk_stat check}
    L973 -->|No| L975_RETURN2[return - Not completed exit]
    L973 -->|Yes| L980{kzkAfKeiChgFlg check}
    
    L980 -->|No| L982_RETURN3[return - Not in number change exit]
    L980 -->|Yes| L987[callETU0011B018SC - Number porting work list]
    
    L987 --> L990[Retrieve eTU0011B018HashList from resultHash]
    L990 --> L991{eTU0011B018HashList valid}
    
    L991 -->|No| L1012{hakkoSod check}
    L991 -->|Yes| L993[getSvcKeiUcwkInfo - Fetch porting info]
    
    L993 --> L994{bmpHash is not null}
    L994 -->|No| L1012
    L994 -->|Yes| L996[Extract bmpKojiStat from bmpHash]
    
    L996 --> L998{bmpKojiStat >= 040}
    L998 -->|No| L1012
    L998 -->|Yes| L1000{bmpKojiStat < 090}
    
    L1000 -->|No| L1012
    L1000 -->|Yes| L1002[Set hakkoSod to true]
    
    L1002 --> L1012
    L1012 -->|No| END_RETURN[Return - No SOD issuance]
    L1012 -->|Yes| L1014[Create SODData HashMap]
    
    L1014 --> L1015[Put INFO_SYSID from eKK0081A010Hash]
    L1015 --> L1016[Put INFO_SVC_KEI_NO from eKK0081A010Hash]
    L1016 --> L1017[Put INFO_SVC_KEI_UCWK_NO from eKK0161C040CBSMsg]
    L1017 --> L1018[Put INFO_CHAF_SVC_KEI_UCWK_GENE_ADD_DTM]
    L1018 --> L1019[Add SODData to hakkoSODDataList]
    L1019 --> END_RETURN2[Return - SOD data added]
```

**CRITICAL — Constant Resolution:**

| Constant | Resolved Value | Business Meaning | Source |
|----------|---------------|-----------------|--------|
| `PRC_GRP_CD_TEL` | `"10"` | Process group code for NTT Electronics Telephone (NTTエレクトロニクス電話) | [-> PRC_GRP_CD_TEL="10" (JKKSvcConst.java:114)] |
| `SVC_KEI_STAT_030` | `"030"` | Service contract work status - Completed (契約済み) | [-> SVC_KEI_STAT_030="030" (JKKSvcConst.java:354)] |
| `KEIZK_AF_KEI_FLG_1` | `"1"` | Post-continuity contract change-in-progress flag (継承後契約変更中フラグ) | [-> KEIZK_AF_KEI_FLG_1="1" (JKKSvcConst.java:2023)] |
| `BMP_IRAI_NAIYO_CD_ITEN` | `"1"` | Bitmap arrival content code - Reassignment (再着信) | [-> BMP_IRAI_NAIYO_CD_ITEN="1" (JKKSvcConst.java:1035)] |
| `BMP_IRAI_NAIYO_CD_UPD` | `"2"` | Bitmap arrival content code - Update (更新) | [-> BMP_IRAI_NAIYO_CD_UPD="2" (JKKSvcConst.java:1037)] |
| `BMP_KOJI_STAT_SOD_HAKKOZM` | `"040"` | Bitmap construction status - SOD issued/completed (SOD発行済み) | [-> BMP_KOJI_STAT_SOD_HAKKOZM="040" (JKKSvcConst.java:1931)] |
| `BMP_KOJI_STAT_KOJICL` | `"090"` | Bitmap construction status - Work cancelled (番ポ工事取消) | [-> BMP_KOJI_STAT_KOJICL="090" (JKKSvcConst.java:1939)] |
| `TEMPLATE_ID_EKK0081A010` | `"EKK0081A010"` | Template ID for service contract header information | [-> TEMPLATE_ID_EKK0081A010="EKK0081A010" (JKKHakkoSODConstCC.java:638)] |
| `TEMPLATE_ID_ETU0011B018` | `"ETU0011B018"` | Template ID for number porting work list query | [-> TEMPLATE_ID_ETU0011B018="ETU0011B018" (JKKOrsjgsUseStpRunCC.java:198)] |
| `INFO_SYSID` | `"sysid"` | SOD basic info - System ID | [-> INFO_SYSID="sysid" (JKKHakkoSODConstCC.java:68)] |
| `INFO_SVC_KEI_NO` | `"svc_kei_no"` | SOD basic info - Service contract number | [-> INFO_SVC_KEI_NO="svc_kei_no" (JKKHakkoSODConstCC.java:110)] |
| `INFO_SVC_KEI_UCWK_NO` | `"svc_kei_ucwk_no"` | SOD basic info - Service contract line item number | [-> INFO_SVC_KEI_UCWK_NO="svc_kei_ucwk_no" (JKKHakkoSODConstCC.java:122)] |
| `INFO_CHAF_SVC_KEI_UCWK_GENE_ADD_DTM` | `"chaf_svc_kei_ucwk_gene_add_dtm"` | SOD basic info - Chafed service contract line item generation/addition timestamp (世代登録年月日時刻) | [-> INFO_CHAF_SVC_KEI_UCWK_GENE_ADD_DTM="chaf_svc_kei_ucwk_gene_add_dtm" (JKKHakkoSODConstCC.java:130)] |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Request parameter object providing read/write access to the inbound request data for the current transaction. Used by called services to extract or modify request-scoped parameters. |
| 2 | `handle` | `SessionHandle` | Session handle representing the current user session and transaction context. Passed to service layer calls to maintain session state and transaction boundaries. |
| 3 | `requestParam` | `HashMap<String, Object>` | Incoming request parameters map carrying data from the calling screen/batch (e.g., service contract details, customer information). Not directly accessed by this method but passed through the call chain. |
| 4 | `resultHash` | `HashMap<String, Object>` | Output result map populated with data from previous CBS/SC calls. This method reads from it to retrieve `eKK0081A010Hash` (service contract header info) and receives the number porting work list (`eTU0011B018HashList`) from `callETU0011B018SC`. Keyed by template IDs. |
| 5 | `eKK0161B004Hash` | `HashMap<String, Object>` | Service contract line item data map pre-populated by a prior CBS call. Contains the line item number (`svc_kei_ucwk_no`), line item status (`svc_kei_ucwk_stat`), and the post-continuity contract change-in-progress flag (`keizk_af_kei_chgechu_flg`). Critical for determining if this is a post-continuity number porting scenario. |
| 6 | `prc_grp_cd` | `String` | Process group code identifying the service type. This method only processes telecom group (`"10"` — NTT Electronics Telephone). Other values cause an immediate return. |
| 7 | `hakkoSODDataList` | `ArrayList<HashMap<String, Object>>` | Output parameter — a caller-supplied list into which this method appends SOD issuance candidate records. Each record is a HashMap containing the basic SOD header information (system ID, service contract number, line item number, generation timestamp). If the method determines SOD issuance is required, it adds one entry to this list. |

**External state / instance fields:** None directly accessed. All state flows through method parameters and the result/request maps.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKOrsjgsUseStpRunCC.callETU0011B018SC` | ETU0011B018SC | - | Calls `callETU0011B018SC` in `JKKOrsjgsUseStpRunCC` to query number porting work list for the given service contract number, filtering by arrival content codes "1" (reassignment) and "2" (update). |
| R | `JKKOrsjgsUseStpRunCC.getSvcKeiUcwkInfo` | - | - | Calls `getSvcKeiUcwkInfo` in `JKKOrsjgsUseStpRunCC` to find the matching porting work record from the retrieved list by service contract line item number. |

### Full CRUD analysis from method body:

This method performs no direct Create, Update, or Delete operations. It is a **Read-only gate-and-collect** method:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callETU0011B018SC` | ETU0011B018SC | Number porting work tables (番ポ工事関連テーブル) | Queries the number porting work list for the given service contract number, requesting records with arrival content codes for reassignment (`"1"`) and update (`"2"`). Results are stored in `resultHash` under template ID `ETU0011B018`. |
| R | `getSvcKeiUcwkInfo` | - | - (in-memory search) | Performs an in-memory lookup in the porting work list returned by `callETU0011B018SC`, finding the record whose `svc_kei_ucwk_no` matches the target line item. Returns the matching HashMap or null. |
| C | `hakkoSODDataList.add()` | - | - (caller-side persistence) | When the SOD issuance gate passes, a new HashMap is created and populated with SOD basic info (system ID, service contract number, line item number, generation timestamp), then appended to the caller's list for downstream SOD generation. No DB write occurs here. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKOrsjgsUseStpRunCC.svcKei_UseStp` | `svcKei_UseStp()` -> `hakkoSodUcwk()` | `callETU0011B018SC [R] Number porting work data`, `getSvcKeiUcwkInfo [R] in-memory list search` |

**Note:** `hakkoSodUcwk` is a private method called by `svcKei_UseStp` within the same class. No public entry points or screen/batch screens directly invoke this method.

## 6. Per-Branch Detail Blocks

### Block 1 — [IF] Telecom process group check (L956)

> Check whether the processing group code corresponds to the telecom group. If not, exit immediately — the comment states 「電話以外の場合は無関係」（If not telephone, this is irrelevant）.

| # | Type | Code |
|---|------|------|
| 1 | COND | `!PRC_GRP_CD_TEL.equals(prc_grp_cd)` [-> PRC_GRP_CD_TEL="10"] |
| 2 | RETURN | `return;` // Exit if not telecom group |

### Block 2 — [PROC] Extract service contract data from maps (L960–L969)

> Retrieve the service contract header hash and extract key fields needed for subsequent validation.

| # | 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)` [-> SVC_KEI_NO="svc_kei_no"] // Service contract number |
| 3 | SET | `svc_kei_ucwk_no = (String) eKK0161B004Hash.get(EKK0161B004CBSMsg1List.SVC_KEI_UCWK_NO)` [-> SVC_KEI_UCWK_NO="svc_kei_ucwk_no"] // Service contract line item number |
| 4 | SET | `svc_kei_ucwk_stat = (String) eKK0161B004Hash.get(EKK0161B004CBSMsg1List.SVC_KEI_UCWK_STAT)` [-> SVC_KEI_UCWK_STAT="svc_kei_ucwk_stat"] // Service contract line item status |
| 5 | SET | `kzkAfKeiChgFlg = (String) eKK0161B004Hash.get(EKK0161B004CBSMsg1List.KEIZK_AF_KEI_CHGECHU_FLG)` [-> KEIZK_AF_KEI_CHGECHU_FLG="keizk_af_kei_chgechu_flg"] // Post-continuity contract change-in-progress flag |

### Block 3 — [IF] Service contract status check (L973)

> The contract must be in "completed" status (`"030"`). If not completed, the method exits. Comment: 「締結済以外対象外」（Excludes non-completed contracts）.

| # | Type | Code |
|---|------|------|
| 1 | COND | `!JKKSvcConst.SVC_KEI_STAT_030.equals(svc_kei_ucwk_stat)` [-> SVC_KEI_STAT_030="030"] |
| 2 | RETURN | `return;` // Not completed, exit |

### Block 4 — [IF] Post-continuity change flag check (L980)

> The post-continuity contract change-in-progress flag must be `"1"`. If not, the method exits. Comment: 「番号変更中でない場合対象外」（Excludes non-number-change situations）.

| # | Type | Code |
|---|------|------|
| 1 | COND | `!JKKSvcConst.KEIZK_AF_KEI_FLG_1.equals(kzkAfKeiChgFlg)` [-> KEIZK_AF_KEI_FLG_1="1"] |
| 2 | RETURN | `return;` // Not in number change, exit |

### Block 5 — [CALL] Query number porting work list (L987–L991)

> Call the service component `callETU0011B018SC` to retrieve the number porting work list. The method queries for porting records with arrival content codes for reassignment (`"1"`: 「再着信」) and update (`"2"`: 「更新」), concatenated with `","`.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callETU0011B018SC(param, handle, svc_kei_no, BMP_IRAI_NAIYO_CD_ITEN + "," + BMP_IRAI_NAIYO_CD_UPD, resultHash)` [-> ITEN="1", UPD="2"] |
| 2 | SET | `eTU0011B018HashList = (ArrayList<HashMap>) resultHash.get(TEMPLATE_ID_ETU0011B018)` [-> TEMPLATE_ID_ETU0011B018="ETU0011B018"] |

### Block 6 — [IF] Porting list validation (L991)

> Check if the porting work list exists and is not empty. If empty, skip porting status check and proceed directly to SOD issuance determination.

| # | Type | Code |
|---|------|------|
| 1 | COND | `eTU0011B018HashList != null && !eTU0011B018HashList.isEmpty()` |
| 2 | EXEC | (Branch yes: proceed to Block 7) |
| 3 | EXEC | (Branch no: skip to L1012 hakkoSod check) |

### Block 6.1 — [IF] bmpHash non-null check (L994)

> Retrieve the porting work info for the target line item. If no matching record found, skip porting status check.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `bmpHash = getSvcKeiUcwkInfo(svc_kei_ucwk_no, eTU0011B018HashList, ETU0011B018CBSMsg1List.SVC_KEI_UCWK_NO)` [-> SVC_KEI_UCWK_NO="svc_kei_ucwk_no"] |
| 2 | COND | `null != bmpHash` |
| 3 | EXEC | (Branch yes: proceed to Block 6.2) |
| 4 | EXEC | (Branch no: skip to L1012 hakkoSod check) |

### Block 6.1.1 — [IF] Porting status range check (L999–L1001)

> The porting work status must be between `"040"` (SOD issued/completed) inclusive and `"090"` (work cancelled) exclusive. In other words, the porting is in-flight but the SOD has not yet been generated. If this condition is met, set `hakkoSod = true`. Comment: 「番ポ工事ステータスが「040：SOD発行済み」以上、番ポ工事取消」未満の場合はSOD発行を実施」（If porting work status is "040: SOD issued" or above, but below "090: Porting work cancelled", execute SOD issuance）.

| # | Type | Code |
|---|------|------|
| 1 | COND | `JKKSvcConst.BMP_KOJI_STAT_SOD_HAKKOZM.compareTo(bmpKojiStat) <= 0` [-> BMP_KOJI_STAT_SOD_HAKKOZM="040"] |
| 2 | COND | `&& JKKSvcConst.BMP_KOJI_STAT_KOJICL.compareTo(bmpKojiStat) > 0` [-> BMP_KOJI_STAT_KOJICL="090"] |
| 3 | SET | `hakkoSod = true` |

### Block 7 — [IF] SOD issuance determination (L1012)

> Check the `hakkoSod` flag. If false, return without adding SOD data. If true, assemble the SOD header data record and append it to the caller's list.

| # | Type | Code |
|---|------|------|
| 1 | COND | `hakkoSod` |
| 2 | EXEC | (Branch no: return immediately — no SOD issuance) |
| 3 | EXEC | (Branch yes: proceed to Block 7.1) |

### Block 7.1 — [PROC] Build SOD data record (L1014–L1019)

> Create a new HashMap representing basic SOD header information and populate it with system ID, service contract number, service contract line item number, and generation timestamp. Then add the record to the caller's `hakkoSODDataList`. Comment: 「サービスオーダ発行CC用の情報を設定」（Set information for SOD issuance CC）.

| # | Type | Code |
|---|------|------|
| 1 | SET | `SODData = new HashMap<String, Object>()` |
| 2 | SET | `SODData.put(JKKHakkoSODConstCC.INFO_SYSID, eKK0081A010Hash.get(EKK0081A010CBSMsg1List.SYSID))` [-> INFO_SYSID="sysid", SYSID="sysid"] // SOD basic info - System ID |
| 3 | SET | `SODData.put(JKKHakkoSODConstCC.INFO_SVC_KEI_NO, eKK0081A010Hash.get(EKK0081A010CBSMsg1List.SVC_KEI_NO))` [-> INFO_SVC_KEI_NO="svc_kei_no"] // SOD basic info - Service contract number |
| 4 | 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"] // SOD basic info - Service contract line item number |
| 5 | 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="chaf_svc_kei_ucwk_gene_add_dtm"] // SOD basic info - Chafed generation timestamp |
| 6 | EXEC | `hakkoSODDataList.add(SODData)` // Append SOD data record to caller's issuance list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `prc_grp_cd` | Field | Process group code — classifies the service type (telecom, fiber, mobile, etc.). `"10"` denotes NTT Electronics Telephone. |
| `svc_kei_no` | Field | Service contract number — the top-level identifier for a customer's service agreement. |
| `svc_kei_ucwk_no` | Field | Service contract line item number — the sub-identifier for a specific line item within a service contract. |
| `svc_kei_ucwk_stat` | Field | Service contract line item status — lifecycle state of the line item (e.g., `"030"` = completed/contract finalized). |
| `kzkAfKeiChgFlg` | Field | Post-continuity contract change-in-progress flag — indicates whether a contract is being transferred/changed after continuity. `"1"` means the change is in progress. |
| `hakkoSod` | Variable | SOD issuance flag — local boolean flag indicating whether an SOD document should be generated for the current transaction. |
| `hakkoSODDataList` | Parameter | SOD issuance data list — caller-supplied output list; each entry is a HashMap of basic SOD header info for a service contract line item that requires SOD issuance. |
| `bmp_koji_stat` | Field | Bitmap construction (porting work) status — indicates the current stage of a number porting work item (e.g., `"040"` = SOD issued, `"090"` = work cancelled). |
| SOD | Acronym | Service Order Data — a telecom order fulfillment document representing the data payload for order processing. Issued when a new or modified service contract line item needs to be provisioned. |
| 番ポ | Acronym | Bangou porting (番号ポーターリング) — Number porting, the process of retaining a phone number when transferring between service providers or entities. |
| 番号切替 | Business term | Number change / number porting — the business operation of changing or retaining phone numbers during contract transfer. |
| 締結済み | Business term | Completed contract — the state where a service contract has been finalized and is ready for execution. |
| 継承後契約変更中 | Business term | Post-continuity contract change-in-progress — a contract that has been transferred (continued from a prior contract) and is currently undergoing modification. |
| 再着信 | Business term | Reassignment — arrival content code `"1"` for porting work, indicating a number is being reassigned. |
| 更新 | Business term | Update — arrival content code `"2"` for porting work, indicating an existing porting record is being updated. |
| 番ポ工事取消 | Business term | Number porting work cancellation — the state where a porting operation has been cancelled (`"090"` status). |
| NTT | Business term | Nippon Telegraph and Telephone — Japan's largest telecommunications company. In this context, NTT Electronics is a subsidiary/service provider. |
| EKK0081A010 | CBS Code | Service contract header information CBS — retrieves the main service contract record. |
| EKK0161B004 | CBS Code | Service contract line item information CBS — retrieves the line item detail record. |
| EKK0161C040 | CBS Code | Service contract line item generation data CBS — provides generation/timestamp fields for chafed (derived) line item data. |
| ETU0011B018 | SC Code | Number porting work list query SC — service component that queries the number porting work records for a given service contract. |
| chaf (chafed) | Business term | Chafed data — derived/generated data created from original source data (e.g., a child contract line item generated from a parent contract). |
| GENE_ADD_DTM | Field | Generation add date/time — timestamp when the chafed (derived) contract line item record was created. |
