# Business Logic — JKKSmtvlYoSanshoKeiInfCC.callSC() [43 LOC]

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

## 1. Role

### JKKSmtvlYoSanshoKeiInfCC.callSC()

This method serves as the **centralized service component (SC) invocation bridge** within the Japan Kotsu (transportation / railway) service migration and establishment workflow. It encapsulates the complete request-response lifecycle for calling downstream service components: building the inbound parameter mapping from raw request data, executing the remote SC, extracting and interpreting the response, and handling error propagation in a standardized fashion. The method follows a **delegation pattern** — it does not contain domain-specific logic itself, but instead coordinates data transformation (via `editInMsg`), remote invocation (via `scCall.run`), and result normalization (via `editErrorInfo` and `TemplateErrorUtil.getErrorInfo`). Its **role in the larger system** is that of a shared utility called by multiple higher-level business methods within the same class (`getMskmBngu`, `getSmtvlYoSanshoKeiInf`, `getSokuWariUm`), each of which triggers different service operations (e.g., service area determination, shipping/receiving establishment, speed allocation) depending on the `svcIfId` and `svcIfMapData` parameters passed in. The method is **not** a screen entry point or batch executor — it is an internal common component that abstracts away the repetitive SC call boilerplate so that domain methods can focus on business-specific data preparation and post-processing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callSC(params)"])
    STEP1["Build paramMap via editInMsg"]
    STEP2["Invoke SC via scCall.run"]
    STEP3["Extract CAANMsg templates from result"]
    STEP4["Extract rtnCode from result"]
    STEP5["Transfer error info via editErrorInfo"]
    STEP6["Retrieve errList from param"]
    STEP7["Set ERROR_INFO via TemplateErrorUtil"]
    STEP8["Extract status from templates[0]"]
    COND{rtnCode equals 0 AND status equals 0}
    THROWS["Throw SCCallException"]
    RETURN["Return templates[0]"]
    END_NODE(["End"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> STEP6
    STEP6 --> STEP7
    STEP7 --> STEP8
    STEP8 --> COND
    COND -->|True| RETURN
    RETURN --> END_NODE
    COND -->|False| THROWS
    THROWS --> END_NODE
```

**Processing Description:**

1. **Build Inbound Map (`editInMsg`)**: Constructs a `HashMap<String, Object>` parameter map from the raw request parameter (`param`), service interface ID (`svcIfId`), function code (`funcCode`), and service interface map data (`svcIfMapData`). This map becomes the input payload for the SC call.

2. **Invoke Service Component**: Executes the remote SC via `scCall.run(paramMap, handle)`, returning a `Map<?, ?>` result that contains the service response templates, return code, and status.

3. **Extract Templates**: Retrieves the `CAANMsg[]` templates array from the result using the template list key `[-> JCMConstants.TEMPLATE_LIST_KEY]`.

4. **Extract Return Code**: Reads the integer return code from the result using the return code key `[-> JCMConstants.RET_CD_INT_KEY]` and converts it to a String for comparison.

5. **Transfer Error Info**: Invokes `editErrorInfo` to copy error information from the SC result into the parameter object, keyed by the return code integer `[-> JCMConstants.RET_CD_INT_KEY]`.

6. **Retrieve Existing Error List**: Attempts to read any pre-existing error list from the param's control map using `[-> SCControlMapKeys.ERROR_INFO]`. If null, initializes a new empty `ArrayList`.

7. **Set ERROR_INFO**: Populates the param's control map with enriched error information by calling `TemplateErrorUtil.getErrorInfo(result, errList)`, which aggregates errors from the SC result and the existing error list.

8. **Extract Status & Validate**: Reads the integer status from `templates[0]` using `[-> JCMConstants.STATUS_INT_KEY]`. If either the return code is not "0" or the status is non-zero, throws an `SCCallException` with error details. Otherwise, returns the first template from the result as a `CAANMsg`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Represents the current transaction/session context, providing the connection context for the SC invocation. It carries session metadata such as the database connection, transaction isolation level, and user authentication context. |
| 2 | `param` | `IRequestParameterReadWrite` | The request parameter object that carries business input data from the calling screen or CBS. It is read to build the inbound map and written to populate error information and control map data. |
| 3 | `scCall` | `ServiceComponentRequestInvoker` | The service component invocation proxy used to execute the remote SC. This is the communication channel to the underlying service component layer (often a distributed EJB or microservice). |
| 4 | `svcIfId` | `String` | The service interface identifier that specifies which SC to invoke. It identifies the service contract (e.g., service determination, shipping establishment). Acts as a key for routing within `editInMsg`. |
| 5 | `funcCode` | `String` | The function code that identifies the specific business function being executed. Used alongside `svcIfId` in `editInMsg` for parameter mapping and error correlation. [-> FUNC_CODE="func_code" (JKKItntokiStaEndConstCC.java:28)] |
| 6 | `svcIfMapData` | `Object[][]` | A two-dimensional object array containing the raw service interface mapping data. Each inner array typically holds key-value pairs or column data that get placed into the `paramMap` for the SC call. |

**External State / Instance Fields:** None — this method is stateless and relies entirely on passed-in parameters and external utility classes (`editInMsg`, `editErrorInfo`, `TemplateErrorUtil`).

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKSmtvlYoSanshoKeiInfCC.editInMsg` | - | - | Calls `editInMsg` to build the inbound parameter map from request data (internal utility, SC-agnostic mapping) |
| C/R/U/D | `scCall.run` | (Dynamic — determined by `svcIfId`) | (Dynamic — determined by `svcIfId`) | Invokes the remote service component. The actual CRUD operation depends on which SC is targeted — the SC Code and entity tables are resolved at runtime based on the `svcIfId` passed in. |
| U | `JKKSmtvlYoSanshoKeiInfCC.editErrorInfo` | - | - | Calls `editErrorInfo` to copy error information from the SC result into the request parameter object |
| R | `TemplateErrorUtil.getErrorInfo` | - | - | Retrieves and aggregates enriched error information from the SC result and existing error list |

**Analysis:** This method does not directly reference entity tables or SQL. The actual database operations are performed by the downstream SC invoked via `scCall.run`. The SC Code is dynamically determined by the `svcIfId` parameter (e.g., `JKKSmtvl`, `JKKSokuWari`), and the entity tables depend on the specific SC implementation. The method's direct database footprint is limited to the error-info transfer (`editErrorInfo`) and error retrieval (`getErrorInfo`).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Method: `getMskmBngu` | `JKKSmtvlYoSanshoKeiInfCC.getMskmBngu` -> `callSC` | `scCall.run [C/R/U/D] (svcIfId-dependent)` |
| 2 | Method: `getSmtvlYoSanshoKeiInf` | `JKKSmtvlYoSanshoKeiInfCC.getSmtvlYoSanshoKeiInf` -> `callSC` | `scCall.run [C/R/U/D] (svcIfId-dependent)` |
| 3 | Method: `getSokuWariUm` | `JKKSmtvlYoSanshoKeiInfCC.getSokuWariUm` -> `callSC` | `scCall.run [C/R/U/D] (svcIfId-dependent)` |

**No screen/batch entry points found within 8 hops.** All callers are internal methods within `JKKSmtvlYoSanshoKeiInfCC` that act as domain-specific wrappers. The terminal operations from this method are: `getErrorInfo` [R], `editErrorInfo` [U], `run` [-].

## 6. Per-Branch Detail Blocks

**Block 1** — [SET/ASSIGN] `(Build inbound parameter map)` (L672-674)

> Builds the HashMap parameter map from raw request data. The comment reads: "▼ 上りマッピング処理" (▼ Upward mapping processing) and "上りマッピングの結果を取得するためのマップを生成" (Generate a map to obtain the result of upward mapping).

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap<String, Object> paramMap = editInMsg(param, svcIfId, funcCode, svcIfMapData);` // Build inbound map [-> func_code (JKKItntokiStaEndConstCC.java:28)] |

**Block 2** — [SET/ASSIGN] `(Execute SC call)` (L677-678)

> The comment reads: "SC呼出実行" (SC call execution). Invokes the remote service component with the built parameter map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Map<?, ?> result = scCall.run(paramMap, handle);` // Execute remote SC |

**Block 3** — [SET/ASSIGN] `(Extract templates from result)` (L681-682)

> The comment reads: "処理結果の判定" (Processing result judgment). Casts the result map to extract the CAANMsg templates array.

| # | Type | Code |
|---|------|------|
| 1 | SET | `CAANMsg[] templates = (CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY);` // Extract templates [-> JCMConstants.TEMPLATE_LIST_KEY] |

**Block 4** — [SET/ASSIGN] `(Extract return code)` (L685-686)

> The comment reads: "取得したリターンコード、ステータスの内容を見て異常かどうかの判定をする" (Check the obtained return code and status to determine if abnormal).

| # | Type | Code |
|---|------|------|
| 1 | SET | `String rtnCode = result.get(JCMConstants.RET_CD_INT_KEY).toString();` // Extract return code [-> JCMConstants.RET_CD_INT_KEY] |

**Block 5** — [EXEC] `(Transfer error info)` (L689-690)

> The comment reads: "エラー情報の転記" (Error information transfer). Copies error info from SC result into param.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `editErrorInfo(param, templates, (Integer)result.get(JCMConstants.RET_CD_INT_KEY));` // Transfer error info [-> JCMConstants.RET_CD_INT_KEY] |

**Block 6** — [SET/ASSIGN] `(Retrieve existing error list)` (L693-698)

> The comment reads: "エラー情報のマップを取得" (Get the error information map). Attempts to read existing error list from param's control map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ArrayList<Object> errList = (ArrayList<Object>)param.getControlMapData(SCControlMapKeys.ERROR_INFO);` // Get existing error list [-> SCControlMapKeys.ERROR_INFO] |
| 2 | IF-ELSE | `if (errList == null)` |
| 2.1 | SET | `errList = new ArrayList<Object>();` // Initialize empty list |

**Block 7** — [EXEC] `(Set enriched error info)` (L701)

> The comment reads: "コントロールマップに設定" (Set in control map). Aggregates errors from SC result and existing list.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(result, errList));` // Set ERROR_INFO [-> SCControlMapKeys.ERROR_INFO] |

**Block 8** — [SET/ASSIGN] `(Extract status)` (L703)

> Reads the status integer from the first template.

| # | Type | Code |
|---|------|------|
| 1 | SET | `int status = templates[0].getInt(JCMConstants.STATUS_INT_KEY);` // Extract status [-> JCMConstants.STATUS_INT_KEY] |

**Block 9** — [IF-CONDITION] `(Validate result: rtnCode equals "0" AND status equals 0)` (L705-708)

> The comment reads: "異常の場合、SCCallExceptionを生成してスローする" (In case of abnormality, generate and throw SCCallException). Checks if the SC call succeeded — both the return code must be "0" and the status must be 0. If either condition fails, throws an exception.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (!(\"0\".equals(rtnCode) && 0 == status))` // Check for success |
| 1.1 | THROW | `throw new SCCallException(\"戻値不正\", rtnCode, status);` // Invalid return value [-> "戻値不正" = "Invalid return value"] |

**Block 10** — [RETURN] `(Return first template)` (L711)

> Returns the first CAANMsg template from the result array.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return ((CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY))[0];` // Return first template [-> JCMConstants.TEMPLATE_LIST_KEY] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svcIfId` | Field | Service Interface ID — identifies which downstream service component to invoke. Each value corresponds to a specific business operation in the transportation service workflow. |
| `funcCode` | Field | Function Code — identifies the specific business function. Used for parameter mapping and error correlation. [-> FUNC_CODE="func_code" (JKKItntokiStaEndConstCC.java:28)] |
| `svcIfMapData` | Field | Service Interface Map Data — a 2D object array carrying the raw input data for the service component call. |
| paramMap | Field | Parameter Map — a `HashMap<String, Object>` built by `editInMsg` that holds all parameters to be passed to the SC. |
| rtnCode | Field | Return Code — the result code returned by the SC. "0" indicates success; any other value indicates an error condition. |
| status | Field | Status Code — an integer status indicator extracted from the first response template. 0 indicates normal completion. |
| SC | Acronym | Service Component — a remote service unit (often an EJB or microservice) that performs specific business operations. |
| SC Call | Acronym | Service Component Call — the invocation of a remote service component via the ServiceComponentRequestInvoker. |
| SCCallException | Type | A custom exception thrown when the SC returns an abnormal result (non-zero return code or non-zero status). Contains the original return code and status for error reporting. |
| CAANMsg | Type | A message/template class used by the framework to carry structured response data from SC calls. Each CAANMsg represents a response entity or error container. |
| JCMConstants | Type | Framework constant class defining keys for the result map, including `TEMPLATE_LIST_KEY` (templates array key), `RET_CD_INT_KEY` (return code key), and `STATUS_INT_KEY` (status key). |
| SCControlMapKeys | Type | Framework constant class defining keys for the param's control map, including `ERROR_INFO` (error information key). |
| editInMsg | Method | An internal utility method that transforms raw request parameters into a structured HashMap for the SC call. The comment reads: "上りマッピング処理" (Upward mapping processing). |
| editErrorInfo | Method | An internal utility method that transfers error information from the SC result into the request parameter object. The comment reads: "エラー情報の転記" (Error information transfer). |
| TemplateErrorUtil | Class | A utility class that aggregates and enriches error information from the SC result and existing error list. |
| handle | Field | Session Handle — carries the current transaction/session context including database connection and authentication. |
| param | Field | Request Parameter — carries business input from the calling screen/CBS. Read for mapping, written for error propagation. |
| scCall | Field | Service Component Request Invoker — the communication proxy to the underlying service component layer. |
| JKK | Acronym | Japan Kotsu — a domain prefix indicating this code belongs to the Japan Transportation (railway/transportation service) module. |
| Smtvl | Abbreviation | Shuttling / Transportation — relates to transportation or shuttle service operations. |
| YoSansho | Abbreviation | Delivery / Shipping — relates to shipping or delivery operations. |
| Kei | Abbreviation | Type / Category — indicates a classification or category of the service. |
| Inf | Abbreviation | Information — indicates a method dealing with information retrieval or establishment. |
| Mskm | Abbreviation | Area / District — relates to service area or district determination. |
| Bngu | Abbreviation | Binding / Connection — relates to binding or connection operations within the area. |
| SokuWari | Abbreviation | Speed Allocation — relates to speed or capacity allocation operations. |
| Um | Abbreviation | Allocation / Assignment — relates to resource or schedule assignment. |
