# Business Logic — JKKTicktUseSisakListUkCC.editErrorInfoCom() [73 LOC]

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

## 1. Role

### JKKTicktUseSisakListUkCC.editErrorInfoCom()

This method is a shared common-component utility that aggregates and normalizes error information across the ticket-use-application policy list registration screen. Its primary business responsibility is to determine the **higher-priority error status** between the Service Component (SC) return status and the Business Process (BP) return code, ensuring that the screen always surfaces the most severe error to the user. When the SC-level template carries a higher status than what the BP has already recorded, it updates the request parameter's control map with the dominant status code and its corresponding human-readable message via `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + status)`. Additionally, the method processes an error-contents array (`contents`) containing field-level error identifiers (names ending in `_err`) and maps their localized error messages from the template into the user data map, transforming special identifiers like `key_svc_kei_no_err` into the display field `svc_kei_no_err`. This enables the screen to highlight exactly which input fields failed validation and why, supporting both SC-level failures and field-level validation errors in a single consolidated step.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editErrorInfoCom"])
    START --> GET_TEMPLATE["template = templates[0]"]
    GET_TEMPLATE --> GET_STATUS["templateStatus = template.getInt(STATUS_INT_KEY)"]
    GET_STATUS --> CHECK_RC["returnCode != 0?"]
    CHECK_RC -->|Yes| SET_RC["templateStatus = 9000"]
    CHECK_RC -->|No| CHECK_MSG["No constant for RETURN_MESSAGE_ + templateStatus?"]
    SET_RC --> CHECK_MSG
    CHECK_MSG -->|Yes| RESET_STATUS["templateStatus = 0"]
    CHECK_MSG -->|No| GET_BP_STATUS["bpStatus = param.getControlMapData(RETURN_CODE)"]
    RESET_STATUS --> GET_BP_STATUS
    GET_BP_STATUS --> PARSE_BP_STATUS["bpStatus = Integer.parseInt(returnCode from param)"]
    PARSE_BP_STATUS --> GET_BP_NULL["param.getControlMapData(RETURN_CODE) is null?"]
    GET_BP_NULL -->|Yes| SET_BP_NEG1["bpStatus = -1"]
    GET_BP_NULL -->|No| PARSE_INT["bpStatus = Integer.parseInt((String) param.getControlMapData(RETURN_CODE))"]
    SET_BP_NEG1 --> COMPARE["templateStatus > bpStatus?"]
    PARSE_INT --> COMPARE
    COMPARE -->|No| GET_USERDATA["inMap = (HashMap)param.getData(dataMapKey)"]
    COMPARE -->|Yes| FORMAT_STATUS["formatStatus = String.format(templateStatus as 4-digit)"]
    FORMAT_STATUS --> GET_MSG["message = JCMAPLConstMgr.getString(RETURN_MESSAGE_ + formatStatus)"]
    GET_MSG --> SET_RETURN_CODE["param.setControlMapData(RETURN_CODE, formatStatus)"]
    SET_RETURN_CODE --> SET_RETURN_MSG["param.setControlMapData(RETURN_MESSAGE, message)"]
    SET_RETURN_MSG --> GET_USERDATA
    GET_USERDATA --> LOOP_CHECK["contents != null && i < contents.length?"]
    LOOP_CHECK -->|No| RETURN_PARAM["return param"]
    LOOP_CHECK -->|Yes| GET_ITEM["itemNm = (String)contents[i][0]"]
    GET_ITEM --> CHECK_SUFFIX["itemNm ends with '_err'?"]
    CHECK_SUFFIX -->|No| INCR_I["i++"]
    CHECK_SUFFIX -->|Yes| GET_ERR_CD["errCd = template.getString(itemNm)"]
    GET_ERR_CD --> CHECK_NOTBLANK["errCd not null or blank?"]
    CHECK_NOTBLANK -->|No| INCR_I
    CHECK_NOTBLANK -->|Yes| CHECK_KEY_TYPE["itemNm == 'key_svc_kei_no_err'?"]
    CHECK_KEY_TYPE -->|Yes| MAP_KEY_ERR["inMap.put('svc_kei_no_err', errCd)"]
    CHECK_KEY_TYPE -->|No| MAP_ITEM["inMap.put(itemNm, errCd)"]
    MAP_KEY_ERR --> INCR_I
    MAP_ITEM --> INCR_I
    INCR_I --> LOOP_CHECK
    RETURN_PARAM --> END(["End"])
```

**Processing flow description:**

1. **Template extraction** — Extracts the first CAANMsg template from the templates array.
2. **SC status retrieval** — Reads the status integer from the template using the `JCMConstants.STATUS_INT_KEY` constant.
3. **SC error override** — If the SC returned a non-zero return code, forces `templateStatus` to `9000` (generic SC error).
4. **Status validation** — Checks whether a return message constant exists for the current status via `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + status)`. If no constant exists, resets the status to `0` (success/no error).
5. **BP status comparison** — Retrieves the existing BP return code from the parameter's control map. If absent (null), defaults `bpStatus` to `-1`. Otherwise parses the string value to an integer.
6. **Status promotion** — If the SC template status is numerically greater than the BP status, promotes the SC status: formats it as a 4-digit string, fetches the localized message, and writes both `RETURN_CODE` and `RETURN_MESSAGE` back into the control map. This ensures the screen displays the more severe error.
7. **Field error mapping** — Iterates over the `contents` array. For each entry whose name ends with `_err`, retrieves the error code from the template and stores it in the user data map (`inMap`), with a special key transformation for `key_svc_kei_no_err` -> `svc_kei_no_err` to map the service detail number error field.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object that carries the entire screen context — user data, control map data (operator ID, hostname, return codes, error info), and telegram/operation metadata. This is the central data carrier passed between the screen, BP layer, and SC layer. |
| 2 | `templates` | `CAANMsg[]` | An array of message templates returned from a Service Component (SC) call. Each CAANMsg holds localized strings, status codes, and field-level error messages. `templates[0]` is the primary template used for status extraction and error message lookup. |
| 3 | `returnCode` | `int` | The integer return code from the SC call. A non-zero value indicates an SC-level failure, triggering an override of `templateStatus` to `9000`. A value of `0` means the SC succeeded and the status from the template is trusted. |
| 4 | `dataMapKey` | `String` | The key used to retrieve the user data `HashMap<String, String>` from `param`. This map holds screen-field data that will be augmented with error codes. In the caller (`callSC`), this is `dataMapKey` which maps to a user-specific data region. |
| 5 | `mappingData` | `Object[][]` | Mapping data that was originally passed from the caller. This method reads it but does not use it in its logic — it is an artifact of the method signature inherited from similar methods in the common component. The caller passes mapping data used to build the SC request (`editInMsg`), not consumed directly here. |
| 6 | `contents` | `Object[][]` | An array of field-name/error-pair entries. Each row's first element (`contents[i][0]`) is a field name string ending with `_err` (e.g., `key_svc_kei_no_err`, `field_name_err`). The method scans these to identify which fields have errors and maps the corresponding error codes from the template into the user data map. |

**External state / instance fields read:**

| Field | Source | Usage |
|-------|--------|-------|
| `JCMConstants.STATUS_INT_KEY` | `com.fujitsu.futurity.common.JCMConstants` | Constant key used to retrieve the status integer from a CAANMsg template |
| `JCMConstants.TEMPLATE_LIST_KEY` | `com.fujitsu.futurity.common.JCMConstants` | Not directly read by this method (used by caller `callSC`) |
| `SCControlMapKeys.RETURN_CODE` | `com.fujitsu.futurity.common.x01.sc.SCControlMapKeys` | Control map key to retrieve/set the business process return code |
| `SCControlMapKeys.RETURN_MESSAGE` | `com.fujitsu.futurity.common.x01.sc.SCControlMapKeys` | Control map key to retrieve/set the localized return message |
| `JCMAPLConstMgr` | `com.fujitsu.futurity.model.common.JCMAPLConstMgr` | Constants manager that provides localized messages via string keys like `"RETURN_MESSAGE_XXXX"` |
| `JKKStringUtil.isNullBlank()` | `eo.common.util.JKKStringUtil` | Utility to check if a string is null, empty, or blank — used to skip empty error codes |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JCMAPLConstMgr.getString` | - | - | Reads localized return message constants (e.g., `RETURN_MESSAGE_XXXX`) from the application constants manager. No database hit — resolves from in-memory constant definitions. |
| - | `JKKStringUtil.isNullBlank` | - | - | Utility check for null/empty/blank strings. Used to skip empty error codes from the template. No data access. |
| R | `param.getControlMapData` | - | - | Reads the existing BP return code from the control map (in-memory data). |
| R | `param.getData` | - | - | Reads the user data HashMap from the parameter by the given dataMapKey (in-memory data). |
| R | `template.getInt` | - | - | Reads the status integer from the CAANMsg template (in-memory data). |
| R | `template.getString` | - | - | Reads error codes from the CAANMsg template by field name (in-memory data). |
| R | `param.getControlMapData` | - | - | Reads the existing BP return code from the control map (in-memory data). |
| U | `param.setControlMapData` | - | - | Writes the formatted status code to the control map when SC status is higher. |
| U | `param.setControlMapData` | - | - | Writes the localized return message to the control map when SC status is higher. |
| U | `inMap.put` | - | - | Stores the error code in the user data HashMap for field-level error display. |

**CRUD classification summary:**

This method performs **no database operations**. It is a pure in-memory data transformation and status comparison utility. It reads from the CAANMsg template and parameter objects (all in-memory), compares status codes, and writes back to the control map and user data map. There are no SC calls, no CBS invocations, and no entity persistence operations within this method.

## 5. Dependency Trace

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

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `callSC` (JKKTicktUseSisakListUkCC) | `searchTicktUseSisakList()` -> `callSC(handle, scCall, param, dataMapKey, mappingData, contents)` -> `editErrorInfoCom(param, templates, (Integer)return_code, dataMapKey, mappingData, contents)` | `isNullBlank` [-], `JCMAPLConstMgr.getString` [R], `param.getControlMapData` [R], `param.getData` [R], `template.getInt` [R], `template.getString` [R] |

**Caller details:**

The method `callSC` is a **private helper** within `JKKTicktUseSisakListUkCC` that orchestrates Service Component invocations. It is called from the public entry point `searchTicktUseSisakList()`, which is the screen handler for the "Ticket Use Application Policy List Confirmation Screen." After each SC call, `callSC` invokes `editErrorInfoCom` to consolidate error status and field-level error codes into the request parameter before returning the result message to the caller.

The terminal operations (no further downstream calls) are all **in-memory** — constant lookups, parameter reads/writes, and string checks. No SC codes, CBS modules, or database entities are reached from this method.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(template extraction)` (L560)

Extracts the first template from the templates array and reads its status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template = templates[0]` // Get primary template from SC response |
| 2 | SET | `templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)` // Read SC status code from template |

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

If the SC returned a non-zero return code, override the status to the generic error code 9000.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateStatus = 9000` // [RETURN_CODE_NON_ZERO -> "Non-zero SC return code forces generic error status"] // SC-level failure overrides template status |

**Block 3** — [IF] `(null == JCMAPLConstMgr.getString("RETURN_MESSAGE_" + status))` `(L568)`

Validates whether a return message constant exists for the computed status. If the constant is missing (the status has no corresponding message definition), resets the status to 0.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus))` // Check if return message constant exists |
| 2 | IF | `null == result` // No constant defined for this status |
| 3 | SET | `templateStatus = 0` // [RESET_TO_ZERO -> "No message constant found, reset to success/0"] // Unknown status treated as no error |

**Block 4** — [SET] `(bpStatus initialization)` `(L573–L582)`

Reads the existing BP return code from the parameter's control map. If absent, defaults to -1 (lowest priority). Otherwise parses the string value.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bpStatus = 0` // Default BP status |
| 2 | SET | `obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` // Retrieve existing BP return code |
| 3 | IF | `null == obj` // No existing BP return code |
| 4 | SET | `bpStatus = -1` // [NO_BP_STATUS -> "No previous BP status, use lowest priority"] |
| 5 | ELSE | |
| 6 | SET | `bpStatus = Integer.parseInt((String) param.getControlMapData(SCControlMapKeys.RETURN_CODE))` // Parse existing status |

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

**Primary business logic:** If the SC template status is higher (more severe) than the BP's recorded status, promote the SC status to the control map. This ensures the screen always shows the most severe error.

| # | Type | Code |
|---|------|------|
| 1 | SET | `formatStatus = String.format("%1$04d", templateStatus)` // Format as 4-digit zero-padded string (e.g., "0000", "9000") |
| 2 | SET | `message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // [CONSTANT_LOOKUP -> "Fetch localized return message from constants"] // e.g., RETURN_MESSAGE_0000 = "Normal end", RETURN_MESSAGE_9000 = "SC error" |
| 3 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` // [WRITE_RETURN_CODE -> "Store promoted status code in control map"] |
| 4 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` // [WRITE_RETURN_MESSAGE -> "Store localized message in control map"] |

**Block 6** — [SET] `(userData map retrieval)` `(L587–L589)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = null` // Initialize user data map reference |
| 2 | SET | `inMap = (HashMap<String, String>) param.getData(dataMapKey)` // [RETRIEVE_USERDATA -> "Get user data HashMap by dataMapKey"] // This is where field-level error codes will be stored |

**Block 7** — [FOR] `(iteration over contents array)` `(L591)`

Iterates over the `contents` array to process field-level error mappings. Each entry is expected to have a field name in `[0]` ending with `_err`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` // Loop counter |
| 2 | SET | `itemNm = (String) contents[i][0]` // [FIELD_NAME_EXTRACT -> "Extract field name from contents entry"] e.g., "key_svc_kei_no_err", "field_name_err" |

**Block 7.1** — [IF] `(itemNm.endsWith("_err"))` `(L593)`

Only process entries that are error fields (names ending with `_err`).

| # | Type | Code |
|---|------|------|
| 1 | SET | `errCd = template.getString(itemNm)` // [ERROR_CODE_LOOKUP -> "Get error code from template by field name"] // e.g., template.getString("key_svc_kei_no_err") returns the localized error code |
| 2 | IF | `!JKKStringUtil.isNullBlank(errCd)` // Skip if error code is null or blank |

**Block 7.1.1** — [IF] `("key_svc_kei_no_err".equals(itemNm))` `(L597)`

Special key transformation: the internal key `key_svc_kei_no_err` is mapped to the display field `svc_kei_no_err` (service detail number error). This handles the Japanese term `サービス detail 番号` (service detail number) which is used in the policy list screen.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `inMap.put("svc_kei_no_err", errCd)` // [SVC_KEY_MAPPING -> "Map internal key to display field name"] // Transform: key_svc_kei_no_err -> svc_kei_no_err |

**Block 7.1.2** — [ELSE] `(L599)`

Standard mapping for all other error fields — use the field name as-is.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `inMap.put(itemNm, errCd)` // [DIRECT_MAPPING -> "Store error code directly using field name as key"] |

**Block 8** — [RETURN] `(L608)`

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return the enriched parameter with updated status, message, and field error codes |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `JCMConstants.STATUS_INT_KEY` | Constant | Status integer key — the standard key used to retrieve the SC status code from a CAANMsg template |
| `JCMConstants.TEMPLATE_LIST_KEY` | Constant | Template list key — key to retrieve the template array from SC invocation results |
| `JCMConstants.RET_CD_INT_KEY` | Constant | Return code integer key — key to retrieve the integer return code from SC results |
| `SCControlMapKeys.RETURN_CODE` | Constant | Return code control map key — stores the business process status code in the request parameter's control map |
| `SCControlMapKeys.RETURN_MESSAGE` | Constant | Return message control map key — stores the localized return message text in the control map |
| `JCMAPLConstMgr` | Class | Application constants manager — provides localized message strings (e.g., `RETURN_MESSAGE_0000`, `RETURN_MESSAGE_9000`) from configuration |
| `JKKStringUtil.isNullBlank()` | Utility | Null/blank check — returns true if the string is null, empty, or contains only whitespace |
| `templateStatus` | Field | SC template status — the error status extracted from the Service Component's response template |
| `bpStatus` | Field | BP status — the business process's own recorded return code, used for status priority comparison |
| `formatStatus` | Field | Formatted status — the template status zero-padded to 4 digits (e.g., "9000"), used as a constant key suffix |
| `errCd` | Field | Error code — the localized error code string retrieved from the template for a specific error field |
| `contents` | Parameter | Error contents array — contains field names ending in `_err` that indicate which fields have validation errors |
| `dataMapKey` | Parameter | Data map key — the key used to access the user data HashMap within the request parameter |
| `inMap` | Field | User data map — the HashMap<String, String> holding field-level error codes mapped to field names |
| `key_svc_kei_no_err` | Field | Internal service detail number error key — internal identifier for the service contract line item error field |
| `svc_kei_no_err` | Field | Display service detail number error key — the mapped field name used by the screen to display the service detail number error |
| `service detail number` (`svc_kei_no`) | Field | Service contract line item number — an internal tracking identifier for each service contract in the ticket use application policy list |
| CAANMsg | Class | Common Application ANswer Message — a Fujitsu message container class holding structured message data including status codes, error messages, and field values |
| IRequestParameterReadWrite | Interface | Request parameter interface — the data carrier that flows between screen, BP, and SC layers, holding user data, control map data, and telegram metadata |
| SC (Service Component) | Term | Service Component — the backend service layer that performs database operations and business logic; returns status codes and messages via CAANMsg |
| BP (Business Process) | Term | Business Process — the middleware layer between screens and SCs that orchestrates SC invocations and manages transaction flow |
| CC (Common Component) | Term | Common Component — shared utility classes (like `JKKTicktUseSisakListUkCC`) used across multiple screens and BPs for common operations |
| control map | Term | A map within IRequestParameterReadWrite that holds metadata such as operator ID, hostname, return codes, and error info — used for cross-layer coordination |
| RETURN_MESSAGE_XXXX | Constant | Localized return message key — constant key pattern where XXXX is the 4-digit status code; maps to human-readable messages like "Normal end" or "SC error" |
| SCCallException | Class | SC call exception — thrown by the caller (`callSC`) when the SC returns a non-zero return code or non-zero status, signaling the screen to display an error |
