# Business Logic — JKKPopPwdShkkaRnkAddCC.editResultRP() [60 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKPopPwdShkkaRnkAddCC` |
| Layer | Controller / Common Component (CC) — shared result-processing utility |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKPopPwdShkkaRnkAddCC.editResultRP()

The `editResultRP` method serves as the central post-service result mapping and status resolution dispatcher. After a service component (SC) is invoked, this method extracts the SC return code, template status, and error information from the raw response map (`msgList`), then consolidates them into the business-process response object (`IRequestParameterReadWrite param`) that drives screen-level decision making.

Its primary business operation is **status dominance resolution**: it compares the status code returned by the service component against the business-process status (`bpStatus`) already set on the parameter object, and promotes the higher (worse) status to ensure that service-level errors always take precedence over earlier business-process outcomes. When the template status is elevated, the method also resolves the corresponding human-readable error message from the constant manager and writes both the status code and message back into the parameter's control map.

Additionally, the method performs **error info aggregation**: it retrieves any pre-existing error list from the parameter and merges it with fresh error details extracted from the service response via `TemplateErrorUtil.getErrorInfo`, enabling multi-source error accumulation (e.g., from multiple parallel SC invocations).

This method implements a **delegation pattern** — it does not invoke business services directly but instead reads structured response data (`CAANMsg[]`) and delegates error extraction to `TemplateErrorUtil`. It is a shared utility called by multiple internal callers (e.g., `callEKK0081A010SC()`, `callSvcInter()`) within `JKKPopPwdShkkaRnkAddCC`, meaning it is the canonical result-processing hook after any service component invocation in this component family.

**Block-level processing summary:**

- **Block 1 (L2708–L2712):** Extract `CAANMsg[] templates` and the first template, then retrieve the raw return code and template status from the service response map.
- **Block 2 (L2717–L2724):** Override status to 9000 if the return code is non-zero; validate template status against available message constants, resetting to 0 if the message key is missing.
- **Block 3 (L2726–L2738):** Derive the business-process status from `param`, then compare it against the template status — if the template status is worse (higher), promote it and write the corresponding error message.
- **Block 4 (L2740–L2747):** Aggregate error information by retrieving the existing error list (or creating a new one) and merging it with error data from the service response.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editResultRP params"])
    A["Get CAANMsg[] templates from msgList TEMPLATE_LIST_KEY"] --> B["Get template = templates[0]"]
    B --> C["Get Integer returnCode from msgList RET_CD_INT_KEY"]
    C --> D["int templateStatus = template getInt STATUS_INT_KEY"]
    D --> E{returnCode != 0?}
    E -- Yes --> F["templateStatus = 9000"]
    E -- No --> G["templateStatus unchanged"]
    F --> H{"JCMAPLConstMgr getString RETURN_MESSAGE_ + format templateStatus == null?"}
    G --> H
    H -- Yes --> I["templateStatus = 0"]
    H -- No --> J["templateStatus unchanged"]
    I --> K["Get bpStatus from param.getControlMapData RETURN_CODE"]
    J --> K
    K --> L{bpStatus derivation}
    L -- obj is null --> M["bpStatus = -1"]
    L -- obj not null --> N["bpStatus = parseInt obj"]
    M --> O{"templateStatus > bpStatus?"}
    N --> O
    O -- Yes --> P["formatStatus = format templateStatus as 4-digit"]
    P --> Q["message = JCMAPLConstMgr getString RETURN_MESSAGE_ + formatStatus"]
    Q --> R["param.setControlMapData RETURN_CODE formatStatus"]
    R --> S["param.setControlMapData RETURN_MESSAGE message"]
    S --> T["Get errList from param ERROR_INFO"]
    T --> U{"errList is null?"}
    U -- Yes --> V["errList = new ArrayList"]
    U -- No --> W["errList existing list"]
    V --> X["param.setControlMapData ERROR_INFO TemplateErrorUtil getErrorInfo msgList errList"]
    W --> X
    O -- No --> X
    X --> Y["return param"]
    Y --> END(["End"])
```

**CRITICAL — Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `JCMConstants.TEMPLATE_LIST_KEY` | `"templateList"` (inferred) | Map key to retrieve the `CAANMsg[]` array containing SC response templates |
| `JCMConstants.RET_CD_INT_KEY` | `"returnCdInt"` (inferred) | Map key for the service return code as an Integer |
| `JCMConstants.STATUS_INT_KEY` | `"status"` (inferred) | Map key for the template status code as an int |
| `SCControlMapKeys.RETURN_CODE` | `"RETURN_CODE"` (inferred) | Control map key for the status code on the param object |
| `SCControlMapKeys.RETURN_MESSAGE` | `"RETURN_MESSAGE"` (inferred) | Control map key for the human-readable status message |
| `SCControlMapKeys.ERROR_INFO` | `"ERROR_INFO"` (inferred) | Control map key for the aggregated error list on the param object |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `msgList` | `Map<?, ?>` | The raw response map returned by a service component invocation. It carries the CAANMsg template array (`TEMPLATE_LIST_KEY`), the integer return code (`RET_CD_INT_KEY`), and per-template status data. This map is the conduit through which all SC-level results flow into the business process — it encapsulates success/failure indicators, status codes, and error details from the backend. |
| 2 | `param` | `IRequestParameterReadWrite` | The business-process request/response parameter object. It holds the current business-process status (`RETURN_CODE`), the current error list (`ERROR_INFO`), and other control-map data used by the framework. This method mutates `param` to reflect the consolidated result and returns it for further processing or screen rendering. |

**Instance fields / external state:**
- `JCMConstants` — framework-level constant definitions (static references to template list, return code, and status map keys).
- `JCMAPLConstMgr` — application constant manager used to resolve status-code-to-message mappings (e.g., `RETURN_MESSAGE_0000`, `RETURN_MESSAGE_9000`).
- `SCControlMapKeys` — control map key constants for return code, return message, and error info.
- `TemplateErrorUtil.getErrorInfo(msgList, errList)` — utility method that extracts and formats error entries from the service response map.

## 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` (inherited from code graph) |
| R | `JBSbatACKojiChrgInfoTrkm.getErrorInfo` | - | - | Calls `getErrorInfo` in `JBSbatACKojiChrgInfoTrkm` (inherited from code graph) |
| R | `JBSbatFUCaseFileRnkData.getString` | - | - | Calls `getString` in `JBSbatFUCaseFileRnkData` (inherited from code graph) |
| R | `JBSbatFUMoveNaviData.getString` | - | - | Calls `getString` in `JBSbatFUMoveNaviData` (inherited from code graph) |
| R | `JBSbatZMAdDataSet.getString` | - | - | Calls `getString` in `JBSbatZMAdDataSet` (inherited from code graph) |
| R | `JESC0101B010TPMA.getString` | - | - | Calls `getString` in `JESC0101B010TPMA` (inherited from code graph) |
| R | `JESC0101B020TPMA.getString` | - | - | Calls `getString` in `JESC0101B020TPMA` (inherited from code graph) |
| R | `ApiBpInterface.getErrorInfo` | - | - | Calls `getErrorInfo` in `ApiBpInterface` (inherited from code graph) |

### Direct method calls within `editResultRP()`:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `CAANMsg.getInt()` | - | - | Reads the template status code from the first CAANMsg template in the SC response |
| R | `IRequestParameterReadWrite.getControlMapData()` (x2) | - | - | Reads existing bpStatus and error info from the param control map |
| U | `IRequestParameterReadWrite.setControlMapData()` (x3) | - | - | Writes the resolved return code, return message, and aggregated error info back to the param control map |
| R | `JCMAPLConstMgr.getString()` (x2) | - | - | Resolves human-readable error messages from the constant manager by template status key |
| R | `TemplateErrorUtil.getErrorInfo(msgList, errList)` | - | - | Aggregates error entries from the SC response map and the existing error list |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Component: `JKKPopPwdShkkaRnkAddCC.callEKK0081A010SC()` | `callEKK0081A010SC()` -> `editResultRP(msgList, param)` | `CAANMsg.getInt() [R]`, `getString() [R]`, `setControlMapData() [U]`, `TemplateErrorUtil.getErrorInfo() [R]` |
| 2 | Component: `JKKPopPwdShkkaRnkAddCC.callSvcInter()` | `callSvcInter()` -> `editResultRP(msgList, param)` | `CAANMsg.getInt() [R]`, `getString() [R]`, `setControlMapData() [U]`, `TemplateErrorUtil.getErrorInfo() [R]` |

**Terminal operations reached from this method:**

`CAANMsg.getInt()` [R], `JCMAPLConstMgr.getString()` [R], `IRequestParameterReadWrite.getControlMapData()` [R], `TemplateErrorUtil.getErrorInfo()` [R], `IRequestParameterReadWrite.setControlMapData()` [U], `CAANMsg.getString()` [R]

No screen/batch entry points found within 8 hops. Direct callers found: 2 methods.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET / EXEC] `(L2708–L2714)`

> Extract CAANMsg templates and return code from the service response map, then read the initial template status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `CAANMsg[] templates = (CAANMsg[])msgList.get(JCMConstants.TEMPLATE_LIST_KEY)` // Retrieve SC response template array [-> JCMConstants.TEMPLATE_LIST_KEY] |
| 2 | SET | `CAANMsg template = templates[0]` // Take the first (primary) template from the array |
| 3 | SET | `Integer returnCode = (Integer)msgList.get(JCMConstants.RET_CD_INT_KEY)` // Extract integer return code [-> JCMConstants.RET_CD_INT_KEY] |
| 4 | SET | `int templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)` // Read status code from template [-> JCMConstants.STATUS_INT_KEY] |

**Block 2** — [IF / IF] `(L2716–L2724)`

> If the SC returned a non-zero return code, override the status to 9000 (generic error). Then validate that a message key exists for the current status; if not, reset status to 0 (success/unknown).

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (returnCode.intValue() != 0)` // Non-zero return code from SC indicates failure [-> JCMConstants.RET_CD_INT_KEY] |
| 1.1 | SET | `templateStatus = 9000` // Override status to 9000 (service-level error) |
| 2 | IF | `if (JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null)` // Check if status message key exists |
| 2.1 | SET | `templateStatus = 0` // Reset to 0 if message constant is undefined — treat as success/unknown [-> "0000"] |

**Block 3** — [IF / ELSE] `(L2726–L2732)`

> Derive the current business-process status (bpStatus) from the param object. If no status is set yet, default to -1 (no prior status).

| # | Type | Code |
|---|------|------|
| 1 | SET | `int bpStatus = 0` // Initialize to 0 (success) |
| 2 | SET | `Object obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` // Read current BP status [-> SCControlMapKeys.RETURN_CODE] |
| 3 | IF | `if (obj == null)` // No prior BP status set |
| 3.1 | SET | `bpStatus = -1` // Default: no prior status exists |
| 4 | ELSE | // obj is not null |
| 4.1 | SET | `bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE))` // Parse existing status code |

**Block 4** — [IF] `(L2734–L2740)`

> Status dominance check: if the template (SC) status is higher (worse) than the current BP status, promote the SC status and write the corresponding message. This ensures service-level errors are never silently downgraded.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (templateStatus > bpStatus)` // SC status is worse than BP status — promote it [-> SCControlMapKeys.RETURN_CODE, SCControlMapKeys.RETURN_MESSAGE] |
| 1.1 | SET | `String formatStatus = String.format("%1$04d", templateStatus)` // Format as 4-digit zero-padded string |
| 1.2 | SET | `String message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // Resolve human-readable error message |
| 1.3 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` // Update param with escalated status code |
| 1.4 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` // Update param with error message |

**Block 5** — [IF / ELSE] `(L2742–L2747)`

> Error info aggregation: retrieve the existing error list from the param (or create a new one) and merge it with error details from the SC response via `TemplateErrorUtil.getErrorInfo()`. This supports multi-source error accumulation where errors from parallel SC calls are combined.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ArrayList<Object> errList = (ArrayList<Object>)param.getControlMapData(SCControlMapKeys.ERROR_INFO)` // Get existing error list [-> SCControlMapKeys.ERROR_INFO] |
| 2 | IF | `if (errList == null)` // No prior error list exists |
| 2.1 | SET | `errList = new ArrayList<Object>()` // Initialize empty list |
| 3 | EXEC | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errList))` // Merge SC errors with existing errors and write back [-> SCControlMapKeys.ERROR_INFO] |

**Block 6** — [RETURN] `(L2749)`

> Return the fully resolved `param` object containing the final status code, error message, and aggregated error list. This param is passed up the call chain to the screen or calling CBS for final decision making.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param;` // Return the consolidated response |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `msgList` | Parameter | Service Component response map — carries `CAANMsg` templates, return codes, and status data from the backend service invocation |
| `param` | Parameter | Business Process request/response parameter — the framework object that carries status codes, error messages, and error lists to the calling screen/CBS |
| `templateStatus` | Field | Template status code — the status returned by the service component's response template (e.g., 0 = success, 9000 = service error) |
| `bpStatus` | Field | Business Process status — the current status code previously set by the business process layer; used as a baseline for comparison against the SC status |
| `returnCode` | Field | Return code from SC — raw integer status from the service component (non-zero indicates failure) |
| `CAANMsg` | Type | CAAN Message — the framework message object containing key-value data returned from a service component invocation |
| `CAANMsg[] templates` | Field | Array of CAAN message templates — the complete set of responses from an SC call; `templates[0]` is the primary template |
| `TemplateErrorUtil.getErrorInfo()` | Method | Error extraction utility — aggregates error entries from the SC response map and an existing error list |
| `JCMConstants` | Class | Java Configuration Message Constants — framework constants defining map keys for template list, return code, and status |
| `JCMAPLConstMgr` | Class | Java Configuration Message Application Constants Manager — resolves status-code-to-message mappings (e.g., `RETURN_MESSAGE_0000` → success message, `RETURN_MESSAGE_9000` → error message) |
| `SCControlMapKeys` | Class | Service Component Control Map Keys — constant class defining keys for return code, return message, and error info in the param control map |
| `RETURN_CODE` | Constant | Control map key for the status code — the key used to store and retrieve the business status code in the param object |
| `RETURN_MESSAGE` | Constant | Control map key for the error message — the key used to store the human-readable status description in the param object |
| `ERROR_INFO` | Constant | Control map key for the error list — the key used to store the aggregated error entries in the param object |
| `9000` | Status | Service-level error code — used when the SC return code is non-zero, indicating a backend service failure |
| `0000` (formatStatus) | Status | Success / no-error code — the zero-padded representation of status 0, indicating normal completion |
| `-1` | Status | No prior status — sentinel value indicating no business-process status has been set yet (so any SC status will take precedence) |
