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

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

## 1. Role

### JKKCustMemberSbtChgCC.editResultRPECK0201C010()

This method is the **post-service result handler** for the "Contact Information Change" (連絡先変更) business operation. After a service component has been executed to modify a customer's contact details, this method processes the execution result and populates the `IRequestParameterReadWrite` work object with status codes, error messages, and structured error information that the calling screen or controller expects. It acts as a **response normalization** step that ensures the downstream UI layer receives consistent status information regardless of whether the underlying service succeeded, failed, or encountered an unexpected error.

The method implements a **status prioritization pattern**: it compares the template (service-level) status against the business process (BP-level) status and only overwrites the BP status if the service returned a higher (more severe) status code. This ensures that a service-level failure is always surfaced to the user even if the business process itself reported a more benign status. It also applies a **validation gate**: if the status does not correspond to a registered return message template, it collapses to status `0` (success/default), preventing undefined message lookups from reaching the presentation layer.

Its role in the larger system is that of a **shared result mapper** used by the contact information change flow (`RPECK0201`). It is called at the end of the change operation's business logic chain, after all service components have executed, and serves as the final step before the method returns control to the caller (typically the `execute()` method of the same component, or `runShosa()` in the eligibility verification component).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editResultRPECK0201C010(msgList, param)"])
    GET_TEMPLATES["Get CAANMsg[] templates from msgList via TEMPLATE_LIST_KEY"]
    TEMPLATE_0["Set template = templates[0]"]
    GET_RETURN_CODE["Get returnCode from msgList via RET_CD_INT_KEY"]
    GET_TEMPLATE_STATUS["Get templateStatus = template.getInt(ECK0201C010CBSMsg.STATUS)"]
    CHECK_RETURN_CODE{returnCode != 0?}
    SET_STATUS_9000["Set templateStatus = 9000"]
    VALIDATE_MSG_KEY{"Message key valid?"}
    SET_STATUS_0["Set templateStatus = 0"]
    GET_BP_STATUS["Get bpStatus from param controlMap RETURN_CODE, default -1 if null"]
    COMPARE_STATUS{templateStatus > bpStatus?}
    FORMAT_STATUS["Set formatStatus = String.format('%04d', templateStatus)"]
    GET_MESSAGE["Set message = JCMAPLConstMgr.getString(RETURN_MESSAGE_ + formatStatus)"]
    SET_RETURN_CODE["param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)"]
    SET_RETURN_MESSAGE["param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)"]
    INIT_ERROR_LIST["Create new ArrayList<Object> errorList"]
    CALL_GET_ERROR_INFO["Set ERROR_INFO = TemplateErrorUtil.getErrorInfo(msgList, errorList)"]
    CHECK_ERROR_LIST{errorList not null and not empty?}
    THROW_EXCEPTION["Throw SCCallException with returnCode and template status"]
    RETURN_ERROR["Return errorList"]
    END(["End"])

    START --> GET_TEMPLATES
    GET_TEMPLATES --> TEMPLATE_0
    TEMPLATE_0 --> GET_RETURN_CODE
    GET_RETURN_CODE --> GET_TEMPLATE_STATUS
    GET_TEMPLATE_STATUS --> CHECK_RETURN_CODE
    CHECK_RETURN_CODE -->|Yes| SET_STATUS_9000
    SET_STATUS_9000 --> VALIDATE_MSG_KEY
    CHECK_RETURN_CODE -->|No| VALIDATE_MSG_KEY
    VALIDATE_MSG_KEY -->|Yes| SET_STATUS_0
    SET_STATUS_0 --> GET_BP_STATUS
    VALIDATE_MSG_KEY -->|No| GET_BP_STATUS
    GET_BP_STATUS --> COMPARE_STATUS
    COMPARE_STATUS -->|Yes| FORMAT_STATUS
    COMPARE_STATUS -->|No| INIT_ERROR_LIST
    FORMAT_STATUS --> GET_MESSAGE
    GET_MESSAGE --> SET_RETURN_CODE
    SET_RETURN_CODE --> SET_RETURN_MESSAGE
    SET_RETURN_MESSAGE --> INIT_ERROR_LIST
    INIT_ERROR_LIST --> CALL_GET_ERROR_INFO
    CALL_GET_ERROR_INFO --> CHECK_ERROR_LIST
    CHECK_ERROR_LIST -->|Yes| THROW_EXCEPTION
    CHECK_ERROR_LIST -->|No| RETURN_ERROR
    THROW_EXCEPTION --> END
    RETURN_ERROR --> END
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `msgList` | `Map<?, ?>` | A message execution result map populated by the prior service component call. It carries the service-level status templates (`CAANMsg[]` array keyed by `TEMPLATE_LIST_KEY`) and the raw return code (`Integer` keyed by `RET_CD_INT_KEY`). The map is the communication conduit between the service execution layer and this result-mapping method. |
| 2 | `param` | `IRequestParameterReadWrite` | The business data read/write work object (control map) that carries state throughout the request lifecycle. This method reads the existing BP-level return code from it, writes back the normalized return code and message, and writes the aggregated error info. It is the bridge between the business component and the calling screen/controller. |

**Instance fields / external state read:** None directly. This method is purely functional, relying only on its parameters and static/utility lookups (`JCMAPLConstMgr.getString`, `TemplateErrorUtil.getErrorInfo`).

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `CAANMsg[].get(msgList)` | - | - | Retrieves the CAANMsg[] template array from msgList using the `TEMPLATE_LIST_KEY` constant |
| R | `CAANMsg.getInt(ECK0201C010CBSMsg.STATUS)` | - | - | Reads the service status code from the first template message in the array |
| R | `Integer.get(msgList)` | - | - | Retrieves the return code from msgList using the `RET_CD_INT_KEY` constant |
| R | `JCMAPLConstMgr.getString(key)` | - | - | Looks up a localized return message string by concatenating `RETURN_MESSAGE_` with the formatted status code; returns null if no mapping exists |
| R | `IRequestParameterReadWrite.getControlMapData(SCControlMapKeys.RETURN_CODE)` | - | - | Reads the existing BP-level return code from the control map (default -1 if absent) |
| W | `IRequestParameterReadWrite.setControlMapData(...)` | - | - | Writes the normalized return code, return message, and error info back to the control map |
| R | `TemplateErrorUtil.getErrorInfo(msgList, errorList)` | - | - | Reads the msgList to extract structured error information into the errorList; aggregates any errors generated during the service execution |

**Note:** This method performs no direct database CRUD operations (no SC Code or CBS invocations). It is a **pure result normalization utility** — all data reads come from in-memory objects (`msgList`, `param`), and all writes go to the control map for the next layer to consume.

## 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], `getControlMapData` [R], `setControlMapData` [W], `getInt` [R]

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

**Terminal operations from this method:** The method ultimately reads error info from `TemplateErrorUtil.getErrorInfo`, resolves message text via `JCMAPLConstMgr.getString`, reads/writes the control map via `getControlMapData`/`setControlMapData`, and reads status codes via `CAANMsg.getInt`. No service components (SC) or CBS codes are invoked, and no database entities or tables are directly accessed.

## 6. Per-Branch Detail Blocks

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

This block initializes the processing by extracting the service-level result data from the `msgList` map. It retrieves the `CAANMsg[]` template array, takes the first template element, and extracts the raw return code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = (CAANMsg[])msgList.get(JCMConstants.TEMPLATE_LIST_KEY)` // Extract CAANMsg template array from msgList [-> JCMConstants.TEMPLATE_LIST_KEY = "TEMPLATE_LIST_KEY"] |
| 2 | SET | `template = templates[0]` // Take first template element from array |
| 3 | SET | `returnCode = (Integer)msgList.get(JCMConstants.RET_CD_INT_KEY)` // Extract return code [-> JCMConstants.RET_CD_INT_KEY = "RET_CD_INT_KEY"] |
| 4 | SET | `templateStatus = template.getInt(ECK0201C010CBSMsg.STATUS)` // Read service status from template [-> ECK0201C010CBSMsg.STATUS = "status"] |

---

**Block 2** — [IF] Override status to 9000 on non-zero return code (L1817-L1819)

If the service returned a non-zero return code (indicating an error at the transport/invocation level), the method forces `templateStatus` to `9000` (a generic error status), overriding whatever status the template itself reported.

| # | Type | Code |
|---|------|------|
| 1 | IF | `returnCode.intValue() != 0` [-> If service returned an error code] |
| 2 | SET | `templateStatus = 9000` // Force generic error status |

---

**Block 3** — [IF] Validate message key against JCMAPLConstMgr (L1820-L1824)

Checks whether a localized message exists for the current `templateStatus`. The key is constructed by prepending `RETURN_MESSAGE_` and appending a zero-padded 4-digit version of the status. If no message mapping exists, the status is collapsed to `0` (default/success). This prevents the presentation layer from receiving status codes with no corresponding message text.

| # | Type | Code |
|---|------|------|
| 1 | IF | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null` [-> If no message template exists for this status] |
| 2 | SET | `templateStatus = 0` // Collapse to default status |

---

**Block 4** — [IF-ELSE] Determine BP-level status (L1826-L1835)

Reads the existing return code from the control map. If no return code is present (`obj == null`), sets `bpStatus` to `-1`, ensuring the template status always wins the comparison in Block 5 (since any valid status >= 0 > -1). If a return code exists, it is parsed from the string value.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bpStatus = 0` // Initialize BP status default |
| 2 | SET | `obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` // Read existing BP return code |
| 3 | IF | `obj == null` |
| 4 | SET | `bpStatus = -1` // No prior BP status — template status always wins |
| 5 | ELSE | |
| 6 | SET | `bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE))` // Parse existing BP status |

---

**Block 5** — [IF] Overwrite BP status if template status is higher (L1837-L1844)

Compares the service-level template status against the BP-level status. If the template status is higher, the method overwrites the BP-level return code and sets the corresponding localized message. This implements the **status escalation** logic: a service-level failure takes precedence over any business process status.

| # | Type | Code |
|---|------|------|
| 1 | IF | `templateStatus > bpStatus` [-> If service status is more severe than BP status] |
| 2 | SET | `formatStatus = String.format("%1$04d", templateStatus)` // Zero-padded 4-digit status string |
| 3 | SET | `message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // Lookup localized message |
| 4 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` // Write normalized return code |
| 5 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` // Write localized return message |

---

**Block 6** — [SET] Initialize error list and extract error info (L1846-L1848)

Creates a new empty `ArrayList<Object>` for error aggregation and calls `TemplateErrorUtil.getErrorInfo()` to populate it from the `msgList`. The resulting error list is then written into the control map under the `ERROR_INFO` key so the calling screen can iterate over structured error messages.

| # | Type | Code |
|---|------|------|
| 1 | SET | `errorList = new ArrayList<Object>()` // Initialize empty error collection |
| 2 | SET | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errorList))` // Populate and store error info |

---

**Block 7** — [IF] Throw exception if errors detected (L1850-L1853)

If the error list contains any entries after extraction, an `SCallException` is thrown with three constructor arguments: an empty message, the return code as a string, and the original template status. This signals a hard failure to the caller, which will handle the exception and propagate it up the stack.

| # | Type | Code |
|---|------|------|
| 1 | IF | `errorList != null && !errorList.isEmpty()` [-> If any errors were detected during service execution] |
| 2 | EXEC | `throw new SCCallException("", ((Integer)returnCode).toString(), templates[0].getInt(ECK0201C010CBSMsg.STATUS))` // Throw with return code and status |

---

**Block 8** — [RETURN] Return empty or populated error list (L1855)

If no errors were detected (Block 7 was not taken), the method returns the (possibly empty) `errorList` to the caller. The caller typically discards this return value since the error info is already stored in `param`, but it provides a secondary access path for callers that check the return value directly.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return errorList` // Return error collection to caller |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `editResultRPECK0201C010` | Method | Edit Result Handler for Contact Information Change — the post-service result normalization method for the RPECK0201 contact change screen flow |
| 連絡先変更 (Rentakuhenkou) | Business term | Contact Information Change — the business operation that modifies a customer's contact details (address, phone, email, etc.) |
| CAANMsg | Technical | Customer Application ANd message — a message wrapper class used for service component request/response payloads |
| `TEMPLATE_LIST_KEY` | Constant Key | Map key used to retrieve the `CAANMsg[]` template array from the execution result map |
| `RET_CD_INT_KEY` | Constant Key | Map key used to retrieve the integer return code from the execution result map |
| `ECK0201C010CBSMsg.STATUS` | CBS Message Field | The "status" field in the ECK0201C010 CBS response message — contains the service-level return status code (integer) |
| `RETURN_MESSAGE_` | Constant Prefix | Prefix for localized message keys in `JCMAPLConstMgr`; combined with a zero-padded 4-digit status code to form the lookup key (e.g., `RETURN_MESSAGE_0000`) |
| `JCMConstants` | Constant Class | JCM (J:COM Master?) constants class — holds map key definitions for message list operations |
| `JCMAPLConstMgr` | Utility Class | JCM Application Constants Manager — provides `getString()` for localized message retrieval by key |
| `SCControlMapKeys` | Constant Class | Service Component control map key definitions — defines keys like `RETURN_CODE`, `RETURN_MESSAGE`, `ERROR_INFO` used in the work object control map |
| `IRequestParameterReadWrite` | Interface | Read/write interface for the business data work object (control map) — used to pass data between processing layers |
| `TemplateErrorUtil.getErrorInfo()` | Utility Method | Extracts structured error information from the execution result map and populates the provided error list |
| `SCCallException` | Exception Class | Service Component Call Exception — thrown when a service-level error is detected; carries error code and status for upstream propagation |
| `templateStatus` | Variable | The service-level (template) status code — reflects the result of the underlying CBS/service execution |
| `bpStatus` | Variable | The business process-level return code — the status previously set by the business flow, potentially overwritten if the service status is higher |
| `returnCode` | Variable | The raw return code from the message list — indicates whether the service invocation itself succeeded (0) or failed (non-zero) |
| `formatStatus` | Variable | Zero-padded 4-digit string representation of `templateStatus` (e.g., `"0000"`, `"9000"`) used for message key lookup and control map storage |
| `errorList` | Variable | An `ArrayList<Object>` that holds structured error information extracted from the service result; populated by `TemplateErrorUtil.getErrorInfo()` |
