# Business Logic — JFUMkmInfoAddFrontiaPreTrnCC.editErrorInfoCom() [58 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JFUMkmInfoAddFrontiaPreTrnCC` |
| Layer | CC / Common Component — shared business logic helper class within the Custom Common package |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JFUMkmInfoAddFrontiaPreTrnCC.editErrorInfoCom()

This method performs **post-service-component error message normalization, prioritization, and collection** for the K-Opticom customer base system (eo customer infrastructure). After each service component (SC) invocation, the method inspects the SC's returned status code and error templates, then decides whether the SC's status should override any existing business-process-level status on the request parameter. It uses a numeric severity comparison: the template's status is compared against the BP's current status, and the higher (more severe) value wins. If the template is higher, the corresponding `RETURN_CODE` and `RETURN_MESSAGE` are written back into the parameter's control map. Finally, it iterates over a field-level error mapping table and copies any new `_err` suffix fields from the message template into the user data HashMap, skipping entries that are already present to preserve previously set messages. The method follows a **route-and-normalize** pattern — it normalizes unknown statuses to zero, applies an error override when returnCode is non-zero, and then collects field-level errors for screen display. It is a **shared utility** called by the `callSC()` method after every service component invocation, ensuring consistent error handling across all SC calls in this custom component. The Japanese comment "本来はサービスインターフェース分の処理が必要" (A process for the service interface is originally required) indicates this method is a simplified handler that consolidates the most common post-SC error-processing logic rather than delegating to a full service-interface abstraction.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editErrorInfoCom
param, templates,
returnCode, fixedText,
mappingData"])
    STEP1["Extract template =
templates[0]"]
    STEP2["Get templateStatus =
template.getInt(STATUS_INT_KEY)"]
    COND1{"returnCode
!= 0?"}
    STEP3["Set templateStatus = 9000
(Non-zero returnCode
error override)"]
    COND2{"RETURN_MESSAGE_
+ formattedStatus
exists in constants?"}
    STEP4["Set templateStatus = 0
(Unknown status key
counts as clean/normal)"]
    STEP5["Read bpStatus from
param.getControlMapData
(RETURN_CODE)
null -> -1, else parse int"]
    COND3{"templateStatus
> bpStatus?"}
    STEP6["Format status as %04d
Lookup message from
constants
Set RETURN_CODE and
RETURN_MESSAGE in
control map
(Replace with higher severity)"]
    STEP7["Get user data HashMap
param.getData(fixedText)"]
    STEP8["Loop over mappingData
i = 0 to length-1"]
    COND4{"template
isNull(
mappingData[i][0] + \"_err\")?"}
    COND5{"inMap
containsKey(
key + \"_err\")?"}
    STEP9["inMap.put(
key + \"_err\",
template.getString(
key + \"_err\"))
(Set new error message)"]
    END_RETURN["Return param
(updated with errors)"]

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> COND1
    COND1 -->|Yes| STEP3
    COND1 -->|No| COND2
    STEP3 --> COND2
    COND2 -->|null| STEP4
    COND2 -->|not null| STEP5
    STEP4 --> STEP5
    STEP5 --> COND3
    COND3 -->|Yes| STEP6
    COND3 -->|No| STEP7
    STEP6 --> STEP7
    STEP7 --> STEP8
    STEP8 --> COND4
    COND4 -->|True| COND5
    COND4 -->|False| STEP8
    COND5 -->|Not contained| STEP9
    COND5 -->|Already contained| STEP8
    STEP9 --> STEP8
    STEP8 --> END_RETURN
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object that carries user data (via `setData`/`getData` with a fixed-text key) and control map data (via `getControlMapData`/`setControlMapData`). It represents the complete in-flight request context for a screen transaction, including the current return code, return message, and error info list. |
| 2 | `templates` | `CAANMsg[]` | An array of message template objects returned from a service component call. Each `CAANMsg` holds key-value pairs for status codes, error messages, and field-level error messages (identified by `fieldName + "_err"` suffix). Only `templates[0]` is consumed by this method. |
| 3 | `returnCode` | `int` | The integer return code from the service component. A value of `0` indicates success; any non-zero value triggers an error override that forces `templateStatus` to `9000`, ensuring the error message is always displayed regardless of the original SC status code. |
| 4 | `fixedText` | `String` | A key used to identify the user data HashMap within the `param` object. It corresponds to a form data section name (e.g., a screen-specific prefix like `"data"` or `"inData"`). All field-level error messages are merged into this user data map. |
| 5 | `mappingData` | `Object[][]` | A 2D array mapping field names to their error message template keys. Each row contains at least one element: the field name (e.g., `"tel_no"`). The `_err` suffix is appended to look up the error message in the template (e.g., `"tel_no_err"`). |

**External state read by the method:**
- `JCMConstants.STATUS_INT_KEY` — constant key used to extract the status code from the message template.
- `SCControlMapKeys.RETURN_CODE` — constant key for the current business process return code in the control map.
- `SCControlMapKeys.RETURN_MESSAGE` — constant key for the business process return message in the control map.
- `JCMAPLConstMgr.getString(...)` — external constant manager that provides message text by key (e.g., `RETURN_MESSAGE_0000` through `RETURN_MESSAGE_9999`). These are defined in external resource bundles or configuration tables outside this class.

## 4. CRUD Operations / Called Services

This method does not perform any database or SC CRUD operations. It is a pure data-normalization and aggregation helper that works entirely within the in-memory request parameter object. All operations it performs are local reads/writes to Java objects.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCMConstants.STATUS_INT_KEY` | - | In-memory constant | Reads the status key constant to extract status code from template |
| R | `JCMAPLConstMgr.getString` | - | External message constants | Reads message text by constructed key (e.g., `RETURN_MESSAGE_0000`) |
| R | `param.getControlMapData` | - | In-memory control map | Reads current business process return code |
| W | `param.setControlMapData` | - | In-memory control map | Writes updated return code and return message |
| R | `param.getData` | - | In-memory user data | Reads the user data HashMap by `fixedText` key |
| W | `inMap.put` | - | In-memory HashMap | Writes field-level error message to user data |
| R | `template.getInt` | - | In-memory CAANMsg | Reads status code from message template |
| R | `template.isNull` | - | In-memory CAANMsg | Checks if a field-level error key exists in the template |
| R | `template.getString` | - | In-memory CAANMsg | Reads field-level error message text from template |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `isNull` [-], `containsKey` [-], `put` [-], `getString` [-], `setControlMapData` [-], `getString` [-], `setControlMapData` [-], `getInt` [-], `getControlMapData` [-], `getData` [-]

Trace who calls this method and what this method ultimately calls.
Uses the pre-computed evidence and caller search results from Step 2 above.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class: JFUMkmInfoAddFrontiaPreTrnCC.callSC() | `callSC(handle, scCall, param, fixedText, mappingData)` -> calls `editErrorInfoCom(param, templates, returnCode, fixedText, mappingData)` | `isNull` [R], `getString` [R], `setControlMapData` [W], `getData` [R], `put` [W] |

**Note:** `callSC()` is the parent method that wraps service component invocations. After each SC call, it retrieves the result and calls `editErrorInfoCom()` to process error status, then calls `TemplateErrorUtil.getErrorInfo()` to finalize the error info list, and finally throws `SCCallException` if the SC reported a non-zero return code or status.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] (L1899)

> Extracts the first template message and retrieves its status code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template = templates[0]` // Extract first CAANMsg from template array |
| 2 | SET | `templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)` // Extract business status code from template |

**Block 2** — [IF] `(returnCode != 0)` `[Non-zero returnCode detected]` (L1904)

> When the SC returns a non-zero return code, this block overrides the template status to `9000`, forcing a generic error state to ensure the error message is always displayed to the user. The Japanese comment "0以外のとき" means "when not 0".

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateStatus = 9000` // Error override: set to generic error status code |

**Block 3** — [IF] `(JCMAPLConstMgr.getString(...) == null)` `[Unknown status key]` (L1908)

> Constructs a message key as `"RETURN_MESSAGE_" + formattedStatus` (e.g., `"RETURN_MESSAGE_0000"`). If the constant manager returns null for this key, the status is considered unrecognized and is reset to `0` (normal/clean). The Japanese comment "nullのとき" means "when null".

| # | Type | Code |
|---|------|------|
| 1 | SET | `formattedStatus = String.format("%1$04d", templateStatus)` // e.g., 9000 -> "9000", 0 -> "0000" |
| 2 | SET | `msgKey = "RETURN_MESSAGE_" + formattedStatus` // Construct message lookup key |
| 3 | EXEC | `JCMAPLConstMgr.getString(msgKey)` // Lookup message text; null means unknown |
| 4 | SET | `templateStatus = 0` // Reset unknown status to normal/clean |

**Block 4** — [IF-ELSE] `(obj == null) / else` `[BP Status read from control map]` (L1914-1921)

> Reads the current business process return code from the param's control map. If it does not exist (null), defaults to `-1` so that any template status will win the comparison. The Japanese comments "nullの場合" (when null) and "他の場合" (otherwise) describe the two branches.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bpStatus = 0` // Initialize to zero |
| 2 | SET | `obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` // Read current BP status |
| 3 | SET | `bpStatus = -1` // null case: any positive template status will override |
| 4 | SET | `bpStatus = Integer.parseInt((String) param.getControlMapData(SCControlMapKeys.RETURN_CODE))` // Parse existing status |

**Block 5** — [IF] `(templateStatus > bpStatus)` `[Higher severity status]` (L1923)

> Compares the (now normalized) template status against the BP status. If the template's status is more severe (higher number), it overwrites the BP's return code and message with the template's values. The Japanese comment "セットが比較する" (compare sets) and "BPにサービスコンポーネントのステータスを設定する" (set the service component's status on BP) describe this priority-based replacement.

| # | Type | Code |
|---|------|------|
| 1 | SET | `formatStatus = String.format("%1$04d", templateStatus)` // e.g., "9000" |
| 2 | SET | `message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // Lookup error message |
| 3 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` // Override return code |
| 4 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` // Override return message |

**Block 6** — [SET] (L1928-L1931)

> Retrieves the user data HashMap that the method will populate with field-level error messages. The Japanese comment "ユーザーデータ情報" (user data information) describes this.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = null` // Initialize map reference |
| 2 | SET | `inMap = (HashMap<String, String>) param.getData(fixedText)` // Get user data map by fixedText key |

**Block 7** — [FOR] `(i = 0; i < mappingData.length; i++)` (L1933)

> Iterates over the field mapping table. For each row, extracts the field name, appends `"_err"`, and conditionally copies the error message from the template into the user data map. The Japanese comment "nullチェック" (null check) describes the first condition.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` // Initialize loop counter |
| 2 | SET | `fieldKey = (String) mappingData[i][0]` // Extract field name from mapping data |
| 3 | SET | `errKey = fieldKey + "_err"` // Construct error message key |

**Block 7.1** — [IF] `(!template.isNull(errKey))` `[Error message exists in template]` (L1935)

> Checks if the template contains a non-null error message for this field. If present, proceed to merge it into the user data map.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `template.isNull(errKey)` // Check for null or missing error field |

**Block 7.2** — [IF] `(!inMap.containsKey(errKey))` `[Error not already set]` (L1937)

> Only writes the error message if the user data map does not already contain this error key. This preserves any previously set error message (e.g., from input validation) and only fills in errors from the SC template. The Japanese comment "ユーザーデータ情報にエラーを確認する" (check error in user data information) describes this intent.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `inMap.containsKey(errKey)` // Check if error already set |
| 2 | EXEC | `inMap.put(errKey, template.getString(errKey))` // Copy error message from template to user data |

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

> Returns the updated `param` object with the merged error information. The control map may have been updated with a higher-priority status code and message, and the user data map contains field-level error messages.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return updated parameter with errors |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `param` | Field | Request parameter object — the central in-memory carrier for all data in a screen transaction, including user form data and control map metadata |
| `CAANMsg` | Class | Message object — a key-value message container used to exchange structured data between service components and business components; supports type-safe access (getInt, getString, isNull) |
| `templateStatus` | Field | Template status code — the severity level of the service component's result, used to determine which error message should be displayed |
| `bpStatus` | Field | Business process status code — the current status recorded on the request parameter; used for severity comparison with the template status |
| `RETURN_CODE` | Constant | Control map key — stores the numeric return code that determines which screen/message to navigate to |
| `RETURN_MESSAGE` | Constant | Control map key — stores the localized message text corresponding to the return code |
| `STATUS_INT_KEY` | Constant | Template key — the key used to extract the status integer from a CAANMsg template object |
| `RETURN_MESSAGE_XXXX` | Constant | Message key prefix — when combined with a zero-padded 4-digit status code (e.g., `RETURN_MESSAGE_0000`), forms the lookup key for error message text in external constants |
| `fixedText` | Field | User data key — a string key that identifies the user data HashMap within the param object, corresponding to a form section |
| `mappingData` | Field | Field error mapping table — a 2D array where each row contains a field name; the `_err` suffix is appended to look up field-level error messages |
| `_err` suffix | Convention | Error message field naming — field names appended with `_err` (e.g., `tel_no_err`) indicate the error message variant for a given field |
| `SCControlMapKeys` | Class | Control map constant class — defines keys used to store and retrieve metadata (return code, return message, error info) on the request parameter's control map |
| `JCMAPLConstMgr` | Class | Message constant manager — external utility class that reads message text from configuration/resource bundles by key |
| `9000` | Constant | Generic error status code — the override status code used when a service component returns a non-zero return code |
| `0` | Constant | Normal/clean status code — indicates no error; used as the default and as a reset value for unrecognized status codes |
| `-1` | Constant | Default BP status — used when no return code exists on the control map, ensuring any positive template status wins the comparison |
| SC | Abbreviation | Service Component — a Fujitsu middleware component (from the ASCI/Java Enterprise framework) that encapsulates business logic and data access; invoked via `ServiceComponentRequestInvoker` |
| BP | Abbreviation | Business Process — the custom layer (`JFUMkmInfoAddFrontiaPreTrnCC`) that orchestrates service component calls and handles post-processing |
| CC | Abbreviation | Custom Component — a naming convention for business logic classes in the `JFUMkmInfoAddFrontiaPreTrnCC` package |
| BK | Abbreviation | Business Knowledge — the overall system architecture layer that contains the `JFUMkmInfoAddFrontiaPreTrnCC` custom component |
| eo | Abbreviation | e-Operator — the customer service system name (Fujitsu's "eo" telecommunications platform for K-Opticom) |
| K-Opticom | Business term | Telecom operator — the service provider whose customer base system this code supports |
