# Business Logic — JKKOrsjgsUseStpRlsRunCC.executeKkopSvcKei_UseStp() [81 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKOrsjgsUseStpRlsRunCC` |
| Layer | CC/Common Component — shared business logic component within the service processing tier |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKOrsjgsUseStpRlsRunCC.executeKkopSvcKei_UseStp()

This method performs the **equipment option service contract use stop release processing** (機器提供オプションサービス契約 利用停止解除処理) — the core business operation that lifts a previously imposed service suspension on an equipment option service contract linked to a device-provided service contract. In Fujitsu's telecom order fulfillment system, when a customer's equipment option service contract has been placed in a stopped (suspended) state (status code `220`), this method reactivates the contract by coordinating a multi-step workflow.

The method implements a **dispatch-and-delegate pattern**: it first fetches the equipment option service contract details (via `EKK2811B010SC`), then iterates over the returned list and applies conditional logic based on the contract's current state and the pre-suspension service status. Specifically:

- For each equipment option service contract found, it performs an **idling migration eligibility check** (異動可否判定処理 — determines whether the contract can transition its status without restriction).
- If the migration check passes and the contract status is `220` (Stop — `利用停止`), it fetches the full contract agreement details (via `EKK2811A010SC`), then checks what the service status was *before* the stop.
- If the pre-stop status was `210` (Pause/Termination — `休止・中断中`), it calls the **suspended equipment option service contract stop** SC (`EKK2811C100SC`) to process the stop release.
- If the pre-stop status was anything else (typically `001` — Service Provision Active), it calls the **equipment option service contract stop release** SC (`EKK2811C090SC`).
- If the current status is not `220`, the contract is not a stop release target and processing is skipped.

This method is a **shared utility** called by `executeKktkSvcKei_UseStp()` within the same class, which itself is invoked as part of the larger service use stop release workflow orchestrated by `executeKopSvcKei_UseStpRlsRun()`. It does not directly handle multiple service types — it specializes exclusively in equipment option service contracts (KOP — 機器オプションサービス).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeKkopSvcKei_UseStp"])
    CALL_SC1["callEKK2811B010SC
Fetch equipment option service contract list"]
    GET_LIST["Get EKK2811B010HashList from resultHash"]

    CHECK_LIST["EKK2811B010HashList != null
AND size > 0"]

    FOR_LOOP["For each element in list"]
    CREATE_MAP["Create checkKkopIdoKhInputdata map"]
    PUT_SVC_CD["PUT KKOP_SVC_CD from element"]
    PUT_IDO_DIV["PUT IDO_DIV = SVC_STP_RSN_CD_USESTPRLS
Constant: SVC_STP_RSN_CD_USESTPRLS = 01
(Stop release reason code)"]
    SET_DATA["param.setData checkKkopIdoKh"]

    CHECK_IDO["JKKBpCommon.checkKkopIdoKh
returns true"]

    GET_STAT["Get kkopSvcKeiStat from element"]
    CHECK_STAT["kkopSvcKeiStat == SVC_KEI_STAT_STP
Constant: SVC_KEI_STAT_STP = 220
(Service stop status)"]

    CALL_SC2["callEKK2811A010SC
Equipment option service contract agreement"]
    GET_RESULT["Get EKK2811A010Hash from resultHash"]
    GET_SVKEI_MAP["Get svkeiStatMap from resultHash"]
    GET_BF_STAT["Get useStpBfSvcKeiStat from svkeiStatMap"]
    CHECK_BF_STAT["useStpBfSvcKeiStat == SVC_KEI_STAT_KYUS
Constant: SVC_KEI_STAT_KYUS = 210
(Pause/termination status)"]

    CALL_SC3["callEKK2811C100SC
Suspended equipment option service contract stop"]
    CALL_SC4["callEKK2811C090SC
Equipment option service contract stop release"]

    NO_EQUIP["No processing
No equipment option"]
    NO_MIGRATE["No processing
Not migration target"]
    NO_TRANSITION["No processing
Contract status not stop release target"]

    END_NODE(["Return 0"])

    START --> CALL_SC1
    CALL_SC1 --> GET_LIST
    GET_LIST --> CHECK_LIST
    CHECK_LIST -- true --> FOR_LOOP
    CHECK_LIST -- false --> NO_EQUIP
    NO_EQUIP --> END_NODE

    FOR_LOOP --> CREATE_MAP
    CREATE_MAP --> PUT_SVC_CD
    PUT_SVC_CD --> PUT_IDO_DIV
    PUT_IDO_DIV --> SET_DATA
    SET_DATA --> CHECK_IDO

    CHECK_IDO -- true --> GET_STAT
    CHECK_IDO -- false --> NO_MIGRATE
    NO_MIGRATE --> FOR_LOOP

    GET_STAT --> CHECK_STAT
    CHECK_STAT -- true --> CALL_SC2
    CHECK_STAT -- false --> NO_TRANSITION
    NO_TRANSITION --> FOR_LOOP

    CALL_SC2 --> GET_RESULT
    GET_RESULT --> GET_SVKEI_MAP
    GET_SVKEI_MAP --> GET_BF_STAT
    GET_BF_STAT --> CHECK_BF_STAT

    CHECK_BF_STAT -- true --> CALL_SC3
    CHECK_BF_STAT -- false --> CALL_SC4

    CALL_SC3 --> FOR_LOOP
    CALL_SC4 --> FOR_LOOP
```

**Processing Flow Summary:**

1. **Fetch contract list**: Calls `callEKK2811B010SC` with the device-provided service contract number (`kktkSvcKeiNo`) to retrieve all associated equipment option service contracts.
2. **List check**: If the returned list (`EKK2811B010HashList`) is null or empty, processing ends — no equipment option services exist.
3. **Per-contract iteration**: For each equipment option service contract element:
   - Build an input map for the migration check, populating `KKOP_SVC_CD` (equipment option service code) and `IDO_DIV` (operation division).
   - The `IDO_DIV` is set to `SVC_STP_RSN_CD_USESTPRLS` (`"01"`) — indicating this is a stop release reason operation.
   - Set the input data on the parameter object via `param.setData()`.
   - Call `JKKBpCommon.checkKkopIdoKh()` to determine if the contract is eligible for status transition (migration check).
4. **Migration check branch**:
   - **If eligible (returns true)**: The method checks if the current status equals `SVC_KEI_STAT_STP` (`"220"` — Stop).
     - **If status is 220**: The contract is stopped and eligible for release. Fetches the full contract agreement via `callEKK2811A010SC`, then checks the pre-suspension status:
       - **If pre-stop was `210` (Pause/Termination)**: Calls `callEKK2811C100SC` to process the suspended equipment contract stop.
       - **If pre-stop was not 210**: Calls `callEKK2811C090SC` to process a standard equipment contract stop release.
     - **If status is not 220**: The contract is not in a stop state, so no processing is performed.
   - **If not eligible (returns false)**: The equipment option service is not migration-targeted; no processing is performed.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session manager handle providing database and application session context for service component invocations. Carries the transaction scope and session state. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object containing the model group and control map. Used to pass data between processing stages via `setData()`/`getData()` and to communicate migration check inputs/outputs. |
| 3 | `requestParam` | `HashMap<String, Object>` | Request parameter map carrying raw request attributes. Passed through to `callEKK2811B010SC` for SIF (Service Interface) invocation context. |
| 4 | `resultHash` | `HashMap<String, Object>` | Output result map where SC responses are stored by template key (e.g., `"EKK2811B010"`, `"EKK2811A010"`). Used to retrieve SC return values and pre-suspension status data. |
| 5 | `prm_svc_kei_no` | `String` | Input service contract number — the service detail line item number identifying the parent service contract. Passed through from the caller as context. |
| 6 | `kktkSvcKeiNo` | `String` | **Device-provided service contract number** (機器提供サービス契約番号) — the primary key used to look up the list of associated equipment option service contracts. This is the device-level contract that owns the option services being released from stop status. |

**No instance fields or external state** are read by this method. All data dependencies are passed through parameters.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callEKK2811B010SC(param, handle, requestParam, kktkSvcKeiNo, null, resultHash)` | EKK2811B010SC | KK_T_OP_SVC_KEI (Equipment Option Service Contract Table) | **Read** — Fetches the list of equipment option service contracts associated with a device-provided service contract. Returns `EKK2811B010HashList` containing service codes, status codes, and contract numbers. |
| R | `callEKK2811A010SC(param, handle, kkopSvcKeiNo, resultHash)` | EKK2811A010SC | KK_T_OP_SVC_KEI (Equipment Option Service Contract Table) | **Read** — Fetches the full agreement details of a single equipment option service contract, including last update timestamp. Returns `EKK2811A010Hash` with current status and timestamps. |
| U | `callEKK2811C090SC(param, handle, eKK2811A010Hash, resultHash)` | EKK2811C090SC | KK_T_OP_SVC_KEI (Equipment Option Service Contract Table) | **Update** — Processes the equipment option service contract stop release. Updates the contract status from Stop (`220`) to Active, recording the stop release date and reason code. Called when the pre-stop status was NOT Pause/Termination. |
| U | `callEKK2811C100SC(param, handle, eKK2811A010Hash, resultHash)` | EKK2811C100SC | KK_T_OP_SVC_KEI (Equipment Option Service Contract Table) | **Update** — Processes the suspended equipment option service contract stop. Updates the contract when the pre-stop status was Pause/Termination (`210`). This is a specialized stop release variant for contracts that were in a suspended state. |
| R | `JKKBpCommon.checkKkopIdoKh(handle, param, checkKkopIdoKhInputdata, checkKkopIdoKhFixedText)` | - | Migration eligibility check | **Read** — Checks whether the equipment option service contract is eligible for status transition (migration eligibility). Validates the service code against migration rules and the specified operation division. |
| EXEC | `JKKKeiIdoKhCheck.checkKkopIdoKh` (via param) | - | - | Internal check invoked through the parameter object's migration check mechanism. Not a direct SC call. |
| EXEC | `param.setData(...)` | - | - | **Set** — Stores data in the request parameter object. Used to pass migration check input data and check result. |

**CRUD Summary:**
- **Read operations**: 2 SC calls (`EKK2811B010SC`, `EKK2811A010SC`) for data retrieval, plus the migration eligibility check.
- **Update operations**: 2 SC calls (`EKK2811C090SC`, `EKK2811C100SC`) for contract status changes, conditionally invoked based on pre-suspension status.
- **Target entity**: `KK_T_OP_SVC_KEI` — the Equipment Option Service Contract master table.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `executeKktkSvcKei_UseStp()` | `executeKktkSvcKei_UseStp(handle, param, requestParam, resultHash, prm_svc_kei_no, true)` → `executeKkopSvcKei_UseStp(handle, param, requestParam, resultHash, prm_svc_kei_no, kkopSvcKeiNo)` | `callEKK2811B010SC [R] KK_T_OP_SVC_KEI`, `callEKK2811A010SC [R] KK_T_OP_SVC_KEI`, `callEKK2811C090SC [U] KK_T_OP_SVC_KEI`, `callEKK2811C100SC [U] KK_T_OP_SVC_KEI`, `checkKkopIdoKh [-] Migration Check` |

**Notes:**
- This method is called from `executeKktkSvcKei_UseStp()` within the same class (`JKKOrsjgsUseStpRlsRunCC`), which handles the device-provided service contract use stop release processing.
- `executeKktkSvcKei_UseStp()` is itself called from `executeKopSvcKei_UseStpRlsRun()` — the main service use stop release orchestrator.
- The terminal operations reach the `KK_T_OP_SVC_KEI` (Equipment Option Service Contract) table through 4 SC endpoints.

## 6. Per-Branch Detail Blocks

**Block 1** — [METHOD_ENTRY] (L5439)

Entry point for equipment option service contract stop release processing.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEKK2811B010SC(param, handle, requestParam, kktkSvcKeiNo, null, resultHash)` // Fetch equipment option service contract list for the given device-provided service contract [-> EKK2811B010SC] |
| 2 | SET | `eKK2811B010HashList = (ArrayList<HashMap<String, Object>>)resultHash.get(TEMPLATE_ID_EKK2811B010)` // Retrieve the contract list from result hash [-> TEMPLATE_ID_EKK2811B010 = "EKK2811B010"] |

**Block 2** — [IF] `(eKK2811B010HashList != null && eKK2811B010HashList.size() > 0)` (L5452)

Checks whether any equipment option service contracts were found. If the list is empty or null, the method skips all processing and returns `0` (success).

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (HashMap<String, Object> eKK0251B010HashListElement : eKK2811B010HashList)` // Iterate over each equipment option service contract in the fetched list |

**Block 2.1** — [FOR_BODY] — Equipment option service contract processing (L5454)

For each equipment option service contract element, performs migration eligibility checking.

> 機器オプションサービス契約異動可否判定処理を呼び出し、無条件で状態遷移可能な機器オプションかどうかを判定します — Calls the migration eligibility determination process to check whether the equipment option can transition its status unconditionally.

| # | Type | Code |
|---|------|------|
| 1 | SET | `checkKkopIdoKhInputdata = new HashMap<String, Object>()` // Create new input map for migration check |
| 2 | SET | `checkKkopIdoKhInputdata.put(JKKKeiIdoKhCheckConstCC.KKOP_SVC_CD, (String)eKK0251B010HashListElement.get(EKK2811B010CBSMsg1List.KKOP_SVC_CD))` // Set equipment option service code [-> KKOP_SVC_CD = "kkop_svc_cd"] |
| 3 | SET | `checkKkopIdoKhInputdata.put(JKKKeiIdoKhCheckConstCC.IDO_DIV, SVC_STP_RSN_CD_USESTPRLS)` // Set operation division to stop release reason code [-> IDO_DIV = "ido_div", SVC_STP_RSN_CD_USESTPRLS = "01" (Stop release reason code)] |
| 4 | SET | `checkKkopIdoKhFixedText = "checkKkopIdoKh"` // Fixed text label for the migration check parameter |
| 5 | EXEC | `param.setData(checkKkopIdoKhFixedText, checkKkopIdoKhInputdata)` // Store migration check input data in parameter [-> "checkKkopIdoKh"] |

**Block 2.1.1** — [IF] `(JKKBpCommon.checkKkopIdoKh(handle, param, checkKkopIdoKhInputdata, checkKkopIdoKhFixedText))` (L5474)

Migration eligibility check. Returns `true` if the equipment option service contract can transition its status (is eligible for stop release processing).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JKKBpCommon.checkKkopIdoKh(handle, param, checkKkopIdoKhInputdata, checkKkopIdoKhFixedText)` // Perform migration eligibility check against the equipment option service contract |

**Block 2.1.1.1** — [IF_BODY] — Status is Stop (220), process stop release (L5476)

> 機器オプションサービス契約の状態に従い、利用停止解除を実行 — Execute stop release according to the equipment option service contract status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kkopSvcKeiStat = (String)eKK0251B010HashListElement.get(EKK2811B010CBSMsg1List.KKOP_SVC_KEI_STAT)` // Get current contract status from the list element [-> KKOP_SVC_KEI_STAT field] |

**Block 2.1.1.1.1** — [IF] `(SVC_KEI_STAT_STP.equals(kkopSvcKeiStat))` (L5479)

Checks if the contract status equals `220` (Stop). Only stopped contracts should have their stop release processed.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEKK2811A010SC(param, handle, (String)eKK0251B010HashListElement.get(EKK2811B010CBSMsg1List.KKOP_SVC_KEI_NO), resultHash)` // Fetch the equipment option service contract agreement details [-> EKK2811A010SC, KKOP_SVC_KEI_NO key] |
| 2 | SET | `eKK2811A010Hash = (HashMap<String, Object>)resultHash.get(TEMPLATE_ID_EKK2811A010)` // Retrieve the agreement data from result [-> TEMPLATE_ID_EKK2811A010 = "EKK2811A010"] |
| 3 | SET | `svkeiStatMap = (HashMap<String, Object>)resultHash.get(MAP_KEY_GET_SVKEI_STAT)` // Get the pre-suspension status map from result [-> MAP_KEY_GET_SVKEI_STAT = "JKKGetSvkeiStat"] |
| 4 | SET | `useStpBfSvcKeiStat = (String)svkeiStatMap.get(JKKGetSvkeiStatConstCC.LAST_KK0081_STAT)` // Get the status before stop [-> LAST_KK0081_STAT = "last_kk0081_stat"] |

**Block 2.1.1.1.1.1** — [IF] `(SVC_KEI_STAT_KYUS.equals(useStpBfSvcKeiStat))` (L5490)

Checks if the pre-suspension status was `210` (Pause/Termination — 休止・中断中).

> 休止中機器オプションサービス契約停止 — Suspended equipment option service contract stop.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEKK2811C100SC(param, handle, eKK2811A010Hash, resultHash)` // Process suspended equipment contract stop release [-> EKK2811C100SC, uses KKOP_SVC_KEI_NO, SVC_STP_RLS_YMD = current date, SVC_STP_RLS_RSN_CD = "01", IDO_DIV = "00063"] |

**Block 2.1.1.1.1.2** — [ELSE] — Pre-stop status was NOT Pause/Termination (L5497)

> サービス提供中だった場合 — If the service was in active provision.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEKK2811C090SC(param, handle, eKK2811A010Hash, resultHash)` // Process equipment option service contract stop release [-> EKK2811C090SC, same parameters as C100 but for non-suspended contracts] |

**Block 2.1.1.1.2** — [ELSE] — Contract status is NOT Stop (220) (L5503)

> 契約状態が利用停止解除対象外のため、処理なし — Contract status is not a stop release target, no processing.

The contract is already in an active or other non-stopped state. No stop release processing is needed.

| # | Type | Code |
|---|------|------|
| 1 | — | // No processing — contract is not in stopped state |

**Block 2.1.1.2** — [ELSE] — Migration check failed (L5507)

> 異動対象外の機器オプションのため、処理なし — Equipment option is not a migration target, no processing.

The equipment option service contract failed the migration eligibility check. It cannot transition its status under the current conditions.

| # | Type | Code |
|---|------|------|
| 1 | — | // No processing — not migration target |

**Block 2.1.2** — [ELSE] — No equipment option services found (L5512)

> 機器オプションがないため、処理なし — No equipment options exist, no processing.

| # | Type | Code |
|---|------|------|
| 1 | — | // No processing — no equipment option services found |

**Block 3** — [RETURN] (L5516)

Returns a fixed success code of `0`. The return value is not used by callers (documented as fixed).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return 0;` // Fixed return code — success (リターンコード 未使用なので固定値：正常とする) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kktkSvcKeiNo` | Field | Device-provided service contract number — the primary contract identifier for a device (equipment) service that may have associated option services |
| `prm_svc_kei_no` | Field | Input service contract number — the parent service detail line item number passed from the caller context |
| `kkopSvcKeiNo` | Field | Equipment option service contract number — identifies a specific equipment option service contract linked to a device-provided service contract |
| `kkopSvcKeiStat` | Field | Equipment option service contract status — the current operational state of the contract |
| `useStpBfSvcKeiStat` | Field | Service status before use stop — the status code recorded prior to when the service was placed in stop status |
| `KKOP_SVC_CD` | Field | Equipment option service code — the service type identifier for equipment option services (e.g., G01 for return, G02 for value-added) |
| `IDO_DIV` | Field | Operation division — classifies the type of operation/transition being performed |
| `SVC_STP_RSN_CD_USESTPRLS` | Constant | Stop release reason code = `"01"` — indicates this operation is a use stop release (利用停止解除) |
| `IDO_DIV_USESTPRLS` | Constant | Operation division code = `"00063"` — stop release operation division |
| `SVC_KEI_STAT_STP` | Constant | Service contract status = `"220"` — Stop (利用停止) — service is suspended |
| `SVC_KEI_STAT_KYUS` | Constant | Service contract status = `"210"` — Pause/Termination (休止・中断中) — service was paused before being stopped |
| `TEMPLATE_ID_EKK2811B010` | Constant | Template key = `"EKK2811B010"` — used to retrieve the equipment option service contract list from result hash |
| `TEMPLATE_ID_EKK2811A010` | Constant | Template key = `"EKK2811A010"` — used to retrieve the equipment option service contract agreement details |
| `MAP_KEY_GET_SVKEI_STAT` | Constant | Map key = `"JKKGetSvkeiStat"` — key in result hash for the pre-suspension status data |
| `LAST_KK0081_STAT` | Constant | Status field = `"last_kk0081_stat"` — field name for the pre-stop status value in the status map |
| EKK2811B010SC | SC | Equipment option service contract agreement list (device-provided SV) — reads the list of option services for a given device contract |
| EKK2811A010SC | SC | Equipment option service contract agreement — reads full details of a single equipment option service contract |
| EKK2811C090SC | SC | Equipment option service contract stop release — updates a stopped contract back to active status (standard release) |
| EKK2811C100SC | SC | Suspended equipment option service contract stop — specialized stop release for contracts that were in pause/termination state before stop |
| KOP | Acronym | Kiki Option Service (機器オプションサービス) — Equipment Option Service, an optional add-on service linked to a device-provided service contract |
| KKTk | Acronym | Kiki Teikyo (機器提供) — Device-Provided service, the main equipment/service contract |
| KKOP | Acronym | Kiki Option Service Contract (機器オプションサービス契約) — Equipment Option Service Contract |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity |
| IDO | Acronym | Idou (異動) — Migration/Operation, a transition or change operation on a service contract |
| 異動可否判定 | Business term | Migration eligibility determination — checks whether a service contract can transition its status |
| 利用停止解除 | Business term | Use stop release — reactivating a service that was previously suspended/stopped |
| 休止・中断中 | Business term | Pause/Termination — status code 210, indicating the service was in a paused or interrupted state |
| 契約 | Business term | Contract — a service agreement record in the telecom order management system |
| SIF | Acronym | Service Interface — the interface layer for calling Service Components (SC) |
| SC | Acronym | Service Component — a business logic module invoked via the Service Interface (SIF) |
