# Business Logic — JKKCancelSvcKeiMapperCC.mappinEKK1091D010SCInMsgWrib() [86 LOC]

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

## 1. Role

### JKKCancelSvcKeiMapperCC.mappinEKK1091D010SCInMsgWrib()

This method maps input data onto the SIF (System Interface) message template `EKK1091D010` for the **Service Contract Cancellation Discount-Support** service component (`EKK1091D010SC`). In business terms, it constructs the outbound message that carries cancellation request details when a customer cancels their service contract under a discount-related scenario.

The method implements a **routing/dispatch pattern** based on the call pattern number (`callPtnNo`). It branches into two paths: when the call pattern equals `"4"`, it iterates over a list of reason code entries from `trgt_data` and maps each child record into the `EKK1091D010CBSMSG1LIST` nested array — this path is used exclusively by the **Service Contract Update Screen** where the user may provide multiple cancellation reason entries. In all other cases, a single default reason code `"56"` (Other) is inserted, representing a catch-all cancellation rationale.

It also sets core header fields — a fixed template ID `"EKK1091D010"`, function code `"1"`, the service contract number, the system datetime for the modification timestamp, and the modification division and progress status from the working field. The method is a **data transformer** called by the service-level CC `JKKCancelSvcKeiCC.callEKK1091D010SCwrib` and is a shared utility within the K-Opticom customer base system for service cancellation workflows, particularly those involving discount or promotional contract adjustments.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["mappinEKK1091D010SCInMsgWrib"])
    INIT_VARS["Initialize: templateArray=null, idoRsnDataList=null"]
    GET_CALL_PTN["Get callPtnNo from trgt_data"]
    NULL_MAP["fillCAANMSGNullMapping"]
    SET_TEMPLATE_ID["Set TEMPLATEID"]
    SET_FUNC_CODE["Set FUNC_CODE to 1"]
    SET_SVC_KEI_NO["Set SVC_KEI_NO from inHash"]
    SET_IDO_DTM["Set IDO_DTM via getSysDateTimeStamp"]
    SET_IDO_DIV["Set IDO_DIV from workField"]
    SET_PRG_STAT["Set PRG_STAT from workField"]
    CALL_PTN_CHECK{"callPtnNo equals \"4\""}
    GET_IDO_RSN_LIST["Get idoRsnDataList from trgt_data"]
    GET_TEMPLATE_ARRAY["Get EKK1091D010CBSMSG1LIST from template"]
    CHECK_ARRAY{"templateArray == null"}
    NEW_ARRAY["templateArray = new CAANMsg[size]"]
    FOR_LOOP["for i = 0 to size"]
    GET_CHILD_MAP["childMap = idoRsnDataList.get(i)"]
    GET_CHILD_TPL["childTemplate = templateArray[i]"]
    CHECK_CHILD{"childTemplate == null"}
    NEW_CHILD["childTemplate = new CAANMsg"]
    SET_IDO_RSN_CD["SetNull IDO_RSN_CD, then set from childMap"]
    SET_IDO_RSN_MEMO["SetNull IDO_RSN_MEMO"]
    SET_ARRAY_ITEM["templateArray[i] = childTemplate"]
    SET_TEMPLATE_LIST["template.setEKK1091D010CBSMSG1LIST"]
    CREATE_IDO_RSN["Create idoRsnTemp CAANMsg"]
    SET_IDO_RSN_OTHER["Set IDO_RSN_CD to 56"]
    SET_IDO_MEMO_OTHER["SetNull IDO_RSN_MEMO"]
    CREATE_SINGLE_LIST["list = new CAANMsg[1]"]
    SET_SINGLE_TEMPLATE["list[0] = idoRsnTemp"]
    SET_SINGLE_LIST["template.setEKK1091D010CBSMSG1LIST"]
    SET_MSKM_DTL_NO["Set MSKM_DTL_NO from workField"]
    END_NODE(["Return"])

    START --> INIT_VARS --> GET_CALL_PTN --> NULL_MAP --> SET_TEMPLATE_ID --> SET_FUNC_CODE --> SET_SVC_KEI_NO --> SET_IDO_DTM --> SET_IDO_DIV --> SET_PRG_STAT --> CALL_PTN_CHECK
    CALL_PTN_CHECK -->|yes| GET_IDO_RSN_LIST
    CALL_PTN_CHECK -->|no| CREATE_IDO_RSN
    GET_IDO_RSN_LIST --> GET_TEMPLATE_ARRAY --> CHECK_ARRAY
    CHECK_ARRAY -->|is null| NEW_ARRAY
    CHECK_ARRAY -->|not null| FOR_LOOP
    NEW_ARRAY --> FOR_LOOP
    FOR_LOOP --> GET_CHILD_MAP --> GET_CHILD_TPL --> CHECK_CHILD
    CHECK_CHILD -->|is null| NEW_CHILD
    CHECK_CHILD -->|not null| SET_IDO_RSN_CD
    NEW_CHILD --> SET_IDO_RSN_CD
    SET_IDO_RSN_CD --> SET_IDO_RSN_MEMO --> SET_ARRAY_ITEM --> SET_TEMPLATE_LIST
    CREATE_IDO_RSN --> SET_IDO_RSN_OTHER --> SET_IDO_MEMO_OTHER --> CREATE_SINGLE_LIST --> SET_SINGLE_TEMPLATE --> SET_SINGLE_LIST
    SET_ARRAY_ITEM --> SET_TEMPLATE_LIST
    FOR_LOOP -->|loop back| GET_CHILD_MAP
    FOR_LOOP -->|loop end| SET_TEMPLATE_LIST
    SET_TEMPLATE_LIST --> SET_MSKM_DTL_NO
    SET_SINGLE_LIST --> SET_MSKM_DTL_NO --> END_NODE
```

**CRITICAL — Constant Resolution:**

| Constant Name | Resolved Value | Business Meaning |
|---------------|---------------|-----------------|
| `CALL_PTN_NO_4` | `"4"` | Call Pattern No. 4 — Service Contract Update Screen |
| `FUNC_CODE_ONE` (`JPCModelConstant.FUNC_CD_1`) | `"1"` | Function Code 1 — standard registration/execution |
| `IDO_RSN_CD_56` | `"56"` | Cancellation Reason Code 56 — Other (catch-all) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `template` | `CAANMsg` | The SIF message template (`EKK1091D010CBSMsg`) being populated for the cancellation discount-support SC. This is the primary output carrier — the method fills in all header and detail fields here. |
| 2 | `trgt_data` | `HashMap<String, Object>` | Target data container holding the call pattern number (`REQ_PARAM_CALL_PTN_NO`) and, when the pattern is `"4"`, the list of cancellation reason entries (`REQ_PARAM_IDO_RSN_DATA_LIST`). Determines which branch (multi-reason vs. default) is taken. |
| 3 | `inHash` | `HashMap<String, Object>` | Input condition hash carrying the service contract number (`EKK0441A010CBSMsg1List.SVC_KEI_NO`) which identifies the specific service line item being cancelled. |
| 4 | `workField` | `HashMap<String,Object>` | Working area that stores runtime state: modification division (`WRIB_IDO_DIV`), program status (`WRIB_PRG_STAT`), and application detail number (`MSKM_DTL_NO`). These provide contextual metadata about the cancellation operation. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKCancelSvcKeiMapperCC.fillCAANMSGNullMapping` | EKK1091D010SC | - | Initializes the template by null-mapping all fields in `EKK1091D010CBSMsg` to a clean state before populating |
| R | `JKKCancelSvcKeiMapperCC.getContents` | EKK1091D010SC | - | Retrieves the null mapping definition from `EKK1091D010CBSMsg` used as the source for the null mapping template |
| R | `JCCBPCommon.getSysDateTimeStamp` | JCCBPCommon | - | Returns the current system datetime used as the modification timestamp (`IDO_DTM`) for the cancellation |
| - | `CAANMsg.set` | EKK1091D010SC | - | Sets individual message fields on the template (TEMPLATEID, FUNC_CODE, SVC_KEI_NO, IDO_DTM, IDO_DIV, PRG_STAT, MSKM_DTL_NO) |
| - | `CAANMsg.setNull` | EKK1091D010SC | - | Sets fields to null (IDO_RSN_CD, IDO_RSN_MEMO) before assigning values in the child message |
| - | `CAANMsg.getCAANMsgList` | EKK1091D010SC | - | Retrieves existing `EKK1091D010CBSMSG1LIST` array from the template, or returns null if not yet initialized |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Service CC: `JKKCancelSvcKeiCC` | `JKKCancelSvcKeiCC.callEKK1091D010SCwrib` → `JKKCancelSvcKeiMapperCC.mappinEKK1091D010SCInMsgWrib` | `fillCAANMSGNullMapping [-]`, `getSysDateTimeStamp [R]`, `setNull [-]`, `set [-]`, `getName [R]` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Variable initialization (L2552)

> Initialize local variables before processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateArray = null` |
| 2 | SET | `idoRsnDataList = null` |

**Block 2** — [SET] Get call pattern number (L2555)

> Retrieve the call pattern number from target data to determine which processing branch to take. The Japanese comment reads: サービス呼び出し区分 (Service call division).

| # | Type | Code |
|---|------|------|
| 1 | SET | `callPtnNo = (String) trgt_data.get(JKKCancelSvcKeiCC.REQ_PARAM_CALL_PTN_NO)` |

**Block 3** — [CALL] Null mapping initialization (L2558)

> Null-map all fields in the template using the `EKK1091D010CBSMsg` contents definition. The Japanese comment reads: まず全条件のNullマッピング (First, null-map all conditions).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `fillCAANMSGNullMapping(template, new EKK1091D010CBSMsg().getContents())` |

**Block 4** — [SET] Set template ID (L2561)

> Assign the SIF message ID. The Japanese comment reads: テンプレートID (SIFのID) — Template ID (SIF ID).

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1091D010CBSMsg.TEMPLATEID, "EKK1091D010")` |

**Block 5** — [SET] Set function code (L2564)

> Set the function code to `"1"` (standard registration/execution). The Japanese comment reads: 機能コード -- チェック&登録 (Function Code -- Check & Register).

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1091D010CBSMsg.FUNC_CODE, FUNC_CODE_ONE)` | [-> FUNC_CODE_ONE = "1"] |

**Block 6** — [SET] Set service contract number (L2567)

> Set the K-Opticom service contract number from the input hash. The Japanese comment reads: ＫＯＭＯＰサービス契約番号 — K-Opticom Service Contract Number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1091D010CBSMsg.SVC_KEI_NO, inHash.get(EKK0441A010CBSMsg1List.SVC_KEI_NO))` |

**Block 7** — [SET] Set modification datetime (L2570–2571)

> Set the system datetime stamp for the modification timestamp. The Japanese comment reads: ＫＯＭＯＰ異動年月日時刻分秒 — K-Opticom Modification Year Month Date Hour Minute Second.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1091D010CBSMsg.IDO_DTM, JCCBPCommon.getSysDateTimeStamp())` |

**Block 8** — [SET] Set modification division (L2574)

> Set the modification division from the work field. The Japanese comment reads: ＫＯＭＯＰ異動区分 — K-Opticom Modification Division (e.g., cancellation, DSL disconnect).

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1091D010CBSMsg.IDO_DIV, workField.get(JKKCancelSvcKeiCC.WRIB_IDO_DIV))` |

**Block 9** — [SET] Set program status (L2577)

> Set the progress status from the work field. The Japanese comment reads: ＫＯＭＯＰ進捗ステータス — K-Opticom Progress Status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1091D010CBSMsg.PRG_STAT, workField.get(JKKCancelSvcKeiCC.WRIB_PRG_STAT))` |

**Block 10** — [IF/ELSE] Call pattern branch (L2579–2626)

> Branch on whether the call pattern equals `"4"` (Service Contract Update Screen). This determines if cancellation reasons are provided as a list (pattern "4") or as a single default value (other patterns). The Japanese comment reads: サービス呼び出し区分 (Service call division).

**Block 10.1** — [IF] `callPtnNo.equals(CALL_PTN_NO_4)` — Multi-reason path (L2579)

> When called from the Service Contract Update Screen (`callPtnNo = "4"`), iterate over the list of cancellation reason entries and populate each child message. The condition value is: `CALL_PTN_NO_4 = "4"`.

**Block 10.1.1** — [SET] Get reason data list (L2580)

> Retrieve the list of cancellation reason entries from target data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `idoRsnDataList = (ArrayList) trgt_data.get(JKKCancelSvcKeiCC.REQ_PARAM_IDO_RSN_DATA_LIST)` |

**Block 10.1.2** — [SET] Get existing template array (L2582)

> Retrieve the existing `EKK1091D010CBSMSG1LIST` array from the template.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateArray = template.getCAANMsgList(EKK1091D010CBSMsg.EKK1091D010CBSMSG1LIST)` |

**Block 10.1.3** — [IF] `templateArray == null` (L2584)

> If no existing array, allocate a new one sized to the reason data list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateArray = new CAANMsg[idoRsnDataList.size()]` |

**Block 10.1.4** — [FOR] Loop over reason entries (L2589)

> Iterate over each cancellation reason entry in the list and map it to a child `CAANMsg`.

**Block 10.1.4.1** — [SET] Get child entry (L2591)

> Retrieve the i-th HashMap from the reason data list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childMap = (HashMap) idoRsnDataList.get(i)` |

**Block 10.1.4.2** — [SET] Get child template (L2593)

> Retrieve the i-th element from the template array (may be null if not yet created).

| # | Type | Code |
|---|------|------|
| 1 | SET | `childTemplate = templateArray[i]` |

**Block 10.1.4.3** — [IF] `childTemplate == null` (L2595)

> If the child template hasn't been created yet, instantiate it with the `EKK1091D010CBSMsg1List` class.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childTemplate = new CAANMsg(EKK1091D010CBSMsg1List.class.getName())` |

**Block 10.1.4.4** — [SET] Set cancellation reason code (L2600)

> Null the field first, then set from childMap. The Japanese comment reads: 異動理由詳細.異動理由コード — Cancellation Reason Details: Cancellation Reason Code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childTemplate.setNull(EKK1091D010CBSMsg1List.IDO_RSN_CD)` |
| 2 | SET | `childTemplate.set(EKK1091D010CBSMsg1List.IDO_RSN_CD, (String) childMap.get(JKKCancelSvcKeiCC.REQ_PARAM_IDO_RSN_CD))` |

**Block 10.1.4.5** — [SET] Set cancellation reason memo (L2603)

> Set the reason memo to null. The Japanese comment reads: 異動理由詳細.異動理由メモ — Cancellation Reason Details: Cancellation Reason Memo.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childTemplate.setNull(EKK1091D010CBSMsg1List.IDO_RSN_MEMO)` |

**Block 10.1.4.6** — [SET] Store and update template list (L2605–2606)

> Assign child template back to array and update the parent template's list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateArray[i] = childTemplate` |
| 2 | SET | `template.set(EKK1091D010CBSMsg.EKK1091D010CBSMSG1LIST, templateArray)` |

**Block 10.2** — [ELSE] `callPtnNo != "4"` — Default reason path (L2608–2624)

> For all other call patterns, create a single default cancellation reason entry with reason code `"56"` (Other). The Japanese comment reads: 異動理由コード (その他) — Cancellation Reason Code (Other).

**Block 10.2.1** — [SET] Create default reason message (L2610)

> Instantiate a new child message for the default reason entry.

| # | Type | Code |
|---|------|------|
| 1 | SET | `idoRsnTemp = new CAANMsg(EKK1091D010CBSMsg1List.class.getName())` |

**Block 10.2.2** — [SET] Set default reason code (L2611)

> Set the cancellation reason code to `"56"` (Other).

| # | Type | Code |
|---|------|------|
| 1 | SET | `idoRsnTemp.set(EKK1091D010CBSMsg1List.IDO_RSN_CD, IDO_RSN_CD_56)` | [-> IDO_RSN_CD_56 = "56"] |

**Block 10.2.3** — [SET] Set default reason memo (L2613)

> Null the memo field. The Japanese comment reads: 異動理由詳細.異動理由メモ — Cancellation Reason Details: Cancellation Reason Memo.

| # | Type | Code |
|---|------|------|
| 1 | SET | `idoRsnTemp.setNull(EKK1091D010CBSMsg1List.IDO_RSN_MEMO)` |

**Block 10.2.4** — [SET] Build single-element array (L2616–2618)

> Create a single-element array, assign the default reason, and set it on the template.

| # | Type | Code |
|---|------|------|
| 1 | SET | `list = new CAANMsg[1]` |
| 2 | SET | `list[0] = idoRsnTemp` |
| 3 | SET | `template.set(EKK1091D010CBSMsg.EKK1091D010CBSMSG1LIST, list)` |

**Block 11** — [SET] Set application detail number (L2621)

> Set the application detail number from the work field. The Japanese comment reads: 申請明細番号 — Application Detail Number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1091D010CBSMsg.MSKM_DTL_NO, workField.get(JKKCancelSvcKeiCC.MSKM_DTL_NO))` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `SVC_KEI_NO` | Field | Service contract number — the unique identifier for a K-Opticom service line item being cancelled |
| `IDO_RSN_CD` | Field | Cancellation reason code — the code indicating why the service is being cancelled |
| `IDO_RSN_MEMO` | Field | Cancellation reason memo — free-text explanation for the cancellation reason |
| `IDO_DIV` | Field | Modification division — classifies the type of modification (cancellation, DSL disconnect, address change, etc.) |
| `IDO_DTM` | Field | Modification datetime — timestamp of when the service modification occurred |
| `PRG_STAT` | Field | Progress status — indicates the current processing stage of the cancellation operation |
| `MSKM_DTL_NO` | Field | Application detail number — the detail-level identifier for the service application |
| `TEMPLATEID` | Field | SIF message template ID — identifies the message format version (`EKK1091D010`) |
| `FUNC_CODE` | Field | Function code — operational mode indicator (`"1"` = standard registration/execution) |
| `EKK1091D010SC` | Service Component | Service Contract Cancellation Discount-Support — SC for handling cancellation of discounted service contracts |
| `EKK1091D010CBS` | CBS | Cancellation service contract CBS — the underlying CBS module for service contract cancellation |
| `EKK1091D010CBSMSG1LIST` | Message | Nested child message array carrying cancellation reason detail entries |
| `CALL_PTN_NO_4` | Constant | Call Pattern No. `"4"` — indicates invocation from the Service Contract Update Screen (allows multi-reason input) |
| `IDO_RSN_CD_56` | Constant | Default cancellation reason code `"56"` — "Other" (catch-all when no specific reason is provided) |
| `FUNC_CODE_ONE` | Constant | Function Code `"1"` — standard check-and-register operation mode |
| `REQ_PARAM_CALL_PTN_NO` | Constant | Key for call pattern number in target data map |
| `REQ_PARAM_IDO_RSN_DATA_LIST` | Constant | Key for cancellation reason data list in target data map |
| `WRIB_IDO_DIV` | Constant | Key for modification division in work field map |
| `WRIB_PRG_STAT` | Constant | Key for program status in work field map |
| `MSKM_DTL_NO` | Constant | Key for application detail number in work field map |
| SIF | Acronym | System Interface — the messaging protocol between service components |
| CAANMsg | Technical | Canonical message object — Fujitsu's base message type for SIF data exchange |
| SC | Acronym | Service Component — a business logic unit in the service-oriented architecture |
| CBS | Acronym | CBS Service — a CBS (Customer Business System) service component handling database operations |
| K-Opticom | Business term | Japanese broadband/telecommunications provider — the domain entity for which this system operates |
| 割引対応 | Business term | Discount support — this method's specific Javadoc indicates it handles cancellations involving promotional/discount contracts |
