# Business Logic — JKKDslRunCC.editErrorInfo() [7 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKDslRunCC` |
| Layer | CC / Common Component (delegates to MapperCC for error handling logic) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKDslRunCC.editErrorInfo()

This method implements **cancellation execution error mapping** (Japanese: 解約実行のエラー転記処理) — a post-service error routing step invoked after DSL (domain-specific language) run operations execute a business service component. Its business purpose is to **transfer error status and messages** returned by a service component (SC) into the `IRequestParameterReadWrite` object so that the calling business process can detect failures, display appropriate error messages to the user, and decide whether to abort or continue processing. The method acts as a **delegation wrapper** that forwards four parameters (`param`, `templates`, `returnCode`, `fixedText`) to `JKKDslRunMapperCC.editResultRPEKK0081A010ErrMap`, which contains the core error-mapping logic. This method is a **shared utility** used across dozens of business-process-check classes (BPCheck) for screens in the K-Opticom customer infrastructure system (eo customer backbone system), making it a critical error-handling touchpoint for cancellation, service change, and subscription operations.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editErrorInfo params"])
    CALL["CALL mapper.editResultRPEKK0081A010ErrMap"]
    STEP2["Get template from templates[0]"]
    STEP3["Get templateStatus from template.getInt EKK0081A010CBSMsg.STATUS"]
    COND_RC{"returnCode != 0"}
    RC_TRUE["Set templateStatus = 9000"]
    COND_MSG{"JCMAPLConstMgr.getString RETURN_MESSAGE_ formatStatus == null"}
    MSG_TRUE["Set templateStatus = 0"]
    GET_BPSTATUS["Get bpStatus from param.controlMap RETURN_CODE"]
    COND_BP{"obj == null"}
    BP_NULL["Set bpStatus = -1"]
    BP_PARSE["Set bpStatus = Integer.parseInt obj"]
    COND_TEMPLATE{"templateStatus > bpStatus"}
    TMPL_TRUE["Set RETURN_CODE and RETURN_MESSAGE in param"]
    GET_INMAP["Get inMap = param.getData fixedText"]
    COND_KEY{"template has KEY_SVC_KEI_NO_ERR"}
    COND_MAP{"inMap.containsKey svc_kei_no_err"}
    PUT_ERR["inMap.put svc_kei_no_err from template"]
    END_RETURN(["Return param"])

    START --> CALL
    CALL --> STEP2
    STEP2 --> STEP3
    STEP3 --> COND_RC
    COND_RC -->|true| RC_TRUE
    COND_RC -->|false| COND_MSG
    RC_TRUE --> COND_MSG
    COND_MSG -->|true| MSG_TRUE
    COND_MSG -->|false| GET_BPSTATUS
    MSG_TRUE --> GET_BPSTATUS
    GET_BPSTATUS --> COND_BP
    COND_BP -->|true| BP_NULL
    COND_BP -->|false| BP_PARSE
    BP_NULL --> COND_TEMPLATE
    BP_PARSE --> COND_TEMPLATE
    COND_TEMPLATE -->|true| TMPL_TRUE
    COND_TEMPLATE -->|false| GET_INMAP
    TMPL_TRUE --> GET_INMAP
    GET_INMAP --> COND_KEY
    COND_KEY -->|true| COND_MAP
    COND_KEY -->|false| END_RETURN
    COND_MAP -->|true| END_RETURN
    COND_MAP -->|false| PUT_ERR
    PUT_ERR --> END_RETURN
```

**Processing Flow Summary:**

1. The method delegates to `mapper.editResultRPEKK0081A010ErrMap()` which performs the actual error-mapping logic on `param`, `templates`, `returnCode`, and `fixedText`.
2. Inside the called method, the first `CAANMsg` template is extracted and its status code is read via `EKK0081A010CBSMsg.STATUS`.
3. If `returnCode != 0`, the template status is overridden to `9000` (indicating an abnormal/unknown service error).
4. The method validates whether a human-readable message exists in the constant manager for the computed status code; if not, status is reset to `0`.
5. The current BP-level return code (`bpStatus`) is read from `param.controlMap` — if missing, defaults to `-1`.
6. If the template's error status exceeds the BP status, the template's return code and message overwrite the BP-level values (higher-priority error propagation).
7. The method retrieves the user-data map keyed by `fixedText` and, if the template carries a service contract error number (`KEY_SVC_KEI_NO_ERR`), propagates it into the map — but only if not already present (last-write-wins prevention).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Business data access/write I/F object carrying the operational context: control map (including `RETURN_CODE`, `RETURN_MESSAGE`), and user data maps. This is the primary vehicle through which error information flows back to the calling business process. |
| 2 | `templates` | `CAANMsg[]` | Array of message objects returned from a service component (SC) call. Each `CAANMsg` encapsulates typed return values — notably the status code (`EKK0081A010CBSMsg.STATUS`) and optional service contract error number (`KEY_SVC_KEI_NO_ERR`). `templates[0]` is the primary response. |
| 3 | `returnCode` | `int` | Return code from the service component invocation. A value of `0` indicates success; any non-zero value signals an error, triggering template status override to `9000` (abnormal termination code). |
| 4 | `fixedText` | `String` | User-defined arbitrary string used as a data map key (`param.getData(fixedText)`). In practice, it serves as a namespace identifier (e.g., `"KKSV079101CC"`) to partition error data within the parameter object. |

**External State Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `this.mapper` | `JKKDslRunMapperCC` | Delegation target for error-mapping logic. Lazily instantiated (first-access creates a new instance). |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JKKDslRunMapperCC.editResultRPEKK0081A010ErrMap` | JKKDslRunMapperCC | - | Delegates to `JKKDslRunMapperCC` which updates `param` with error status, return message, and service contract error number |

**Note:** This method contains no direct database operations. The entire business logic is delegated to `JKKDslRunMapperCC.editResultRPEKK0081A010ErrMap`, which performs **Update** operations on the `IRequestParameterReadWrite` object (modifying its control map and data maps in-place).

### Pre-computed evidence from called method `editResultRPEKK0081A010ErrMap` analysis:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `template.getInt(EKK0081A010CBSMsg.STATUS)` | - | - | Read status code from service component response message |
| R | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + status)` | - | - | Read human-readable error message from constant manager (in-memory configuration) |
| R | `param.getControlMapData(SCControlMapKeys.RETURN_CODE)` | - | - | Read current BP-level return code from control map |
| U | `param.setControlMapData(RETURN_CODE, formatStatus)` | - | - | Set error return code in control map for higher-priority SC status |
| U | `param.setControlMapData(RETURN_MESSAGE, message)` | - | - | Set error message text in control map |
| R | `param.getData(fixedText)` | - | - | Read user-data map by `fixedText` key |
| U | `inMap.put("svc_kei_no_err", template.getString(...))` | - | - | Write service contract error number into user-data map (if not already set) |

## 5. Dependency Trace

This method is invoked by **dozens of BP (Business Process) check classes** (`KKSV*OPBPCheck`, `CRSV*OPBPCheck`, `FUSV*OPBPCheck`, `SCSV*OPBPCheck`, `ZMSV*OPBPCheck`, etc.) across the K-Opticom customer infrastructure system. These are post-execution validation/checkpoint classes that run after DSL operations complete and need to map any error information back to the parameter object for downstream error handling.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0791 | `KKSV0791_KKSV0791OPBPCheck.editErrorInfo` -> `jkkopchrirekilistdlydcc.editErrorInfo` | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 2 | Screen:KKSV0195 | `KKSV0195OPOperation` -> `JKKDslRunCC.editErrorInfo` (via DSL run CC setup) | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 3 | Screen:KKSV0098 | `KKSV0098OPOperation` -> `JKKDslRunCC` cancel execution CC | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 4 | Screen:KKSV0325 | `KKSV0325OPOperation` -> `JKKDslRunCC` DSL run setup | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 5 | Screen:KKSV0150 | `KKSV0150OPOperation` -> `JKKDslRunCC` DSL run setup | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 6 | Screen:KKSV0201 | `KKSV0201OPOperation` -> `JKKDslRunCC` DSL run setup | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 7 | Screen:KKSV0464 | `KKSV0464OPOperation` -> `JKKDslRunCC` DSL run setup | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 8 | Screen:KKSV0674 | `KKSV0674OPOperation` -> `JKKDslRunCC` DSL run setup | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 9 | Screen:KKSV0725 | `KKSV0725OPOperation` -> `JKKDslRunCC` DSL run setup | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 10 | Screen:KKSV0729 | `KKSV0729OPOperation` -> `JKKDslRunCC` DSL run setup | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 11 | Screen:KKSV0495 | `KKSV0495_KKSV0495OPBPCheck` -> multiple BSmapper.editErrorInfo calls | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 12 | Screen:KKSV0718 | `KKSV0718_KKSV0718OPBPCheck` -> multiple BSmapper.editErrorInfo calls | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 13 | Screen:KKSV0551 | `KKSV0551_KKSV0551OPBPCheck` -> `editErrorInfo` | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 14 | Screen:KKSV0557 | `KKSV0557_KKSV0557OPBPCheck` -> `editErrorInfo` | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |
| 15 | Screen:KKSV0585 | `KKSV0585_KKSV0585OPBPCheck` -> multiple BSmapper.editErrorInfo calls | `mapper.editResultRPEKK0081A010ErrMap [U] param.controlMap` |

**Note:** Many additional screens (`CRSV*`, `FUSV*`, `SCSV*`, `ZMSV*`, `CCSV*`, `CNSV*`, `CHSV*`, `DKSV*`) also invoke `editErrorInfo` via their respective BSmapper objects or direct CC invocations. The pattern is consistent: a BP check class calls `editErrorInfo` on a mapper or CC instance to propagate error information after a DSL run completes.

## 6. Per-Branch Detail Blocks

### Block 1 — CALL `(delegate to mapper)` (L99-L105)

> Delegates to `JKKDslRunMapperCC.editResultRPEKK0081A010ErrMap` which performs the full error-mapping logic.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `this.mapper.editResultRPEKK0081A010ErrMap(param, templates, returnCode, fixedText)` |
| 2 | RETURN | `return param;` |

---

### Block 1.1 — Nested logic inside `editResultRPEKK0081A010ErrMap` (delegated) (L8119+)

> The core error-mapping logic resides in `JKKDslRunMapperCC.editResultRPEKK0081A010ErrMap`. This block details that logic.

| # | Type | Code |
|---|------|------|
| 1 | SET | `CAANMsg template = templates[0];` // Extract first template from array |
| 2 | SET | `int templateStatus = template.getInt(EKK0081A010CBSMsg.STATUS);` // Read SC status code |
| 3 | IF | `returnCode != 0` — non-zero return code from SC [L8124] |
| 3.1 | SET | `templateStatus = 9000;` // Override with abnormal termination code [-> `9000` (abnormal)] |
| 4 | IF | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null` — message constant missing [L8127] |
| 4.1 | SET | `templateStatus = 0;` // Reset to normal if no constant exists [-> `0` (normal)] |
| 5 | SET | `Object obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE);` // Read BP-level return code [-> `RETURN_CODE` key] |
| 6 | IF | `obj == null` — BP return code not yet set [L8131] |
| 6.1 | SET | `bpStatus = -1;` // Default: no prior error [-> `-1` (unset)] |
| 6.2 | ELSE | `bpStatus = Integer.parseInt((String) obj);` // Parse existing BP return code |
| 7 | IF | `templateStatus > bpStatus` — SC error is higher priority than current BP error [L8137] |
| 7.1 | SET | `String formatStatus = String.format("%1$04d", templateStatus);` // Zero-padded to 4 digits (e.g., `"9000"`) |
| 7.2 | SET | `String message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus);` // Human-readable message |
| 7.3 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus);` // Override BP return code [-> `RETURN_CODE` key] |
| 7.4 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message);` // Override BP message [-> `RETURN_MESSAGE` key] |
| 8 | SET | `HashMap inMap = (HashMap) param.getData(fixedText);` // Get user-data map by fixedText key |
| 9 | IF | `!template.isNull(EKK0081A010CBSMsg.KEY_SVC_KEI_NO_ERR)` — template carries service contract error number [L8144] |
| 9.1 | IF | `!inMap.containsKey("svc_kei_no_err")` — not already present [L8145] |
| 9.1.1 | SET | `inMap.put("svc_kei_no_err", template.getString(EKK0081A010CBSMsg.KEY_SVC_KEI_NO_ERR));` // Write service contract error number |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `IRequestParameterReadWrite` | Class | Business data access/write interface — the central data carrier between screens, business processes, and service components. Contains control maps (metadata like return codes) and data maps (business payload). |
| `CAANMsg` | Class | Message object returned from a service component (SC) call, encapsulating typed return values such as status codes, error numbers, and field values. |
| `returnCode` | Field | Service component return code — `0` means success, any non-zero value indicates an error. Used to trigger error status override to `9000`. |
| `fixedText` | Field | User-defined arbitrary string used as a namespace key for the user-data map. Acts as a logical partition identifier within the parameter object (e.g., `"KKSV079101CC"`). |
| `param` | Field | Business data access/write I/F — the primary parameter object carrying all business context for a DSL run operation. |
| `templates` | Field | Array of `CAANMsg` objects returned by a service component, containing status codes and error information. |
| `JKKDslRunCC` | Class | Cancellation execution CC (Common Component) — orchestrates cancellation (解約) operations in the K-Opticom DSL run framework. |
| `JKKDslRunMapperCC` | Class | Mapper CC for DSL run — handles mapping between service component responses and business parameter objects. |
| `JKK` | Prefix | K-Opticom business domain prefix — indicates this code belongs to the K-Opticom customer infrastructure system (e.g., `JKKDslRunCC`, `JKKMainSubKeiJudgeMapperCC`). |
| `EKK0081A010CBSMsg` | Class | Message constant class for SC code `EKK0081A010SC` — defines message key constants including `STATUS`, `KEY_SVC_KEI_NO_ERR`. |
| `EKK0081A010SC` | SC Code | Service Component for error result mapping (RPE = Result Post-Entry, KKK = cancellation/termination) |
| `RPE` | Abbreviation | Result Post-Entry — the process of recording error results after a service component execution. Japanese: エラー転記. |
| `JOKEN` | Abbreviation | Cancellation/termination (解除) — refers to service contract cancellation operations in the telecom domain. |
| `SC` | Abbreviation | Service Component — a reusable business logic module that performs a specific operation (e.g., contract change, order processing). |
| `CBS` | Abbreviation | Core Business System — the backend system that executes service component calls and returns results. |
| `BP` | Abbreviation | Business Process — a workflow or process definition that orchestrates multiple components to fulfill a business operation. |
| `BPCheck` | Class Suffix | Post-execution check class — runs after a DSL operation to validate and map error results (e.g., `KKSV0791_KKSV0791OPBPCheck`). |
| `DC` | Abbreviation | DSL Call — indicates a DSL execution wrapper component (e.g., `jkkopchrirekilistdlydcc`). |
| `STATUS` | Constant | Message key for the service component status code, accessed via `EKK0081A010CBSMsg.STATUS`. |
| `KEY_SVC_KEI_NO_ERR` | Constant | Message key for the service contract error number — a number identifying which service contract line item encountered an error. |
| `RETURN_CODE` | Constant | Control map key for the business-level return code (see `SCControlMapKeys.RETURN_CODE`). |
| `RETURN_MESSAGE` | Constant | Control map key for the human-readable error message (see `SCControlMapKeys.RETURN_MESSAGE`). |
| `RETURN_MESSAGE_XXXX` | Constant | Constant manager key pattern mapping status codes to human-readable messages (e.g., `RETURN_MESSAGE_9000`). |
| `svc_kei_no_err` | Field | Service contract error number — identifies which service contract line item encountered an error. Stored in the user-data map keyed by `fixedText`. |
| `bpStatus` | Variable | BP-level status code — the current error severity level in the parameter object. Higher values indicate more severe errors. Defaults to `-1` when not set. |
| `templateStatus` | Variable | SC template status code — the error severity returned by the service component. Potentially overridden to `9000` if `returnCode != 0`. |
