# Business Logic — JKKSvkeiShosaBaseCC.callScCmn() [39 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKSvkeiShosaBaseCC` |
| Layer | Common Component (CC) — shared utility within the custom business logic layer |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKSvkeiShosaBaseCC.callScCmn()

This method serves as a **unified service component (SC) invocation gateway** — a common entry point that any screen or business component in the `JKKSvkeiShosaBaseCC` hierarchy uses to call an external Service Component via the SIF (Service Interface) layer. It encapsulates the full request-response lifecycle for a single SC call: it prepares the template metadata, builds the service input message from the request parameters, delegates to `ServiceComponentRequestInvoker` to execute the SC, retrieves the result messages, maps the SC response back onto the request parameter object for downstream processing, performs error checking, and validates the return code. The method follows a **delegation pattern** — it does not implement business logic itself but acts as an orchestrated conduit that prepares, dispatches, and post-processes every SC invocation. Its role in the larger system is critical as a shared utility; it is called by screen-level methods (e.g., `updCustinfo`) whenever they need to invoke a backend service component, ensuring consistent message preparation, error handling, and result mapping across all SC calls in the JKKS service contract editing domain.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callScCmn(param, handle, template, mapper)"])
    
    START --> S1["Initialize: sIFRequest=null, resultMsgs=null, sIFResult=null"]
    
    S1 --> S2["mapper.editTemplateCommon(param, template)"]
    S2 --> S3["sIFRequest = mapper.editInMsgCmn(param)"]
    S3 --> S4["sIFRequest.put(TEMPLATE_LIST_KEY, new CAANMsg[]{template})"]
    S4 --> S5["sIFResult = ServiceComponentRequestInvoker.run(sIFRequest, handle)"]
    S5 --> S6["resultMsgs = (CAANMsg[])sIFResult.get(TEMPLATE_LIST_KEY)"]
    S6 --> S7["editResultRP(sIFResult, param)"]
    S7 --> S8["errChk(sIFResult)"]
    S8 --> S9{"returnCode != 0"}
    
    S9 -->|No| S10["return resultMsgs"]
    S9 -->|Yes| S11["throw new Exception()"]
    S11 --> END(["End"])
    S10 --> END
```

**Processing description:**

1. **Initialization**: Local variables `sIFRequest`, `resultMsgs`, and `sIFResult` are declared and initialized to `null`.
2. **Template setup**: Calls `mapper.editTemplateCommon(param, template)` to set template-related common information (テンプレート共通情報を設定) on the request.
3. **Input message construction**: Calls `mapper.editInMsgCmn(param)` to build the service IF common input map from the request parameters (サービスIF共通の情報を設定).
4. **Template list registration**: Puts the template CAANMsg array into the request map using the key `TEMPLATE_LIST_KEY` (リクエスト用クラスタの設定) — this ensures the SC invocation receives the original template for correlation.
5. **SC invocation**: Creates a `ServiceComponentRequestInvoker` instance and calls `run(sIFRequest, handle)` to dispatch the request to the backend service component (SIFの呼び出し出し).
6. **Result extraction**: Retrieves the `CAANMsg[]` array from the result map using `TEMPLATE_LIST_KEY` (結果の取得).
7. **Result mapping**: Calls `editResultRP(sIFResult, param)` to map the SC response data back onto the request parameter object for downstream use (エラー情報のマッピング).
8. **Error checking**: Calls `errChk(sIFResult)` to validate the SC result for any error conditions (implicit from method name and usage pattern).
9. **Return code validation**: Retrieves the return code from the result map using `RET_CD_INT_KEY`. If the return code is non-zero, throws an `Exception` (return code not equal to zero).
10. **Return**: If the return code is zero, returns the `resultMsgs` array.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The business data I/O object carrying all request parameters and serving as the output container for mapped SC response data. It holds service contract editing domain data passed from the calling screen/business component. |
| 2 | `handle` | `SessionHandle` | The session handle used by the SIF layer to maintain transaction and session context across the SC invocation boundary. |
| 3 | `template` | `CAANMsg` | The CAANMsg template object containing metadata about the service component call — used for result correlation and passed through the SIF layer to the SC. |
| 4 | `mapper` | `JKKSIFMapperBase` | The mapper base class instance that transforms request parameters into SC input data and prepares template common information. Concrete implementations provide domain-specific mapping logic. |

**Instance fields / external state read:**
- None directly — all state flows through parameters and local variables.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `ServiceComponentRequestInvoker.run` | SIF Layer | - | Invokes an external Service Component with the prepared request map and session handle |
| U | `JKKSIFMapperBase.editTemplateCommon` | JKKSIFMapperBase | - | Sets template common information on the request parameter |
| U | `JKKSIFMapperBase.editInMsgCmn` | JKKSIFMapperBase | - | Builds the service IF common input map from request parameters |
| U | `JKKSvkeiShosaBaseCC.editResultRP` | JKKSvkeiShosaBaseCC | - | Maps SC response data back onto the request parameter object |
| R | `JKKSvkeiShosaBaseCC.errChk` | JKKSvkeiShosaBaseCC | - | Checks SC result for error conditions |

**Classification rationale:**
- `editTemplateCommon` / `editInMsgCmn` are **Update** operations — they populate and modify the request input structures.
- `ServiceComponentRequestInvoker.run` is the SC dispatch itself — business operation type marked as `-` since the actual CRUD (C/R/U/D) depends on the specific SC being invoked, which is determined by the `sIFRequest` contents at runtime.
- `editResultRP` is an **Update** — it writes SC response data back into the request parameter object.
- `errChk` is a **Read** — it reads and inspects the result for error flags without modifying data.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `errChk` [-], `editResultRP` [U], `run` [-], `editInMsgCmn` [U], `editTemplateCommon` [U]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKSvkeiShosaBaseCC.updCustinfo` | `JKKSvkeiShosaBaseCC.updCustinfo` -> `JKKSvkeiShosaBaseCC.callScCmn` | `errChk` [-], `editResultRP` [U], `run` [-], `editInMsgCmn` [U], `editTemplateCommon` [U] |

**Note:** `JKKSvkeiShosaBaseCC` is a base class in the service contract editing (振替査定) domain. `updCustinfo` invokes `callScCmn` to execute service component calls as part of customer information update processing. No direct screen entry points (KKSV*) were found — this method is a CC-level shared utility, not a screen-level entry point.

## 6. Per-Branch Detail Blocks

**Block 1** — VARIABLE DECLARATION (Local Variables) (L619)

> Declares and initializes local variables used throughout the method.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap<String, Object> sIFRequest = null;` // Service IF request map |
| 2 | SET | `CAANMsg[] resultMsgs = null;` // Service IF result message array |
| 3 | SET | `Map<?, ?> sIFResult = null;` // Service IF result map |

**Block 2** — TEMPLATE SETUP (L623)

> Sets template common information on the request. (テンプレート共通情報を設定)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `mapper.editTemplateCommon(param, template);` // Template common info setup |

**Block 3** — INPUT MESSAGE CONSTRUCTION (L626)

> Builds the service IF common input map from request parameters. (サービスIF共通の情報を設定)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `sIFRequest = mapper.editInMsgCmn(param);` // Service IF common input construction |

**Block 4** — TEMPLATE LIST REGISTRATION (L629)

> Inserts the template CAANMsg array into the request map under `TEMPLATE_LIST_KEY`. (リクエスト用クラスタの設定)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `sIFRequest.put(JCMConstants.TEMPLATE_LIST_KEY, new CAANMsg[]{template});` // Register template list |

**Block 5** — SERVICE COMPONENT INVOCATION (L632)

> Dispatches the prepared request to the backend Service Component via SIF. (SIFの呼び出し出し)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `sIFResult = (new ServiceComponentRequestInvoker()).run(sIFRequest, handle);` // SC invocation |

**Block 6** — RESULT EXTRACTION (L635)

> Retrieves the CAANMsg result array from the SC response map. (結果の取得)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `resultMsgs = (CAANMsg[])sIFResult.get(JCMConstants.TEMPLATE_LIST_KEY);` // Extract result messages |

**Block 7** — RESULT MAPPING (L638)

> Maps SC response data back onto the request parameter object for downstream business processing. (エラー情報のマッピング)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editResultRP(sIFResult, param);` // Map result data back to request |

**Block 8** — ERROR CHECKING (L640)

> Validates the SC result for error conditions. (Implicit — method name indicates error checking)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `errChk(sIFResult);` // Error condition check |

**Block 9** — RETURN CODE VALIDATION (IF BRANCH) (L643)

> Retrieves the return code from the SC result and checks for non-zero (error) status. (リターンコード取得)

| # | Type | Code |
|---|------|------|
| 1 | SET | `int returnCode = (Integer)sIFResult.get(JCMConstants.RET_CD_INT_KEY);` // Retrieve return code [-> JCMConstants.RET_CD_INT_KEY] |
| 2 | IF | `if (returnCode != 0)` // Non-zero return code indicates SC error |

**Block 9.1** — ERROR BRANCH (L644)

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new Exception();` // SC returned non-zero; propagate error |

**Block 9.2** — SUCCESS BRANCH (implicit)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return resultMsgs;` // SC returned successfully; return result messages |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `callScCmn` | Method | Common service component caller — a shared method that orchestrates external SC invocation for service contract editing operations |
| SIF | Acronym | Service Interface — the middleware layer that enables communication between the application and backend Service Components |
| SC | Acronym | Service Component — a backend business logic module that performs specific operations (e.g., customer info update, order processing) |
| CC | Acronym | Common Component — a shared utility class in the business layer providing cross-cutting functionality |
| CAANMsg | Class | A message object used within the CAAN framework for passing structured data between layers |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity representing service orders |
| JCM | Acronym | Likely "Java Common Module" or framework-specific common module constants namespace |
| `TEMPLATE_LIST_KEY` | Constant | Key for storing/retrieving the CAANMsg template array in the request/result maps |
| `RET_CD_INT_KEY` | Constant | Key for retrieving the integer return code from the SC result map (0 = success, non-zero = error) |
| `editTemplateCommon` | Method | Mapper method that sets up template-related common metadata on the request |
| `editInMsgCmn` | Method | Mapper method that constructs the service IF input map from request parameters |
| `editResultRP` | Method | Maps the SC response data back onto the request parameter object for downstream processing |
| `errChk` | Method | Validates the SC result for error conditions; throws if errors are detected |
| `ServiceComponentRequestInvoker` | Class | The SIF dispatcher that executes a Service Component given a request map and session handle |
| `updCustinfo` | Method | Customer information update method in JKKSvkeiShosaBaseCC — calls callScCmn to invoke SCs as part of update processing |
| JKKS | Domain | Service Contract Editing (振替査定) — the business domain for adjusting and editing service contracts |
| `IRequestParameterReadWrite` | Interface | Bidirectional parameter object for carrying business data between screens and business components |
| `SessionHandle` | Class | Session context handle maintaining transaction state across SIF invocation boundaries |
