# Business Logic — JKKKapKeiInfoCancelCC.editErrorInfoHaisoUketsuke() [118 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKKapKeiInfoCancelCC` |
| Layer | CC/Common Component (Controller Common — shared business component for process control) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKKapKeiInfoCancelCC.editErrorInfoHaisoUketsuke()

This method is the **delivery reception error aggregation handler** (配送受付エラー処理メソッド) for the delivery reception blocking (配送受付拒絶) workflow in the delivery reception cancellation process. It aggregates error messages collected from service component (SC) templates across multiple processing levels — a parent template and two child lists (inList1 and inList2) — and consolidates them into a single error map (`inMap`) stored on the request parameter data map.

The method implements a **priority-based status routing** design pattern. It compares the SC template's error status (`templateStatus`) against the business process's own return code (`bpStatus`). If the SC status is numerically higher (worse), the method elevates the status by writing the SC's return code and corresponding localized error message into the control map — ensuring the caller's highest-priority error surfaces to the UI.

Its role in the larger system is a **shared aggregation utility** called by `callHaisoUketsuke()` at the end of the delivery reception blocking process chain. It collects errors from two different list-level templates (the first and second list error messages), merges parent-level errors, and writes all of them into the error map so that the screen layer can render them. The method acts as the bridge between component-level validation results and end-user error reporting.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editErrorInfoHaisoUketsuke(params)"])
    START --> EXTRACT_TEMPLATE["Extract template from templates[0]"]
    EXTRACT_TEMPLATE --> GET_STATUS["Read templateStatus from template.STATUS_INT_KEY"]
    GET_STATUS --> CHECK_RETURN{"returnCode != 0?"}
    CHECK_RETURN -->|true| SET_ERROR_STATUS["templateStatus = 9000"]
    SET_ERROR_STATUS --> VALIDATE_STATUS{"RETURN_MESSAGE_'templateStatus' exists?"}
    CHECK_RETURN -->|false| VALIDATE_STATUS
    VALIDATE_STATUS -->|no| RESET_STATUS["templateStatus = 0"]
    VALIDATE_STATUS -->|yes| READ_BP_STATUS
    RESET_STATUS --> READ_BP_STATUS["Read bpStatus from param.controlMap RETURN_CODE"]
    READ_BP_STATUS --> CHECK_NULL{"bpStatus null?"}
    CHECK_NULL -->|yes| SET_BP_NEG1["bpStatus = -1"]
    SET_BP_NEG1 --> COMPARE_STATUS{"templateStatus > bpStatus?"}
    CHECK_NULL -->|no| COMPARE_STATUS
    COMPARE_STATUS -->|no| COLLECT_ERRORS
    COMPARE_STATUS -->|yes| FORMAT_STATUS["formatStatus = 'templateStatus' zero-padded"]
    FORMAT_STATUS --> GET_MESSAGE["message = RETURN_MESSAGE_'formatStatus'"]
    GET_MESSAGE --> SET_CONTROL["Set RETURN_CODE and RETURN_MESSAGE in param"]
    SET_CONTROL --> COLLECT_ERRORS["Collect error info from inHaisoMap keySet"]
    COLLECT_ERRORS --> BUILD_LIST1["Get templateArray from inListMsgName[0]"]
    BUILD_LIST1 --> LOOP_LIST1["Iterate inList1 (0..size)"]
    LOOP_LIST1 --> EXTRACT_ERRORS1["Copy _err fields into inMap"]
    EXTRACT_ERRORS1 --> CHECK_PARENT1{"template.isNull(inListMsgName[0]_err)?"}
    CHECK_PARENT1 -->|no| ADD_PARENT1["inMap.put(inListMsgName[0]_err)"]
    CHECK_PARENT1 -->|yes| BUILD_LIST2
    ADD_PARENT1 --> BUILD_LIST2["Get templateArray2 from inListMsgName[1]"]
    BUILD_LIST2 --> LOOP_LIST2["Iterate inList2 (0..size)"]
    LOOP_LIST2 --> EXTRACT_ERRORS2["Copy _err fields into inMap"]
    EXTRACT_ERRORS2 --> CHECK_PARENT2{"template.isNull(inListMsgName[1]_err)?"}
    CHECK_PARENT2 -->|no| ADD_PARENT2["inMap.put(inListMsgName[1]_err)"]
    CHECK_PARENT2 -->|yes| RETURN_PARAM
    ADD_PARENT2 --> RETURN_PARAM["Return param"]
    RETURN_PARAM --> END(["End"])
```

**Processing flow summary:**

1. **Extract and validate template status**: The method extracts the first template from the array and reads its status integer. If a non-zero return code was passed, it overrides the status to 9000 (error override). If no localized message exists for the resulting status code, it resets to 0.

2. **Read and compare business process status**: It reads the current business process return code from the control map (defaulting to -1 if absent). If the template's status is numerically higher, it elevates the control map with the template's status code and localized message.

3. **Collect parent-level delivery errors**: It iterates over all keys in `inHaisoMap` (delivery-related data map) and copies any `_err` suffixed error strings from the template into the result map, skipping duplicates.

4. **Process List 1 child errors**: It retrieves the template array for the first list (named by `inListMsgName[0]`) and iterates each list entry, copying per-field error strings into the result map. It also checks for a parent-level error key for the entire list.

5. **Process List 2 child errors**: It retrieves the template array for the second list (named by `inListMsgName[1]`) and performs the same child-level and parent-level error extraction.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying the business process state. Used to read/write control map data (return code, return message) and to access the error data map by key. |
| 2 | `templates` | `CAANMsg[]` | Array of message templates from service component validation. `templates[0]` contains the parent template with the error status code and error message fields for the entire operation. |
| 3 | `returnCode` | `int` | The caller's return code from the SC invocation. When non-zero, it signals that the service component encountered an error and forces `templateStatus` to 9000 (indicating a delivery reception rejection error). A value of 0 means the caller did not encounter an error at this level. |
| 4 | `dataMapKey` | `String` | The key used to retrieve the `HashMap<String, String>` from `param` where error messages are aggregated. This map is the central error collector into which all `_err` fields are written. |
| 5 | `inHaisoMap` | `HashMap<String, String>` | The delivery (配送) data map from the service component. Its keySet defines which error fields to check (each key gets a `"_err"` suffix lookup). Represents the delivery-specific business data that was validated. |
| 6 | `inListMsgName` | `String[]` | An array of two String names used as lookup keys. `inListMsgName[0]` identifies the first child list template name; `inListMsgName[1]` identifies the second child list template name. These are used to extract sub-template arrays and to check for parent-level list errors. |
| 7 | `inList1` | `ArrayList<HashMap<String, String>>` | The first list of child items (delivery detail records). Each entry is a HashMap of field-value pairs. The method iterates this list to extract per-field error messages from the corresponding child template. |
| 8 | `inList2` | `ArrayList<HashMap<String, String>>` | The second list of child items, processed identically to `inList1`. Represents a separate group of delivery detail records (e.g., additional service items or alternate delivery lines). |

**External/instance state**: This method does not access any instance fields. It is stateless and purely functional — all state flows through parameters.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JACBatCommon.isNull` | JACBatCommon | - | Calls `isNull` in `JACBatCommon` |
| - | `JACbatRknBusinessUtil.isNull` | JACbatRknBusiness | - | Calls `isNull` in `JACbatRknBusinessUtil` |
| - | `JCHbatSeikyKaknoBusinessUtil.isNull` | JCHbatSeikyKaknoBusiness | - | Calls `isNull` in `JCHbatSeikyKaknoBusinessUtil` |
| - | `JBSbatACInsentetivePrcInfoSaksei.isNull` | JBSbatACInsentetivePrcInfoSaksei | - | Calls `isNull` in `JBSbatACInsentetivePrcInfoSaksei` |
| - | `JBSbatAKCHSeikyYsoInfMake.isNull` | JBSbatAKCHSeikyYsoInfMake | - | Calls `isNull` in `JBSbatAKCHSeikyYsoInfMake` |
| R | `JBSbatDKNyukaFinAdd.getData` | JBSbatDKNyukaFinAdd | - | Calls `getData` in `JBSbatDKNyukaFinAdd` |
| R | `JBSbatFUCaseFileRnkData.getString` | JBSbatFUCaseFileRnkData | - | Calls `getString` in `JBSbatFUCaseFileRnkData` |
| R | `JBSbatFUMoveNaviData.getString` | JBSbatFUMoveNaviData | - | Calls `getString` in `JBSbatFUMoveNaviData` |
| - | `JBSbatKKCashPostAddMail.keySet` | JBSbatKKCashPostAddMail | - | Calls `keySet` in `JBSbatKKCashPostAddMail` |
| - | `JBSbatKKCashPostChsht.keySet` | JBSbatKKCashPostChsht | - | Calls `keySet` in `JBSbatKKCashPostChsht` |
| R | `JBSbatZMAdDataSet.getString` | JBSbatZMAdDataSet | - | Calls `getString` in `JBSbatZMAdDataSet` |
| R | `JFUeoTelOpTransferCC.getData` | JFUeoTelOpTransferCC | - | Calls `getData` in `JFUeoTelOpTransferCC` |
| R | `JFUTransferCC.getData` | JFUTransferCC | - | Calls `getData` in `JFUTransferCC` |
| R | `JFUTransferListToListCC.getData` | JFUTransferListToListCC | - | Calls `getData` in `JFUTransferListToListCC` |
| R | `JESC0101B010TPMA.getString` | JESC0101B010TPMA | - | Calls `getString` in `JESC0101B010TPMA` |
| R | `JESC0101B020TPMA.getString` | JESC0101B020TPMA | - | Calls `getString` in `JESC0101B020TPMA` |
| R | `KKW12701SFLogic.getData` | KKW12701SFLogic | - | Calls `getData` in `KKW12701SFLogic` |

**Method-level CRUD analysis (actual calls within `editErrorInfoHaisoUketsuke`):**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `param.getControlMapData` | — | — | Reads the business process return code from the control map to compare against the template status |
| R | `param.getData` | — | — | Retrieves the error aggregation HashMap by the data map key |
| R | `template.getInt` | — | — | Reads the status integer from the CAANMsg template |
| R | `template.isNull` | — | — | Checks whether a specific error field exists and is non-null in a CAANMsg template (called ~8 times) |
| R | `template.getString` | — | — | Reads error message strings from CAANMsg templates (called ~6 times) |
| R | `template.getCAANMsgList` | — | — | Retrieves a sub-template array for a named child list (called 2 times: for list1 and list2) |
| R | `param.getControlMapData` | — | — | Reads control map data to determine bpStatus |
| W | `param.setControlMapData` | — | — | Writes the escalated status code and message into the control map (only when templateStatus > bpStatus) |
| W | `inMap.put` | — | — | Writes aggregated error message key-value pairs into the error map (called for every non-null _err field found) |
| - | `inHaisoMap.keySet` | — | — | Iterates over delivery field keys to check for corresponding error messages |
| - | `childMap.keySet` | — | — | Iterates over child item field keys for each list entry |
| - | `inMap.containsKey` | — | — | Checks for duplicate error entries before writing (idempotency guard) |

> **Note**: This method is a **pure aggregation and routing utility** — it does not directly query any database tables. It reads templates and parameter data structures and writes consolidated error information. All database/SC access is performed by the *caller* (`callHaisoUketsuke`) before this method is invoked.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 4 methods.
Terminal operations from this method: `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `isNull` [-], `isNull` [-], `isNull` [-], `isNull` [-], `isNull` [-], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `isNull` [-], `isNull` [-], `isNull` [-], `isNull` [-], `isNull` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC:JKKKapKeiInfoCancelCC | `callHaisoUketsuke()` -> `editErrorInfoHaisoUketsuke()` | `template.isNull` [R], `template.getString` [R], `param.setControlMapData` [W] |

**Caller context**: The method is called by `callHaisoUketsuke()` within the same class `JKKKapKeiInfoCancelCC`. The caller invokes this after executing the delivery reception blocking (配送受付拒絶) service component logic, passing the resulting templates, data maps, and error list references to consolidate errors for screen display.

## 6. Per-Branch Detail Blocks

### Block 1 — [EXTRACT] (L2702)

> Extract the template and determine the effective status code.

| # | Type | Code |
|---|------|------|
| 1 | COMMENT | `//本来はサービスインターフェース分の処理が必要` // "Service interface processing is originally required" |
| 2 | SET | `template = templates[0]` |
| 3 | SET | `templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)` |

### Block 2 — [IF] `(returnCode != 0)` (L2705)

> If the caller's return code indicates an error, override the template status to 9000.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateStatus = 9000` // Error override status code |

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

> If no localized message constant exists for the status code, reset status to 0. The constant lookup pattern is `RETURN_MESSAGE_XXXX` where `XXXX` is the zero-padded 4-digit status code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateStatus = 0` // Reset to success/neutral status |

### Block 4 — [IF/ELSE] (`obj == null`) — Reading bpStatus (L2712)

> Read the business process return code from the control map. If absent, default to -1.

| # | Type | Code |
|---|------|------|
| 1 | SET | `obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` |
| 2 | IF | `obj == null` |
| 2.1 — [IF true] | SET | `bpStatus = -1` // No previous BP status |
| 2.2 — [IF else] | SET | `bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE))` |

### Block 5 — [IF] (`templateStatus > bpStatus`) (L2726)

> If the SC template's status code is numerically higher (worse) than the BP's own return code, elevate the control map with the SC's status. This ensures the highest-priority error message is forwarded.

| # | Type | Code |
|---|------|------|
| 1 | SET | `formatStatus = String.format("%1$04d", templateStatus)` // Zero-padded 4-digit string |
| 2 | SET | `message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // Localized message |
| 3 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` |
| 4 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` |

### Block 6 — [EXTRACT] (L2734)

> Retrieve the error aggregation HashMap from the parameter data map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = (HashMap<String, String>)param.getData(dataMapKey)` |

### Block 7 — [WHILE] (`haisoIt.hasNext()`) — Parent delivery errors (L2736)

> Iterate over all keys in `inHaisoMap` (delivery data map) and copy any non-null `_err` suffixed error strings from the template into the result map. Skips duplicates using `containsKey`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `haisoIt = inHaisoMap.keySet().iterator()` |
| 2 | WHILE | `haisoIt.hasNext()` |
| 2.1 | SET | `key = (String)haisoIt.next()` |
| 2.2 | IF | `!template.isNull(key + "_err")` // Error field exists and is non-null |
| 2.2.1 | IF | `!inMap.containsKey(key + "_err")` // Not already aggregated |
| 2.2.1.1 | SET | `inMap.put(key + "_err", template.getString(key + "_err"))` |

### Block 8 — [EXTRACT] (L2748)

> Retrieve the child template array for the first list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateArray = template.getCAANMsgList(inListMsgName[0])` |

### Block 9 — [FOR] (`i = 0; i < inList1.size()`) — List 1 child errors (L2750)

> Iterate each entry in the first child list. For each entry, copy per-field error strings from the corresponding child template into the result map.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `i = 0; i < inList1.size(); i++` |
| 1.1 | SET | `childMap = (HashMap)inList1.get(i)` |
| 1.2 | SET | `childTemplate = templateArray[i]` |
| 1.3 | SET | `it = childMap.keySet().iterator()` |
| 1.4 | WHILE | `it.hasNext()` |
| 1.4.1 | SET | `key = (String)it.next()` |
| 1.4.2 | IF | `!childTemplate.isNull(key + "_err")` // Error field exists |
| 1.4.2.1 | IF | `!inMap.containsKey(key + "_err")` // Idempotency guard |
| 1.4.2.1.1 | SET | `inMap.put(key + "_err", childTemplate.getString(key + "_err"))` |

### Block 10 — [IF] (`!template.isNull(inListMsgName[0] + "_err")`) (L2765)

> After processing all List 1 entries, check for a parent-level error message for the entire list and copy it into the result map.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!template.isNull(inListMsgName[0] + "_err")` |
| 1.1 | IF | `!inMap.containsKey(inListMsgName[0] + "_err")` |
| 1.1.1 | SET | `inMap.put(inListMsgName[0] + "_err", template.getString(inListMsgName[0] + "_err"))` |

### Block 11 — [EXTRACT] (L2774)

> Retrieve the child template array for the second list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateArray2 = template.getCAANMsgList(inListMsgName[1])` |

### Block 12 — [FOR] (`i = 0; i < inList2.size()`) — List 2 child errors (L2776)

> Iterate each entry in the second child list. For each entry, copy per-field error strings from the corresponding child template into the result map (identical logic to Block 9).

| # | Type | Code |
|---|------|------|
| 1 | FOR | `i = 0; i < inList2.size(); i++` |
| 1.1 | SET | `childMap = (HashMap)inList2.get(i)` |
| 1.2 | SET | `childTemplate = templateArray2[i]` |
| 1.3 | SET | `it = childMap.keySet().iterator()` |
| 1.4 | WHILE | `it.hasNext()` |
| 1.4.1 | SET | `key = (String)it.next()` |
| 1.4.2 | IF | `!childTemplate.isNull(key + "_err")` |
| 1.4.2.1 | IF | `!inMap.containsKey(key + "_err")` |
| 1.4.2.1.1 | SET | `inMap.put(key + "_err", childTemplate.getString(key + "_err"))` |

### Block 13 — [IF] (`!template.isNull(inListMsgName[1] + "_err")`) (L2794)

> After processing all List 2 entries, check for a parent-level error message for the entire list.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!template.isNull(inListMsgName[1] + "_err")` |
| 1.1 | IF | `!inMap.containsKey(inListMsgName[1] + "_err")` |
| 1.1.1 | SET | `inMap.put(inListMsgName[1] + "_err", template.getString(inListMsgName[1] + "_err"))` |

### Block 14 — [RETURN] (L2802)

> Return the parameter object with all aggregated error information now stored in the data map.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `editErrorInfoHaisoUketsuke` | Method | Delivery reception error aggregation method — "haiso" (配送) means delivery, "ketsu" (拒) means reject/block, "uke" (受) means reception |
| `delivery reception blocking` | Business term | A process where delivery of ordered goods/services is blocked/rejected due to validation errors, and error messages are consolidated for user display |
| `delivery reception cancellation` | Business term | The overall business process (配送受付取消) — cancelling or rejecting a delivery reception |
| `templateStatus` | Field | Status code extracted from the service component (SC) template, representing the validation outcome level |
| `bpStatus` | Field | Business Process return code — the status code set by the calling business process itself |
| `RETURN_CODE` | Constant | Control map key used to store and retrieve the status return code between process layers |
| `RETURN_MESSAGE` | Constant | Control map key used to store and retrieve the localized error message string |
| `STATUS_INT_KEY` | Constant | Template field name used to extract an integer status code from a CAANMsg template |
| `CAANMsg` | Type | Fujitsu's message template class — carries named fields including status integers and localized message strings; supports sub-template arrays via `getCAANMsgList()` |
| `IRequestParameterReadWrite` | Type | Interface for request/response parameter handling — provides `getData()` to access the business data map and `setControlMapData()`/`getControlMapData()` to manage control/status information |
| `inHaisoMap` | Parameter | Delivery data map — the set of delivery-related field keys from the SC validation result |
| `inListMsgName` | Parameter | Array of two template list names — identifies the first and second child list template groups |
| `inList1` | Parameter | First child list of delivery detail records — each entry is a HashMap of field names to values |
| `inList2` | Parameter | Second child list of delivery detail records — processed identically to inList1 |
| `RETURN_MESSAGE_XXXX` | Constant pattern | Localized message constant key pattern where `XXXX` is a zero-padded 4-digit status code (e.g., `RETURN_MESSAGE_9000`) |
| `SC` | Acronym | Service Component — a component in this architecture that performs business logic and returns templates with status codes and error messages |
| `CC` | Acronym | Common Component — a shared controller component (e.g., `JKKKapKeiInfoCancelCC`) that orchestrates business processes |
| `_err` | Naming convention | Suffix appended to field names to indicate the error message version of that field |
| `haiso` (配送) | Japanese term | Delivery — refers to the delivery/logistics aspect of the order fulfillment process |
| `ketsu` (拒) | Japanese term | Reject/Block — indicates the delivery is being blocked or refused |
