# (DD40) Business Logic — JDKCommon08CC.editInMsg() [86 LOC]

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

## 1. Role

### JDKCommon08CC.editInMsg()

This method performs **domestic device one-to-one matching (2) processing** (宅内機器一意照会(2)処理). It is a Common Component (CC) that builds an input message (`CAANMsg`) for the CBS `EWCA0010002` used in the Return Device Acceptance (返品機器承認) business process (DKSV0081 BP). The method acts as a **message builder** — it collects operational context (transaction ID, usecase ID, operator ID, etc.), system control data (host name, IP address, screen ID), and business data (equipment model code `key_tk_mdl_cd` and manufacturing number `key_kk_seizo_no`) from the `IRequestParameterReadWrite` parameter, then assembles them into a structured `CAANMsg` template for downstream CBS invocation.

The method implements the **Template pattern** combined with the **Builder pattern**: it constructs a `CAANMsg` object typed to `EWCA0010002CBSMsg`, populates its fields with resolved input data, and returns a `HashMap` containing the prepared message within a `TEMPLATE_LIST_KEY` array.

It serves as a **shared utility** called by multiple mapping layers (e.g., `EDKA0010008BSMapper`, `EDKA0010005BSMapper`) across the Return Device Acceptance (返品機器承認) screens. The `key_tk_mdl_cd` and `key_kk_seizo_no` parameters carry the target device's model code and serial number, respectively, allowing the downstream CBS to look up the specific device's details.

The method has a simple conditional branch: when `inMap` (the data map from `DKSV008101CC`) is not null, it sets `FUNC_CODE = "1"` (default) on the template. This flag signals the CBS that standard/default processing is expected. Null/empty checks on `key_tk_mdl_cd` and `key_kk_seizo_no` ensure that missing values are explicitly set as null on the template rather than omitted.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editInMsg(param, key_tk_mdl_cd, key_kk_seizo_no)"])
    START --> INIT["Create paramMap HashMap"]
    INIT --> SC_DATA["Copy SC Import Common Data: telegramID, usecaseID, operationID, callType"]
    SC_DATA --> USER_DATA["Copy User Data: client hostname, IP, screen ID, operator ID"]
    USER_DATA --> TEMPLATE["Create CAANMsg template (EWCA0010002CBSMsg.class)"]
    TEMPLATE --> SET_TEMPLATE_ID["Set template ID = EWCA0010002"]
    SET_TEMPLATE_ID --> SET_USER_FIELDS["Set operator ID, operate date, operate datetime on template"]
    SET_USER_FIELDS --> GET_DATA["Get data map from param.getData(DKSV008101CC)"]
    GET_DATA --> CHECK_DATA{inMap != null}
    CHECK_DATA -->|true| SET_FUNC_CODE["Set template FUNC_CODE = 1 (Default)"]
    CHECK_DATA -->|false| SKIP_FUNC["Skip FUNC_CODE setting"]
    SET_FUNC_CODE --> CHECK_MODEL{key_tk_mdl_cd == null or \"\"?}
    SKIP_FUNC --> CHECK_MODEL
    CHECK_MODEL -->|yes| SET_NULL_MODEL["Set template KEY_TK_MDL_CD = null"]
    CHECK_MODEL -->|no| SET_MODEL["Set template KEY_TK_MDL_CD = key_tk_mdl_cd"]
    SET_NULL_MODEL --> CHECK_SEIZO{key_kk_seizo_no == null or \"\"?}
    SET_MODEL --> CHECK_SEIZO
    CHECK_SEIZO -->|yes| SET_NULL_SEIZO["Set template KEY_KK_SEIZO_NO = null"]
    CHECK_SEIZO -->|no| SET_SEIZO["Set template KEY_KK_SEIZO_NO = key_kk_seizo_no"]
    SET_NULL_SEIZO --> ARRANGE_TEMPLATE["Create templates array with single template"]
    SET_NULL_MODEL --> ARRANGE_TEMPLATE
    SET_SEIZO --> ARRANGE_TEMPLATE
    ARRANGE_TEMPLATE --> PUT_TEMPLATE["Put templates array into paramMap[TEMPLATE_LIST_KEY]"]
    PUT_TEMPLATE --> END(["Return paramMap"])
```

**CRITICAL — Constant Resolution:**
- `DKSV008101CC` = `"DKSV008101CC"` — Data key for return device acceptance data from upstream screens. [-> DKSV008101CC="DKSV008101CC" (JDKCommon08CC.java:140)]
- `EWCA0010002` — Template ID for the Return Device Acceptance domestic device lookup CBS. [-> EWCA0010002CBSMsg.TEMPLATEID="EWCA0010002" (EWCA0010002CBSMsg.java)]
- `FUNC_CODE = "1"` — Default function code indicating standard processing mode.
- `JCMConstants.TEMPLATE_LIST_KEY` — Key under which the prepared `CAANMsg[]` array is stored in the output map.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying all inbound data for the Return Device Acceptance (返品機器承認) process. Contains transaction metadata (telegram ID, usecase ID, operation ID, call type), control map data (hostname, IP, screen ID, operator ID, operating date/time), and business data maps keyed by constant strings (e.g., `DKSV008101CC`). |
| 2 | `key_tk_mdl_cd` | `String` | Target take-back (返品) equipment model code — identifies the specific device model being returned for acceptance. Used to look up device specifications and return eligibility. Null/empty values are explicitly set as null on the CBS template. |
| 3 | `key_kk_seizo_no` | `String` | Target take-back (返品) manufacturing (serial) number — uniquely identifies a specific device unit within the model. Used alongside `key_tk_mdl_cd` to perform one-to-one device lookup in the domestic equipment database. Null/empty values are explicitly set as null on the CBS template. |

**External state read:**

| Field / State | Description |
|--------------|-------------|
| `DKSV008101CC` (constant) | `"DKSV008101CC"` — Key used to retrieve the business data HashMap from `param.getData()`. Represents the data payload from the Return Device Acceptance screen (DKSV008101). [-> DKSV008101CC="DKSV008101CC" (JDKCommon08CC.java:140)] |
| `EWCA0010002CBSMsg.class` | CBS message class defining the schema for the domestic device lookup message. [-> EWCA0010002CBSMsg.class (EWCA0010002CBSMsg.java)] |
| `JCMConstants` fields | Transaction metadata keys: `TRANZACTION_ID_KEY`, `USECASE_ID_KEY`, `OPERATION_ID_KEY`, `OPERATOR_ID_KEY`, `OPERATE_DATE_KEY`, `OPERATE_DATETIME_KEY`, `TEMPLATE_LIST_KEY`. [-> JCMConstants (JCMConstants.java)] |
| `SCControlMapKeys` fields | Control map keys: `REQ_HOSTNAME`, `REQ_HOSTIP`, `REQ_VIEWID`, `OPERATOR_ID`, `OPE_DATE`, `OPE_TIME`. [-> SCControlMapKeys (SCControlMapKeys.java)] |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `EWCA0010002CBSMsg` | EWCA0010002 | (CBS Template) | Creates and populates the CBS input message template for domestic device one-to-one matching lookup. This CBS is invoked downstream by the calling mapper classes. |

The `editInMsg` method itself is a **pure message builder** — it does not perform direct database operations or SC calls. Instead, it:

1. Reads data from `param` (in-memory parameter object) — categorized as **R** (Read) since data flows from the request parameter.
2. Calls `param.getTelegramID()`, `param.getUsecaseID()`, `param.getOperationID()`, `param.getCallType()` — reads metadata.
3. Calls `param.getControlMapData(...)` for hostname, IP, screen ID, operator ID — reads control data.
4. Calls `param.getData("DKSV008101CC")` — reads business data map.
5. Creates and populates `CAANMsg` template (via `set()`, `setNull()`) — prepares the CBS input.
6. Calls `param.set()` on template fields — writes to the in-memory template object.

No direct DB access or SC invocation occurs within this method. The prepared `paramMap` is consumed by calling mappers (e.g., `EDKA0010008BSMapper`, `EDKA0010005BSMapper`) which then invoke the actual CBS `EWCA0010002` for the device lookup.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | BP:DKSV0081OPOperation | `DKSV0081OPOperation` -> `CCRequestBroker(JDKCommon08CC.approve)` -> calls `editInMsg` indirectly via mapping layer | `EDKA0010008BSMapper` -> `EWCA0010002CBSMsg` [R] Domestic Device Lookup |
| 2 | BP:DKSV0081OPOperation | `DKSV0081OPOperation` -> `CCRequestBroker(JDKCommon08CC)` -> `EDKA0010008BSMapper.editInMsg(param)` -> `JDKCommon08CC.editInMsg` | `EWCA0010002CBS` [R] Domestic Device One-to-One Match |
| 3 | BP:DKSV0081OPOperation | `DKSV0081OPOperation` -> `EDKA0010005BSMapper.editInMsg(param)` -> `JDKCommon08CC.editInMsg` | `EWCA0010002CBS` [R] Domestic Device Lookup for Stock |
| 4 | Mapper: EDKA0010008BSMapper | `EDKA0010008BSMapper` -> `JDKCommon08CC.editInMsg(param, modelCd, productNo)` | `EWCA0010002CBS` [R] Domestic Device One-to-One Match |
| 5 | Mapper: EDKA0010005BSMapper | `EDKA0010005BSMapper` -> `JDKCommon08CC.editInMsg(param, modelCd, productNo)` | `EWCA0010002CBS` [R] Domestic Device Stock Lookup |

**Caller Context:**

| # | Caller Class | Call Context |
|---|-------------|-------------|
| 1 | `DKSV0081OPOperation` | BPM Operation for Return Device Acceptance (返品機器承認). The `CCRequestBroker target4` is configured for `JDKCommon08CC.approve`, and mapping layers call `editInMsg` to build input messages for the CBS. |
| 2 | `EDKA0010008BSMapper` | Mapping class for Domestic Device List Inquiry (宅内機器一覧照会). Calls `editInMsg` with `key_tk_mdl_cd` and `key_kk_seizo_no` from the hmpin (homing pin) device map to build the CBS message for device detail lookup. |
| 3 | `EDKA0010005BSMapper` | Mapping class for Domestic Device Stock Inquiry (宅内機器在庫照会). Calls `editInMsg` with device model code and serial number to build the CBS message for stock status lookup. |

**Note:** The Japanese comment `宅内機器一意照会(2)処理を行う` translates to "Performs domestic device one-to-one matching (2) processing." This confirms the method's role in the return device acceptance workflow where a specific device unit is identified by model code and serial number.

## 6. Per-Branch Detail Blocks

**Block 1** — SET `(parameter initialization)` (L878-881)

> Initialize the output parameter map and populate SC import common data from the request parameter.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = new HashMap<String, Object>()` // Output parameter map |
| 2 | SET | `paramMap.put(JCMConstants.TRANZACTION_ID_KEY, param.getTelegramID())` // Transaction ID [-> TRANZACTION_ID_KEY (JCMConstants.java)] |
| 3 | SET | `paramMap.put(JCMConstants.USECASE_ID_KEY, param.getUsecaseID())` // Use case ID [-> USECASE_ID_KEY (JCMConstants.java)] |
| 4 | SET | `paramMap.put(JCMConstants.OPERATION_ID_KEY, param.getOperationID())` // Operation ID [-> OPERATION_ID_KEY (JCMConstants.java)] |
| 5 | SET | `paramMap.put(JCMConstants.CALL_TYPE_KEY, param.getCallType())` // Service call type classification [-> CALL_TYPE_KEY (JCMConstants.java)] |

**Block 2** — SET `(user control data extraction)` (L888-899)

> Copy user-side control data from the control map: hostname, IP address, screen ID, operator ID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put(JCMConstants.CLIENT_HOST_NAME_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTNAME))` // Client hostname [-> REQ_HOSTNAME (SCControlMapKeys.java)] |
| 2 | SET | `paramMap.put(JCMConstants.CLIENT_IP_ADDRESS_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTIP))` // Client IP address [-> REQ_HOSTIP (SCControlMapKeys.java)] |
| 3 | SET | `paramMap.put(JCMConstants.INVOKE_GAMEN_ID_KEY, param.getControlMapData(SCControlMapKeys.REQ_VIEWID))` // Invoke screen ID [-> REQ_VIEWID (SCControlMapKeys.java)] |
| 4 | SET | `paramMap.put(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` // Operator ID [-> OPERATOR_ID (SCControlMapKeys.java)] |

**Block 3** — NEW/SET `(template creation and user field setup)` (L901-919)

> Create a CAANMsg template for CBS EWCA0010002 and populate it with operator and operating date/time information.

| # | Type | Code |
|---|------|------|
| 1 | NEW | `template = new CAANMsg(EWCA0010002CBSMsg.class.getName())` // CBS message template [-> EWCA0010002CBSMsg.class (EWCA0010002CBSMsg.java)] |
| 2 | SET | `template.set(EWCA0010002CBSMsg.TEMPLATEID, "EWCA0010002")` // Template ID [-> TEMPLATEID="EWCA0010002" (EWCA0010002CBSMsg.java)] |
| 3 | SET | `template.set(JCMConstants.OPERATOR_ID_KEY, operatorId)` // Operator ID from control map [-> OPERATOR_ID_KEY (JCMConstants.java)] |
| 4 | SET | `template.set(JCMConstants.OPERATE_DATE_KEY, operateDate)` // Operating date from control map [-> OPERATE_DATE_KEY (JCMConstants.java)] |
| 5 | SET | `template.set(JCMConstants.OPERATE_DATETIME_KEY, operateDateTime)` // Operating date-time from control map [-> OPERATE_DATETIME_KEY (JCMConstants.java)] |

**Block 4** — SET `(business data extraction)` (L921-922)

> Retrieve the business data HashMap associated with key `DKSV008101CC` from the request parameter.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = (HashMap)param.getData(DKSV008101CC)` // Business data map [-> DKSV008101CC="DKSV008101CC" (JDKCommon08CC.java:140)] |

**Block 5** — IF `(inMap null check — default function code)` (L924-928)

> When the business data map is present (not null), set the function code to "1" (default processing mode). This indicates the CBS should apply standard processing logic for the device lookup.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EWCA0010002CBSMsg.FUNC_CODE, "1")` // Default function code [-> FUNC_CODE (EWCA0010002CBSMsg.java)] |

**Block 6** — IF `(key_tk_mdl_cd null/empty check)` (L930-939)

> Conditional null handling for the device model code. If the model code is null or empty, explicitly set it as null on the template; otherwise set its actual value.

| # | Type | Code |
|---|------|------|
| 1 | IF | `key_tk_mdl_cd == null || "".equals(key_tk_mdl_cd)` |
| 2 | SET (yes-branch) | `template.setNull(EWCA0010002CBSMsg.KEY_TK_MDL_CD)` // Null value for model code [-> KEY_TK_MDL_CD (EWCA0010002CBSMsg.java)] |
| 3 | SET (no-branch) | `template.set(EWCA0010002CBSMsg.KEY_TK_MDL_CD, key_tk_mdl_cd)` // Actual model code value |

**Block 7** — IF `(key_kk_seizo_no null/empty check)` (L941-950)

> Conditional null handling for the device manufacturing (serial) number. If the serial number is null or empty, explicitly set it as null on the template; otherwise set its actual value.

| # | Type | Code |
|---|------|------|
| 1 | IF | `key_kk_seizo_no == null || "".equals(key_kk_seizo_no)` |
| 2 | SET (yes-branch) | `template.setNull(EWCA0010002CBSMsg.KEY_KK_SEIZO_NO)` // Null value for serial number [-> KEY_KK_SEIZO_NO (EWCA0010002CBSMsg.java)] |
| 3 | SET (no-branch) | `template.set(EWCA0010002CBSMsg.KEY_KK_SEIZO_NO, key_kk_seizo_no)` // Actual serial number value |

**Block 8** — SET `(template assembly and return)` (L952-957)

> Assemble the prepared template into a single-element array, store it in the output parameter map under the template list key, and return the map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = new CAANMsg[1]` // Single-element template array |
| 2 | SET | `templates[0] = template` // Populate array with the built template |
| 3 | SET | `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` // Store template array [-> TEMPLATE_LIST_KEY (JCMConstants.java)] |
| 4 | RETURN | `return paramMap` // Return fully constructed parameter map |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `key_tk_mdl_cd` | Field | Target take-back (返品) equipment model code — identifies the model of the device being returned for acceptance processing. |
| `key_kk_seizo_no` | Field | Target take-back (返品) manufacturing (serial) number — uniquely identifies a specific device unit. Used for one-to-one device lookup. |
| `DKSV008101CC` | Constant | Data key `"DKSV008101CC"` — key used to retrieve the business data HashMap from the request parameter. Represents data payload from the Return Device Acceptance screen. |
| EWCA0010002 | CBS | Domestic Device One-to-One Matching (2) CBS — service component that performs device detail lookup by model code and serial number. |
| `TRANZACTION_ID_KEY` | Constant | Transaction ID key — unique identifier for the service transaction session. |
| `USECASE_ID_KEY` | Constant | Use case ID key — identifies the business use case being executed. |
| `OPERATION_ID_KEY` | Constant | Operation ID key — identifies the specific operation within the use case. |
| `CALL_TYPE_KEY` | Constant | Service call type classification key — distinguishes between different service call types (e.g., synchronous, asynchronous). |
| `TEMPLATE_LIST_KEY` | Constant | Key under which the `CAANMsg[]` array is stored in the output parameter map. |
| `CLIENT_HOST_NAME_KEY` | Constant | Client hostname key — identifies the originating server/host. |
| `CLIENT_IP_ADDRESS_KEY` | Constant | Client IP address key — source IP address of the request. |
| `INVOKE_GAMEN_ID_KEY` | Constant | Invoked screen ID key — identifies which screen initiated the request. |
| `OPERATOR_ID_KEY` | Constant | Operator ID key — identifies the user performing the operation. |
| `OPERATE_DATE_KEY` | Constant | Operating date key — the business processing date. |
| `OPERATE_DATETIME_KEY` | Constant | Operating date-time key — the full timestamp of the operation. |
| `REQ_HOSTNAME` | Constant | Requested hostname control map key. |
| `REQ_HOSTIP` | Constant | Requested host IP control map key. |
| `REQ_VIEWID` | Constant | Requested view ID (screen ID) control map key. |
| `OPE_DATE` | Constant | Operation date control map key. |
| `OPE_TIME` | Constant | Operation time control map key. |
| `SCControlMapKeys` | Class | Control map key constants class — provides standardized keys for accessing request control data. |
| `CAANMsg` | Class | Fujurity's CBS message wrapper class — encapsulates CBS input/output parameters with type-safe `set()`/`setNull()`/`get()` methods. |
| `CAANSchemaInfo` | Class | Base class for CBS message schemas — provides field accessors and validators. |
| `EWCA0010002CBSMsg` | Class | CBS message schema for EWCA0010002 — defines fields like TEMPLATEID, FUNC_CODE, KEY_TK_MDL_CD, KEY_KK_SEIZO_NO. |
| `JCMConstants` | Class | JCM (Java Common Module) constants — defines standard key names for transaction metadata and control data across the system. |
| `IRequestParameterReadWrite` | Interface | Request parameter interface — read-write contract for BPM request data including metadata, control maps, and business data. |
| `IRequestParameterReadOnly` | Interface | Read-only variant of the request parameter interface. |
| `FUNC_CODE` | Field | Function code — CBS-level flag indicating processing mode (e.g., "1" = default/standard). |
| `TEMPLATEID` | Field | CBS template identification string — links the message to its schema definition. |
| `KEY_TK_MDL_CD` | Field | CBS template field for target take-back equipment model code. |
| `KEY_KK_SEIZO_NO` | Field | CBS template field for target take-back manufacturing (serial) number. |
| 宅内機器一意照会 | Japanese term | Domestic device one-to-one matching — business process of looking up a specific device by its model code and serial number. |
| 返品機器承認 | Japanese term | Return device acceptance — business process (DKSV0081 BP) for accepting returned customer equipment. |
| EDKA0010008BSMapper | Class | BS Mapper class for Domestic Device List Inquiry — maps data for the device list lookup CBS call. |
| EDKA0010005BSMapper | Class | BS Mapper class for Domestic Device Stock Inquiry — maps data for the device stock status lookup CBS call. |
| DKSV0081OPOperation | Class | BPM Operation class for the Return Device Acceptance process — orchestrates the overall business flow. |
| CCRequestBroker | Class | BPM framework class that invokes Common Component (CC) methods with configurable bean factory and exception handling. |
