# Business Logic — JKKIntrInfoChgCfmCC.editResultRP() [173 LOC]

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

## 1. Role

### JKKIntrInfoChgCfmCC.editResultRP()

This method is a post-service-component result handler used across the K-Opticom customer core system for processing the outcomes of any Service Component (SC) invocation related to intermedier (紹介) coupon, coupon, and advance registration business flows. It normalizes SC return values, resolves business status codes, maps template error messages, extracts field-level error data, and delegates SC-specific post-processing. The method implements a **dispatch-by-template-id pattern**: it branches on the `templateId` returned by the SC to populate a `contents` metadata array from a corresponding `CBSMsg` class, then iterates that array to pull field-level error strings (suffix `_err`) back into the inbound `inMap`. Finally, it performs business-level error determination — overriding the BP-level return code with the SC status if it is worse, injecting consolidated error info into the response parameter, handling the special "intermediary coupon update" (`EKK0081C310`) case that early-returns on service number errors, handling the "advance registration" (`EKK1091D010`) case that extracts program number and update timestamp, and throwing an `SCCallException` if the SC return code or status indicates failure.

As a shared utility called by 18+ `callEKKxxxxxxSC()` methods within the same class, this method is a central aggregation point in the introduction-coupon and advance-registration service lifecycle. It is the last step before returning control to the caller after any of the following service types are executed: Service Contract One-Shot Agreement (`EKK0081A010`), Intermediary List Confirmation (`EKK0311B001`), Intermediary Coupon Update (`EKK0081C310`), Post-Open Intermediary Coupon Application workflows (`EKK2891A010`, `EKK2891C020`, `EKK2891D010`, `EKK2891E010`), Discount Service Agreement List Confirmation (`EKK0481B001`), Discount Service Agreement One-Shot (`EKK0451A010`), Discount Service Contract Condition List (`EKK2391B003`), Coupon Code workflows (`EKK0311B002`, `EKK0311A010`, `EKK0311C010`), Advance Registration (`EKK1091D010`), and Advance Update (`EKK1091C010`).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editResultRP()"])
    
    START --> A["Get templates from msgList[JCMConstants.TEMPLATE_LIST_KEY]"]
    A --> B["Get first template: templates[0]"]
    B --> C["Get returnCode from msgList[JCMConstants.RET_CD_INT_KEY]"]
    C --> D["Get templateId and templateStatus from template"]
    D --> E{"returnCode != 0?"}
    E -->|Yes| F["templateStatus = 9000"]
    E -->|No| G["Return message check: JCMAPLConstMgr.getString for templateStatus"]
    F --> G
    G --> H["Get bpStatus from param.getControlMapData[RETURN_CODE]"]
    H --> I{"templateStatus > bpStatus?"}
    I -->|Yes| J["Set RETURN_CODE and RETURN_MESSAGE on param"]
    I -->|No| K["contents = null"]
    J --> K
    
    K --> L["Branch on templateId"]
    L --> L1["EKK0081A010?"]
    L1 -->|Yes| L1A["contents = EKK0081A010CBSMsg.getContents()"]
    L1 -->|No| L2["EKK0311B001?"]
    L2 -->|Yes| L2A["contents = EKK0311B001CBSMsg.getContents()"]
    L2 -->|No| L3["EKK0081C310?"]
    L3 -->|Yes| L3A["contents = EKK0081C310CBSMsg.getContents()"]
    L3 -->|No| L4["EKK2891A010?"]
    L4 -->|Yes| L4A["contents = EKK2891A010CBSMsg.getContents()"]
    L4 -->|No| L5["EKK2891C020?"]
    L5 -->|Yes| L5A["contents = EKK2891C020CBSMsg.getContents()"]
    L5 -->|No| L6["EKK2891D010?"]
    L6 -->|Yes| L6A["contents = EKK2891D010CBSMsg.getContents()"]
    L6 -->|No| L7["EKK2891E010?"]
    L7 -->|Yes| L7A["contents = EKK2891E010CBSMsg.getContents()"]
    L7 -->|No| L8["EKK2391B003?"]
    L8 -->|Yes| L8A["contents = EKK2391B003CBSMsg.getContents()"]
    L8 -->|No| L9["EKK0481B001?"]
    L9 -->|Yes| L9A["contents = EKK0481B001CBSMsg.getContents()"]
    L9 -->|No| L10["EKK0451A010?"]
    L10 -->|Yes| L10A["contents = EKK0451A010CBSMsg.getContents()"]
    L10 -->|No| L11["EKK1091D010?"]
    L11 -->|Yes| L11A["contents = EKK1091D010CBSMsg.getContents()"]
    L11 -->|No| L12["EKK0311B002?"]
    L12 -->|Yes| L12A["contents = EKK0311B002CBSMsg.getContents()"]
    L12 -->|No| L13["EKK0311A010?"]
    L13 -->|Yes| L13A["contents = EKK0311A010CBSMsg.getContents()"]
    L13 -->|No| L14["EKK0311C010?"]
    L14 -->|Yes| L14A["contents = EKK0311C010CBSMsg.getContents()"]
    L14 -->|No| L15["EKK1091C010?"]
    L15 -->|Yes| L15A["contents = EKK0311C010CBSMsg.getContents()"]
    L15 -->|No| L15B["contents stays null"]
    
    L1A --> M["Loop: contents != null && i < contents.length"]
    L2A --> M
    L3A --> M
    L4A --> M
    L5A --> M
    L6A --> M
    L7A --> M
    L8A --> M
    L9A --> M
    L10A --> M
    L11A --> M
    L12A --> M
    L13A --> M
    L14A --> M
    L15A --> M
    L15B --> M
    
    M --> N["element = contents[i][0]"]
    N --> O{"element contains '_err'?"}
    O -->|No| P{"i < length?"}
    O -->|Yes| Q{"template.isNull(element)?"}
    Q -->|No| R{"inMap.containsKey(element)?"}
    R -->|No| S["inMap.put(element, template.getString(element))"]
    R -->|Yes| P
    Q -->|Yes| P
    S --> P
    P -->|Yes| N
    P -->|No| T["Get errList from param[SCControlMapKeys.ERROR_INFO]"]
    T --> U["errList = new ArrayList if null"]
    U --> V["param.setControlMapData[ERROR_INFO] = TemplateErrorUtil.getErrorInfo(msgList, errList)"]
    V --> W["status = template.getInt[JCMConstants.STATUS_INT_KEY]"]
    W --> X{"EKK0081C310?"}
    X -->|Yes| Y["getEKK0081C310Msg(msgList, workMap)"]
    Y --> Z{"workMap[svc_kei_no_err_o] not blank?"}
    Z -->|Yes| AA["return param"]
    Z -->|No| AB{"EKK1091D010?"}
    X -->|No| AB
    AB -->|Yes| AC["inMap.put PRG_NO and upd_dtm_bf from template"]
    AB -->|No| AD{"returnCode != '0' OR status != 0?"}
    AC --> AD
    AD -->|Yes| AE["throw SCCallException('Return value invalid')"]
    AD -->|No| AF["return param"]
    AA --> END(["Return / Next"])
    AF --> END
    AE --> END
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `msgList` | `Map<?, ?>` | The result map returned from the SC invocation. Contains the `CAANMsg[]` template array keyed by `TEMPLATE_LIST_KEY` (used to derive templateId, templateStatus, and field-level error values), and the integer return code keyed by `RET_CD_INT_KEY` (SC-level success/failure indicator). |
| 2 | `param` | `IRequestParameterReadWrite` | The business data read/write interface. Used to read the BP-level return code (`RETURN_CODE`), to set override return code and message, to manage the error info list (`ERROR_INFO`), and ultimately returned as the populated response parameter. |
| 3 | `inMap` | `HashMap<String, Object>` | The inbound business data map keyed by `fixText` (user-specified string). Accumulates field-level error values from the template (fields whose name contains `_err`). Also used to inject advance registration metadata (`prg_no`, `upd_dtm_bf`) for `EKK1091D010`. |
| 4 | `workMap` | `HashMap<String, Object>` | A shared working map used for SC-specific post-processing delegation. For `EKK0081C310`, it holds `svc_kei_no_err_o` (service number error flag) after `getEKK0081C310Msg` processes it. |

**Instance fields / external state read:**
- `EKK0081A010` through `EKK1091C010` — private static final String constants defining SC template IDs used in the dispatch-by-template-id branching.
- `JCMConstants.TEMPLATE_LIST_KEY`, `JCMConstants.RET_CD_INT_KEY`, `JCMConstants.STATUS_INT_KEY` — keys for extracting data from `msgList` and `template`.
- `SCControlMapKeys.RETURN_CODE`, `SCControlMapKeys.RETURN_MESSAGE`, `SCControlMapKeys.ERROR_INFO` — keys for managing control data on `param`.

## 4. CRUD Operations / Called Services

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

The following table classifies all method calls within `editResultRP()` by their business operation type. SC Codes are inferred from the method/class names of the called components.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `EKK0081A010CBSMsg.getContents` | EKK0081A010 | - | Reads the message contents metadata for Service Contract One-Shot Agreement template |
| R | `EKK0311B001CBSMsg.getContents` | EKK0311B001 | - | Reads the message contents metadata for Intermediary List Confirmation template |
| R | `EKK0081C310CBSMsg.getContents` | EKK0081C310 | - | Reads the message contents metadata for Intermediary Coupon Update template |
| R | `EKK2891A010CBSMsg.getContents` | EKK2891A010 | - | Reads the message contents metadata for Post-Open Intermediary Coupon Application One-Shot Agreement template |
| R | `EKK2891C020CBSMsg.getContents` | EKK2891C020 | - | Reads the message contents metadata for Post-Open Intermediary Coupon Application Information Change template |
| R | `EKK2891D010CBSMsg.getContents` | EKK2891D010 | - | Reads the message contents metadata for Post-Open Intermediary Coupon Application Registration template |
| R | `EKK2891E010CBSMsg.getContents` | EKK2891E010 | - | Reads the message contents metadata for Post-Open Intermediary Coupon Application Deletion template |
| R | `EKK2391B003CBSMsg.getContents` | EKK2391B003 | - | Reads the message contents metadata for Discount Service Contract Condition List Confirmation template |
| R | `EKK0481B001CBSMsg.getContents` | EKK0481B001 | - | Reads the message contents metadata for Discount Service Target Contract List Confirmation template |
| R | `EKK0451A010CBSMsg.getContents` | EKK0451A010 | - | Reads the message contents metadata for Discount Service Agreement One-Shot Agreement template |
| R | `EKK1091D010CBSMsg.getContents` | EKK1091D010 | - | Reads the message contents metadata for Advance Registration template |
| R | `EKK0311B002CBSMsg.getContents` | EKK0311B002 | - | Reads the message contents metadata for Coupon Code List Confirmation template |
| R | `EKK0311A010CBSMsg.getContents` | EKK0311A010 | - | Reads the message contents metadata for Coupon Code One-Shot Agreement template |
| R | `EKK0311C010CBSMsg.getContents` | EKK0311C010 | - | Reads the message contents metadata for Coupon Code Update template |
| R | `EKK0311C010CBSMsg.getContents` | EKK1091C010 | - | Reads the message contents metadata for Advance Update template (note: delegates to EKK0311C010CBSMsg — possible defect) |
| R | `JKKIntrInfoChgCfmCC.getEKK0081C310Msg` | EKK0081C310 | - | Calls SC-specific post-processor for Intermediary Coupon Update; populates workMap with error info |
| R | `JCMAPLConstMgr.getString` | JCMAPLConstMgr | - | Reads localized return message string by key `RETURN_MESSAGE_XXXX` |
| R | `TemplateErrorUtil.getErrorInfo` | TemplateErrorUtil | - | Reads and consolidates error information from msgList into an ArrayList |
| - | `template.getString` | - | - | Reads individual field values from the CAANMsg template |
| - | `template.getInt` | - | - | Reads status code from the CAANMsg template |
| - | `template.isNull` | - | - | Checks whether a field exists in the CAANMsg template (for error field dedup) |
| - | `param.getControlMapData` | - | - | Reads control data from the response parameter |
| - | `param.setControlMapData` | - | - | Writes control data (RETURN_CODE, RETURN_MESSAGE, ERROR_INFO) to the response parameter |
| - | `workMap.get` | - | - | Reads the service number error flag from the working map |
| - | `inMap.put` | - | - | Writes field-level error data or metadata to the inbound business map |

## 5. Dependency Trace

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Call: `JKKIntrInfoChgCfmCC.callEKK0081A010SC()` | `callEKK0081A010SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 2 | Call: `JKKIntrInfoChgCfmCC.callEKK0081C310SC()` | `callEKK0081C310SC()` -> `editResultRP()` | `getEKK0081C310Msg [R]`, `getString [R]`, `isNullBlank [-]` |
| 3 | Call: `JKKIntrInfoChgCfmCC.callEKK0311A010SC()` | `callEKK0311A010SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 4 | Call: `JKKIntrInfoChgCfmCC.callEKK0311A010SC_search()` | `callEKK0311A010SC_search()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 5 | Call: `JKKIntrInfoChgCfmCC.callEKK0311A010SC_upd()` | `callEKK0311A010SC_upd()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 6 | Call: `JKKIntrInfoChgCfmCC.callEKK0311B001SC()` | `callEKK0311B001SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 7 | Call: `JKKIntrInfoChgCfmCC.callEKK0311B002SC()` | `callEKK0311B002SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 8 | Call: `JKKIntrInfoChgCfmCC.callEKK0311C010SC()` | `callEKK0311C010SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 9 | Call: `JKKIntrInfoChgCfmCC.callEKK0451A010SC()` | `callEKK0451A010SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 10 | Call: `JKKIntrInfoChgCfmCC.callEKK0481B001SC()` | `callEKK0481B001SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 11 | Call: `JKKIntrInfoChgCfmCC.callEKK1091C010SC()` | `callEKK1091C010SC()` -> `editResultRP()` | `getString [R]`, `isNullBlank [-]`, `getEKK0081C310Msg [R]` |
| 12 | Call: `JKKIntrInfoChgCfmCC.callEKK1091D010SC()` | `callEKK1091D010SC()` -> `editResultRP()` | `getString [R]`, `isNullBlank [-]` |
| 13 | Call: `JKKIntrInfoChgCfmCC.callEKK2391B003SC()` | `callEKK2391B003SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 14 | Call: `JKKIntrInfoChgCfmCC.callEKK2891A010SC()` | `callEKK2891A010SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 15 | Call: `JKKIntrInfoChgCfmCC.callEKK2891C020SC()` | `callEKK2891C020SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 16 | Call: `JKKIntrInfoChgCfmCC.callEKK2891D010SC()` | `callEKK2891D010SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |
| 17 | Call: `JKKIntrInfoChgCfmCC.callEKK2891E010SC()` | `callEKK2891E010SC()` -> `editResultRP()` | `getErrorInfo [R]`, `getString [R]`, `isNullBlank [-]` |

All callers are methods within the same `JKKIntrInfoChgCfmCC` class that serve as SC invocation wrappers. Each wrapper executes a specific service component and then delegates to `editResultRP()` to process the result. No screen/batch entry points were found within 8 hops, indicating this is a deep utility method in the service component result handling chain.

## 6. Per-Branch Detail Blocks

### Block 1 — GET (SC Return Value Extraction) (L1911)

Extracts the CAANMsg template array and return code from the SC result map.

| # | Type | Code |
|---|------|------|
| 1 | GET | `CAANMsg[] templates = (CAANMsg[]) msgList.get(JCMConstants.TEMPLATE_LIST_KEY)` // Get template list from SC result [-> TEMPLATE_LIST_KEY] |
| 2 | SET | `CAANMsg template = templates[0]` // Take the first template from the array |
| 3 | GET | `Integer returnCode = (Integer) msgList.get(JCMConstants.RET_CD_INT_KEY)` // Get SC return code [-> RET_CD_INT_KEY] |

### Block 2 — GET (Template Metadata Extraction) (L1917)

Extracts templateId and templateStatus from the CAANMsg template.

| # | Type | Code |
|---|------|------|
| 1 | GET | `String templateId = template.getString(JCMConstants.TEMPLATE_ID_KEY)` // Get template identifier [-> TEMPLATE_ID_KEY] |
| 2 | GET | `int templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)` // Get status code from template [-> STATUS_INT_KEY] |

### Block 3 — IF (Return Code Override) (L1920)

If the SC return code is non-zero, override the template status to 9000 (failure indicator).

| # | Type | Code | Condition |
|---|------|------|-----------|
| 1 | COND | `returnCode.intValue() != 0` | If SC did not return success code |
| 2 | SET | `templateStatus = 9000` // Override status to 9000 (SC failure) |

### Block 4 — IF (Return Message Validation) (L1923)

Validates that a localized return message exists for the current status. If the message key is null (message not found), reset templateStatus to 0 (default/success).

| # | Type | Code | Condition |
|---|------|------|-----------|
| 1 | COND | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null` | If return message for this status is not configured |
| 2 | SET | `templateStatus = 0` // Reset to default (message not found) |

### Block 5 — GET (BP-Level Return Code) (L1927)

Retrieves the BP-level return code from the parameter's control map.

| # | Type | Code |
|---|------|------|
| 1 | GET | `Object obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` |
| 2 | COND | `obj == null` |
| 3 | SET | `bpStatus = -1` // No BP return code set |
| 4 | SET | `bpStatus = Integer.parseInt((String) param.getControlMapData(SCControlMapKeys.RETURN_CODE))` // Parse BP return code |

### Block 6 — IF (Status Override — SC Status Takes Precedence) (L1933)

If the SC template status is higher (worse) than the BP-level return code, override the param's return code and message with the SC status.

> Sets the SC's business status as the authoritative status on the response parameter, ensuring the SC's judgment takes priority over any BP-level code.

| # | Type | Code | Condition |
|---|------|------|-----------|
| 1 | COND | `templateStatus > bpStatus` | SC status is worse than BP status |
| 2 | SET | `String formatStatus = String.format("%1$04d", templateStatus)` // Zero-padded status string |
| 3 | GET | `String message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // Look up localized message |
| 4 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` // Override BP return code |
| 5 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` // Set localized message |

### Block 7 — CONTENTS BRANCH (Template-Id-Based Content Metadata Assignment) (L1942)

This block initializes `contents = null` (L1942) then dispatches to the appropriate CBSMsg class based on the templateId returned from the SC. Each branch reads the message contents metadata (field definitions) from the corresponding CBSMsg to enable subsequent error field extraction.

> Comment: "Map error information into user data information" — the contents array is used to identify which template fields are error fields (those with `_err` suffix).

| # | Type | Code | Condition |
|---|------|------|-----------|
| 1 | SET | `Object[][] contents = null` // Initialize to null |
| 2 | COND | `EKK0081A010.equals(templateId)` [Service Contract One-Shot Agreement] |
| 3 | SET | `contents = new EKK0081A010CBSMsg().getContents()` |
| 4 | COND | `EKK0311B001.equals(templateId)` [Intermediary List Confirmation] |
| 5 | SET | `contents = new EKK0311B001CBSMsg().getContents()` |
| 6 | COND | `EKK0081C310.equals(templateId)` [Intermediary Coupon Update] |
| 7 | SET | `contents = new EKK0081C310CBSMsg().getContents()` |
| 8 | COND | `EKK2891A010.equals(templateId)` [Post-Open Intermediary Coupon Application One-Shot Agreement] |
| 9 | SET | `contents = new EKK2891A010CBSMsg().getContents()` |
| 10 | COND | `EKK2891C020.equals(templateId)` [Post-Open Intermediary Coupon Application Information Change] |
| 11 | SET | `contents = new EKK2891C020CBSMsg().getContents()` |
| 12 | COND | `EKK2891D010.equals(templateId)` [Post-Open Intermediary Coupon Application Registration] |
| 13 | SET | `contents = new EKK2891D010CBSMsg().getContents()` |
| 14 | COND | `EKK2891E010.equals(templateId)` [Post-Open Intermediary Coupon Application Deletion] |
| 15 | SET | `contents = new EKK2891E010CBSMsg().getContents()` |
| 16 | COND | `EKK2391B003.equals(templateId)` [Discount Service Contract Condition List Confirmation] |
| 17 | SET | `contents = new EKK2391B003CBSMsg().getContents()` |
| 18 | COND | `EKK0481B001.equals(templateId)` [Discount Service Target Contract List Confirmation] |
| 19 | SET | `contents = new EKK0481B001CBSMsg().getContents()` |
| 20 | COND | `EKK0451A010.equals(templateId)` [Discount Service Agreement One-Shot Agreement] |
| 21 | SET | `contents = new EKK0451A010CBSMsg().getContents()` |
| 22 | COND | `EKK1091D010.equals(templateId)` [Advance Registration] |
| 23 | SET | `contents = new EKK1091D010CBSMsg().getContents()` |
| 24 | COND | `EKK0311B002.equals(templateId)` [Coupon Code List Confirmation] |
| 25 | SET | `contents = new EKK0311B002CBSMsg().getContents()` |
| 26 | COND | `EKK0311A010.equals(templateId)` [Coupon Code One-Shot Agreement] |
| 27 | SET | `contents = new EKK0311A010CBSMsg().getContents()` |
| 28 | COND | `EKK0311C010.equals(templateId)` [Coupon Code Update] |
| 29 | SET | `contents = new EKK0311C010CBSMsg().getContents()` |
| 30 | COND | `EKK1091C010.equals(templateId)` [Advance Update] |
| 31 | SET | `contents = new EKK0311C010CBSMsg().getContents()` // Note: delegates to EKK0311C010CBSMsg instead of EKK1091C010CBSMsg |

### Block 8 — FOR (Error Field Extraction) (L1986)

Iterates the contents metadata array. For each field whose name contains `_err`, if the template has a value for that field AND the inMap does not already contain it, extract the error string from the template and store it in inMap.

> Comment: "Map error information into user data information" — this extracts field-level validation errors from the SC response into the inbound business data map for downstream display.

| # | Type | Code |
|---|------|------|
| 1 | LOOP | `for (int i = 0; contents != null && i < contents.length; i++)` |
| 2 | SET | `String element = (String) contents[i][0]` // Field name from contents metadata |
| 3 | COND | `element.indexOf("_err") > 0` // Field is an error field |
| 4 | COND | `!template.isNull(element)` // Template has a value for this field |
| 5 | COND | `!inMap.containsKey(element)` // inMap does not already have this error |
| 6 | SET | `inMap.put(element, template.getString(element))` // Map error field value into inMap |

### Block 9 — EXEC (Error Info Consolidation) (L1996)

Retrieves or creates the error info list from the parameter's control map, then consolidates all errors from the msgList and sets the consolidated result back on the parameter.

> Comment: "Get error information mapping" and "Set into control map" — this is the final error aggregation step that prepares error data for screen rendering.

| # | Type | Code |
|---|------|------|
| 1 | GET | `ArrayList<Object> errList = (ArrayList<Object>) param.getControlMapData(SCControlMapKeys.ERROR_INFO)` |
| 2 | COND | `errList == null` |
| 3 | SET | `errList = new ArrayList<Object>()` // Create new error list |
| 4 | EXEC | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errList))` // Consolidate all errors |

### Block 10 — GET (Re-Read Status) (L2005)

Re-reads the status from the template after error info consolidation, as the status may have changed during prior processing.

| # | Type | Code |
|---|------|------|
| 1 | GET | `String rtnCode = returnCode.toString()` // Convert return code to string |
| 2 | GET | `int status = template.getInt(JCMConstants.STATUS_INT_KEY)` // Re-read status from template |

### Block 11 — IF (SC-Specific: Intermediary Coupon Update Early Return) (L2009)

For the Intermediary Coupon Update flow (`EKK0081C310`), delegates to SC-specific post-processing. If the service number error flag is set, returns early without further processing.

> Comment: "For Service Contract Information Change (Intermediary Code)" — this is a specialized handling path for a particular service type.

| # | Type | Code | Condition |
|---|------|------|-----------|
| 1 | COND | `EKK0081C310.equals(templateId)` [Intermediary Coupon Update] |
| 2 | CALL | `getEKK0081C310Msg(msgList, workMap)` |
| 3 | COND | `!JKKStringUtil.isNullBlank((String) workMap.get("svc_kei_no_err_o"))` [Service number error flag is set] |
| 4 | RETURN | `return param` // Early return — error detected in service number |

### Block 12 — IF (SC-Specific: Advance Registration Metadata Extraction) (L2019)

For the Advance Registration flow (`EKK1091D010`), extracts the program number and update timestamp from the template into inMap.

> Comment: "For Advance Registration" — stores program number and pre-update timestamp for audit trail.

| # | Type | Code | Condition |
|---|------|------|-----------|
| 1 | COND | `EKK1091D010.equals(templateId)` [Advance Registration] |
| 2 | SET | `inMap.put("prg_no", template.getString(EKK1091D010CBSMsg.PRG_NO))` // Store program number |
| 3 | SET | `inMap.put("upd_dtm_bf", template.getString(EKK1091D010CBSMsg.ADD_DTM))` // Store pre-update timestamp |

### Block 13 — IF (Exception — Non-Success SC Result) (L2027)

If the SC return code is not "0" or the template status is not 0, throw an `SCCallException` with details. This is the final safety check ensuring any unrecognized SC failure is surfaced as an exception rather than silently passing through.

> Comment: "In case of abnormality, generate SCCallException and throw" — guards against undetected SC failures.

| # | Type | Code | Condition |
|---|------|------|-----------|
| 1 | COND | `!("0".equals(rtnCode) && 0 == status)` | Return code is non-zero OR status is non-zero |
| 2 | EXEC | `SCCallException scCallEx = new SCCallException("Return value invalid", rtnCode, status)` |
| 3 | RETURN | `throw scCallEx` // Exception — SC failed |

### Block 14 — RETURN (Success) (L2032)

Normal completion: the SC succeeded (return code = "0", status = 0).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return the populated response parameter |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `templateId` | Field | SC template identifier — classifies which service component was invoked (e.g., `EKK0081A010`, `EKK0081C310`) |
| `templateStatus` | Field | Status code returned by the SC template — numeric indicator of success/failure state |
| `bpStatus` | Field | BP (business process) level return code — the status set by the calling business process |
| `returnCode` | Field | SC-level return code — integer from msgList indicating SC execution result (0 = success) |
| `rtnCode` | Field | String-formatted return code used for the final success/failure check |
| `contents` | Field | 2D object array from CBSMsg.getContents() — contains field metadata including names and types |
| `errList` | Field | ArrayList of error objects — consolidated list of all errors from the SC response |
| `inMap` | Field | Inbound business data map — accumulates field-level error values and metadata (keyed by user-specified `fixText`) |
| `workMap` | Field | Shared working map — used for SC-specific post-processing data exchange (e.g., service number error flag) |
| `msgList` | Field | SC result map — contains template array, return code, and all field-level data from the SC |
| `param` | Field | IRequestParameterReadWrite — the business data read/write interface passed through the processing chain |
| SC | Acronym | Service Component — a reusable business logic unit (identified by codes like EKK0081A010) executed via the service component framework |
| CAANMsg | Acronym | Fujitu's canonical message class — carries structured data between SC and caller |
| CBSMsg | Acronym | Component Business Service Message — message metadata class defining field structures for each SC |
| CC | Acronym | Common Component — a shared utility class (AbstractCommonComponent subclass) providing reusable business logic |
| BP | Acronym | Business Process — the overarching workflow that invokes SCs and processes results |
| RETURN_MESSAGE_XXXX | Field | Localized message key pattern — maps status codes to human-readable messages stored in JCMAPLConstMgr |
| RETURN_CODE | Field | Control map key — stores the authoritative return code for the response parameter |
| RETURN_MESSAGE | Field | Control map key — stores the localized message for the return code |
| ERROR_INFO | Field | Control map key — stores the consolidated error info list for screen display |
| TEMPLATE_LIST_KEY | Field | Map key — used to retrieve the CAANMsg[] array from msgList |
| RET_CD_INT_KEY | Field | Map key — used to retrieve the integer return code from msgList |
| STATUS_INT_KEY | Field | Map key — used to retrieve the status integer from a CAANMsg template |
| TEMPLATE_ID_KEY | Field | Map key — used to retrieve the template identifier string from a CAANMsg template |
| `svc_kei_no_err_o` | Field | Service number error output flag — set by `getEKK0081C310Msg` when the service number validation fails, causing an early return |
| `prg_no` | Field | Program number — stored for advance registration audit trail |
| `upd_dtm_bf` | Field | Update date-time before — pre-update timestamp for advance registration |
| EKK0081A010 | Constant | Service Contract One-Shot Agreement SC — initial agreement processing for service contracts |
| EKK0081C310 | Constant | Intermediary Coupon Update SC — updates intermediary coupon information for service contracts |
| EKK0311B001 | Constant | Intermediary List Confirmation SC — confirms list of intermediary codes |
| EKK0311B002 | Constant | Coupon Code List Confirmation SC — confirms list of coupon codes |
| EKK0311A010 | Constant | Coupon Code One-Shot Agreement SC — one-shot agreement processing for coupon codes |
| EKK0311C010 | Constant | Coupon Code Update SC — updates coupon code information |
| EKK2891A010 | Constant | Post-Open Intermediary Coupon Application One-Shot Agreement SC |
| EKK2891C020 | Constant | Post-Open Intermediary Coupon Application Information Change SC |
| EKK2891D010 | Constant | Post-Open Intermediary Coupon Application Registration SC |
| EKK2891E010 | Constant | Post-Open Intermediary Coupon Application Deletion SC |
| EKK2391B003 | Constant | Discount Service Contract Condition List Confirmation SC |
| EKK0481B001 | Constant | Discount Service Target Contract List Confirmation SC |
| EKK0451A010 | Constant | Discount Service Agreement One-Shot Agreement SC |
| EKK1091D010 | Constant | Advance Registration SC — registers advance registration information |
| EKK1091C010 | Constant | Advance Update SC — updates advance registration information |
| SCCallException | Class | Custom exception thrown when SC returns a non-zero return code or non-zero status |
| TemplateErrorUtil | Class | Utility class for consolidating error information from SC results |
| JKKStringUtil.isNullBlank | Method | String null/blank check utility used for error flag validation |
| JCMAPLConstMgr | Class | Message constant manager — provides localized string lookups by key |
| `_err` | Suffix | Field naming convention — template fields with this suffix indicate validation error data |
| `fixText` | Parameter | User-specified string key — used to identify and access the user data section of param |
