# Business Logic — JKKStbUcwkEoTvKktkSvcKeiCC.callSC() [37 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKStbUcwkEoTvKktkSvcKeiCC` |
| Layer | CC/Common Component — shared service invocation utility used across STB (Set-Top Box) service contract business logic |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKStbUcwkEoTvKktkSvcKeiCC.callSC()

This method is the central service invocation gateway for the STB (Set-Top Box) service contract subsystem. It delegates a business operation to an arbitrary Service Component (SC) via the `ServiceComponentRequestInvoker`, then standardizes the response processing pipeline: converting the inbound message to a parameter map, executing the SC, extracting templates and return codes, collecting error information into the control map, and validating the result. The method implements a **delegation + response normalization** pattern — it does not contain domain-specific logic itself but acts as a shared, reusable adapter that any STB service operation screen or CBS can invoke. Its role in the larger system is to abstract away the repetitive boilerplate of service invocation (parameter assembly, result parsing, error collection, and status validation) so that calling methods like `setKojiKikiData` and `stbUcwkEoTvKktkSvcKei` can focus on business-specific data preparation. The method handles two logical branches: (1) the success path, where the SC returns a return code of `"0"` and status of `0`, in which case the first template message is returned to the caller; and (2) the error path, where any non-zero return code or non-zero status triggers an `SCCallException` with the raw return value and status details.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callSC(handle, scCall, param, dataMapKey, inCAANMsg)"])
    START --> STEP1["editInMsg(param, inCAANMsg)"]
    STEP1 --> STEP2["scCall.run(paramMap, handle)"]
    STEP2 --> STEP3["Extract TEMPLATE_LIST_KEY from result"]
    STEP3 --> STEP4["CAANMsg msg = templates[0]"]
    STEP4 --> STEP5["Get RET_CD_INT_KEY as return_code"]
    STEP5 --> STEP6["Get STATUS_INT_KEY from templates[0] as status"]
    STEP6 --> STEP7["editErrorInfoCom(param, templates, return_code, dataMapKey)"]
    STEP7 --> STEP8["Get ERROR_INFO from control map"]
    STEP8 --> STEP9{"errList == null?"}
    STEP9 -->|true| STEP10["errList = new ArrayList<Object>()"]
    STEP9 -->|false| STEP11["Use existing errList"]
    STEP10 --> STEP12["Set ERROR_INFO via TemplateErrorUtil.getErrorInfo()"]
    STEP11 --> STEP12
    STEP12 --> STEP13{"Is return_code == '0' AND status == 0?"}
    STEP13 -->|true| RETURN["Return msg"]
    STEP13 -->|false| THROW["throw new SCCallException('戻り値不正', return_code, status)"]
    THROW --> END(["End — exception propagates"])
    RETURN --> END2(["End — success"])
```

**Processing description:**

1. **Inbound message conversion** — The method delegates to `editInMsg(param, inCAANMsg)` to transform the inbound `CAANMsg` and the request parameter object into a unified `HashMap<String, Object>` parameter map suitable for the SC invocation layer.

2. **SC invocation** — The `ServiceComponentRequestInvoker.run()` method is called with the prepared parameter map and session handle. This is the actual remote/local service component call. The result is a `Map` containing template messages, a return code, and status information.

3. **Response extraction** — The method extracts the template array using the constant `JCMConstants.TEMPLATE_LIST_KEY`, retrieves the first template (`templates[0]`) as the return message, and reads both the return code (`JCMConstants.RET_CD_INT_KEY`) and status code (`JCMConstants.STATUS_INT_KEY`) from the result.

4. **Error info pre-processing** — `editErrorInfoCom` is called to populate initial error information into the control map based on the return code and templates.

5. **Error info collection** — The method retrieves any existing error list from the control map under `SCControlMapKeys.ERROR_INFO`. If none exists, it creates a new empty list. Then it populates the control map with consolidated error information by calling `TemplateErrorUtil.getErrorInfo(result, errList)`.

6. **Result validation** — The method validates that both the return code is the string `"0"` AND the status integer is exactly `0`. If either condition fails, an `SCCallException` is thrown with the message `"戻り値不正"` (Return value abnormal), along with the actual return code and status values.

7. **Return** — On success, the first template message (`msg`) is returned to the caller.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | The database session handle used during SC execution. Carries transaction context, connection pool reference, and session-scoped data shared across the business operation's DB interactions. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | The service component invocation proxy — an invoker object that wraps the actual SC call (e.g., CHSV0065OPOperation, CHSV0066Flow). Determines which service component executes and what business operation is performed. This is injected by the caller, making this method SC-agnostic. |
| 3 | `param` | `IRequestParameterReadWrite` | The request parameter object that carries business data between the screen/CBS layer and the service component. Read/written for both input (parameter map assembly) and output (error info, control map data). Its control map is used as the error aggregation channel. |
| 4 | `dataMapKey` | `String` | The key used to identify or scope the data map entry within the session or request context. Passed to `editErrorInfoCom` for error categorization. |
| 5 | `inCAANMsg` | `CAANMsg` | The inbound message carrying the business data payload sent to the service component. Contains structured fields (e.g., service contract codes, work numbers, customer data) that need to be mapped into the parameter map. |

**External state / constants referenced:**

| Name | Type | Business Description |
|------|------|---------------------|
| `JCMConstants.TEMPLATE_LIST_KEY` | String constant | The key used to retrieve the CAANMsg template array from the SC result map. Defines where the service component places its response messages. |
| `JCMConstants.RET_CD_INT_KEY` | String constant | The key used to retrieve the return code from the SC result map. A return code of `"0"` indicates success. |
| `JCMConstants.STATUS_INT_KEY` | String constant | The key used to retrieve the integer status code from the first template message. A status of `0` indicates normal completion. |
| `SCControlMapKeys.ERROR_INFO` | String constant | The control map key under which error information is stored and retrieved for aggregation across the business operation. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKStbUcwkEoTvKktkSvcKeiCC.editInMsg` | (internal) | - | Converts inbound CAANMsg into a HashMap parameter map for SC invocation. Internal helper method. |
| C/R/U | `scCall.run` (paramMap, handle) | Varies by caller | Varies by SC | Delegates to the actual Service Component (e.g., CHSV0065OPOperation, CHSV0066Flow, CHSV0067Flow). The specific CRUD operation depends on which SC is invoked — the SC may create, read, update, or delete data via its own entity mappings. |
| U | `JKKStbUcwkEoTvKktkSvcKeiCC.editErrorInfoCom` | (internal) | - | Populates error information into the control map based on the SC return code and templates. Internal helper method. |
| R | `IRequestParameterReadWrite.getControlMapData` | - | - | Reads the error list from the control map of the request parameter object. |
| U | `IRequestParameterReadWrite.setControlMapData` | - | - | Writes consolidated error information back to the control map for downstream error display. |
| R | `TemplateErrorUtil.getErrorInfo` | - | - | Extracts and consolidates error information from the SC result map into the error list. Utility method for error aggregation. |

**Analysis notes:**

This method itself is a **service invocation wrapper** — the actual CRUD operations are performed by the SC that is passed in via `scCall`. The SC Code and Entity/DB tables vary depending on the caller:
- If the caller invokes **CHSV0065OPOperation**, the SC Code would be `CHSV0065` and the operations depend on that operation's entity mappings.
- If the caller invokes **CHSV0066Flow** or **CHSV0067Flow**, similar flow-level operations occur.
- The `scCall.run()` invocation is the single point where actual data operations (C/R/U/D) are executed, but the specific operation type and target tables are determined at call time by the caller's configuration.

## 5. Dependency Trace

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

Direct callers of this method: 2 methods (both in `JKKStbUcwkEoTvKktkSvcKeiCC`).
Terminal operations from this method: `editInMsg`, `run`, `editErrorInfoCom`, `getControlMapData`, `setControlMapData`, `getErrorInfo`.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKStbUcwkEoTvKktkSvcKeiCC.setKojiRenkeiKikiData` | `setKojiRenkeiKikiData` → `callSC` | `scCall.run` [varies] — SC Code and Entity depend on caller's configured SC |
| 2 | `JKKStbUcwkEoTvKktkSvcKeiCC.stbUcwkEoTvKktkSvcKei` | `stbUcwkEoTvKktkSvcKei` → `callSC` | `scCall.run` [varies] — SC Code and Entity depend on caller's configured SC |

**Notes:** Both callers are internal CBS methods within the same class (`JKKStbUcwkEoTvKktkSvcKeiCC`). No screen (KKSV*) or batch entry points were found within 8 hops. The method acts as a private utility that supports higher-level business methods in the same class.

## 6. Per-Branch Detail Blocks

**Block 1** — [METHOD START] `(paramMap assembly)` (L772)

> Assembles the parameter map from the inbound message and prepares for SC invocation.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramMap = editInMsg(param, inCAANMsg)` | Returns a `HashMap<String, Object>` containing the mapped input parameters for the SC. |

**Block 2** — [METHOD START] `(SC invocation)` (L780)

> Executes the delegated service component call.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `result = scCall.run(paramMap, handle)` | Delegates to the ServiceComponentRequestInvoker to execute the SC with the assembled parameters and session handle. Returns a `Map` containing `TEMPLATE_LIST_KEY`, `RET_CD_INT_KEY`, and template messages. |

**Block 3** — [METHOD START] `(response extraction)` (L782)

> Extracts the return message, return code, and status from the SC result.

| # | Type | Code | Code |
|---|------|------|------|
| 1 | SET | `templates = (CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY)` | Extracts the template array from the SC result. | -> CONSTANT: `JCMConstants.TEMPLATE_LIST_KEY` |
| 2 | SET | `msg = templates[0]` | First template is the primary return message. | |
| 3 | SET | `return_code = result.get(JCMConstants.RET_CD_INT_KEY)` | Gets the raw return code object. | -> CONSTANT: `JCMConstants.RET_CD_INT_KEY` |
| 4 | SET | `status = templates[0].getInt(JCMConstants.STATUS_INT_KEY)` | Gets the integer status from the first template. | -> CONSTANT: `JCMConstants.STATUS_INT_KEY` |

**Block 4** — [METHOD START] `(error info pre-processing)` (L787)

> Populates initial error information into the control map.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editErrorInfoCom(param, templates, (Integer)return_code, dataMapKey)` | Prepares error info in the control map based on the SC return code. |

**Block 5** — [METHOD START] `(error list preparation)` (L790)

> Retrieves any existing error list and prepares it for consolidation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `errList = (ArrayList<Object>)param.getControlMapData(SCControlMapKeys.ERROR_INFO)` | Retrieves existing error list from control map. | -> CONSTANT: `SCControlMapKeys.ERROR_INFO` |

**Block 6** — [IF] `(errList == null)` (L792)

> If no error list exists yet, create a new empty one.

| # | Type | Code |
|---|------|------|
| 1 | SET | `errList = new ArrayList<Object>()` | Initializes a new empty error list. | |

**Block 7** — [METHOD START] `(error list consolidation)` (L796)

> Sets the consolidated error info back into the control map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(result, errList))` | Writes consolidated error info to the control map. | -> CONSTANT: `SCControlMapKeys.ERROR_INFO` |

**Block 8** — [IF] `(return_code != "0" OR status != 0)` `(error validation)` (L800)

> Validates the SC result. If the return code is not `"0"` or the status is not `0`, throws an exception with the Japanese message "戻り値不正" (Return value abnormal).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `"0".equals(return_code.toString())` | Checks if return code equals success. | |
| 2 | EXEC | `0 == status` | Checks if status equals zero. | |
| 3 | EXEC | `throw new SCCallException("戻り値不正", return_code.toString(), status)` | Throws exception on failure. Japanese message: "戻り値不正" = "Return value abnormal / Invalid return value". | |

**Block 9** — [ELSE / SUCCESS PATH] `(return_code == "0" AND status == 0)` (L804)

> On successful SC execution, returns the first template message.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return msg` | Returns the primary template CAANMsg from the SC response. | |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| SC | Acronym | Service Component — a reusable business logic unit in the Fujitsu Futurity framework that performs specific operations (e.g., data insertion, validation, flow execution). |
| STB | Business term | Set-Top Box — refers to the cable/telecom set-top box service domain. The entire `JKKStbUcwkEoTvKktkSvcKeiCC` class operates within the STB service contract management context. |
| CAANMsg | Type | Custom message class used throughout the Futurity framework for structured data exchange between layers. Contains typed getters/setters for business fields. |
| SessionHandle | Type | Database session handle carrying transaction context, connection pool reference, and session-scoped data. |
| ServiceComponentRequestInvoker | Type | Proxy/wrapper class that invokes a Service Component (SC) with parameter maps and session handles. The abstraction allows the same invocation pattern for different SC types (Operations and Flows). |
| IRequestParameterReadWrite | Type | Interface for bidirectional parameter passing between CBS/screen layers and SCs. Supports both input parameter assembly and output/error data collection. |
| TEMPLATE_LIST_KEY | Constant | Map key (in `JCMConstants`) for extracting the CAANMsg template array from an SC result. |
| RET_CD_INT_KEY | Constant | Map key (in `JCMConstants`) for extracting the return code from an SC result. `"0"` indicates success. |
| STATUS_INT_KEY | Constant | Key (in `JCMConstants`) for extracting the integer status code from a CAANMsg template. `0` indicates normal completion. |
| SCControlMapKeys.ERROR_INFO | Constant | Key used in the request parameter's control map to store aggregated error information for display on the screen. |
| TemplateErrorUtil | Utility | Utility class that extracts and consolidates error information from SC result maps into error lists for UI display. |
| SCCallException | Exception | Custom exception thrown when an SC invocation returns a non-success return code or status. Carries the raw return code and status for debugging. |
| 戻り値不正 | Japanese literal | "Return value abnormal" / "Invalid return value" — the Japanese error message used in `SCCallException` to indicate an unexpected SC response. |
| editInMsg | Internal method | Converts the inbound CAANMsg and request parameter into a HashMap parameter map for SC invocation. |
| editErrorInfoCom | Internal method | Populates initial error information into the control map based on the SC return code and response templates. |
| CHSV0065OPOperation | SC Class | Service component operation (CHSV0065) — one of the STB service contract operations this method may delegate to. |
| CHSV0066Flow | SC Class | Service component flow (CHSV0066) — a multi-step flow for STB service contract processing. |
| CHSV0067Flow | SC Class | Service component flow (CHSV0067) — another multi-step flow for STB service contract processing. |
| JKKStbUcwkEoTvKktkSvcKeiCC | Class | STB Service Contract Business Logic Common Component — the class containing this method, handling Set-Top Box service contract operations including work coordination and completion notification. |
| param | Field | The request parameter object carrying business data fields such as service contract codes, work numbers, and customer identifiers. |
| dataMapKey | Field | A string key used to scope or identify the data map entry within the session/request context. |
