# Business Logic — JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo() [60 LOC]

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

## 1. Role

### JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()

`editErrorInfo` is a shared utility method within the Fujitsu Futurity business process framework that maps CBS (Common Business Service) return values and error information back into the `IRequestParameterReadWrite` request parameter object. It serves as the bridge between CBS-level execution outcomes and the business process layer, ensuring that error statuses, messages, and field-level error annotations are consistently propagated from the CBS response (wrapped in a `CAANMsg[]` array) into the param's control map and business data map.

The method implements a status-priority resolution pattern: it compares the status code returned from the CBS template against the status code already recorded by the business process (BP). If the CBS status is higher, the CBS status and its associated message overwrite the BP-level status, guaranteeing that CBS-level failures (e.g., database errors, system exceptions) take precedence over BP-level validations. Additionally, the method iterates over all keys in the CBS response template that end with the `_err` suffix — a convention used by the CBS layer to flag fields with validation or processing errors — and copies those error values into the business data HashMap identified by `mapName`.

This method is called by `editResultRP()` within the same class, which in turn is invoked by a wide range of `*BSMapper` classes (hundreds across screens such as KKSV0054, KKSV0461, CRSV0074, ZMSV0123, and many more). Each mapper calls `editResultRP` after a CBS invocation to normalize error information before returning control to the calling screen or batch job. The method follows a delegate-and-map design pattern, acting as the error-mapping final step in the CBS result-processing pipeline.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editErrorInfo(params)"])

    START --> A["Extract template from templates[0]"]
    A --> B["Get templateStatus = template.getInt(EKK0081A010CBSMsg.STATUS)"]
    B --> C{"returnCode != 0?"}
    C -->|Yes| D["Set templateStatus = 9000 (generic CBS failure)"]
    C -->|No| E["Keep templateStatus as-is"]
    D --> F["Check if JCMAPLConstMgr.getString('RETURN_MESSAGE_' + formattedStatus) == null"]
    E --> F
    F -->|Yes - no message constant| G["Set templateStatus = 0 (reset to success)"]
    F -->|No - message exists| H["Keep templateStatus"]
    G --> I["Get bpStatus from param.getControlMapData(SCControlMapKeys.RETURN_CODE)"]
    H --> I
    I --> I2{"bp control map data null?"}
    I2 -->|Yes| I3["Set bpStatus = -1"]
    I2 -->|No| I4["Parse bpStatus = Integer.parseInt()"]
    I3 --> J{"templateStatus > bpStatus?"}
    I4 --> J
    J -->|Yes| K["Format status to 4-digit string"]
    J -->|No| L["Skip setting return info"]
    K --> M["Retrieve message from JCMAPLConstMgr.getString('RETURN_MESSAGE_' + formatStatus)"]
    M --> N["Set RETURN_CODE and RETURN_MESSAGE in param control map"]
    N --> O
    L --> O["Extract inMap from param.getData(mapName)"]
    O --> P["Get iterator over template.getHashMap().keySet()"]
    P --> Q{"Has next key?"}
    Q -->|Yes| R{"key ends with '_err'?"}
    Q -->|No| S["Return param (end)"]
    R -->|Yes| T{"template.isNull(key)?"}
    R -->|No| Q
    T -->|True - null value| Q
    T -->|False - has value| U["inMap.put(key, template.getString(key))"]
    U --> Q
    S --> END(["Return param"])
```

**Processing steps explained:**

1. **Template extraction** — Retrieves the first `CAANMsg` object from the CBS response array (`templates[0]`).
2. **Status extraction** — Reads the CBS status field (`EKK0081A010CBSMsg.STATUS` which resolves to the string `"status"`) from the template.
3. **Return-code override** — If the explicit `returnCode` parameter is non-zero, forces the status to `9000`, which is a generic CBS failure code indicating the CBS layer encountered an error.
4. **Message constant validation** — Checks whether a message constant exists for the current status code in the `JCMAPLConstMgr` resource manager. The status is zero-padded to 4 digits (e.g., `0000`, `9000`) and looked up as `"RETURN_MESSAGE_0000"`, `"RETURN_MESSAGE_9000"`, etc. If no message constant exists for the status, the status is reset to `0` (success).
5. **BP status comparison** — Retrieves the business process-level return code from the param's control map (`SCControlMapKeys.RETURN_CODE`). If the control map entry is absent, `bpStatus` defaults to `-1`. Otherwise it is parsed from its string representation.
6. **Status priority check** — If the template's CBS status exceeds the BP status, the CBS status takes priority. The method formats the status as a 4-digit zero-padded string, looks up the corresponding human-readable message from `JCMAPLConstMgr`, and writes both `RETURN_CODE` and `RETURN_MESSAGE` into the param's control map.
7. **Error field propagation** — Extracts the business data HashMap identified by `mapName` (the SC map name), then iterates over all keys in the CBS template's internal HashMap. For keys ending with `_err` (the error-field naming convention), if the value is not null, it copies the error value into the business data map.
8. **Return** — Returns the modified `param` object with updated control map data and error fields.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The business request/response parameter object that carries data between the screen layer, business process layer, and CBS layer. It holds both control map data (system-level metadata like return codes, error info, hostname, IP) and business data maps (the actual order/service data). Used for both reading (extracting current BP status, accessing business data map) and writing (setting return code/message, populating error fields). |
| 2 | `templates` | `CAANMsg[]` | An array of CBS response message objects. Each `CAANMsg` carries the field-level results of a CBS service call, including status codes, error flags, and data values. The first element (`templates[0]`) contains the primary CBS response for the current operation. Keys ending in `_err` indicate field-level errors reported by the CBS layer. |
| 3 | `returnCode` | `int` | The integer return code from the CBS invocation. A value of `0` indicates the CBS call succeeded without exceptions. Any non-zero value forces the template status to `9000` (generic CBS failure), overriding the CBS-reported status. This provides a reliable fallback: if the CBS framework itself reports an error, it takes precedence over the CBS business logic status. |
| 4 | `mapName` | `String` | The SC (Service Component) map name — a string key identifying which business data HashMap within the `param` object should receive the propagated error field values. This maps to the data section of the request parameter that holds the business entity data (e.g., malware blocking flag change data). |

**External state / constants referenced:**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `EKK0081A010CBSMsg.STATUS` | `"status"` | The CBS message field key for the status code returned by CBS services. This is a shared field used across CBS message objects to convey execution status. |
| `SCControlMapKeys.RETURN_CODE` | `"RETURN_CODE"` | Control map key for the business process return code. Holds the current BP-level status for comparison against CBS status. |
| `SCControlMapKeys.RETURN_MESSAGE` | `"RETURN_MESSAGE"` | Control map key for the human-readable return message corresponding to the return code. |
| `SCControlMapKeys.ERROR_INFO` | `"ERROR_INFO"` | Control map key for a list of structured error information objects (populated by the caller `editResultRP`, not by this method). |
| `JCMConstants.TEMPLATE_LIST_KEY` | `"TEMPLATE_LIST_KEY"` | Used by caller `editResultRP` to extract the CAANMsg array from the CBS result map. |
| `JCMConstants.RET_CD_INT_KEY` | `"RET_CD_INT_KEY"` | Used by caller `editResultRP` to extract the integer return code from the CBS result map. |
| `JCMConstants.STATUS_INT_KEY` | `"status"` | Used by caller `editResultRP` to get the status from the first CAANMsg template. |

## 4. CRUD Operations / Called Services

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

All method calls within `editErrorInfo` are utility or data-access methods on parameters, local objects, and shared constant managers. No direct CBS/SC service invocations originate from this method — it operates purely at the data-mapping level.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `template.getInt(EKK0081A010CBSMsg.STATUS)` | - | - | Reads the CBS status integer from the template's first message object |
| R | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formattedStatus)` | - | - | Looks up the human-readable error message from the constant manager for the given status code (e.g., RETURN_MESSAGE_0000, RETURN_MESSAGE_9000). Returns null if no constant exists for that status. |
| R | `param.getControlMapData(SCControlMapKeys.RETURN_CODE)` | - | - | Reads the BP-level return code from the param's control map for status priority comparison |
| R | `param.getData(mapName)` | - | - | Reads the business data HashMap (keyed by `mapName`) from the param to populate error fields |
| R | `template.getHashMap().keySet()` | - | - | Iterates over all field keys in the CBS template's internal HashMap to find `_err`-suffixed keys |
| R | `template.isNull(key)` | - | - | Checks whether a specific field in the CBS template is null, determining whether the error value should be propagated |
| R | `template.getString(key)` | - | - | Reads the string value of an error field from the CBS template for propagation to the business data map |
| SET | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, ...)` | - | - | Writes the CBS status as a 4-digit formatted string to the param's control map |
| SET | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, ...)` | - | - | Writes the human-readable error message to the param's control map |
| SET | `inMap.put(key, ...)` | - | - | Copies the error field value into the business data HashMap for the given `_err`-suffixed key |

No CBS or SC service calls are made directly from this method. All operations are read/write on the `param` object, the `CAANMsg` template, and the constant manager. The CBS data ultimately flows from the CBS layer through the `templates` array (populated by the caller's CBS invocation) and is mapped into the param's data structures.

## 5. Dependency Trace

### Direct callers of this method (from code analysis graph):

The method `editErrorInfo()` is called internally by `editResultRP()` within `JKKMalwareBlockingNonFlgChengeOverCC`. The `editResultRP()` method in turn is called by hundreds of `*BSMapper` classes across the application. Below are representative callers showing the call chains:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0946 (via KKSV0946OPOperation) | `KKSV0946OPOperation.main()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editResultRP()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()` | template.getInt [R], JCMAPLConstMgr.getString [R], param.get/setControlMapData [R/W], param.getData [R], template.getString [R] |
| 2 | Screen:KKSV0781 | `KKSV0781OP_EKK0081B010BSMapper.editResultRP()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()` | template.getInt [R], JCMAPLConstMgr.getString [R], param.get/setControlMapData [R/W], param.getData [R], template.getString [R] |
| 3 | Screen:KKSV0054 | `KKSV0054OP_EKK0081A010BSMapper.editResultRP()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()` | template.getInt [R], JCMAPLConstMgr.getString [R], param.get/setControlMapData [R/W], param.getData [R], template.getString [R] |
| 4 | Screen:KKSV0461 | `KKSV0461OP_EKK0081A010BSMapper.editResultRP()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()` | template.getInt [R], JCMAPLConstMgr.getString [R], param.get/setControlMapData [R/W], param.getData [R], template.getString [R] |
| 5 | Screen:CRSV0074 | `CRSV0074OP_ECR0241B010BSMapper.editResultRP()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()` | template.getInt [R], JCMAPLConstMgr.getString [R], param.get/setControlMapData [R/W], param.getData [R], template.getString [R] |
| 6 | Screen:ZMSV0123 | `ZMSV0123OP_EZM0031C010BSMapper.editResultRP()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()` | template.getInt [R], JCMAPLConstMgr.getString [R], param.get/setControlMapData [R/W], param.getData [R], template.getString [R] |
| 7 | Screen:WCSV0018 | `WCSV0018OP_EWC0101B010BSMapper.editResultRP()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()` | template.getInt [R], JCMAPLConstMgr.getString [R], param.get/setControlMapData [R/W], param.getData [R], template.getString [R] |
| 8 | Screen:DKSV0081 | `DKSV0081OP_EKK0081B007BSMapper.editResultRP()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()` | template.getInt [R], JCMAPLConstMgr.getString [R], param.get/setControlMapData [R/W], param.getData [R], template.getString [R] |
| 9 | Screen:FUSV0165 | `FUSV0165OP_EKK0011D020BSMapper.editResultRP()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()` | template.getInt [R], JCMAPLConstMgr.getString [R], param.get/setControlMapData [R/W], param.getData [R], template.getString [R] |
| 10 | Screen:TUSV0039 | `TUSV0039OP_EZM0171B012BSMapper.editResultRP()` -> `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo()` | template.getInt [R], JCMAPLConstMgr.getString [R], param.get/setControlMapData [R/W], param.getData [R], template.getString [R] |

**Note:** The `editErrorInfo()` method in `JKKMalwareBlockingNonFlgChengeOverCC` is also called by `editResultRP()` defined within the same class at line 552+. This internal `editResultRP` method is invoked from the `KKSV0946` malware-blocking-non-flag-change operation (as seen in `KKSV0946OPOperation.java`). Additionally, numerous other `*BSMapper` classes (hundreds) call their own `editResultRP` which delegates to the shared `editErrorInfo` in the same class.

## 6. Per-Branch Detail Blocks

**Block 1** — [EXTRACT] `(templates[0])` (L624)

Extract the primary CBS response template from the array and read its status field.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template = templates[0]` // Extract first CAANMsg from CBS response array |
| 2 | SET | `templateStatus = template.getInt(EKK0081A010CBSMsg.STATUS)` // [-> `STATUS = "status"`] — Read CBS status integer from template |

**Block 2** — [IF] `(returnCode != 0)` (L626)

If the CBS invocation returned a non-zero return code (indicating an exception or error at the CBS framework level), override the template status to `9000`, a generic failure code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateStatus = 9000` // [-> 9000] — Override with generic CBS failure status |

**Block 3** — [IF] `(JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null)` (L630)

Validate that a human-readable message constant exists for the current status code. The status is zero-padded to 4 digits (e.g., `0000`, `9000`, `0100`) and used as a suffix to look up `"RETURN_MESSAGE_XXXX"` in the constant manager. If no constant exists, reset the status to `0` (success/no error), effectively treating unknown statuses as non-error conditions.

| # | Type | Code |
|---|------|------|
| 1 | SET | `formatStatus = String.format("%1$04d", templateStatus)` // Zero-pad to 4 digits, e.g. "9000" |
| 2 | EXEC | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // Look up message constant; returns null if not found |
| 3 | SET | `templateStatus = 0` // Reset to success if no message constant exists for this status |

**Block 4** — [IF/ELSE] `(bpStatus resolution from control map)` (L633)

Retrieve the business process-level return code from the param's control map. This represents the status that the BP itself has determined (e.g., from validation). If the control map entry is absent, default `bpStatus` to `-1` (meaning no BP status is set, so any CBS status will win the comparison). Otherwise, parse the string value to an integer.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bpStatus = 0` // Initialize default value |
| 2 | SET | `obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` // [-> `RETURN_CODE`] — Read BP-level return code |
| 3 | SET | `bpStatus = -1` // Default: no BP status set |
| 4 | SET | `bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE))` // Parse existing BP return code |

**Block 5** — [IF] `(templateStatus > bpStatus)` (L643)

Compare CBS template status against the BP status. If the CBS status is higher, the CBS layer has a more severe condition (e.g., database failure) than the BP detected (e.g., field validation). The CBS status and its human-readable message take precedence and overwrite the BP-level return code and message in the param's control map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `formatStatus = String.format("%1$04d", templateStatus)` // Zero-pad to 4 digits |
| 2 | SET | `message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // Look up human-readable message |
| 3 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` // [-> `RETURN_CODE`] — Write CBS status as 4-digit string |
| 4 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` // [-> `RETURN_MESSAGE`] — Write CBS error message |

**Block 6** — [EXTRACT] `(param.getData(mapName))` (L653)

Extract the business data HashMap identified by `mapName` so that error field values can be propagated into it.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = (HashMap<String, String>)param.getData(mapName)` // Get business data map for error propagation |
| 2 | SET | `inMap = null` // Initialize map reference before extraction |

**Block 7** — [WHILE] `(iterator over template.getHashMap().keySet())` (L655)

Iterate over all keys in the CBS template's internal HashMap. For each key, check if it ends with `_err` (the error-field naming convention used by the CBS framework). If it does, and the value is not null, copy the error value into the business data HashMap. This propagates field-level error information from the CBS response to the business data layer.

| # | Type | Code |
|---|------|------|
| 1 | SET | `it = template.getHashMap().keySet().iterator()` // Get iterator over all template keys |
| 2 | SET | `key = it.next()` // Get next key in iteration |
| 3 | IF | `key.endsWith("_err")` // Check if key is an error-flagged field |
| 4 | IF | `!template.isNull(key)` // Only propagate if the error field has a non-null value |
| 5 | SET | `inMap.put(key, template.getString(key))` // Copy error field value to business data map |

**Block 8** — [RETURN] (L659)

Return the modified `param` object with updated control map data (return code/message) and populated business data error fields.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return updated param with error info mapped |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `EKK0081A010CBSMsg` | Class | CBS (Common Business Service) message class for operation `EKK0081A010`. Used as a shared type reference for the `STATUS` field across CBS response templates. |
| `STATUS` | Constant | The CBS response field key `"status"` — holds the integer status code returned by a CBS service invocation (e.g., `0` = success, `9000` = generic failure, other values = specific CBS business status codes). |
| `IRequestParameterReadWrite` | Interface | The request/response parameter interface used throughout the Fujitsu Futurity framework for passing data between screens, business processes, and CBS layers. Supports both read and write operations on control map and business data maps. |
| `CAANMsg` | Class | A CBS message object that wraps the response from a CBS service call. Contains field-level values, status codes, and error flags. Provides methods like `getInt()`, `getString()`, `isNull()`, and `getHashMap()` for accessing the CBS response data. |
| `JCMAPLConstMgr` | Class | A shared constant manager utility that provides access to localized message constants. The `getString()` method retrieves a message by key (e.g., `"RETURN_MESSAGE_0000"`) from the application's message resource bundle. Returns `null` if the key is not found. |
| `SCControlMapKeys` | Class | A constants class defining keys for the control map within `IRequestParameterReadWrite`. Includes keys like `RETURN_CODE`, `RETURN_MESSAGE`, `ERROR_INFO`, `REQ_HOSTNAME`, `REQ_HOSTIP`, `REQ_VIEWID`. |
| `RETURN_CODE` | Constant | Control map key for the business process return code string (e.g., `"0000"`, `"9000"`). Used by screens and BP logic to determine the outcome of a service call. |
| `RETURN_MESSAGE` | Constant | Control map key for the human-readable error/status message corresponding to the return code. Displayed to users on error screens. |
| `ERROR_INFO` | Constant | Control map key for a list of structured error information objects (populated by `TemplateErrorUtil.getErrorInfo()` in the caller `editResultRP`). |
| `templateStatus` | Field | The integer status code extracted from the CBS response template. Represents the outcome of the CBS service execution. |
| `bpStatus` | Field | The business process-level return code retrieved from the param's control map. Represents the status determined by the BP's own validation logic. |
| `9000` | Constant | Generic CBS failure status code. Used when `returnCode != 0` (i.e., the CBS framework itself reported an error). Takes precedence over any CBS business-logic status code. |
| `_err` | Naming convention | Suffix used on CBS template field keys to indicate that a field has an error or validation issue. E.g., `name_err`, `amount_err`. The `editErrorInfo` method filters keys ending with `_err` and copies their values to the business data map. |
| `mapName` | Parameter | The SC (Service Component) map name — a string key identifying which business data HashMap within the param should receive error field values. Corresponds to the data section of the request parameter. |
| `JCMConstants` | Class | Shared constants class for the Java Common Middleware (JCM) framework. Defines keys like `TEMPLATE_LIST_KEY`, `RET_CD_INT_KEY`, `STATUS_INT_KEY` used to extract CBS result data from maps. |
| `editResultRP` | Method | The caller method within `JKKMalwareBlockingNonFlgChengeOverCC` that extracts the CBS result map, retrieves the template array and return code, then delegates to `editErrorInfo` to map error information into the param. Also sets the `ERROR_INFO` control map entry and throws `SCCallException` on non-zero status/return-code combinations. |
| `*BSMapper` | Class pattern | Screen-specific CBS mapper classes (e.g., `KKSV0054_KKSV0054OP_EKK0081A010BSMapper`) that mediate between a screen and its CBS service. Each has an `editResultRP` method that calls `editErrorInfo` after CBS execution. |
| `KKSV0946` | Screen | A screen associated with the malware blocking non-flag change operation. The `JKKMalwareBlockingNonFlgChengeOverCC` class is the primary CC (Common Component) for this screen's business process. |
| `SCCallException` | Class | A framework exception class thrown when a CBS call returns an error. Carries an error message ("返値不整合" = "Return value inconsistency"), return code, and status for screen-level error display. |
| `TemplateErrorUtil.getErrorInfo` | Method | A utility method called by the caller `editResultRP` that extracts structured error information from the CBS result map and populates the `ERROR_INFO` control map entry. |
