# Business Logic — JKKCustMemberSbtChgCC.editResultRPECK0031C010() [55 LOC]

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

## 1. Role

### JKKCustMemberSbtChgCC.editResultRPECK0031C010()

This method serves as a **post-service result mapping and status-routing utility** for the **Corporate Customer Information Change (法人お客様情報変更)** screen workflow. It is invoked after the business service component (CBS) has been executed to process a corporate customer record update. Its primary responsibility is to take the raw execution result returned in a message map (`msgList`), determine the effective business status code, compare it against the BP-level control status, and write the appropriate return code and message back into the control map so the calling screen can display the correct result to the user.

The method implements a **status priority pattern**: when the CBS returns a status code that is numerically higher (i.e., more severe) than the BP-level status already held in the control map, the method promotes the CBS status and message to the control map, ensuring that the most severe outcome is always surfaced to the user. If the CBS return code is non-zero (indicating a CBS-level error), the template status is escalated to `9000` (error override). Additionally, the method validates that the computed template status has a corresponding return message in the application constant store; if no message exists, it falls back to status `0` (success/informational).

It also handles **error collection** via `TemplateErrorUtil.getErrorInfo(msgList, errorList)`, aggregating any template-level errors into an `ArrayList` and writing them to the control map under `ERROR_INFO`. If the error list is non-empty after aggregation, the method throws an `SCCallException` carrying the return code and CBS status for higher-level exception handling. This method acts as a shared utility called by multiple entry points in the corporate customer management domain — both the main screen controller (`execute()`) and the investigation routine (`runShosa()`).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editResultRPECK0031C010(msgList, param)"])

    START --> EXTRACT["Extract templates from msgList via TEMPLATE_LIST_KEY"]
    EXTRACT --> GET_RETCD["Extract returnCode from msgList via RET_CD_INT_KEY"]
    GET_RETCD --> GET_STATUS["Read template status from CBS message (STATUS field)"]
    GET_STATUS --> CHECK_RETCD{returnCode == 0?}

    CHECK_RETCD -->|No| SET_STATUS["Set templateStatus = 9000"]
    CHECK_RETCD -->|Yes| CHECK_MSG{Template message null?}

    SET_STATUS --> CHECK_MSG
    CHECK_MSG -->|Yes| SET_DEFAULT["Set templateStatus = 0"]
    CHECK_MSG -->|No| GET_BPSTATUS

    SET_DEFAULT --> GET_BPSTATUS["Read bpStatus from control map RETURN_CODE"]
    GET_BPSTATUS --> CHECK_BPOBJ{Control map entry null?}

    CHECK_BPOBJ -->|Yes| SET_BPSTATUS["Set bpStatus = -1"]
    CHECK_BPOBJ -->|No| PARSE_BPSTATUS["Parse bpStatus from control map value"]

    SET_BPSTATUS --> CHECK_STATUS_GT{templateStatus > bpStatus?}
    PARSE_BPSTATUS --> CHECK_STATUS_GT

    CHECK_STATUS_GT -->|No| INIT_ERROR["Initialize empty errorList"]

    CHECK_STATUS_GT -->|Yes| FORMAT_STATUS["Format status as 4-digit string"]
    FORMAT_STATUS --> GET_MESSAGE["Get message template from JCMAPLConstMgr"]
    GET_MESSAGE --> SET_RETURN_CODE["Set RETURN_CODE on control map"]
    SET_RETURN_CODE --> SET_RETURN_MSG["Set RETURN_MESSAGE on control map"]
    SET_RETURN_MSG --> INIT_ERROR

    INIT_ERROR --> SET_ERROR_INFO["Set ERROR_INFO via TemplateErrorUtil.getErrorInfo"]
    SET_ERROR_INFO --> CHECK_ERROR{errorList not empty?}

    CHECK_ERROR -->|Yes| THROW["Throw SCCallException with returnCode and status"]
    CHECK_ERROR -->|No| RETURN["Return errorList"]
    THROW --> THROWS["Throws SCCallException"]

    THROWS --> END_END(["End"])
    RETURN --> END_END
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `msgList` | `Map<?, ?>` | Execution result map returned by the CBS after processing the corporate customer change request. Contains the template message array (`TEMPLATE_LIST_KEY`), the return code (`RET_CD_INT_KEY`), and potentially additional error templates used by `TemplateErrorUtil`. |
| 2 | `param` | `IRequestParameterReadWrite` | Business data read/write interface holding the control map — a key-value store for cross-method state within the request lifecycle. The method reads the current BP return code and writes the resolved return code, return message, and error info back into it for the calling screen. |

**Control map keys read/written:**

| Key Constant | Source Class | Direction | Business Meaning |
|-------------|-------------|-----------|-----------------|
| `RETURN_CODE` | `SCControlMapKeys` | Read / Write | Current business process return status code |
| `RETURN_MESSAGE` | `SCControlMapKeys` | Write | Human-readable message for the determined status |
| `ERROR_INFO` | `SCControlMapKeys` | Write | Aggregated error information list for the screen |

## 4. CRUD Operations / Called Services

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

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

### Direct method calls within this method:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `msgList.get()` (x2) | - | In-memory map | Reads `TEMPLATE_LIST_KEY` and `RET_CD_INT_KEY` from the CBS execution result map |
| R | `CAANMsg.getInt(ECK0031C010CBSMsg.STATUS)` | - | - | Reads the CBS response status code from the template message object |
| R | `JCMAPLConstMgr.getString()` | - | - | Looks up the return message template by key (`RETURN_MESSAGE_XXXX`) from application constants; returns null if no mapping exists |
| R | `param.getControlMapData(SCControlMapKeys.RETURN_CODE)` | - | - | Reads the BP-level return code currently set in the control map |
| W | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, ...)` | - | - | Writes the resolved 4-digit formatted status code into the control map |
| W | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, ...)` | - | - | Writes the human-readable return message into the control map |
| R | `TemplateErrorUtil.getErrorInfo(msgList, errorList)` | - | - | Scans the CBS message list to aggregate any template-level errors; populates the errorList |

## 5. Dependency Trace

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

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKCustMemberSbtChgCC.execute()` | `execute()` -> `editResultRPECK0031C010(msgList, param)` | `getErrorInfo [R]`, `getString [R]`, `getInt [R]`, `setControlMapData [W]`, `setControlMapData [W]` |
| 2 | `JKKSvkeiShosaCC.runShosa()` | `runShosa()` -> `editResultRPECK0031C010(msgList, param)` | `getErrorInfo [R]`, `getString [R]`, `getInt [R]`, `setControlMapData [W]`, `setControlMapData [W]` |

## 6. Per-Branch Detail Blocks

**Block 1** — SET `(Extract CBS result data)` (L1574)

> Extracts the template array and return code from the CBS execution result map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = msgList.get(JCMConstants.TEMPLATE_LIST_KEY)` // Retrieve CAANMsg array from execution result map [-> TEMPLATE_LIST_KEY] |
| 2 | SET | `template = templates[0]` // Take the primary CBS response template |
| 3 | SET | `returnCode = msgList.get(JCMConstants.RET_CD_INT_KEY)` // Retrieve CBS return code as Integer [-> RET_CD_INT_KEY] |

**Block 2** — SET `(Read CBS template status)` (L1580)

> Reads the raw status code directly from the CBS message template object.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateStatus = template.getInt(ECK0031C010CBSMsg.STATUS)` // CBS status from template message [-> STATUS = "status"] |

**Block 3** — IF `(returnCode != 0 — CBS error override)` (L1581)

> If the CBS returned a non-zero return code (indicating an error or abnormal termination), override the template status to `9000` as an error escalation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateStatus = 9000` // CBS error — force status to 9000 |

**Block 4** — IF `(template message template is null — unknown status fallback)` (L1583)

> Checks whether a return message exists for the computed template status. If no message mapping exists (the key `RETURN_MESSAGE_XXXX` is not defined), the status is considered unknown and falls back to `0` (success/informational).

| # | Type | Code |
|---|------|------|
| 1 | SET | `formatStatus = "RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)` // Build message lookup key |
| 2 | EXEC | `JCMAPLConstMgr.getString(formatStatus)` // Check if message mapping exists |
| 3 | SET | `templateStatus = 0` // Fallback to success if no message exists |

**Block 5** — SET `(Initialize bpStatus)` (L1589)

> Prepares the BP-level status variable for reading from the control map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bpStatus = 0` // Initial value before control map read |
| 2 | SET | `obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` // Read existing BP return code [-> RETURN_CODE] |

**Block 6** — IF/ELSE `(bpStatus control map entry is null)` (L1590)

> If the control map has no return code set yet, default to `-1` (indicating no prior status). Otherwise, parse the existing value.

| # | Type | Code |
|---|------|------|
| 1 | IF | `obj == null` (L1590) |
| 1.1 | SET | `bpStatus = -1` // No prior BP status set |
| 1.2 | ELSE | (L1594) |
| 1.3 | SET | `bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE))` // Parse existing return code |

**Block 7** — IF `(templateStatus > bpStatus — promote CBS status)` (L1599)

> If the CBS template status is numerically higher (more severe) than the current BP-level status, promote the CBS status and message into the control map. This ensures the most severe result is always presented to the user. The status is formatted as a 4-digit zero-padded string (e.g., `0001`, `9000`).

| # | Type | Code |
|---|------|------|
| 1 | SET | `formatStatus = String.format("%1$04d", templateStatus)` // Format as 4-digit string (e.g., "0001") |
| 2 | SET | `message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // Look up human-readable message |
| 3 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` // Write status to control map |
| 4 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` // Write message to control map |

**Block 8** — SET `(Initialize error list and collect errors)` (L1604)

> Creates a new empty error list and populates it via the template error utility, which scans the CBS message map for template-level errors.

| # | Type | Code |
|---|------|------|
| 1 | SET | `errorList = new ArrayList<Object>()` // Initialize empty error collection |
| 2 | EXEC | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errorList))` // Aggregate errors and write to control map [-> ERROR_INFO] |

**Block 9** — IF `(errorList not empty — throw exception)` (L1607)

> If any template-level errors were collected during the error aggregation step, throw an `SCCallException` carrying the return code and CBS status. This signals a hard failure to the calling controller.

| # | Type | Code |
|---|------|------|
| 1 | IF | `errorList != null && !errorList.isEmpty()` (L1607) |
| 1.1 | EXEC | `throw new SCCallException("", ((Integer)returnCode).toString(), templates[0].getInt(ECK0031C010CBSMsg.STATUS))` // Throw with returnCode and CBS status |

**Block 10** — RETURN `(Return error list)` (L1613)

> If no errors were collected, return the (empty) error list to the caller.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return errorList` // Empty list if no errors, or error list with collected items |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `JKKCustMemberSbtChgCC` | Class | Corporate Customer Supplementary Change Component — the shared controller component handling corporate customer record updates |
| `editResultRPECK0031C010` | Method | Result mapping method for screen RPECK0031 — processes the CBS response after corporate customer information change |
| `msgList` | Parameter | CBS execution result map containing templates, return codes, and error data from the service component call |
| `param` | Parameter | Request parameter interface providing a control map for cross-layer state passing within a business request |
| `CONTROL_MAP` | Concept | A key-value store attached to the request parameter, used to pass return codes, messages, and error info between BP components and screens |
| `TEMPLATE_LIST_KEY` | Constant | Key in msgList that holds the array of CBS template messages (CAANMsg[]) returned by the service call |
| `RET_CD_INT_KEY` | Constant | Key in msgList holding the CBS return code as an Integer; `0` means success, non-zero indicates error |
| `SCControlMapKeys.RETURN_CODE` | Constant | Control map key for the business process return status code |
| `SCControlMapKeys.RETURN_MESSAGE` | Constant | Control map key for the human-readable status message |
| `SCControlMapKeys.ERROR_INFO` | Constant | Control map key for the aggregated error information list |
| `STATUS` | Constant | CBS message field identifier — holds the service-level status code (e.g., 0=success, 9000=error) |
| `ECK0031C010CBSMsg` | Class | CBS message data class for the 0031C010 service component — defines the schema of the CBS response including the STATUS field |
| `JCMConstants` | Class | Shared constants class for Java Communication Message keys (TEMPLATE_LIST_KEY, RET_CD_INT_KEY) |
| `JCMAPLConstMgr` | Class | Application-level constant manager — provides string lookups from the application's constant/message store |
| `TemplateErrorUtil` | Class | Utility class that scans CBS message templates to collect error information |
| `SCCallException` | Exception | Service component call exception carrying return code and status for error propagation |
| `CAANMsg` | Class | CBS message wrapper class — provides type-safe accessors (getInt, getObject) to CBS message fields |
| `bpStatus` | Field | BP-level return status — the current status held in the control map before CBS result processing |
| `templateStatus` | Field | CBS template status — the raw or resolved status code from the CBS response after error override and message validation |
| `returnCode` | Field | CBS return code — the numeric indicator from the CBS execution result (0=success, non-zero=error) |
| `0031C010` | Service code | Service component identifier — the CBS code for corporate customer information change processing |
| `RPECK` | Prefix | Screen module prefix — "RPECK0031" refers to the corporate customer change screen |
| `法人` (Hojin) | Japanese term | Corporate / Legal entity — distinguishes corporate customer data from individual customer data |
| `変更` (Henkou) | Japanese term | Change / Update — indicates this workflow handles modifications to existing records |
