# Business Logic — JKKCourseRkRtrNsIdChgCC.getmultiKktkSvcKeiMsg() [41 LOC]

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

## 1. Role

### JKKCourseRkRtrNsIdChgCC.getmultiKktkSvcKeiMsg()

This method retrieves the **equipment-provided service contract details within a service contract line** (機器提供サービス契約一覧照会（サービス契約回線内詳）) for a given service contract change-over work number. It delegates to the `EKK0341B504CBS` Service Component, which queries the service contract line details associated with a specific service contract change-over work number (`svcKeiKaisenUwNo`). 

The method implements a **filter-and-select** pattern: it iterates through the returned service contract lines, first excluding any lines whose status is "cancelled" (920) or "terminated" (910), and then returns the first remaining line whose equipment-provided service code is either "C024" (EO Multi-function Router) or "C025" (HGW — Home Gateway). This filters the full set of service contract lines down to the single active service line for the specific networking equipment associated with the router re-identification process.

If no active service line matches the expected equipment codes, the method returns `null`. This method plays a supporting role within the router authentication PN/D change workflow — it identifies which specific service line carries the target equipment so downstream logic can proceed with re-identification or modification operations. The method is called directly by `JKKCourseRkRtrNsIdChgCC.execute()`, which is the main entry point for the router re-identification change processing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getmultiKktkSvcKeiMsg"]) --> SETUP["Prepare EKK0341B504CBS input message"]
    SETUP --> CALL_SC["callSC with TEMPLATE_ID_EKK0341B504, FUNC_CODE_1, svcKeiKaisenUwNo"]
    CALL_SC --> GET_LIST["Extract EKK0341B504CBSMSG1LIST array"]
    GET_LIST --> LOOP["For each message in array"]
    LOOP --> CHECK_STAT{Status is 920 or 910?}
    CHECK_STAT -->|Yes| SKIP["Skip - cancelled or terminated"]
    SKIP --> LOOP
    CHECK_STAT -->|No| CHECK_CD{Service CD is C024 or C025?}
    CHECK_CD -->|Yes| RETURN["Return current message"]
    CHECK_CD -->|No| LOOP
    RETURN --> END_RETURN["Return found service message"]
    LOOP --> ALL_DONE["End of loop"]
    ALL_DONE --> NULL_RETURN["Return null - no matching service"]
```

**CRITICAL — Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|-----------------|
| `TEMPLATE_ID_EKK0341B504` | `"EKK0341B504"` | Equipment-provided service contract details inquiry (service contract line internal details) |
| `FUNC_CODE_1` | `"1"` | Function code: Check & Update |
| `KKTK_SVC_KEI_STAT_920` | `"920"` | Equipment-provided service contract status: Cancelled (キャンセル済) |
| `KKTK_SVC_KEI_STAT_910` | `"910"` | Equipment-provided service contract status: Terminated (解約済) |
| `CD00132_MULTI_ROUTER` | `"C024"` | Equipment-provided service code: EO Multi-function Router (EO光多機能ルーター) |
| `CD00132_HGW` | `"C025"` | Equipment-provided service code: HGW (Home Gateway) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transactional context and connection for the CBS call. Used to establish the database session when invoking the EKK0341B504CBS service component. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service Component invocation router that dispatches the request to the appropriate CBS (batch processing system) handler. Carries the class name for logging and determines the CBS target. |
| 3 | `param` | `IRequestParameterReadWrite` | Request parameter container used to pass and retrieve business data between components. Passed through to callSC for CBS interaction. |
| 4 | `fixedText` | `String` | Fixed text key used to identify and retrieve parameter data from the request. Passed through to callSC for CBS interaction. |
| 5 | `svcKeiKaisenUwNo` | `String` | Service contract change-over work number — the internal tracking ID for the service contract line change-over operation. Used as the primary lookup key to find service contract line details. |

**Instance fields / external state read:** None directly within this method. Constants are resolved from class-level static fields.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callSC` → `EKK0341B504CBS` | EKK0341B504CBS | Service contract line details table | Calls EKK0341B504CBS via the callSC helper with template ID EKK0341B504, function code "1" (Check & Update), and the service contract change-over work number as the lookup key. Returns an array of service contract line detail messages. |
| R | `getCAANMsgList` | EKK0341B504CBSMsg | - | Extracts the `EKK0341B504CBSMSG1LIST` array from the CBS response message, producing a `CAANMsg[]` of service contract line records. |
| R | `getString` (status check) | EKK0341B504CBSMsg1List | - | Reads the `KKTK_SVC_KEI_STAT` field from each message to check the service contract status (filtering out cancelled/terminated). |
| R | `getString` (service code check) | EKK0341B504CBSMsg1List | - | Reads the `KKTK_SVC_CD` field from each message to check the equipment-provided service code (identifying multi-router or HGW). |

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callSC` (via EKK0341B504CBS) | EKK0341B504CBS | Service contract line details entity | Queries service contract line details using the change-over work number as the search key. Returns all matching service contract line records including status and equipment service codes. |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS:JKKCourseRkRtrNsIdChgCC | `execute(handle, param, fixedText)` → `getmultiKktkSvcKeiMsg(handle, scCall, param, fixedText, svcKeiKaisenUwNo)` | `callSC [R] EKK0341B504CBS` → `KKTK_SVC_KEI_STAT [R]` → `KKTK_SVC_CD [R]` |

**Notes:**
- The method is a private utility called by `JKKCourseRkRtrNsIdChgCC.execute()`, which is the main router authentication PN/D change processing method.
- The `execute()` method itself is a CBS (batch processing system) component, not a screen entry point.
- No screen/batch UI entry points (KKSV*) were found calling this method directly within 8 hops.

## 6. Per-Branch Detail Blocks

**Block 1** — MESSAGE_SETUP (L779)

> Prepares the input message for the EKK0341B504CBS Service Component call. The input message is a 2D Object array containing key-value pairs that form the CBS request parameters.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0341B504InMsg` = new Object[3][] array |
| 2 | SET | `ekk0341B504InMsg[0]` = `{TEMPLATEID, "EKK0341B504"}` [-> `TEMPLATE_ID_EKK0341B504="EKK0341B504"` — Equipment-provided service contract details inquiry template ID] |
| 3 | SET | `ekk0341B504InMsg[1]` = `{FUNC_CODE, "1"}` [-> `FUNC_CODE_1="1"` — Function code: Check & Update] |
| 4 | SET | `ekk0341B504InMsg[2]` = `{KEY_SVC_KEI_KAISEN_UCWK_NO, svcKeiKaisenUwNo}` [Lookup key: service contract change-over work number] |

**Block 2** — SERVICE_COMPONENT_CALL (L790)

> Invokes the EKK0341B504CBS Service Component via the callSC helper, then extracts the result list.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callSC(handle, scCall, param, fixedText, ekk0341B504InMsg)` [Invokes EKK0341B504CBS CBS with the prepared input message] |
| 2 | CALL | `.getCAANMsgList("EKK0341B504CBSMSG1LIST")` [Extracts the EKK0341B504CBSMSG1LIST result array from the CBS response] |
| 3 | SET | `ekk0341B504OutMsg` = `CAANMsg[]` [Array of service contract line detail messages returned by the CBS] |

**Block 3** — FOR_LOOP (L792)

> Iterates through each service contract line detail message returned by the CBS.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` [Loop counter initialized] |
| 2 | CONDITION | `i < ekk0341B504OutMsg.length` [Continue while there are messages to process] |
| 3 | INC | `i++` [Increment loop counter] |

**Block 3.1** — IF (Status Filter) `(KKTK_SVC_KEI_STAT == "920" || "910")` (L797)

> OM-2014-0001951 fix: Excludes cancelled or terminated service contracts from consideration. These are services that are no longer active and should not be returned.

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | `ekk0341B504OutMsg[i].getString("KKTK_SVC_KEI_STAT")` [Read service contract status field] |
| 2 | CHECK | `KKTK_SVC_KEI_STAT_920.equals(...)` [-> `KKTK_SVC_KEI_STAT_920="920"` — Status: Cancelled (キャンセル済)] |
| 3 | CHECK | `KKTK_SVC_KEI_STAT_910.equals(...)` [-> `KKTK_SVC_KEI_STAT_910="910"` — Status: Terminated (解約済)] |
| 4 | COND_OR | `||` [Either cancelled OR terminated status triggers skip] |
| 5 | EXEC | `continue` [Skip this message and proceed to the next iteration] |

**Block 3.2** — IF (Service Code Match) `(KKTK_SVC_CD == "C024" || "C025")` (L806)

> ANK-4315-00-00 modification: Returns the first active service line whose equipment-provided service code matches either EO Multi-function Router (C024) or HGW (C025). This is the target equipment type for the router re-identification process.

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | `ekk0341B504OutMsg[i].getString("KKTK_SVC_CD")` [Read equipment-provided service code field] |
| 2 | CHECK | `CD00132_MULTI_ROUTER.equals(...)` [-> `CD00132_MULTI_ROUTER="C024"` — Equipment code: EO Multi-function Router (EO光多機能ルーター)] |
| 3 | CHECK | `CD00132_HGW.equals(...)` [-> `CD00132_HGW="C025"` — Equipment code: HGW (Home Gateway)] |
| 4 | COND_OR | `||` [Either equipment code triggers return] |
| 5 | RETURN | `return ekk0341B504OutMsg[i]` [Return the matching service contract line message] |

**Block 4** — FINAL_RETURN (L814)

> If the loop completes without finding a matching service contract line, return null.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null` [No active service line with matching equipment code was found] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svcKeiKaisenUwNo` | Field | Service contract change-over work number — internal tracking ID used to identify and retrieve service contract line details during a service contract change-over operation |
| `KKTK_SVC_KEI_STAT` | Field | Equipment-provided service contract status — indicates the current lifecycle state of a service contract line (active, terminated, cancelled, etc.) |
| `KKTK_SVC_CD` | Field | Equipment-provided service code — identifies the type of equipment provided with the service (e.g., multi-function router, home gateway) |
| `TEMPLATE_ID_EKK0341B504` | Constant | Service contract details inquiry template ID — identifies the EKK0341B504CBS CBS that queries service contract line internal details |
| `FUNC_CODE_1` | Constant | Function code "1" — Check and Update mode, enabling the CBS to both query and validate data |
| `920` | Status Code | Service contract status: Cancelled (キャンセル済) — the service contract line has been cancelled and is no longer valid |
| `910` | Status Code | Service contract status: Terminated (解約済) — the service contract line has been terminated and is no longer in effect |
| `C024` | Service Code | Equipment-provided service code for EO Multi-function Router (EO光多機能ルーター) — a multi-function router device provided as part of the EO (Fujitsu) service offering |
| `C025` | Service Code | Equipment-provided service code for HGW (Home Gateway) — a home gateway device provided as part of the EO service offering |
| `EKK0341B504CBS` | Service Component | Equipment-provided service contract details inquiry CBS — batch processing system component that queries service contract line internal details by change-over work number |
| `機器提供` (Kiki Teikyou) | Term | Equipment-provided — services where Fujitsu provides hardware equipment (router, gateway) as part of the service contract |
| `サービス契約回線内詳` (Service Kei Kaisen-nai Shou) | Term | Service contract line internal details — detailed information about individual lines within a service contract |
| `サービス契約変更作業` (Service Kei Henkou Sagyou) | Term | Service contract change-over work — the business operation of modifying a service contract, including line changes, status transitions, and equipment re-identification |
| `EO光多機能ルーター` (EO Hikari Tamaki Nou Router) | Term | EO Multi-function Router — a multi-function optical router device provided by Fujitsu as part of the EO (Fujitsu Optical) service package |
| `HGW` | Acronym | Home Gateway — a networking device that serves as the gateway between the customer premises and the service provider network |
| `キャンセル済` (Kyansel-zumi) | Term | Cancelled — status indicating a service contract line has been cancelled |
| `解約済` (Kaiyaku-zumi) | Term | Terminated — status indicating a service contract line has been fully terminated |
| `PN/D変更` (Pishi/Dishi Henkou) | Term | PN/D (Part Number / Design Number) change — the business operation of changing the hardware identification of equipment in the router re-identification workflow |
