# Business Logic — JKKUseStpRunCC.runUseStp() [77 LOC]

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

## 1. Role

### JKKUseStpRunCC.runUseStp()

`runUseStp` is the primary entry point for executing **Service Suspension** (利用停止 — "Riyō Teishi") processing within the K-Opticom billing and customer management system. Service suspension refers to the operational procedure of halting active telecommunications service contracts (e.g., FTTH broadband, cable TV, IPTV, phone) for designated customers. This method implements a **batch iteration and delegation pattern**: it receives a list of service suspension targets encoded as a map of billing contract number and service contract number pairs, iterates over each pair, and delegates the actual suspension logic to the private `runUseStpProc` method.

The method handles the full lifecycle of a batch suspension operation: it retrieves the operational date, extracts the target list from the request parameter, processes each target sequentially, tracks which contracts could *not* be suspended (e.g., due to mansion master contracts, MINEO plans, or new electricity service groups), and writes back a processing result indicating whether all suspensions succeeded or whether some were ineligible. It is a shared utility CC (Common Component) called by multiple BPM screen operations — primarily KKSV0356 (collection-related service suspension processing) and CHSV0046 (dunning status update processing). The method sets a return code via `SCControlMapKeys.RETURN_CODE` so that calling screens can determine success or failure.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["runUseStp handle, param, fixedText"])
    INIT("statusCode = 0")
    GET_DATE("oPE_DATE = JCCBPCommon.getOpeDate(null)")
    GET_MAP("use_stp_map = (HashMap) param.getData(fixedText)")
    GET_LIST("useStpTrgtLst = use_stp_map.get(USE_STP_LST)")
    INIT_FUKA("fukaUseStpTrgtLst = new ArrayList<HashMap<String,Object>>")
    INIT_FLG("wk_Fuka_flg = false")
    LOOP_START("for i = 0 to useStpTrgtLst.size()")
    GET_ITEM("useStpHash = useStpTrgtLst.get(i)")
    INIT_PARAM("paramHash = new HashMap<String,Object>")
    PUT_SEIKY("paramHash.put(SEIKY_KEI_NO, useStpHash.get(SEIKY_KEI_NO))")
    PUT_SVC("paramHash.put(SVC_KEI_NO, useStpHash.get(SVC_KEI_NO))")
    CALL_PROC("statusCode = runUseStpProc handle, param, paramHash, fixedText, fukaUseStpTrgtLst")
    LOOP_END("i++")
    RESULT_CHECK{"wk_Fuka_flg"}
    SET_FUKA("use_stp_map.put(SYORI_RESULT, SYORI_RESULT_FUKA)")
    SET_OK("use_stp_map.put(SYORI_RESULT, SYORI_RESULT_OK)")
    SET_FUKA_LIST("use_stp_map.put(FUKA_USE_STP_LST, fukaUseStpTrgtLst)")
    WRITE_RESULT("param.setData(fixedText, use_stp_map)")
    SET_RETURN("param.setControlMapData(RETURN_CODE, formatStatus)")
    RETURN(["return param"])

    START --> INIT
    INIT --> GET_DATE
    GET_DATE --> GET_MAP
    GET_MAP --> GET_LIST
    GET_LIST --> INIT_FUKA
    INIT_FUKA --> INIT_FLG
    INIT_FLG --> LOOP_START
    LOOP_START --> GET_ITEM
    GET_ITEM --> INIT_PARAM
    INIT_PARAM --> PUT_SEIKY
    PUT_SEIKY --> PUT_SVC
    PUT_SVC --> CALL_PROC
    CALL_PROC --> LOOP_END
    LOOP_END --> LOOP_START
    LOOP_START --> RESULT_CHECK
    RESULT_CHECK -->|true| SET_FUKA
    RESULT_CHECK -->|false| SET_OK
    SET_FUKA --> SET_FUKA_LIST
    SET_OK --> SET_FUKA_LIST
    SET_FUKA_LIST --> WRITE_RESULT
    WRITE_RESULT --> SET_RETURN
    SET_RETURN --> RETURN
```

**Processing Description:**

1. **Initialization** — Sets `statusCode` to 0 and retrieves the current operational date via `JCCBPCommon.getOpeDate(null)`.
2. **Extract Target List** — Retrieves a HashMap from the request parameter keyed by `fixedText` (user-specified string). From this map, extracts the list of service suspension targets (`USE_STP_LST`). Also initializes an empty list for ineligible service suspension targets (`fukaUseStpTrgtLst`) and a flag `wk_Fuka_flg` to false.
3. **Iteration Loop** — For each suspension target in the list:
   - Extracts the billing contract number (`SEIKY_KEI_NO`) and service contract number (`SVC_KEI_NO`) from the target HashMap.
   - Creates a `paramHash` with these two values.
   - Delegates to `runUseStpProc`, which performs the actual suspension logic including eligibility checks, service contract agreement confirmation, billing group classification, and billing overview integration.
4. **Result Determination** — After the loop completes, checks `wk_Fuka_flg`:
   - If `true` (some targets were ineligible): writes result code `"1"` (SYORI_RESULT_FUKA) to indicate partial failure.
   - If `false` (all targets processed): writes result code `"0"` (SYORI_RESULT_OK) to indicate success.
5. **Write-back** — Stores the ineligible targets list, writes the result map back to the request parameter, and sets the return code as a 4-digit zero-padded string.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transaction context and connection information for all SC (Service Component) calls invoked during processing. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object carrying the request payload, control map, and response data. Contains the service suspension target list under the key specified by `fixedText`, and is updated with processing results and return code. |
| 3 | `fixedText` | `String` | User-specified arbitrary string that serves as the key to retrieve and store the processing map within `param`. It identifies which data section of the parameter object to use for this invocation. |

**Instance Fields Read by the Method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `oPE_DATE` | `String` | Operational date — set by this method via `JCCBPCommon.getOpeDate`, used by downstream SC calls as the transaction date. |
| `wk_Fuka_flg` | `boolean` | Processing result flag — set to `true` by `runUseStpProc` if any service contract is ineligible for suspension. Used after the loop to determine the final result code. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JCCBPCommon.getOpeDate` | - | - | Calls `getOpeDate` in `JCCBPCommon` — retrieves the current operational date |
| - | `JKKUseStpRunCC.runUseStpProc` | - | - | Calls `runUseStpProc` — delegates each suspension target to the processing method |
| R | `callEKK0081A010SC` | EKK0081A010SC | `EKK0081A010CBS` (Service Contract Agreement) | Calls `callEKK0081A010SC` in `runUseStpProc` — fetches service contract agreement data to check billing group code |
| R | `callEKK0321B002SC` | EKK0321B002SC | `EKK0321B002CBS` (Billing Overview — Contract Number List) | Calls `callEKK0321B002SC` in `runUseStpProc` — fetches billing overview records for the billing/service contract numbers |
| R | `callEKK0861B002SC` | EKK0861B002SC | `EKK0861B002CBS` (Mansion Information) | Calls `callEKK0861B002SC` in `runUseStpProc` — retrieves mansion/collective housing information |
| R | `useStpFukaCheck` | - | - | Calls `useStpFukaCheck` — performs ineligibility check, adds ineligible targets to `fukaUseStpTrgtLst` |
| R | `chshtUseStpSvc` | - | - | Calls `chshtUseStpSvc` for the "Service Suspension Target Extraction" phase (separate private method, referenced by `runUseStp` caller CHSV0046) |

**How to classify:**
- **R** (Read): `call*SC` methods are service component calls that query data. They read from CBS (Business Service) tables.
- **-** (Internal): Methods that don't directly access DB tables but delegate to other internal or SC methods.

### Called SC methods with full business descriptions:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callEKK0081A010SC` | EKK0081A010SC | KK_T_SVC_KEI (Service Contract Table) | Read service contract agreement — confirms the service contract exists and retrieves billing group code (PRC_GRP_CD) for eligibility screening |
| R | `callEKK0861B002SC` | EKK0861B002SC | KK_T_MANSION (Mansion/Collective Housing Table) | Read mansion information — gathers collective housing details needed for suspension processing |
| R | `callEKK0321B002SC` | EKK0321B002SC | KK_T_SEIKYU (Billing Contract Table), KK_T_SVC_KEI (Service Contract Table) | Read billing overview — retrieves billing contract and service contract number pairing records for billing reconciliation |

## 5. Dependency Trace

Trace who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0356 | `KKSV0356Operation.run` -> `CCRequestBroker.run(target3)` -> `JKKUseStpRunCC.runUseStp` | `callEKK0081A010SC [R] KK_T_SVC_KEI`<br>`callEKK0321B002SC [R] KK_T_SEIKY, KK_T_SVC_KEI`<br>`callEKK0861B002SC [R] KK_T_MANSION` |
| 2 | Screen:CHSV0046 | `CHSV0046OPOperation.run` -> `CCRequestBroker.run(targetd)` -> `JKKUseStpRunCC.runUseStp` | `callEKK0081A010SC [R] KK_T_SVC_KEI`<br>`callEKK0321B002SC [R] KK_T_SEIKY, KK_T_SVC_KEI`<br>`callEKK0861B002SC [R] KK_T_MANSION` |

**Caller Descriptions:**
- **KKSV0356** — Collection-related service suspension processing screen. Invokes suspension on billing-related contracts when handling customer payment/collection scenarios.
- **CHSV0046** — Dunning status update screen (督促状況更新OP). Called when updating dunning (collection notice) status and needs to suspend services for delinquent customers.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialization (L409)

> Initializes the method's working variables: status code, operational date, target list, ineligible list, and result flag.

| # | Type | Code |
|---|------|------|
| 1 | SET | `statusCode = 0` // Initialize status code [-> 0] |
| 2 | SET | `oPE_DATE = JCCBPCommon.getOpeDate(null)` // Get operational date [-> current date] |
| 3 | SET | `use_stp_map = (HashMap) param.getData(fixedText)` // Extract processing map by key [fixedText] |
| 4 | SET | `useStpTrgtLst = (ArrayList) use_stp_map.get(USE_STP_LST)` // Get suspension target list [-> USE_STP_LST="use_stp_lst"] |
| 5 | SET | `fukaUseStpTrgtLst = new ArrayList` // Create ineligible targets list [-> FUKA_USE_STP_LST="fuka_use_stp_lst"] |
| 6 | SET | `wk_Fuka_flg = false` // Reset ineligibility flag [-> false] |

**Block 2** — [FOR LOOP] Batch Iteration (L420)

> Iterates over each service suspension target, extracts billing and service contract numbers, and delegates to `runUseStpProc`.

| # | Type | Code |
|---|------|------|
| 1 | LOOP | `for(int i = 0; i < useStpTrgtLst.size(); i++)` // Loop over each suspension target |
| 2 | SET | `useStpHash = useStpTrgtLst.get(i)` // Get current target HashMap |
| 3 | SET | `paramHash = new HashMap` // Create parameter map for this target |
| 4 | SET | `paramHash.put(SEIKY_KEI_NO, useStpHash.get(SEIKY_KEI_NO))` // Put billing contract number [-> SEIKY_KEI_NO="seiky_kei_no"] |
| 5 | SET | `paramHash.put(SVC_KEI_NO, useStpHash.get(SVC_KEI_NO))` // Put service contract number [-> SVC_KEI_NO="svc_kei_no"] |
| 6 | CALL | `statusCode = runUseStpProc(handle, param, paramHash, fixedText, fukaUseStpTrgtLst)` // Delegate to suspension processing |

**Block 3** — [IF] Result Flag Check (L462)

> Determines whether any service contract was ineligible for suspension.

| # | Type | Code |
|---|------|------|
| 1 | IF | `wk_Fuka_flg` [true = some targets ineligible] (L462) |
| 2 | SET | `use_stp_map.put(SYORI_RESULT, SYORI_RESULT_FUKA)` // Set result to "1" (partial failure) [-> SYORI_RESULT="syori_result", SYORI_RESULT_FUKA="1"] |

**Block 3.1** — [ELSE] All Targets Processed (L465)

| # | Type | Code |
|---|------|------|
| 1 | SET | `use_stp_map.put(SYORI_RESULT, SYORI_RESULT_OK)` // Set result to "0" (success) [-> SYORI_RESULT_OK="0"] |

**Block 4** — [SET] Ineligible List Write-back (L469)

> Stores the list of ineligible suspension targets back into the result map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `use_stp_map.put(FUKA_USE_STP_LST, fukaUseStpTrgtLst)` // Store ineligible targets [-> FUKA_USE_STP_LST="fuka_use_stp_lst"] |

**Block 5** — [SET] Result Write and Return Code (L473-L477)

> Writes the final result map to the request parameter and sets the return code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param.setData(fixedText, use_stp_map)` // Write result map back |
| 2 | SET | `formatStatus = String.format("%1$04d", statusCode)` // Format as 4-digit zero-padded |
| 3 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` // Set return code in control map |

**Block 6** — [RETURN] Method Completion (L479)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return the updated request parameter |

### Sub-Block: runUseStpProc (delegated processing)

The `runUseStpProc` method (L586+) handles the detailed business logic for a single suspension target. Here are its control flow blocks:

**Block P1** — [SET] Initialization (L590)

| # | Type | Code |
|---|------|------|
| 1 | SET | `statusCode = 0` // Initialize status code |
| 2 | SET | `resultHash = new HashMap` // S-IF result storage |
| 3 | SET | `requestParam.put(SVC_KEI_USE_STP_EXEC_FLG, false)` // Set service suspension execution flag [-> SVC_KEI_USE_STP_EXEC_FLG="svc_kei_use_stp_exec_flg"] |
| 4 | SET | `hakkoSODDataList = new ArrayList` // S-IF emission data list |
| 5 | SET | `seiOpSvcKeiNoList = new ArrayList` // Billing option service contract number list |
| 6 | SET | `prm_svc_kei_no = requestParam.get(SVC_KEI_NO)` // Get service contract number parameter |

**Block P2** — [CALL] Service Contract Agreement Confirmation (L607)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEKK0081A010SC(param, handle, requestParam, resultHash, prm_svc_kei_no)` // Confirm service contract agreement |
| 2 | IF | `statusCode != 0` [error detected] (L609) |
| 3 | RETURN | `return statusCode` // Return error code |

**Block P3** — [IF] Billing Group Code — Mansion Master Check (L619) [PRC_GRP_CD_MANSION_OYA = "99"]

> Mansion master contracts are excluded from suspension processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0081A010Hash = resultHash.get(TEMPLATE_ID_EKK0081A010)` // Get agreement result |
| 2 | SET | `prc_grp_cd = eKK0081A010Hash.get(EKK0081A010CBSMsg1List.PRC_GRP_CD)` // Get billing group code |
| 3 | IF | `PRC_GRP_CD_MANSION_OYA.equals(prc_grp_cd)` [Mansion/One-Parent group] [-> PRC_GRP_CD_MANSION_OYA="99"] (L622) |
| 4 | RETURN | `return 0` // Skip processing — mansion master does not suspend |

**Block P4** — [IF] Billing Group Code — MINEO Check (L629) [PRC_GRP_CD_MINEO = "51"]

> MINEO (mobile service) contracts are excluded from suspension.

| # | Type | Code |
|---|------|------|
| 1 | IF | `PRC_GRP_CD_MINEO.equals(prc_grp_cd)` [MINEO group] [-> PRC_GRP_CD_MINEO="51"] (L629) |
| 2 | RETURN | `return 0` // Skip processing — MINEO does not suspend |

**Block P5** — [IF] Billing Group Code — New Electricity Check (L637) [PRC_GRP_CD_EODENKI = "10"]

> New electricity service contracts (introduced in v16.00.00 for ANK-2480-00-00) are excluded from suspension.

| # | Type | Code |
|---|------|------|
| 1 | IF | `PRC_GRP_CD_EODENKI.equals(prc_grp_cd)` [New electricity group] [-> PRC_GRP_CD_EODENKI="10"] (L637) |
| 2 | RETURN | `return 0` // Skip processing — new electricity does not suspend |

**Block P6** — [IF] Ineligibility Check (L643)

> Calls `useStpFukaCheck` to verify if this contract is eligible for suspension. If ineligible, sets `wk_Fuka_flg = true` and returns.

| # | Type | Code |
|---|------|------|
| 1 | IF | `useStpFukaCheck(fukaUseStpTrgtLst, requestParam, resultHash)` [ineligible] (L643) |
| 2 | SET | `wk_Fuka_flg = true` // Mark as having ineligible targets |
| 3 | RETURN | `return 0` // Skip suspension for this contract |

**Block P7** — [CALL] Mansion Info and Billing Overview (L650-L656)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEKK0861B002SC(param, handle, requestParam, resultHash)` // Get mansion information |
| 2 | IF | `statusCode != 0` [error] (L652) |
| 3 | RETURN | `return statusCode` // Propagate error |
| 4 | CALL | `callEKK0321B002SC(param, handle, requestParam, resultHash)` // Get billing overview |
| 5 | IF | `statusCode != 0` [error] (L658) |
| 6 | RETURN | `return statusCode` // Propagate error |

**Block P8** — [IF] Billing Overview Empty Check (L664)

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0321B002HashList = resultHash.get(TEMPLATE_ID_EKK0321B002)` // Get billing overview results |
| 2 | IF | `eKK0321B002HashList.size() == 0` [no billing records] (L667) |
| 3 | RETURN | `return 0` // Terminate — no billing records to suspend |

**Block P9** — [FOR LOOP] Billing Overview Iteration (L672)

> Iterates over each billing record from the billing overview, extracting service contract numbers and performing the actual suspension logic (detailed in subsequent blocks within `runUseStpProc`).

| # | Type | Code |
|---|------|------|
| 1 | LOOP | `for(int i = 0; i < eKK0321B002HashList.size(); i++)` // Loop over billing overview records |
| 2 | SET | `eKK0321B002Hash = eKK0321B002HashList.get(i)` // Get current record |
| 3 | SET | `svc_kei_no = eKK0321B002Hash.get(EKK0321B002CBSMsg1List.SVC_KEI_NO)` // Get service contract number |
| 4 | SET | `svcKeiKaisenUcwkNo = eKK0321B002Hash.get(EKK0321B002CBSMsg1List.SVC_KEI_KAISEN_UCWK_NO)` // Get service detail work number |
| ... | ... | (Continues with further SC calls and suspension execution logic within runUseStpProc) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `runUseStp` | Method | Service Suspension Execution — main entry point for batch service suspension processing |
| `runUseStpProc` | Method | Service Suspension Processing — per-contract suspension execution logic |
| `use_stp_lst` | Field | Suspension Target List — HashMap containing all service contracts to be suspended |
| `fuka_use_stp_lst` | Field | Ineligible Suspension Target List — contracts that could not be suspended, with reasons |
| `seiky_kei_no` | Field | Billing Contract Number — the invoice account number under which multiple service contracts are grouped |
| `svc_kei_no` | Field | Service Contract Number — unique identifier for a specific service subscription (e.g., one FTTH line) |
| `svc_kei_use_stp_exec_flg` | Field | Service Contract Suspension Execution Flag — boolean marker indicating suspension is in progress |
| `syori_result` | Field | Processing Result — "0" means all suspensions succeeded, "1" means some were ineligible |
| `wk_Fuka_flg` | Field | Working Ineligibility Flag — internal boolean indicating any contract was ineligible for suspension |
| `PRC_GRP_CD` | Field | Price Group Code — billing group classification that determines suspension eligibility |
| `PRC_GRP_CD_MANSION_OYA` | Field | Mansion Master Group — billing group "99" for collective housing master contracts, excluded from suspension |
| `PRC_GRP_CD_MINEO` | Field | MINEO Group — billing group "51" for MINEO mobile service, excluded from suspension |
| `PRC_GRP_CD_EODENKI` | Field | New Electricity Group — billing group "10" for electricity-only service introduced in 2015, excluded from suspension |
| EKK0081A010SC | SC Code | Service Contract Agreement Confirmation — reads service contract details including billing group code |
| EKK0861B002SC | SC Code | Mansion Information Retrieval — reads collective housing/mansion data |
| EKK0321B002SC | SC Code | Billing Overview Query — retrieves billing contract and service contract number pairings |
| KK_T_SVC_KEI | Table | Service Contract Table — stores service contract records (FTTH, TV, phone, etc.) |
| KK_T_SEIKYU | Table | Billing Contract Table — stores billing account records |
| KK_T_MANSION | Table | Mansion/Collective Housing Table — stores collective housing information |
| S-IF | Acronym | System Interface — external API for emitting service suspension notices to connected systems |
| SOD | Acronym | Service Order Data — order fulfillment data structure for telecom services |
| CC | Acronym | Common Component — a shared service component class in the BPM framework |
| BPM | Acronym | Business Process Management — the workflow engine orchestrating screen operations |
| SC | Acronym | Service Component — a data access layer component that interacts with database tables via CBS |
| CBS | Acronym | Common Business Service — the business logic layer invoked by SC components |
| KKSV### | Class | K-Opticom Screen Validation — screen operation classes (e.g., KKSV0356) |
| CHSV### | Class | K-Opticom CH Screen Validation — CH (Customer Help/Contact) screen operation classes (e.g., CHSV0046) |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service offered by K-Opticom |
| 利用停止 (Riyō Teishi) | Japanese term | Service Suspension — the business process of halting active telecom service contracts |
| 請求契約番号 (Seikyuu Keiyaku Bangou) | Japanese term | Billing Contract Number — the master account number for billing purposes |
| サービス契約番号 (Saabisu Keiyaku Bangou) | Japanese term | Service Contract Number — individual service line identifier |
| マンション・オーナー (Mansion Ou-naa) | Japanese term | Mansion Owner/Master — collective housing billing arrangement where one master contract covers multiple units |
| MINEO | Business term | MINEO — a mobile MVNO service brand, excluded from suspension processing |
| eo電気 (eo Denki) | Business term | eo Electricity — new electricity service offering introduced in 2015 (ANK-2480-00-00) |
| 督促 (Tosoku) | Japanese term | Dunning — collection notice process for delinquent customers |
| 督促状況更新 | Japanese term | Dunning Status Update — the business process handled by CHSV0046 |
| KKSV0356 | Screen | Collection-related service suspension processing screen |
| CHSV0046 | Screen | Dunning status update operation screen |
