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

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

## 1. Role

### JKKUseStpRunCC.chshtUseStpSvcProc()

This method is the **main entry point for service-suspension target extraction** (`利用停止対象抽出メイン処理`). Its purpose is to identify all service contracts (`svc_kei_no`) that are subordinate to a given billing invoice contract (`seiky_kei_no`), and to return a structured list of those service contracts along with their internal detail numbers. In the K-Opticom telecommunications billing system, a single billing invoice (`seiky_kei_no`) can aggregate multiple service contracts (e.g., internet, telephone, TV bundles). Before executing a service suspension (e.g., for non-payment), the system must first determine all affected service contracts under that invoice. The method implements a **gate-and-transform** pattern: it calls a billing-inquiry SC (service component) via `callEKK0321B002SC` to retrieve the invoice-to-service-contract mapping, validates the result, and then iterates over each service contract entry to build a clean list of service information objects. It supports **early-exit paths** for both missing invoice numbers and zero-result queries, avoiding unnecessary downstream processing. The method is a shared utility component called by the higher-level `chshtUseStpSvc` method and serves as a prerequisite step for any downstream suspension-execution processing.

## 2. Processing Pattern (Detailed Business Logic)

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

    START --> INIT["Initialize: statusCode=0, resultHash, svcKeiNoList"]
    INIT --> EXTRACT["Extract chsht_seiky_kei_no from requestParam"]
    EXTRACT --> CHECK_EMPTY{"Is chsht_seiky_kei_no
null or empty?"}

    CHECK_EMPTY --> |Yes| RETURN_EMPTY["Create empty result map
param.setData()
return 0"]
    RETURN_EMPTY --> END_NODE(["End"])

    CHECK_EMPTY --> |No| CALL_SC["Call callEKK0321B002SC()
Billing Prior Invoice Agreement"]
    CALL_SC --> CHECK_STATUS{"statusCode != 0
(Errors)?"}

    CHECK_STATUS --> |Yes| RETURN_ERROR["Return statusCode
(error code from SC call)"]
    RETURN_ERROR --> END_NODE

    CHECK_STATUS --> |No| GET_LIST["Get eKK0321B002HashList
from resultHash"]
    GET_LIST --> CHECK_SIZE{"Is eKK0321B002HashList
size == 0?"}

    CHECK_SIZE --> |Yes| RETURN_EMPTY_LIST["Create empty result map
param.setData()
return 0"]
    RETURN_EMPTY_LIST --> END_NODE

    CHECK_SIZE --> |No| LOOP_START["For each item in eKK0321B002HashList"]
    LOOP_START --> EXTRACT_ITEM["Extract svc_kei_no
Extract svcKeiKaisenUcwkNo"]
    EXTRACT_ITEM --> CHECK_SVC{"Is svc_kei_no
null or empty?"}

    CHECK_SVC --> |Yes| SKIP["continue
(skip to next iteration)"]
    SKIP --> LOOP_END{"More items?"}

    CHECK_SVC --> |No| BUILD_INFO["Create svc_kei_info map
Put svc_kei_no
Put SEIKY_KEI_NO (chsht_seiky_kei_no)
Put SVC_KEI_KAISEN_UCWK_NO"]
    BUILD_INFO --> ADD_LIST["Add svc_kei_info to svcKeiNoList"]
    ADD_LIST --> LOOP_END

    LOOP_END --> |Yes| LOOP_START
    LOOP_END --> |No| FINAL_WRITE["Create result map
Put svcKeiNoList
param.setData()"]
    FINAL_WRITE --> RETURN_SUCCESS["return 0"]
    RETURN_SUCCESS --> END_NODE
```

**Processing flow summary:**

1. **Initialization** — Create an empty `statusCode`, `resultHash`, and `svcKeiNoList` (the accumulating output).
2. **Invoice number extraction** — Pull `chsht_seiky_kei_no` from the `requestParam` map. If missing, return an empty list immediately (early-exit).
3. **Billing inquiry** — Call `callEKK0321B002SC` to query the billing system for the service-contract list associated with the given invoice contract number. On error, return the status code immediately (early-exit).
4. **Result extraction** — Extract the `eKK0321B002HashList` from the result hash. If empty, return an empty list (early-exit).
5. **Service contract iteration** — Loop over each entry in the result list, extracting `svc_kei_no` and `svc_kei_kaisen_ucwk_no`. Skip entries with missing service contract numbers. Build a `svc_kei_info` map per entry and accumulate into `svcKeiNoList`.
6. **Result write-back** — Write the accumulated service contract list into `param` and return `0` (success).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle carrying connection and transaction context. Used by the internal `callEKK0321B002SC` to query the billing system's service-contract mapping data. |
| 2 | `param` | `IRequestParameterReadWrite` | Request/response parameter object carrying model groups and control maps. The method writes its output (the service contract list) back to the caller via `param.setData(fixedText, chsht_use_stp_map)`. |
| 3 | `requestParam` | `HashMap<String, Object>` | Input parameter map carrying the suspension target billing invoice number (`chsht_seiky_kei_no`). The key `chsht_trgt_seiky_kei_no` ("chsht_trgt_seiky_kei_no") holds the invoice contract number that determines which service contracts to extract. |
| 4 | `fixedText` | `String` | User-specified arbitrary string used as a key/identifier when writing results back to the parameter object via `param.setData()`. Allows the caller to identify which output block this method produced. |

**Instance fields read by the method:**

| Field | Type | Value | Business Meaning |
|-------|------|-------|-----------------|
| `SVC_KEI_NO_LIST` | `String` | `"svc_kei_no_list"` | Map key for the accumulated service contract list in the result |
| `SEIKY_KEI_NO` | `String` | `"seiky_kei_no"` | Map key for the billing invoice contract number field |
| `SVC_KEI_NO` | `String` | `"svc_kei_no"` | Map key for the service contract number field |
| `SVC_KEI_KAISEN_UCWK_NO` | `String` | `"svc_kei_kaisen_ucwk_no"` | Map key for the service contract internal detail number (line-item/work detail) |
| `TEMPLATE_ID_EKK0321B002` | `String` | `"EKK0321B002"` | Template ID used to retrieve the billing prior-invoice result list from the result hash |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatAKKshkmRsltInfoTukiawsday.setData` | - | - | Calls `setData` in `JBSbatAKKshkmRsltInfoTukiawsday` |
| R | `JBSbatAKKshkmRsltInfoTukiaws.setData` | - | - | Calls `setData` in `JBSbatAKKshkmRsltInfoTukiaws` |
| R | `JBSbatAKKshkmRsltInfoTukiawsRealSkh.setData` | - | - | Calls `setData` in `JBSbatAKKshkmRsltInfoTukiawsRealSkh` |
| R | `JBSbatAKKshkmRsltInfTkCvsNCnsl.setData` | - | - | Calls `setData` in `JBSbatAKKshkmRsltInfTkCvsNCnsl` |
| R | `JBSbatKKGetCTITelno.setData` | - | - | Calls `setData` in `JBSbatKKGetCTITelno` |
| R | `JKKUseStpRunCC.callEKK0321B002SC` | EKK0321B002SC | Service-contract mapping table (KK_T_OPSVKEI_ISP / KK_T_SEIKYUKEI related) | Calls `callEKK0321B002SC` to query billing prior-invoice agreement by invoice contract number — **the primary read operation of this method** |
| - | `JKKUseStpRunCC.chshtUseStpSvcProc` (param.setData) | - | - | Writes the final result map to the request parameter object |

**Primary data source:** The method reads service-contract mappings via `callEKK0321B002SC`, which invokes the **EKK0321B002 Service Component** — the "Billing Prior Invoice Agreement (Invoice Contract Number / Service Contract Number)" inquiry. This SC looks up which service contracts belong to a given billing invoice contract, returning a list of `(seiky_kei_no, svc_kei_no)` pairs. The exact entity tables are internal to the SC and are not directly accessed by this method.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Component: JKKUseStpRunCC | `JKKUseStpRunCC.chshtUseStpSvc` -> `JKKUseStpRunCC.chshtUseStpSvcProc` | `callEKK0321B002SC [R] EKK0321B002 (Service-contract mapping inquiry)`, `param.setData [-]` |

**Instructions:**
- Caller is a shared CC (Common Component) method `chshtUseStpSvc` within the same class `JKKUseStpRunCC`. This class-level method orchestrates the broader service-suspension execution workflow.
- The `chshtUseStpSvcProc` method is called as a targeted extraction subroutine to resolve which service contracts are affected before proceeding with suspension actions.
- No direct screen (KKSV*) or batch entry points were found calling this method within 8 hops. It is an internal component used by the broader suspension execution flow.

**Terminal operations:** `setData [-]`, `setData [-]`, `setData [-]`, `setData [-]`, `setData [-]`, `callEKK0321B002SC [R]`, `setData [-]`, `setData [-]`, `setData [-]`, `setData [-]`, `setData [-]`

## 6. Per-Branch Detail Blocks

### Block 1 — INITIALIZATION (L492)

> Initialize local variables: error status code, result hash, and the service contract list accumulator.

| # | Type | Code |
|---|------|------|
| 1 | SET | `statusCode = 0` // SIF return code initialized to success [-> `SYORI_RESULT_OK = "0"`] |
| 2 | SET | `resultHash = new HashMap<String, Object>()` // S-IF result storage container |
| 3 | SET | `svcKeiNoList = new ArrayList<HashMap<String, Object>>()` // Accumulator for extracted service contracts |

---

### Block 2 — INVOICE NUMBER EXTRACTION (L504)

> Extract the suspension target billing invoice contract number from the request parameter map.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `chsht_seiky_kei_no = (String) requestParam.get(SEIKY_KEI_NO)` | Extract the billing invoice contract number. `SEIKY_KEI_NO = "seiky_kei_no"` is used as the map key. The input map key is `chsht_trgt_seiky_kei_no = "chsht_trgt_seiky_kei_no"` |

---

### Block 3 — ELSE-IF BRANCH (null or empty invoice number) (L506-L515)

> Early-exit: if no invoice contract number is provided, return an empty result. The comment states `抽出請求契約番号なしの場合` ("When there is no extraction-target billing invoice contract number").

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `chsht_use_stp_map = new HashMap<String, Object>()` | Create result map |
| 2 | SET | `chsht_use_stp_map.put(SVC_KEI_NO_LIST, svcKeiNoList)` | Put empty list into result. `SVC_KEI_NO_LIST = "svc_kei_no_list"` |
| 3 | EXEC | `param.setData(fixedText, chsht_use_stp_map)` | Write result back to caller |
| 4 | RETURN | `return 0` | Return success with empty list |

---

### Block 4 — BILLING INQUIRY SC CALL (L518-L519)

> Call the billing prior-invoice agreement service component to retrieve the service contract list for the given invoice contract number.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `statusCode = callEKK0321B002SC(param, handle, requestParam, resultHash)` | Query service contracts by invoice contract number. `callEKK0321B002SC` is a private method in `JKKUseStpRunCC` that invokes the **EKK0321B002 Service Component** |

---

### Block 5 — ELSE-IF BRANCH (SC call error) (L519-L522)

> Early-exit: if the billing inquiry SC call returned a non-zero status code, propagate the error.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return statusCode` | Propagate error status code from `callEKK0321B002SC` |

---

### Block 6 — RESULT LIST EXTRACTION (L524)

> Extract the result list from the SC's response hash under the template key.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `eKK0321B002HashList = (ArrayList<HashMap<String, Object>>) resultHash.get(TEMPLATE_ID_EKK0321B002)` | Retrieve the service contract list from the result hash. `TEMPLATE_ID_EKK0321B002 = "EKK0321B002"` |

---

### Block 7 — ELSE-IF BRANCH (zero result count) (L526-L535)

> Early-exit: if the billing inquiry returned no records, return an empty list. The comment states `0件の場合、終了` ("When 0 items, terminate").

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `chsht_use_stp_map = new HashMap<String, Object>()` | Create result map |
| 2 | SET | `chsht_use_stp_map.put(SVC_KEI_NO_LIST, svcKeiNoList)` | Put empty list |
| 3 | EXEC | `param.setData(fixedText, chsht_use_stp_map)` | Write result back |
| 4 | RETURN | `return 0` | Return success with empty list |

---

### Block 8 — FOR LOOP (L537-L562)

> Iterate over each service-contract entry returned by the billing inquiry. The comment states `課金先の取得分だけルー プ` ("Loop over the retrieved billing destination entries").

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `i = 0` | Loop counter |
| 2 | CONDITION | `i < eKK0321B002HashList.size()` | Loop condition |
| 3 | EXEC | `eKK0321B002Hash = eKK0321B002HashList.get(i)` | Get current entry |
| 4 | SET | `svc_kei_no = (String) eKK0321B002Hash.get(EKK0321B002CBSMsg1List.SVC_KEI_NO)` | Extract service contract number |
| 5 | SET | `svcKeiKaisenUcwkNo = (String) eKK0321B002Hash.get(EKK0321B002CBSMsg1List.SVC_KEI_KAISEN_UCWK_NO)` | Extract service contract internal detail number |
| 6 | CONDITION | see Block 8.1 (null/empty check) | Validate service contract number |
| 7 | SET | `svc_kei_info = new HashMap<String, Object>()` | Create info map |
| 8 | SET | `svc_kei_info.put(SVC_KEI_NO, svc_kei_no)` | Store service contract number |
| 9 | SET | `svc_kei_info.put(SEIKY_KEI_NO, chsht_seiky_kei_no)` | Store billing invoice number |
| 10 | SET | `svc_kei_info.put(SVC_KEI_KAISEN_UCWK_NO, svcKeiKaisenUcwkNo)` | Store service contract internal detail number |
| 11 | EXEC | `svcKeiNoList.add(svc_kei_info)` | Add to accumulated list |

---

#### Block 8.1 — NESTED IF (null or empty service contract number) (L544-L548)

> Skip entries with missing service contract numbers. The comment states `サービス契約番号なしの場合` ("When there is no service contract number").

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CONDITION | `svc_kei_no == null || "".equals(svc_kei_no)` | Check for missing service contract number |
| 2 | EXEC | `continue` | Skip to next iteration |

---

### Block 9 — RESULT WRITE-BACK (L564-L568)

> Write the final result and return success. The comment states `抽出結果書き込み` ("Write extraction result") and `正常` ("Normal/Success").

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `chsht_use_stp_map = new HashMap<String, Object>()` | Create result map |
| 2 | SET | `chsht_use_stp_map.put(SVC_KEI_NO_LIST, svcKeiNoList)` | Put accumulated service contract list |
| 3 | EXEC | `param.setData(fixedText, chsht_use_stp_map)` | Write result back to caller's parameter object |
| 4 | RETURN | `return 0` | Return success status code [-> `SYORI_RESULT_OK = "0"`] |

---

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|-----------------|
| `chsht_seiky_kei_no` | Field | Suspension-target billing invoice contract number — the invoice number that triggered the suspension extraction process |
| `svc_kei_no` | Field | Service contract number — unique identifier for an individual service contract (e.g., an internet plan, phone plan) |
| `svc_kei_kaisen_ucwk_no` | Field | Service contract internal detail number — a sub-identifier for service contract line items / work detail records within a service contract |
| `seiky_kei_no` | Field | Billing invoice contract number — the customer's consolidated billing invoice that aggregates multiple service contracts |
| `SVC_KEI_NO_LIST` | Constant | Map key `"svc_kei_no_list"` — key under which the output list is stored in the result map |
| `SEIKY_KEI_NO` | Constant | Map key `"seiky_kei_no"` — key for the billing invoice contract number in maps |
| `SVC_KEI_NO` | Constant | Map key `"svc_kei_no"` — key for the service contract number in maps |
| `SVC_KEI_KAISEN_UCWK_NO` | Constant | Map key `"svc_kei_kaisen_ucwk_no"` — key for the service contract internal detail number |
| `chsht_trgt_seiky_kei_no` | Constant | Map key `"chsht_trgt_seiky_kei_no"` — input key in `requestParam` for the suspension target billing invoice number |
| `TEMPLATE_ID_EKK0321B002` | Constant | Template ID `"EKK0321B002"` — template used for billing prior-invoice agreement inquiry |
| EKK0321B002SC | SC Code | Billing Prior Invoice Agreement (Service Component) — queries the mapping between billing invoice contract numbers and their associated service contracts |
| EKK0321B002CBSMsg1List | Class | CBS message list class defining field keys `svc_kei_no` and `svc_kei_kaisen_ucwk_no` for the billing inquiry result |
| 課金先一覧照会 | Japanese term | Billing destination list inquiry — the operation of looking up all service contracts under a given billing invoice |
| 利用停止 | Japanese term | Service suspension — the business process of suspending a customer's telecommunications services (typically for non-payment) |
| 利用停止対象抽出 | Japanese term | Service suspension target extraction — the process of identifying which service contracts are affected by a suspension action |
| SessionHandle | Type | Database session handle — carries the database connection, transaction context, and other runtime session state |
| IRequestParameterReadWrite | Type | Request/response parameter object — the framework's contract for passing structured data between layers (screen -> CBS -> CC) |
| fixedText | Parameter | User-specified arbitrary string — a key/label used by the caller to identify the result data block returned by `param.setData()` |
