# Business Logic — JKKOrsjgsUseStpRlsRunCC.executeOpSvcKei_UseStp() [72 LOC]

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

## 1. Role

### JKKOrsjgsUseStpRlsRunCC.executeOpSvcKei_UseStp()

This method performs **optional service contract suspension release processing** (オプションサービス契約利用停止解除処理) for a K-Opticom telecom customer service management system. It handles the business operation of lifting a previously applied service suspension on a designated optional service contract line (op_svc_kei), restoring the service to active status when conditions permit.

The method implements a **conditional branching / guard pattern** with progressive validation: it first fetches billing front agreement data to authorize the operation, then retrieves the optional service contract details and verifies the target service contract number matches the caller's intent. Based on the current service state and the prior state before the suspension was applied, it dispatches to one of two suspension release subprocesses — either the "suspended-while-suspended" path (when the service was in a suspended state even before the suspension was applied) or the "normal suspension release" path (when the service was in a stopped/interrupted state before suspension).

Its role in the larger system is that of a **shared utility component method**, called by `executeUseStpRlsMain()` which is the main orchestrator for the suspension release workflow. This method specifically isolates optional service (オプションサービス) logic within the broader suspension release process, delegating to SC-layer methods for the actual state transitions.

The method has four processing branches: (1) if the billing agreement fetch fails, it returns an error immediately; (2) if the optional service contract data does not match the target service contract number, it returns early without processing; (3) if the service is in the suspended state (220) and was previously in the suspended-while-suspended state (210), it invokes the suspended suspension release path; (4) if the service is in the suspended state (220) but was in any other pre-suspension state, it invokes the normal suspension release path.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeOpSvcKei_UseStp"])
    INIT["Set statusCode to 0"]
    GET_TEMPLATE["Get eKK0321A010Hash from resultHash"]
    CALL_OP_SVC["callEKK0351A010SC"]
    CHECK_CALL_STATUS{statusCode
is not zero?}
    RETURN_CALL["Return statusCode"]
    GET_OP_HASH["Get eKK0351A010Hash from resultHash"]
    CHECK_TARGET["isOpSvcKeiTargetData"]
    CHECK_TARGET_RESULT{isOpSvcKeiTargetData
equals false?}
    RETURN_TARGET["Return statusCode"]
    GET_OP_STAT["Get op_svc_kei_stat from hash"]
    CHECK_STAT{op_svc_kei_stat == 220?}
    GET_SVKEI_STAT_MAP["Get svkeiStatMap from resultHash"]
    GET_LAST_STAT["Get useStpBfSvcKeiStat from svkeiStatMap"]
    CHECK_LAST_STAT{useStpBfSvcKeiStat == 210?}
    CALL_SUSPENDED_RLS["getEKK0351C051SC"]
    CHECK_RLS_STATUS_1{statusCode
is not zero?}
    RETURN_RLS_1["Return statusCode"]
    CALL_NORMAL_RLS["getEKK0351C050SC"]
    CHECK_RLS_STATUS_2{statusCode
is not zero?}
    RETURN_RLS_2["Return statusCode"]
    END_NODE(["Return 0"])

    START --> INIT --> GET_TEMPLATE --> CALL_OP_SVC --> CHECK_CALL_STATUS
    CHECK_CALL_STATUS -->|true| RETURN_CALL
    CHECK_CALL_STATUS -->|false| GET_OP_HASH --> CHECK_TARGET --> CHECK_TARGET_RESULT
    CHECK_TARGET_RESULT -->|true| RETURN_TARGET
    CHECK_TARGET_RESULT -->|false| GET_OP_STAT --> CHECK_STAT
    CHECK_STAT -->|false| END_NODE
    CHECK_STAT -->|true| GET_SVKEI_STAT_MAP --> GET_LAST_STAT --> CHECK_LAST_STAT
    CHECK_LAST_STAT -->|true| CALL_SUSPENDED_RLS --> CHECK_RLS_STATUS_1
    CHECK_RLS_STATUS_1 -->|true| RETURN_RLS_1
    CHECK_RLS_STATUS_1 -->|false| END_NODE
    CHECK_LAST_STAT -->|false| CALL_NORMAL_RLS --> CHECK_RLS_STATUS_2
    CHECK_RLS_STATUS_2 -->|true| RETURN_RLS_2
    CHECK_RLS_STATUS_2 -->|false| END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session management handle carrying database connection, transaction context, and session state used across all SC calls within this method. |
| 2 | `param` | `IRequestParameterReadWrite` | Request-parameter object containing model groups and control maps; used to pass data to and receive results from called SC methods. |
| 3 | `requestParam` | `HashMap<String, Object>` | Request parameter map carrying incoming request data (e.g., `svc_kei_use_stp_rls_exec_flg`) from the screen/controller layer to the component method. |
| 4 | `resultHash` | `HashMap<String, Object>` | Result hash shared across the method and its called SC methods; populated with template data (e.g., `EKK0321A010`, `EKK0351A010`) by called SCs and read back by this method. |
| 5 | `prm_svc_kei_no` | `String` | Service contract number (サービス契約番号) — the specific optional service contract line identifier targeted for suspension release. This value is compared against the actual service contract number returned by the SC lookup to verify the correct contract is being processed. |

**Instance fields / external state read:**
- `MAP_KEY_GET_SVKEI_STAT` ("JKKGetSvkeiStat") — constant used as map key to retrieve service contract status map from resultHash.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callEKK0351A010SC` | EKK0351A010SC | EKK0351 (Optional Service Contract Agreement) | Fetches optional service contract agreement data to obtain contract details including service contract number and current service status. Uses TEMPLATE_ID_EKK0321A010 (billing front agreement) as input. |
| R | `isOpSvcKeiTargetData` | Internal CC | EKK0161 (Service Contract Detail Agreement) | Internal validation method; if the optional service contract number is not directly available, it fetches the service contract detail agreement (EKK0161A010SC) to resolve the service contract number, then compares it against the target service contract number passed as `prm_svc_kei_no`. |
| C | `getEKK0351C051SC` | EKK0351C051SC | EKK0351C051 (Suspended Optional Service Contract Suspension Release) | Performs suspension release for an optional service contract that was already in a suspended/interrupted state (210) before the suspension was applied. This is the "suspended-while-suspended" path. |
| C | `getEKK0351C050SC` | EKK0351C050SC | EKK0351C050 (Optional Service Contract Suspension Release) | Performs standard suspension release for an optional service contract. Invoked when the service was in any state other than suspended/interrupted (210) before the suspension was applied. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC:JKKOrsjgsUseStpRlsRunCC.executeUseStpRlsMain | `executeUseStpRlsMain` -> `executeOpSvcKei_UseStp` | `callEKK0351A010SC [R] EKK0351`, `isOpSvcKeiTargetData [R] EKK0161`, `getEKK0351C051SC [C] EKK0351C051`, `getEKK0351C050SC [C] EKK0351C050` |
| 2 | CC:JKKUseStpRlsRunCC.executeUseStpRlsMain | `executeUseStpRlsMain` -> `executeOpSvcKei_UseStp` | `callEKK0351A010SC [R] EKK0351`, `isOpSvcKeiTargetData [R] EKK0161`, `getEKK0351C051SC [C] EKK0351C051`, `getEKK0351C050SC [C] EKK0351C050` |

Note: `isOpSvcKeiTargetData` itself internally calls `callEKK0161A010SC` (Service Contract Detail Agreement) if the service contract number is not directly available from the optional service contract data.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(initialization)` (L1129)

This block initializes the local status code variable.

| # | Type | Code |
|---|------|------|
| 1 | SET | `statusCode = 0` // Initialize status code (ステータスコード) |

**Block 2** — [SET] `(billing front agreement data retrieval)` (L1132)

Retrieves the billing front agreement hash from the shared resultHash.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0321A010Hash = (HashMap)resultHash.get(TEMPLATE_ID_EKK0321A010)` // Get billing front agreement result hash [-> TEMPLATE_ID_EKK0321A010="EKK0321A010"] |

**Block 3** — [CALL + IF-EARLY-RETURN] `(optional service contract agreement fetch)` (L1135-L1139)

Invokes the optional service contract agreement SC. The billing front agreement hash is passed as input; the SC populates the resultHash with optional service contract data. If the SC call returns a non-zero status, the method returns the error code immediately.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `statusCode = callEKK0351A010SC(param, handle, eKK0321A010Hash, resultHash)` // Billing front agreement -> optional service contract agreement [-> EKK0351A010SC] |
| 2 | IF | `if (statusCode != 0)` { return statusCode; } // Early return on SC failure |

**Block 4** — [SET] `(optional service contract data retrieval)` (L1142)

Extracts the optional service contract data from the result hash for subsequent processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0351A010Hash = (HashMap)resultHash.get(TEMPLATE_ID_EKK0351A010)` // Get optional service contract agreement hash [-> TEMPLATE_ID_EKK0351A010="EKK0351A010"] |

**Block 5** — [IF-EARLY-RETURN] `(optional service contract target validation)` (L1145-L1148)

Validates that the optional service contract data corresponds to the target service contract number specified by `prm_svc_kei_no`. The `isOpSvcKeiTargetData` method compares the contract number from the SC result against the target; if it does not match, the method returns early without performing any suspension release.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (!isOpSvcKeiTargetData(param, handle, resultHash, prm_svc_kei_no, eKK0351A010Hash))` { return statusCode; } // [-> isOpSvcKeiTargetData: validates svc_kei_no matches prm_svc_kei_no, internally calls callEKK0161A010SC if needed] |

**Block 6** — [SET] `(read current service status)` (L1151)

Reads the current service contract status from the optional service contract data hash.

| # | Type | Code |
|---|------|------|
| 1 | SET | `op_svc_kei_stat = (String)eKK0351A010Hash.get(OP_SVC_KEI_STAT)` // [-> OP_SVC_KEI_STAT="op_svc_kei_stat"] |

**Block 7** — [IF] `(service is in suspended state? SVC_KEI_STAT_STP == "220")` (L1154-L1196)

> This is the main conditional branch: the suspension release is only processed if the current service contract status is "220" (stopped/suspended — 停止中). If the status is anything else (e.g., 100 "service providing", 910 "released"), the method falls through and returns 0 without doing anything.

**Block 7.1** — [IF-BRANCH: true] `(retrieves pre-suspension state)` (L1155-L1156)

Retrieves the service status map and extracts the previous service contract status before suspension.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svkeiStatMap = (HashMap)resultHash.get(MAP_KEY_GET_SVKEI_STAT)` // [-> MAP_KEY_GET_SVKEI_STAT="JKKGetSvkeiStat"] |
| 2 | SET | `useStpBfSvcKeiStat = (String)svkeiStatMap.get(LAST_KK0081_STAT)` // Previous state before suspension [-> LAST_KK0081_STAT="last_kk0081_stat"] |

**Block 7.1.1** — [IF] `(pre-suspension state == "210" / 休止・中断中)` (L1159-L1168)

> 休止中オプションサービス契約停止解除 — Suspended-optional-service-contract suspension release. If the service was already in a suspended/interrupted state (210) before the current suspension was applied, invoke the suspended suspension release SC.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (SVC_KEI_STAT_KYUS.equals(useStpBfSvcKeiStat))` // [-> SVC_KEI_STAT_KYUS="210" (休止・中断中)] |
| 2 | CALL | `statusCode = getEKK0351C051SC(param, handle, requestParam, resultHash)` // Suspended-optional-service-contract suspension release [-> EKK0351C051] |
| 3 | IF | `if (statusCode != 0)` { return statusCode; } |

**Block 7.1.2** — [ELSE] `(pre-suspension state is not "210" / 休止・中断中以外)` (L1172-L1181)

> オプションサービス契約停止解除 — Optional service contract suspension release. If the service was in any state other than suspended/interrupted before suspension, invoke the normal suspension release SC. The comment states "services not in suspended/interrupted are treated as service providing" (休止・中断中はサービス提供中とする).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `statusCode = getEKK0351C050SC(param, handle, requestParam, resultHash)` // Optional service contract suspension release [-> EKK0351C050] |
| 2 | IF | `if (statusCode != 0)` { return statusCode; } |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `op_svc_kei` | Field | Optional service contract — a supplementary service contract attached to a base K-Opticom service (e.g., additional internet services, optional add-ons) |
| `op_svc_kei_stat` | Field | Optional service contract status — the current state code of an optional service contract line |
| `svc_kei_no` | Field | Service contract number (サービス契約番号) — unique identifier for a service contract line |
| `svc_kei_stat` | Field | Service contract status — the current state of a service contract |
| `useStpBfSvcKeiStat` | Field | Pre-suspension service contract status — the service state before the current suspension was applied |
| `prm_svc_kei_no` | Parameter | Target service contract number parameter — the specific service contract targeted for this operation |
| `statusCode` | Variable | Return status code — 0 indicates success, non-zero indicates an error condition to propagate to the caller |
| `resultHash` | Parameter | Shared result hash map — a HashMap used across component methods to exchange template data and results |
| TEMPLATE_ID_EKK0321A010 | Constant | Billing front agreement lookup (課金先一覧照会/請求契約番号・サービス契約番号) — template ID for fetching billing front service contract data |
| TEMPLATE_ID_EKK0351A010 | Constant | Optional service contract agreement lookup (オプションサービス契約一覧照会) — template ID for fetching optional service contract data |
| SVC_KEI_STAT_STP | Constant | "220" — Service suspended/stopped (停止中) |
| SVC_KEI_STAT_KYUS | Constant | "210" — Service suspended/interrupted (休止・中断中) |
| SVC_KEI_STAT_TKC | Constant | "100" — Service providing (サービス提供中) |
| SVC_KEI_STAT_UKE | Constant | "010" — Received (受付済) |
| SVC_KEI_STAT_SHOSA | Constant | "020" — Under review (照会済) |
| SVC_KEI_STAT_TEIK | Constant | "030" — Contracted (締結済) |
| SVC_KEI_STAT_DSL | Constant | "910" — Released/canceled (解約済) |
| SVC_KEI_STAT_CNCL | Constant | "920" — Cancelled (キャンセル済) |
| LAST_KK0081_STAT | Constant | "last_kk0081_stat" — Key for retrieving the previous service contract status before suspension |
| MAP_KEY_GET_SVKEI_STAT | Constant | "JKKGetSvkeiStat" — Map key for retrieving the service contract status retrieval item map |
| EKK0351A010SC | SC Code | Optional service contract agreement SC — reads optional service contract data linked to a billing front agreement |
| EKK0351C050SC | SC Code | Optional service contract suspension release CBS — processes the suspension release for an optional service contract that was not already in a suspended state |
| EKK0351C051SC | SC Code | Suspended-optional-service-contract suspension release CBS — processes the suspension release for an optional service contract that was already in a suspended/interrupted state before suspension |
| EKK0161A010SC | SC Code | Service contract detail agreement SC — reads service contract detail/line item data when the service contract number is not directly available |
| EKK0321A010CBSMsg | CBS Message | Billing front agreement message structure |
| EKK0351A010CBSMsg1List | CBS Message | Optional service contract agreement message list structure containing fields like `op_svc_kei_stat`, `svc_kei_no`, `svc_kei_ucwk_no` |
| CC | Abbreviation | Common Component — a reusable business logic component in the K-Opticom x21 framework |
| SC | Abbreviation | Service Component — the service layer module handling business logic for specific operations |
| CBS | Abbreviation | Component-Based Service — a component that typically wraps a business process or entity operation |
