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

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

## 1. Role

### JKKCourseRkRtrNsIdChgCC.getSvcKeiUcwkMsg()

This method retrieves the service contract detail information for a given service contract number (`svcKeiNo`) and returns the first record whose status indicates an **active service state** — specifically, "Service Provision" (100), "Suspended/Interruption" (210), or "Stopped" (220). It operates as a **filtering dispatcher**: it delegates data retrieval to the `EKK0161B004` service component (which queries the service contract detail data), then iterates over the returned message list to find the first non-excluded record. Records with status "Cancelled" (910) or "Cancelled Completed" (920) are explicitly skipped, as those contracts are no longer valid. The method implements a **delegate-then-filter** pattern, commonly used in this codebase to obtain service contract information while ensuring that only currently relevant records are surfaced. Its role is to serve the `execute()` method within `JKKCourseRkRtrNsIdChgCC`, providing it with the active service contract detail record needed for the course/reference ID change processing flow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getSvcKeiUcwkMsg params"])
    BUILD_INMSG(["Build inMsg: TEMPLATE_ID_EKK0161B004, FUNC_CODE=3, svcKeiNo"])
    CALL_SC(["callSC handle, scCall, param, fixedText, ekk0161b004InMsg"])
    GET_LIST(["getCAANMsgList EKK0161B004CBSMSG1LIST"])
    LOOP_INIT(["for i=0; i<outMsgs.length; i++"])
    GET_STAT(["getString SVC_KEI_UCWK_STAT from outMsgs[i]"])
    COND_EXCLUDE{"svcKeiUcwkStat
910 or 920?"}
    SKIP_EXCLUDE(["continue - skip excluded"])
    COND_ACTIVE{"svcKeiUcwkStat
100 or 210 or 220?"}
    RETURN_MATCH(["return outMsgs[i]"])
    END_NULL(["return null"])

    START --> BUILD_INMSG
    BUILD_INMSG --> CALL_SC
    CALL_SC --> GET_LIST
    GET_LIST --> LOOP_INIT
    LOOP_INIT --> GET_STAT
    GET_STAT --> COND_EXCLUDE
    COND_EXCLUDE -->|"Yes"| SKIP_EXCLUDE
    SKIP_EXCLUDE --> LOOP_INIT
    COND_EXCLUDE -->|"No"| COND_ACTIVE
    COND_ACTIVE -->|"Yes"| RETURN_MATCH
    COND_ACTIVE -->|"No"| LOOP_INIT
```

**Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|-----------------|
| `TEMPLATE_ID_EKK0161B004` | `"EKK0161B004"` | Template ID for the service contract detail inquiry service component |
| `FUNC_CODE_3` | `"3"` | Function code 3 — service contract detail inquiry mode |
| `SVC_KEI_UCWK_STAT_100` | `"100"` | Service Provision — service is actively running |
| `SVC_KEI_UCWK_STAT_210` | `"210"` | Suspended/Interruption — service is temporarily paused |
| `SVC_KEI_UCWK_STAT_220` | `"220"` | Stopped — service is halted but not cancelled |
| `SVC_KEI_UCWK_STAT_910` | `"910"` | Cancelled — service contract has been cancelled |
| `SVC_KEI_UCWK_STAT_920` | `"920"` | Cancelled Completed — cancellation process fully completed |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session context handle carrying the current user's session state, transaction scope, and connection information for the service component call |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service Component invocation proxy used to route the request to the EKK0161B004CBS service component and receive its response |
| 3 | `param` | `IRequestParameterReadWrite` | Request/response parameter map — shared I/O container for data passing between the CBS and this method, used internally by `callSC` |
| 4 | `fixedText` | `String` | Fixed text string passed through to the service component (used for error messages, templates, or display text) |
| 5 | `svcKeiNo` | `String` | **Service contract number** — the primary key used to look up service contract detail records. This is the business identifier that determines which set of contract detail records is retrieved from the EKK0161B004CBS service component |

**Instance fields / external state:**
| Field | Type | Usage |
|-------|------|-------|
| `TEMPLATE_ID_EKK0161B004` | `String` | Constant defining the template ID for the service contract detail inquiry (resolved to `"EKK0161B004"`) |
| `FUNC_CODE_3` | `String` | Constant defining the function code (resolved to `"3"`, inquiry mode) |
| `SVC_KEI_UCWK_STAT_100` / `210` / `220` | `String` | Constants for active service states (resolved to `"100"`, `"210"`, `"220"`) |
| `SVC_KEI_UCWK_STAT_910` / `920` | `String` | Constants for excluded/cancelled service states (resolved to `"910"`, `"920"`) |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callSC` (JKKCourseRkRtrNsIdChgCC) | EKK0161B004CBS | Service contract detail data (EKK0161B004) | Delegates to the EKK0161B004CBS service component to read service contract detail records filtered by `svcKeiNo`, function code 3, and template ID |
| R | `CAANMsg.getString` | - | - | Reads the `SVC_KEI_UCWK_STAT` field from each returned message to inspect the service contract work status |
| R | `CAANMsg.getCAANMsgList` | - | - | Extracts the list of CAANMsg objects from the `EKK0161B004CBSMSG1LIST` key of the service component response |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS:JKKCourseRkRtrNsIdChgCC | `execute()` -> `getSvcKeiUcwkMsg(handle, scCall, param, fixedText, svcKeiNo)` | `callSC [R] EKK0161B004CBS -> SVC_KEI_UCWK_STAT [R]` |

**Terminal operations from this method:** `callSC [R] EKK0161B004CBS`, `getCAANMsgList [R]`, `getString [R] SVC_KEI_UCWK_STAT`

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(L317-323)` Build the input message array for the EKK0161B004CBS service call.

> Prepares the three-field input message that identifies the template, function code, and the specific service contract number to query.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0161b004InMsg` = `Object[][]` array |
| 2 | SET | `ekk0161b004InMsg[0][TEMPLATEID]` = `TEMPLATE_ID_EKK0161B004` -> `"EKK0161B004"` |
| 3 | SET | `ekk0161b004InMsg[1][FUNC_CODE]` = `FUNC_CODE_3` -> `"3"` |
| 4 | SET | `ekk0161b004InMsg[2][KEY_SVC_KEI_NO]` = `svcKeiNo` |

**Block 2** — [CALL] `(L325)` Invoke the service component and extract the result list.

> Calls the `callSC` helper method to forward the request to EKK0161B004CBS, then extracts the `EKK0161B004CBSMSG1LIST` from the response as a `CAANMsg[]` array.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callSC(handle, scCall, param, fixedText, ekk0161b004InMsg)` |
| 2 | EXEC | `.getCAANMsgList(EKK0161B004CBSMsg.EKK0161B004CBSMSG1LIST)` |
| 3 | SET | `ekk0161b004OutMsg` = `CAANMsg[]` (service contract detail records) |

**Block 3** — [FOR LOOP] `(L327-346)` Iterate over returned messages, filtering by status.

> Loops through each record in the response list. For each record, it reads the service contract work status and applies conditional filtering logic.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i` = loop index, iterates over `ekk0161b004OutMsg.length` |
| 2 | SET | `svcKeiUcwkStat` = `ekk0161b004OutMsg[i].getString(EKK0161B012CBSMsg1List.SVC_KEI_UCWK_STAT)` |

**Block 3.1** — [IF] `(condition: SVC_KEI_UCWK_STAT_910 or SVC_KEI_UCWK_STAT_920)` `[SVC_KEI_UCWK_STAT_910="910", SVC_KEI_UCWK_STAT_920="920"]` (L331-334)

> **Exclusion filter:** If the service contract work status is "Cancelled" (910) or "Cancelled Completed" (920), skip this record. These statuses indicate the contract is no longer active and should not be considered for the course reference ID change processing.

| # | Type | Code |
|---|------|------|
| 1 | IF | `SVC_KEI_UCWK_STAT_910.equals(svcKeiUcwkStat) || SVC_KEI_UCWK_STAT_920.equals(svcKeiUcwkStat)` |
| 2 | EXEC | `continue;` — skip to next iteration |

**Block 3.2** — [IF] `(condition: SVC_KEI_UCWK_STAT_100 or SVC_KEI_UCWK_STAT_210 or SVC_KEI_UCWK_STAT_220)` `[SVC_KEI_UCWK_STAT_100="100", SVC_KEI_UCWK_STAT_210="210", SVC_KEI_UCWK_STAT_220="220"]` (L337-342)

> **Active status match:** If the service contract work status is "Service Provision" (100), "Suspended/Interruption" (210), or "Stopped" (220), this is the first valid active record. Return this message immediately. The loop short-circuits at the first match, ensuring the earliest active record is returned.

| # | Type | Code |
|---|------|------|
| 1 | IF | `SVC_KEI_UCWK_STAT_100.equals(svcKeiUcwkStat) \|\| SVC_KEI_UCWK_STAT_210.equals(svcKeiUcwkStat) \|\| SVC_KEI_UCWK_STAT_220.equals(svcKeiUcwkStat)` |
| 2 | RETURN | `ekk0161b004OutMsg[i]` — return the active service contract detail record |

**Block 4** — [RETURN] `(L348)` Return null if no active record found.

> If the loop completes without finding any record with an active status (all records are cancelled/excluded, or the list is empty), return `null`. This signals to the caller that no valid active service contract detail exists for the given `svcKeiNo`.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `null` — no active record found in the result set |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svcKeiNo` | Field | Service contract number — the unique identifier for a service contract line item, used to look up associated detail records |
| `svcKeiUcwkStat` | Field | Service contract work status — indicates the current operational state of a service contract line item |
| `fixedText` | Field | Fixed text string — passed through to service components for use in error messages or display templates |
| `SVC_KEI_UCWK_STAT_100` | Constant | Service Provision — the service is actively running and available |
| `SVC_KEI_UCWK_STAT_210` | Constant | Suspended/Interruption — the service is temporarily paused but not cancelled |
| `SVC_KEI_UCWK_STAT_220` | Constant | Stopped — the service is halted but the contract remains active (not cancelled) |
| `SVC_KEI_UCWK_STAT_910` | Constant | Cancelled — the service contract has been cancelled and is excluded from active processing |
| `SVC_KEI_UCWK_STAT_920` | Constant | Cancelled Completed — the cancellation process has been fully completed; excluded from processing |
| `EKK0161B004CBS` | Service Component | Service contract detail inquiry service component — queries the service contract detail data store |
| `EKK0161B004CBSMSG1LIST` | Constant | Response list key — the named key within the CAANMsg response that holds the list of service contract detail records |
| `TEMPLATE_ID_EKK0161B004` | Constant | Template ID `"EKK0161B004"` — identifies the message template for the service contract detail inquiry SC |
| `FUNC_CODE_3` | Constant | Function code `"3"` — specifies the inquiry (read) operation mode for the SC |
| `callSC` | Method | Service Component invocation helper — delegates to the service component infrastructure to execute a CBS request |
| `CAANMsg` | Class | Fujitsu application message class — structured message container used for CBS request/response data exchange |
| `SessionHandle` | Class | Session context handle — carries the current session, transaction, and connection state |
| `ServiceComponentRequestInvoker` | Class | Service Component request invoker — the proxy used to invoke service component methods |
| `IRequestParameterReadWrite` | Interface | Request parameter read-write interface — shared I/O parameter map for CBS communication |
| JKKCourseRkRtrNsIdChgCC | Class | Course Reference Return New ID Change Common Component — business component handling course/reference ID change processing |
| `execute()` | Method | Parent method in JKKCourseRkRtrNsIdChgCC — orchestrates the course reference ID change workflow and calls this method to retrieve active service contract detail |
| EKK0161B004 | Module Code | Course/Service contract inquiry module — the subsystem handling service contract detail lookups |
