# Business Logic — JKKCourseRkRtrNsIdChgCC.getmultiKktkOpSvcKeiMsg() [42 LOC]

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

## 1. Role

### JKKCourseRkRtrNsIdChgCC.getmultiKktkOpSvcKeiMsg()

This method retrieves the multi-operation service contract details (機器オペレーションサービス契約一覧：Machine Operation Service Contract List) for a specific machine-provided service identified by `kktkSvcKeiNo`. It acts as a data-fetching and filtering helper method within the course/re-routing/namespace-ID change common component (`JKKCourseRkRtrNsIdChgCC`). The method delegates to the `EKK2811B010CBS` service component to retrieve all service contract records matching the given machine service key number, then iterates through the results to find the first usable (active) record. During iteration, it applies two exclusion filters: records with status codes `910` (cancellation/termination) and `920` (cancellation/holding) are skipped per Japanese comment "解約/キャンセルされたものを除外" (Exclude cancelled/cancelled items). Additionally, records whose service code equals `G02` (the `MULTI_ROUTER_VA_OP` constant) are excluded as per a ticket-adapted filter from OM-2014-0001951, which states that service code "G02" is not a target "機器オペレーションサービスコードが「G02」の場合は対象外" (When the machine operation service code is "G02", exclude from target). This is a routing/dispatch-style pattern — it queries a single service component, filters the result set, and returns the first eligible record, or `null` if none remain. Its role in the larger system is a shared utility called by `execute()`, likely during screen flows where a specific service contract line needs to be identified and passed onward for further processing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getmultiKktkOpSvcKeiMsg"])
    INPUT["Create ekk2811B010InMsg array with TEMPLATEID, FUNC_CODE_1, KEY_KKTK_SVC_KEI_NO"]
    CALLSC["callSC handle scCall param fixedText ekk2811B010InMsg"]
    GETLIST["getCAANMsgList EKK2811B010CBSMSG1LIST"]
    INITLOOP["i = 0"]
    CHECKLOOP["i < ekk2811B010OutMsg.length"]
    GETSTATUS["getString KKOP_SVC_KEI_STAT"]
    COND910["status == 910"]
    COND920["status == 920"]
    CONTINUE["continue loop"]
    GETSVCCD["getString KKOP_SVC_CD"]
    CONDG02["KKOP_SVC_CD == MULTI_ROUTER_VA_OP = G02"]
    CONTINUE2["continue loop"]
    RETURN["return ekk2811B010OutMsg[i]"]
    RETURNNULL["return null"]
    END(["End"])

    START --> INPUT
    INPUT --> CALLSC
    CALLSC --> GETLIST
    GETLIST --> INITLOOP
    INITLOOP --> CHECKLOOP
    CHECKLOOP -->|true| GETSTATUS
    GETSTATUS --> COND910
    COND910 -->|true| CONTINUE2
    COND910 -->|false| COND920
    COND920 -->|true| CONTINUE2
    COND920 -->|false| GETSVCCD
    GETSVCCD --> CONDG02
    CONDG02 -->|G02, true| CONTINUE2
    CONDG02 -->|false| RETURN
    CONTINUE2 --> NEXT["i++"]
    NEXT --> CHECKLOOP
    CHECKLOOP -->|false| RETURNNULL
    RETURNNULL --> END
    RETURN --> END
```

**CRITICAL — Constant Resolution:**
- `EKK2811B010CBSMsg.TEMPLATEID` → `"EKK2811B010"` (from `JKKHakkoSODConstCC.TEMPLATE_ID_EKK2811B010`, defined as `"EKK2811B010"`)
- `EKK2811B010CBSMsg.FUNC_CODE` → `FUNC_CODE_1 = "1"` (from `JKKHakkoSODConstCC.FUNC_CODE_1`, defined as `"1"`)
- `EKK2811B010CBSMsg.KEY_KKTK_SVC_KEI_NO` → maps to the `kktkSvcKeiNo` parameter (machine service key number)
- `MULTI_ROUTER_VA_OP` → `"G02"` (defined as `public static final String MULTI_ROUTER_VA_OP = "G02"` in `JKKCourseRkRtrNsIdChgCC` itself, line 138)
- Status code `"910"` → cancellation/termination status
- Status code `"920"` → cancellation/holding status

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transactional context for the CBS (Custom Business System) call. Carries connection, transaction, and session state needed to execute the service component query. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service Component invocation proxy. Used by `callSC` to route the request to the appropriate CBS/SC backend (`EKK2811B010CBS`). Enables invocation of remote or local service components without hardcoding the invocation mechanism. |
| 3 | `param` | `IRequestParameterReadWrite` | Request-response parameter object used to pass and retrieve data between the caller and the called service component. Acts as a shared data carrier for mapping, error handling, and return values. |
| 4 | `fixedText` | `String` | Fixed text / template identifier string passed through to `callSC`. Used by the CBS to determine response formatting or to select a message template for error/success messages. |
| 5 | `kktkSvcKeiNo` | `String` | Machine service key number (機器提供サービスキー番号) — the business identifier for a specific service contract line item associated with a machine (customer premises equipment). This value is used as the lookup key when querying the `EKK2811B010CBS` service component to retrieve all matching service contract records. |

**Fields/External State Read:**
| Field | Type | Business Description |
|-------|------|---------------------|
| `MULTI_ROUTER_VA_OP` | `public static final String` | Constant `"G02"` used as a service code filter to exclude multi-router VA (Value Added) operation entries from results. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callSC` | EKK2811B010CBS | KKOP_SVC_KEI (Service Contract Status Table) | Queries service contract records by machine service key number (`KEY_KKTK_SVC_KEI_NO`). The `callSC` method delegates to the `EKK2811B010CBS` CBS, which returns a list of `CAANMsg` objects in the `EKK2811B010CBSMSG1LIST` message list. Each message represents one service contract line item associated with the provided `kktkSvcKeiNo`. |

**Analysis:**
- **SC Code**: `EKK2811B010CBS` — inferred from the input message structure (`EKK2811B010CBSMsg` class references and `getCAANMsgList(EKK2811B010CBSMsg.EKK2811B010CBSMSG1LIST)` call pattern). The `EKK2811B010` prefix is the standard SC/CBS identification code.
- **Entity / DB**: `KKOP_SVC_KEI` (or equivalent service contract table) — inferred from the field name `KKOP_SVC_KEI_STAT` (service contract status) and `KKOP_SVC_CD` (service contract code). The `KKOP_` prefix follows the convention for "Machine Operation Service Contract" tables (機器オペレーションサービス契約).
- **Operation**: Read (R) — this method invokes a query only. It does not insert, update, or delete any records. It retrieves service contract records and filters them in-memory.

## 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], `callSC` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | JKKCourseRkRtrNsIdChgCC.execute() | `JKKCourseRkRtrNsIdChgCC.execute()` -> `getmultiKktkOpSvcKeiMsg(handle, scCall, param, fixedText, kktkSvcKeiNo)` | `callSC [R] KKOP_SVC_KEI (EKK2811B010CBS)` |

**Call Chain Details:**
- The `execute()` method (within the same class `JKKCourseRkRtrNsIdChgCC`) calls `getmultiKktkOpSvcKeiMsg()` to retrieve a service contract detail record. This is likely executed during screen processing where a user needs to view or modify a specific service contract associated with a machine.
- The terminal operation from this method is `callSC` which invokes the `EKK2811B010CBS` CBS, performing a read (R) operation on the service contract table (`KKOP_SVC_KEI`).

## 6. Per-Branch Detail Blocks

**Block 1** — SET (Input Message Construction) (L833)

Builds the input message array for the `EKK2811B010CBS` service component call. Sets three key-value pairs: template ID, function code, and the machine service key number lookup key.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk2811B010InMsg = { {TEMPLATEID, TEMPLATE_ID_EKK2811B010}, {FUNC_CODE, FUNC_CODE_1}, {KEY_KKTK_SVC_KEI_NO, kktkSvcKeiNo} }` // Two-dimensional array mapping message keys to values [-> TEMPLATE_ID_EKK2811B010="EKK2811B010"] [-> FUNC_CODE_1="1"] |

**Block 2** — CALL (Service Component Invocation) (L843)

Invokes the `EKK2811B010CBS` CBS via the `callSC` helper method and extracts the result list.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callSC(handle, scCall, param, fixedText, ekk2811B010InMsg)` // Invokes EKK2811B010CBS to query service contract records by kktkSvcKeiNo |
| 2 | EXEC | `.getCAANMsgList(EKK2811B010CBSMsg.EKK2811B010CBSMSG1LIST)` // Extracts the EKK2811B010CBSMSG1LIST message list from the returned CAANMsg |
| 3 | SET | `ekk2811B010OutMsg = [CAANMsg]` // Resulting array of service contract records |

**Block 3** — FOR LOOP (Iterate and Filter) (L845)

Iterates through all returned service contract records, applying exclusion filters for cancelled/terminated records and multi-router VA operations.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` // Loop counter initialization |
| 2 | CHECK | `i < ekk2811B010OutMsg.length` // Loop bounds check |
| 3 | EXEC | `ekk2811B010OutMsg[i].getString(EKK2811B010CBSMsg1List.KKOP_SVC_KEI_STAT)` // Get service contract status for current record |

**Block 3.1** — IF-ELSE-IF (Status Filter) (L849)

Excludes records with status codes `910` or `920` (cancelled/terminated). Per Japanese comment "解約/キャンセルされたものを除外" (Exclude cancelled/cancelled items).

| # | Type | Code |
|---|------|------|
| 1 | IF | `"910".equals(status)` [status == "910"] |
| 2 | ELSE-IF | `"920".equals(status)` [status == "920"] |
| 3 | EXEC | `continue` // Skip this record and proceed to next iteration |

**Block 3.2** — IF (Service Code Filter — Multi-Router VA OP) (L853)

Excludes records with service code `G02` (multi-router VA operation). Per Japanese comment "機器オペレーションサービスコードが「G02」の場合は対象外" (When the machine operation service code is "G02", exclude from target). Added as part of ticket OM-2014-0001951.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"G02".equals(svcCd)` [MULTI_ROUTER_VA_OP="G02"] |
| 2 | EXEC | `continue` // Skip this record and proceed to next iteration |

**Block 3.3** — RETURN (First Eligible Record) (L859)

Returns the first record that passes all filters. This implements a "first-match" strategy — the loop exits on the first eligible service contract record.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `ekk2811B010OutMsg[i]` // Return the first non-cancelled, non-G02 service contract record |

**Block 4** — RETURN NULL (No Eligible Record Found) (L862)

If the loop completes without finding any eligible record (all records were cancelled/terminated or had service code G02), returns `null`.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `null` // No eligible service contract record found in the result set |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kktkSvcKeiNo` | Field | Machine service key number (機器提供サービスキー番号) — the business identifier for a service contract line item associated with a customer premises equipment (machine). Used as the primary lookup key when querying service contract records. |
| `KKOP_SVC_KEI_STAT` | Field | Machine Operation Service Contract Status (機器オペレーションサービス契約ステータス) — the status code of a service contract line item. Values `910` and `920` indicate cancelled/terminated states. |
| `KKOP_SVC_CD` | Field | Machine Operation Service Contract Code (機器オペレーションサービス契約コード) — the classification code for the type of machine operation service. Value `G02` indicates a multi-router VA (Value Added) operation, which is excluded from results. |
| `MULTI_ROUTER_VA_OP` | Constant | Multi-Router Value Added Operation — constant `"G02"` used to identify and exclude multi-router VA operation service contracts from result sets. Added as part of ticket OM-2014-0001951. |
| `TEMPLATE_ID_EKK2811B010` | Constant | Template identifier `"EKK2811B010"` — used to identify the message template for the EKK2811B010 CBS query response. |
| `FUNC_CODE_1` | Constant | Function code `"1"` — specifies the operation type for the CBS call. In this context, indicates a standard query/retrieve function. |
| `EKK2811B010CBS` | Service Component | Machine Operation Service Contract List CBS (機器オペレーションサービス契約一覧カスタムビジネスシステム) — the Custom Business System responsible for retrieving machine operation service contract records by key number. |
| EKK2811B010CBSMSG1LIST | Message List | The message list identifier (`EKK2811B010CBSMSG1LIST`) within the CAANMsg response that contains the array of service contract records returned by the EKK2811B010CBS. |
| CAANMsg | Class | Fujitsu's message/parameter object class used across the BPM platform for request-response data exchange between service components. Wraps a map-based structure for structured key-value data exchange. |
| callSC | Method | Service Component invocation helper — a common component method that wraps the ServiceComponentRequestInvoker to execute a CBS call with a given input message structure and session context. |
| Machine Operation Service | Business term | Services related to the operation and management of customer premises equipment (CPE/machines), including installation, maintenance, and modification of service contracts associated with the equipment. |
| Machine-provided SV (機器提供SV) | Business term | Services provided by or associated with customer premises equipment (machines). The Japanese comment "機器オペレーションサービス契約一覧（機器提供SV）" identifies this as the machine operation service contract list for machine-provided services. |
| KKOP_ prefix | Naming convention | Prefix for Machine Operation Service Contract (機器オペレーションサービス契約) related fields and tables. Stands for "Kiki Operation Service" (機器オペレーションサービス). |
| OM-2014-0001951 | Ticket ID | Internal ticket reference for the filter added to exclude service code `G02` entries from multi-operation service contract list results. |
