# Business Logic — JKKCustMemberSbtChgCC.editResultRPECK0011C120() [52 LOC]

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

## 1. Role

### JKKCustMemberSbtChgCC.editResultRPECK0011C120()

This method serves as a **post-service-component error-result mapping utility**. It is called after a CBS (Central Business System) service component — identified by the message key `ECK0011C120CBSMsg` — executes and returns its response through a `CAANMsg` template array. Its business purpose is to translate the raw CBS response into structured data on the `IRequestParameterReadWrite` parameter object so that subsequent processing steps (e.g., screen response preparation, further error handling) can consume it.

The method implements the **post-execution result aggregation** pattern. It performs three distinct responsibilities: (1) extracting and validating the CBS return status code against a return-message catalog; (2) promoting the CBS status to the BP (business process) control map if the CBS status is more severe than what the BP has already recorded; and (3) enriching the error list with structured error information via `TemplateErrorUtil.getErrorInfo()`.

Its role in the larger system is a **shared bridge** between CBS-level response objects (CAANMsg templates) and the BP-level parameter context (IRequestParameterReadWrite control map). It is called directly by `execute()`, `runShosa()`, and `updMemberSjisho()`, making it a central error-handling entry point after CBS invocations related to customer member registration/change operations (CustMemberSbtChg — Customer Member Sub-registration Change).

The method has a single conditional branching path: it checks whether the CBS return status is more severe than the currently recorded BP return status, and if so, promotes the CBS status and its corresponding message. Otherwise, it retains the BP's existing status. All branches funnel through the same error-list enrichment and exception-throwing logic at the end.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editResultRPECK0011C120(msgList, param)"])
    START --> EXTRACT_TEMPLATES["Extract CAANMsg[] templates from msgList using TEMPLATE_LIST_KEY"]
    EXTRACT_TEMPLATES --> EXTRACT_FIRST["Get first template templates[0]"]
    EXTRACT_FIRST --> EXTRACT_RETURN["Extract Integer returnCode from msgList using RET_CD_INT_KEY"]
    EXTRACT_RETURN --> GET_STATUS["Read templateStatus from template.getInt(ECK0011C120CBSMsg.STATUS)"]
    GET_STATUS --> CHECK_RETURN["returnCode != 0 ?"]
    CHECK_RETURN -->|Yes| SET_FAIL["Set templateStatus = 9000"]
    CHECK_RETURN -->|No| VALIDATE_STATUS["Validate templateStatus against JCMAPLConstMgr"]
    SET_FAIL --> VALIDATE_STATUS
    VALIDATE_STATUS --> STATUS_VALID{"JCMAPLConstMgr.getString(RETURN_MESSAGE_" + templateStatus) == null"}
    STATUS_VALID -->|True| RESET_STATUS["Set templateStatus = 0"]
    STATUS_VALID -->|False| GET_BP_STATUS
    RESET_STATUS --> GET_BP_STATUS["Extract bpStatus from param.getControlMapData(RETURN_CODE)"]
    GET_BP_STATUS --> BP_STATUS_NULL{"obj == null ?"}
    BP_STATUS_NULL -->|Yes| BP_STATUS_NEG1["Set bpStatus = -1"]
    BP_STATUS_NULL -->|No| BP_STATUS_PARSE["Parse bpStatus from RETURN_CODE string"]
    BP_STATUS_NEG1 --> STATUS_COMPARE
    BP_STATUS_PARSE --> STATUS_COMPARE["Compare templateStatus > bpStatus"]
    STATUS_COMPARE -->|Yes| SET_CONTROL["Set RETURN_CODE and RETURN_MESSAGE in param controlMap"]
    STATUS_COMPARE -->|No| GET_ERROR_LIST
    SET_CONTROL --> GET_ERROR_LIST["Get errorList from param.controlMapData(ERROR_INFO) or new ArrayList"]
    GET_ERROR_LIST --> CALL_GETERROR["TemplateErrorUtil.getErrorInfo(msgList, errorList)"]
    CALL_GETERROR --> SET_ERROR_INFO["Set param controlMapData(ERROR_INFO) with result"]
    SET_ERROR_INFO --> ERROR_CHECK{"errorList != null and NOT empty"}
    ERROR_CHECK -->|True| THROW_EX["Throw SCCallException with returnCode and status"]
    ERROR_CHECK -->|False| RETURN["Return errorList"]
    THROW_EX --> END(["Method End"])
    RETURN --> END
```

**Processing flow summary:**

1. **Template extraction:** The method retrieves the `CAANMsg[]` template array from the incoming `msgList` using the `TEMPLATE_LIST_KEY` constant, then takes the first element as the CBS response message.
2. **Return code extraction:** The CBS return code (`RET_CD_INT_KEY`) is extracted from `msgList`. If this is non-zero, it indicates a CBS-level failure, and the status is forced to `9000` (error fallback).
3. **Status validation:** The template's status code is looked up in the `JCMAPLConstMgr` return-message catalog using the key pattern `RETURN_MESSAGE_<status>`. If no message is found for that status, the status is reset to `0` (success/no-error default).
4. **BP status comparison:** The current BP return status is retrieved from the `param` control map. If not present, it defaults to `-1` (lower than any real status). The method then compares the validated template status against the BP status.
5. **Status promotion:** If the template status is higher (more severe) than the BP status, the template's status and its corresponding message are written to the BP control map, overwriting the BP's existing status.
6. **Error list enrichment:** Any existing error list is fetched from the control map (or created fresh if absent). `TemplateErrorUtil.getErrorInfo()` is called to append structured error details from the message list into the error list.
7. **Exception or return:** If the resulting error list is non-empty, an `SCCallException` is thrown with the return code and CBS status. Otherwise, the (possibly empty) error list is returned.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `msgList` | `Map<?, ?>` | A message list map containing the CBS response objects. It holds the `CAANMsg[]` template array (containing the CBS return status and message) and other CBS response data. The key `TEMPLATE_LIST_KEY` provides access to the template array, while `RET_CD_INT_KEY` provides the CBS return code. This map is the primary source of CBS-level results after a CBS invocation. |
| 2 | `param` | `IRequestParameterReadWrite` | The business process request/response parameter object. It provides read/write access to a control map (`getControlMapData`/`setControlMapData`) where BP-level state such as `RETURN_CODE`, `RETURN_MESSAGE`, and `ERROR_INFO` is stored. The method reads existing BP state and writes back the consolidated CBS result. |

**Instance fields read:** None — this method is fully stateless with respect to instance fields.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatACECBuyIfTrkm.getErrorInfo` | JBSbatACECBuyIfTrkm | - | Calls `getErrorInfo` in `JBSbatACECBuyIfTrkm` |
| R | `JBSbatACKojiChrgInfoTrkm.getErrorInfo` | JBSbatACKojiChrgInfoTrkm | - | Calls `getErrorInfo` in `JBSbatACKojiChrgInfoTrkm` |
| R | `JBSbatFUCaseFileRnkData.getString` | JBSbatFUCaseFileRnkData | - | Calls `getString` in `JBSbatFUCaseFileRnkData` |
| R | `JBSbatFUMoveNaviData.getString` | JBSbatFUMoveNaviData | - | Calls `getString` in `JBSbatFUMoveNaviData` |
| R | `JBSbatZMAdDataSet.getString` | JBSbatZMAdDataSet | - | Calls `getString` in `JBSbatZMAdDataSet` |
| R | `JESC0101B010TPMA.getString` | JESC0101B010TPMA | - | Calls `getString` in `JESC0101B010TPMA` |
| R | `JESC0101B020TPMA.getString` | JESC0101B020TPMA | - | Calls `getString` in `JESC0101B020TPMA` |
| R | `ApiBpInterface.getErrorInfo` | ApiBpInterface | - | Calls `getErrorInfo` in `ApiBpInterface` |

### Direct method calls within this method:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `template.getInt(ECK0011C120CBSMsg.STATUS)` | - | - | Reads the CBS response status code from the CAANMsg template. The status code indicates the result of the CBS operation (e.g., success, warning, error, with 9000 used as a failure fallback). |
| R | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + status)` | - | - | Reads return-message text from the centralized application constant manager. Status codes map to localized error/success messages (e.g., `RETURN_MESSAGE_0000` for success, `RETURN_MESSAGE_9000` for failure). |
| R | `param.getControlMapData(SCControlMapKeys.RETURN_CODE)` | - | - | Reads the current BP return code from the control map, used for status severity comparison. |
| R | `param.getControlMapData(SCControlMapKeys.ERROR_INFO)` | - | - | Reads any pre-existing error list from the control map for appending new error entries. |
| W | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` | - | - | Writes the promoted CBS status code to the control map. |
| W | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` | - | - | Writes the CBS return message to the control map. |
| W | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, errorList)` | - | - | Writes the enriched error list (containing errors from both BP and CBS) back to the control map. |
| R | `TemplateErrorUtil.getErrorInfo(msgList, errorList)` | - | - | Reads error details from the message list and appends them to the error list. Returns the enriched error list. |

**Note:** This method does **not** directly invoke any SC (Service Component) or CBS (Central Business System) methods. It operates solely on in-memory objects: the `CAANMsg` templates passed in `msgList`, the `IRequestParameterReadWrite` control map, and utility classes. The actual CBS invocation happens in the caller (e.g., `execute()`) before `editResultRPECK0011C120` is called to process the result.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 11 methods.
Terminal operations from this method: `getErrorInfo` [R], `getErrorInfo` [R], `getErrorInfo` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R]  # NOSONAR

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKCustMemberSbtChgCC.execute()` | `execute()` → `editResultRPECK0011C120(msgList, param)` | `getErrorInfo [R]`, `getString [R]` (from TemplateErrorUtil and JCMAPLConstMgr) |
| 2 | `JKKSvkeiShosaCC.runShosa()` | `runShosa()` → `editResultRPECK0011C120(msgList, param)` | `getErrorInfo [R]`, `getString [R]` (from TemplateErrorUtil and JCMAPLConstMgr) |
| 3 | `JKKSvkeiShosaClCC.updMemberSjisho()` | `updMemberSjisho()` → `editResultRPECK0011C120(msgList, param)` | `getErrorInfo [R]`, `getString [R]` (from TemplateErrorUtil and JCMAPLConstMgr) |

**Call chain detail:**

- **JKKCustMemberSbtChgCC.execute():** The main execution entry point for customer member sub-registration change business processing. After invoking the CBS service (identified by `ECK0011C120CBSMsg`), it calls `editResultRPECK0011C120()` to map the CBS response result back into the request parameter for downstream screen or process consumption.

- **JKKSvkeiShosaCC.runShosa():** A business-purpose investigation/processing handler (Shosa = "investigation/verification" in Japanese). After CBS service invocation, it delegates to `editResultRPECK0011C120()` to consolidate and map the result.

- **JKKSvkeiShosaClCC.updMemberSjisho():** A customer-list-side investigation handler that updates member address information (Sjisho = "address" in Japanese). After CBS service invocation, it calls `editResultRPECK0011C120()` to process the CBS return.

**Terminal operations:** The method's terminal operations consist entirely of read operations: `getErrorInfo` (called via `TemplateErrorUtil`) and `getString` (called via `JCMAPLConstMgr`). No create, update, or delete operations are performed.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Extract templates and return code from msgList (L1174-1178)

This block extracts the CBS response objects from the incoming message list.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `CAANMsg[] templates = (CAANMsg[])msgList.get(JCMConstants.TEMPLATE_LIST_KEY)` | Extracts the CAANMsg template array from msgList using the TEMPLATE_LIST_KEY constant. |
| 2 | SET | `CAANMsg template = templates[0]` | Takes the first template as the primary CBS response. |
| 3 | SET | `Integer returnCode = (Integer)msgList.get(JCMConstants.RET_CD_INT_KEY)` | Extracts the CBS return code. Returns 0 for success, non-zero for error. |

**Block 2** — [IF] Validate CBS status code (L1179-1186)

This block retrieves and validates the CBS status code. If the CBS returned a non-zero return code, the status is forced to 9000 (failure fallback). Then it validates the status against the return-message catalog.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `int templateStatus = template.getInt(ECK0011C120CBSMsg.STATUS)` | Reads the CBS status code from the template. STATUS maps to the "status" field of the CBS response. |
| 2 | IF | `returnCode.intValue() != 0` [RETURN_CODE != 0 → "CBS invocation had an error"] | If the CBS return code is non-zero, the operation failed. |
| 2.1 | SET | `templateStatus = 9000` | Overrides the status to 9000 (error/failure fallback status). |
| 3 | IF | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null` [STATUS not in catalog] | Checks whether the status has a corresponding message in the return-message catalog. |
| 3.1 | SET | `templateStatus = 0` | Resets status to 0 (success/no-error default) if no message is found for this status code. |

**Block 3** — [IF] Read BP current status (L1188-1196)

This block determines the current BP-level return status from the control map. It defaults to -1 if no status is recorded yet (ensuring any real CBS status will be higher).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `int bpStatus = 0` | Initializes BP status to 0 (neutral default). |
| 2 | SET | `Object obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` | Reads the current BP return code from the control map. |
| 3 | IF | `obj == null` [BP_RETURN_CODE not set] | If the BP has no return code set yet. |
| 3.1 | SET | `bpStatus = -1` | Sets to -1 so any CBS status will be higher and get promoted. |
| 4 | ELSE | `obj != null` [BP_RETURN_CODE exists] | The BP already has a return code. |
| 4.1 | SET | `bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE))` | Parses the existing BP return code as an integer. |

**Block 4** — [IF] Promote CBS status if more severe (L1198-1203)

This block compares the CBS template status against the BP status. If the CBS status is higher (more severe), it overwrites the BP's status and message.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `templateStatus > bpStatus` [CBS status is more severe than BP status] | The CBS service encountered a more serious condition than the BP itself recorded. |
| 1.1 | SET | `String formatStatus = String.format("%1$04d", templateStatus)` | Formats the status as a 4-digit zero-padded string (e.g., "9000"). |
| 1.2 | SET | `String message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` | Looks up the human-readable return message for this status code. |
| 1.3 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` | Overwrites the BP return code with the CBS status code. |
| 1.4 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` | Overwrites the BP return message with the CBS message. |
| 2 | ELSE | `templateStatus <= bpStatus` [CBS status is not more severe] | The BP already has a status that is at least as severe as CBS. No update needed. |

**Block 5** — [SET] Enrich error list (L1205-1208)

This block retrieves the existing error list from the control map and enriches it with error details from the CBS response using `TemplateErrorUtil.getErrorInfo()`.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ArrayList<Object> errorList = (ArrayList<Object>)param.getControlMapData(SCControlMapKeys.ERROR_INFO)` | Retrieves any existing error list from the control map. |
| 2 | SET | `errorList = (errorList == null ? new ArrayList<Object>() : errorList)` | If no error list exists, creates a fresh one (defensive initialization). |
| 3 | SET | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errorList))` | Calls TemplateErrorUtil.getErrorInfo() to append CBS-level error entries to the list and writes the enriched list back to the control map. |

**Block 6** — [IF] Throw exception if errors present (L1210-1212)

This block checks whether the enriched error list contains any errors. If so, it throws an `SCCallException` to abort processing.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `errorList != null && !errorList.isEmpty()` [Errors found after enrichment] | After CBS result mapping, there are still errors present. |
| 1.1 | THROW | `throw new SCCallException("", ((Integer)returnCode).toString(), templates[0].getInt(ECK0011C120CBSMsg.STATUS))` | Throws an SCCallException with empty detail message, the CBS return code as the error code, and the CBS status code as the status. |
| 2 | ELSE | `errorList == null || errorList.isEmpty()` [No errors] | The CBS response indicates success with no errors. |
| 2.1 | RETURN | `return errorList` | Returns the (possibly empty) error list to the caller. |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `msgList` | Field | Message list — a Map containing CBS (Central Business System) response objects, including the CAANMsg template array and return code. |
| `param` | Field | Business process parameter — the IRequestParameterReadWrite object that holds the request context and control map for passing data between BP processing stages. |
| `IRequestParameterReadWrite` | Interface | Request parameter read-write interface — the contract for objects that store and retrieve business data during a BP processing flow. |
| `CAANMsg` | Class | CAAN (Central Application Access Network) Message — a structured message object used to carry CBS request/response data fields. |
| `TEMPLATE_LIST_KEY` | Constant | The map key used to retrieve the CAANMsg[] template array from msgList. |
| `RET_CD_INT_KEY` | Constant | The map key used to retrieve the CBS integer return code from msgList. |
| `SCControlMapKeys.RETURN_CODE` | Constant | Control map key for the BP-level return code (status code). |
| `SCControlMapKeys.RETURN_MESSAGE` | Constant | Control map key for the BP-level return message text. |
| `SCControlMapKeys.ERROR_INFO` | Constant | Control map key for the error information list (ArrayList of errors). |
| `ECK0011C120CBSMsg` | CBS Message | CBS message definition class for the service identified by code ECK0011C120. Contains the `STATUS` field. |
| `STATUS` | Field | CBS response status field — an integer code indicating the result of the CBS operation (0 = success, non-zero = error/warning, 9000 = fallback error). |
| `JCMAPLConstMgr` | Class | Japan/Custom Application Library Constant Manager — a centralized utility for reading application-level string constants and messages by key. |
| `RETURN_MESSAGE_*` | Constant pattern | Return message key pattern — message catalog entries mapped by 4-digit zero-padded status code (e.g., `RETURN_MESSAGE_0000`, `RETURN_MESSAGE_9000`). |
| `TemplateErrorUtil.getErrorInfo()` | Method | Template error utility — extracts structured error information from CBS message templates and appends it to an error list. |
| `SCCallException` | Exception | Service Component Call Exception — a custom exception thrown when a CBS invocation or post-processing step encounters a fatal error. |
| `bpStatus` | Field | BP-level return status — the current status code recorded by the business process, used for severity comparison against CBS status. |
| `templateStatus` | Field | Template-level return status — the status code extracted from the CBS response template, subject to validation and potential fallback. |
| `returnCode` | Field | CBS return code — a 0-based integer returned by the CBS service indicating success (0) or failure (non-zero). |
| CustMemberSbtChg | Domain term | Customer Member Sub-registration Change — the business domain for this component, handling registration and modification of customer member supplementary registration data. |
| ECK0011C120 | CBS Code | CBS service identification code — the service component being invoked before this method processes the result. |
