# Business Logic — JKKUseStpRlsRunCC.executeUseStpRlsChshtMain() [77 LOC]

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

## 1. Role

### JKKUseStpRlsRunCC.executeUseStpRlsChshtMain()

This method is the **core orchestration entry point for the Service Suspension Release (利停解除) target extraction process** within the K-Opticom customer base system. Specifically, it determines which service contracts should be released from a suspension state, based on a given billing contract number. It delegates the billing front lookup to an SIF-based Service Component (`EKK0321B002SC`) that queries the system's billing data to retrieve the full list of service contracts associated with the specified billing contract. The method then iterates over those service contracts, filters out any entries lacking a valid service contract number, and assembles a list of `{serviceContractNo, billingContractNo}` pairs as the final result. This list is then written back into the request parameter object for consumption by downstream processing — such as invoking the actual suspension release business logic. The method follows a **gate-and-route design pattern**: it first validates the input (billing contract number presence), then calls out to an external SIF service, checks whether the service returned any data, and only proceeds with contract-level processing if both preconditions are satisfied. It plays a **shared utility role** — called by `chshtUseStpRlsSvc()` — and serves as the data preparation layer for the broader suspension release workflow.

## 2. Processing Pattern (Detailed Business Logic)

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

    START --> INIT["Initialize: statusCode=0, resultHash=empty, svcKeiNoList=empty"]

    INIT --> CHECK_SEIKY["Extract chsht_seiky_kei_no from requestParam"]

    CHECK_SEIKY --> SEIKY_NULL{chsht_seiky_kei_no == null or empty}

    SEIKY_NULL -->|Yes| EARLY_RETURN_MAP["Map empty svcKeiNoList into chsht_use_stp_map"]
    EARLY_RETURN_MAP --> EARLY_RETURN["Return 0"]

    SEIKY_NULL -->|No| CALL_SVC["Call getEKK0321B002SC"]

    CALL_SVC --> SIF_QUERY["SIF call: EKK0321B002 - Billing Front Lookup"]

    SIF_QUERY --> SVC_STATUS{statusCode != 0}

    SVC_STATUS -->|Yes| SVC_ERROR["Return statusCode"]

    SVC_STATUS -->|No| EXTRACT_RESULT["Extract eKK0321B002HashList from resultHash"]

    EXTRACT_RESULT --> LIST_SIZE{eKK0321B002HashList.size == 0}

    LIST_SIZE -->|Yes| NO_RESULT_MAP["Map empty svcKeiNoList into result map"]
    NO_RESULT_MAP --> NO_RESULT_RETURN["Return 0"]

    LIST_SIZE -->|No| FOR_LOOP["Loop through eKK0321B002HashList"]

    FOR_LOOP --> GET_HASH["Get entry at index i"]

    GET_HASH --> GET_SVC["Extract svc_kei_no from entry"]

    GET_SVC --> SVC_NULL{svc_kei_no == null or empty}

    SVC_NULL -->|Yes| NEXT_ITER["Continue to next iteration"]

    SVC_NULL -->|No| BUILD_INFO["Build svc_kei_info with SVC_KEI_NO and SEIKY_KEI_NO"]

    BUILD_INFO --> ADD_LIST["Add svc_kei_info to svcKeiNoList"]

    ADD_LIST --> LOOP_CHECK{i < list size}

    LOOP_CHECK -->|Yes| GET_HASH

    LOOP_CHECK -->|No| FINAL_MAP["Build chsht_use_stp_rls_map"]

    FINAL_MAP --> MAP_RESULT["Set result via param.setData"]

    MAP_RESULT --> SUCCESS_RETURN["Return 0"]
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | The session manager handle that carries database connections, transaction context, and runtime configuration needed by downstream SIF calls. |
| 2 | `param` | `IRequestParameterReadWrite` | The request/response parameter container that carries model groups and control maps. This method writes its result (the list of service contracts to release) into this object via `setData()`, making it accessible to the calling screen or business component. |
| 3 | `requestParam` | `HashMap<String, Object>` | The incoming request payload. It contains the **billing contract number** (`SEIKY_KEI_NO` → `"seiky_kei_no"`) that identifies which customer billing account to look up for release-eligible service contracts. |
| 4 | `fixedText` | `String` | A user-specified arbitrary string (typically a screen-specific trace key or identifier) used as the map key when writing results back into `param.setData()`. It ensures the result is stored under a predictable key that the caller expects. |

**External state / fields read:**
| Field | Type | Business Description |
|-------|------|---------------------|
| `SEIKY_KEI_NO` | `static final String` = `"seiky_kei_no"` | The map key used to retrieve the billing contract number from `requestParam`. |
| `SVC_KEI_NO_LIST` | `static final String` = `"svc_kei_no_list"` | The map key under which the resulting list of `{serviceContractNo, billingContractNo}` pairs is stored in `param`. |
| `SVC_KEI_NO` | `static final String` = `"svc_kei_no"` | The map key used when building each service contract info entry. |
| `TEMPLATE_ID_EKK0321B002` | `static final String` = `"EKK0321B002"` | The template ID key used to extract the billing lookup result list from `resultHash`. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `getEKK0321B002SC` | EKK0321B002SC | KK_T_SEIKY_KETUYAKU (billing contract), KK_T_SVC_KETUYAKU (service contract) | Reads service contracts linked to the specified billing contract number via SIF call EKK0321B002 (Billing Front Lookup — 課金先一覧照会). Returns list of `{billingContractNo, serviceContractNo, billingNo, serviceContractStatus}` tuples. |
| U | `JBSbatAKKshkmRsltInfoTukiawsday.setData` | - | - | Sets data in JBSbatAKKshkmRsltInfoTukiawsday result object |
| U | `JBSbatAKKshkmRsltInfoTukiaws.setData` | - | - | Sets data in JBSbatAKKshkmRsltInfoTukiaws result object |
| U | `JBSbatAKKshkmRsltInfoTukiawsRealSkh.setData` | - | - | Sets data in JBSbatAKKshkmRsltInfoTukiawsRealSkh result object |
| U | `JBSbatAKKshkmRsltInfTkCvsNCnsl.setData` | - | - | Sets data in JBSbatAKKshkmRsltInfTkCvsNCnsl result object |
| U | `JBSbatKKGetCTITelno.setData` | - | - | Sets data in JBSbatKKGetCTITelno result object |

### Additional CRUD from this method's direct calls:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `param.setData` | - | - | Writes the result map (`chsht_use_stp_rls_map` containing the extracted service contract list) back into the request parameter under the key specified by `fixedText`. This is a result-passing operation, not a database write. |
| U | `param.setData` (early return path) | - | - | Writes an empty service contract list back to `param` when no billing contract number is provided. |
| U | `param.setData` (empty result path) | - | - | Writes an empty service contract list back to `param` when the billing lookup returns zero contracts. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CCC — `JKKUseStpRlsRunCC.chshtUseStpRlsSvc()` | `chshtUseStpRlsSvc()` → `executeUseStpRlsChshtMain(handle, param, requestParam, fixedText)` | `getEKK0321B002SC [R] EKK0321B002 (Billing Front Lookup)` |

**Terminal operations from this method (full trace):**
- `getEKK0321B002SC` [R] EKK0321B002 — Service Component: Billing Front Lookup (課金先一覧照会) — queries billing/service contract associations.
- `param.setData` [U] — Writes extracted contract list to the request parameter (result-passing, not DB-write).

## 6. Per-Branch Detail Blocks

### Block 1 — Initialization (L511)

> Initialize all local variables: status code, result container, and the service contract list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `statusCode = 0` // SIF return status code — initialized to success (利用停止コード) |
| 2 | SET | `resultHash = new HashMap<>()` // SIF result storage container (SIF結果格納用) |
| 3 | SET | `svcKeiNoList = new ArrayList<>()` // Service contract list for release targets (サービス契約番号リスト) |

### Block 2 — Extract Billing Contract Number (L524)

> Retrieve the billing contract number from the request parameter map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `chsht_seiky_kei_no = (String)requestParam.get(SEIKY_KEI_NO)` // SEIKY_KEI_NO = "seiky_kei_no" — retrieves the billing contract number to target |

### Block 3 — Early Return: No Billing Contract Number [IF] (L527)

> If the billing contract number is missing, the method cannot proceed. It returns an empty list to signal "nothing to release."

| # | Type | Code |
|---|------|------|
| 1 | COND | `chsht_seiky_kei_no == null || "".equals(chsht_seiky_kei_no)` // Check if billing contract number is absent |
| 2 | SET | `chsht_use_stp_map = new HashMap<>()` // Create result map (抽出請求契約番号なしの場合) |
| 3 | EXEC | `chsht_use_stp_map.put(SVC_KEI_NO_LIST, svcKeiNoList)` // SVC_KEI_NO_LIST = "svc_kei_no_list" — puts empty list |
| 4 | EXEC | `param.setData(fixedText, chsht_use_stp_map)` // Writes empty result to parameter |
| 5 | RETURN | `return 0` // Early return — no billing contract to process |

### Block 4 — Call Billing Front Lookup SIF [CALL] (L536)

> Invoke the SIF-based service component to query billing front data for the given billing contract. This performs the core data retrieval.

| # | Type | Code |
|---|------|------|
| 1 | SET | `statusCode = getEKK0321B002SC(param, handle, requestParam, resultHash)` // Calls SIF: EKK0321B002 (課金先一覧照会 — Billing Front Lookup) |

### Block 5 — Error Propagation [IF] (L537)

> If the SIF call returns a non-zero status code, propagate the error immediately without further processing.

| # | Type | Code |
|---|------|------|
| 1 | COND | `statusCode != 0` // Check if SIF call encountered an error |
| 2 | RETURN | `return statusCode` // Error propagation — caller handles the status |

### Block 6 — Extract SIF Result List (L542)

> Cast the SIF result from `resultHash` into the typed list of contract entries.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0321B002HashList = (ArrayList<HashMap<String, Object>>)resultHash.get(TEMPLATE_ID_EKK0321B002)` // TEMPLATE_ID_EKK0321B002 = "EKK0321B002" |

### Block 7 — Early Return: No Contracts Found [IF] (L547)

> If the billing lookup returned zero contracts, return an empty list — there is nothing to release.

| # | Type | Code |
|---|------|------|
| 1 | COND | `eKK0321B002HashList.size() == 0` // No service contracts linked to this billing contract |
| 2 | SET | `chsht_use_stp_map = new HashMap<>()` // Create result map |
| 3 | EXEC | `chsht_use_stp_map.put(SVC_KEI_NO_LIST, svcKeiNoList)` // SVC_KEI_NO_LIST = "svc_kei_no_list" — still empty |
| 4 | EXEC | `param.setData(fixedText, chsht_use_stp_map)` // Writes empty result |
| 5 | RETURN | `return 0` // Success with empty result — no contracts to release |

### Block 8 — Iterate Over Service Contracts [FOR] (L552)

> Loop through each service contract entry returned by the billing lookup, validate the service contract number, and build the result list.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for(int i = 0; i < eKK0321B002HashList.size(); i++)` // Loop: extract each contract entry |
| 2 | SET | `eKK0321B002Hash = eKK0321B002HashList.get(i)` // Get entry at index i |

#### Block 8.1 — Extract Service Contract Number (L556)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svc_kei_no = (String)eKK0321B002Hash.get(EKK0321B002CBSMsg1List.SVC_KEI_NO)` // SVC_KEI_NO = "svc_kei_no" |

#### Block 8.2 — Skip Entry If No Service Contract Number [IF] (L559)

> If a returned entry lacks a valid service contract number, skip it. This is a defensive filter against malformed or partial results.

| # | Type | Code |
|---|------|------|
| 1 | COND | `svc_kei_no == null || "".equals(svc_kei_no)` // Invalid or missing service contract number |
| 2 | EXEC | `continue` // Skip to next iteration — this entry is not a valid release target |

#### Block 8.3 — Build Service Contract Info [ELSE-implicit] (L564)

> Construct a map entry containing both the service contract number and the billing contract number, then add it to the result list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svc_kei_info = new HashMap<>()` // Create new contract info map (サービス契約情報生成) |
| 2 | SET | `svc_kei_info.put(SVC_KEI_NO, svc_kei_no)` // SVC_KEI_NO = "svc_kei_no" |
| 3 | SET | `svc_kei_info.put(SEIKY_KEI_NO, chsht_seiky_kei_no)` // SEIKY_KEI_NO = "seiky_kei_no" — links back to billing contract |
| 4 | EXEC | `svcKeiNoList.add(svc_kei_info)` // Add validated entry to result list (サービス契約情報追加) |

### Block 9 — Write Final Result (L574)

> After the loop completes, assemble the final result map and write it to the parameter object for the caller.

| # | Type | Code |
|---|------|------|
| 1 | SET | `chsht_use_stp_rls_map = new HashMap<>()` // Create final result map (抽出結果書き戻し) |
| 2 | SET | `chsht_use_stp_rls_map.put(SVC_KEI_NO_LIST, svcKeiNoList)` // SVC_KEI_NO_LIST = "svc_kei_no_list" — puts the populated list |
| 3 | EXEC | `param.setData(fixedText, chsht_use_stp_rls_map)` // Writes final result to parameter for caller consumption |

### Block 10 — Success Return (L577)

> Return success status code.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return 0` // Normal completion — 正常 |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `chsht_seiky_kei_no` | Field | Billing contract number — the parent contract identifier under which multiple service contracts are billed together. Also written as 請求契約番号. |
| `svc_kei_no` | Field | Service contract number — the unique identifier for an individual service contract (e.g., an internet service line, TV service line). Also written as サービス契約番号. |
| `svc_kei_no_list` | Field | Service contract list — the key name used to store the result list of `{serviceContractNo, billingContractNo}` pairs in the parameter map. |
| `SEIKY_KEI_NO` | Constant | Map key `"seiky_kei_no"` — used to access the billing contract number from request payloads. |
| `SVC_KEI_NO` | Constant | Map key `"svc_kei_no"` — used to access the service contract number from data entries. |
| `SVC_KEI_NO_LIST` | Constant | Map key `"svc_kei_no_list"` — used to store the extracted service contract list in result maps. |
| `TEMPLATE_ID_EKK0321B002` | Constant | String `"EKK0321B002"` — the template ID used to extract results from the SIF response hash map. |
| EKK0321B002 | SIF ID | Billing Front Lookup (課金先一覧照会) — the SIF call that retrieves the association between billing contracts and their constituent service contracts. |
| EKK0321B002CBSMsg | Message Class | SIF message class for EKK0321B002 — defines the schema for the billing front lookup request and response. |
| EKK0321B002CBSMsg1List | Message Class | SIF message detail class — defines the structure of each returned contract entry (seiky_kei_no, svc_kei_no, kakins_no, svc_kei_stat, etc.). |
| K-Opticom | Business term | A Japanese telecommunications service provider (fiber-optic broadband, TV, fixed-line phone services). |
| 課金先一覧照会 | Business term | Billing Front Lookup — the business process of querying all service contracts linked to a specific billing account. |
| 利用停止解除 | Business term | Service Suspension Release — the process of lifting a previously imposed service suspension, restoring full service functionality. |
| 請求契約番号 | Business term | Billing Contract Number — the contract number under which multiple service lines are aggregated for billing purposes. |
| サービス契約番号 | Business term | Service Contract Number — the unique identifier for an individual telecommunication service line (internet, TV, phone, etc.). |
| SessionHandle | Technical term | The runtime session handle carrying database connection, transaction context, and configuration for service component invocations. |
| IRequestParameterReadWrite | Technical term | The request/response parameter interface used to pass data between screens, business components, and service components. |
| CAANMsg | Technical term | K-Opticom's message container class for SIF-based service component communication — wraps request and response data. |
| ServiceComponentRequestInvoker | Technical term | The SIF invocation framework class used to execute remote service component calls and retrieve results. |
