# Business Logic — JKKCancelSvcKeiMapperCC.mappinEKK1091D010SCInMsg() [100 LOC]

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

## 1. Role

### JKKCancelSvcKeiMapperCC.mappinEKK1091D010SCInMsg()

This method is a **data mapper** that populates a CAANMsg template for the EKK1091D010SC service component, which handles **telecom service contract line item cancellation processing** within the K-Opticom (JKK) billing platform. It is the central entry point for constructing the **input message** that will be sent to the service component via the SIF (System Integration Framework) layer.

The method implements the **template builder pattern**: it takes a CAANMsg template, clears it with null mappings, sets standard header fields (template ID, function code), then populates core service data (service contract number, migration timestamp, migration division, progress status). It then branches based on the call pattern number (`call_ptn_no`): if the call pattern equals `"4"` (the Service Contract Update screen path), it iterates over a list of migration reason entries and maps each one as a child message; otherwise (default/fallback path), it sets a single cancellation reason code of `"56"` (Other), meaning "miscellaneous or default cancellation."

Its **role in the larger system** is as a shared mapper used by the `JKKCancelSvcKeiCC` cancellation service controller, and also indirectly by the service-use-fail add/change components (`JKKSVUseFailAddCC`, `JKKSVUseFailChgCC`). It is a **data transformer** — it does not execute business logic itself, but prepares the structured input message for downstream service component execution.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["mappinEKK1091D010SCInMsg"])
    EXTRACT_CALL_PTN["Extract callPtnNo from trgt_data"]
    NULL_MAPPING["fillCAANMSGNullMapping template with empty contents"]
    SET_TEMPLATE_ID["Set TEMPLATEID to EKK1091D010"]
    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 JCCBPCommon.getSysDateTimeStamp"]
    SET_IDO_DIV["Set IDO_DIV from trgt_data"]
    SET_PRG_STAT["Set PRG_STAT from trgt_data"]
    CHECK_CALL_PTN["callPtnNo equals 4?"]
    CALL_PTN_4_BRANCH["Branch: CALL_PTN_NO_4 = 4<br>(Service Contract Update)"]
    GET_IDO_RSN_LIST["Get idoRsnDataList from trgt_data"]
    GET_TEMPLATE_ARRAY["Get templateArray from template"]
    CHECK_NULL_ARRAY["templateArray is null?"]
    INIT_ARRAY["Initialize templateArray from list size"]
    FOR_LOOP["For each entry in idoRsnDataList"]
    GET_CHILD_MAP["Get childMap from list entry"]
    CHECK_CHILD_TEMPLATE["childTemplate is null?"]
    NEW_CHILD_TEMPLATE["Create new CAANMsg childTemplate"]
    SET_RSN_CD_NULL["Set IDO_RSN_CD to null"]
    SET_RSN_CD["Set IDO_RSN_CD from childMap"]
    SET_RSN_MEMO_NULL["Set IDO_RSN_MEMO to null"]
    STORE_CHILD["Store childTemplate in templateArray"]
    SET_LIST_IN_TPL["Set EKK1091D010CBSMSG1LIST in template"]

    CALL_PTN_OTHER_BRANCH["Branch: Other (Default Reason)"]
    CREATE_RSN_TEMP["Create new CAANMsg idoRsnTemp"]
    SET_DEFAULT_CD["Set IDO_RSN_CD to 56 (Other)"]
    SET_MEMO_EMPTY["Set IDO_RSN_MEMO to null"]
    CREATE_ARRAY["Create CAANMsg array of size 1"]
    SET_ARRAY_ITEM["Set array[0] = idoRsnTemp"]
    SET_ARRAY_IN_TPL["Set EKK1091D010CBSMSG1LIST in template"]

    SET_END_MAKUM["Set MSKM_DTL_NO from workField<br>Return"]

    START --> EXTRACT_CALL_PTN
    EXTRACT_CALL_PTN --> NULL_MAPPING
    NULL_MAPPING --> SET_TEMPLATE_ID
    SET_TEMPLATE_ID --> SET_FUNC_CODE
    SET_FUNC_CODE --> SET_SVC_KEI_NO
    SET_SVC_KEI_NO --> SET_IDO_DTM
    SET_IDO_DTM --> SET_IDO_DIV
    SET_IDO_DIV --> SET_PRG_STAT
    SET_PRG_STAT --> CHECK_CALL_PTN
    CHECK_CALL_PTN -->|Yes| CALL_PTN_4_BRANCH
    CHECK_CALL_PTN -->|No| CALL_PTN_OTHER_BRANCH
    CALL_PTN_4_BRANCH --> GET_IDO_RSN_LIST
    GET_IDO_RSN_LIST --> GET_TEMPLATE_ARRAY
    GET_TEMPLATE_ARRAY --> CHECK_NULL_ARRAY
    CHECK_NULL_ARRAY -->|null| INIT_ARRAY
    INIT_ARRAY --> FOR_LOOP
    CHECK_NULL_ARRAY -->|not null| FOR_LOOP
    FOR_LOOP --> GET_CHILD_MAP
    GET_CHILD_MAP --> CHECK_CHILD_TEMPLATE
    CHECK_CHILD_TEMPLATE -->|null| NEW_CHILD_TEMPLATE
    NEW_CHILD_TEMPLATE --> SET_RSN_CD_NULL
    CHECK_CHILD_TEMPLATE -->|not null| SET_RSN_CD_NULL
    SET_RSN_CD_NULL --> SET_RSN_CD
    SET_RSN_CD --> SET_RSN_MEMO_NULL
    SET_RSN_MEMO_NULL --> STORE_CHILD
    STORE_CHILD --> SET_LIST_IN_TPL
    SET_LIST_IN_TPL --> FOR_LOOP
    CALL_PTN_OTHER_BRANCH --> CREATE_RSN_TEMP
    CREATE_RSN_TEMP --> SET_DEFAULT_CD
    SET_DEFAULT_CD --> SET_MEMO_EMPTY
    SET_MEMO_EMPTY --> CREATE_ARRAY
    CREATE_ARRAY --> SET_ARRAY_ITEM
    SET_ARRAY_ITEM --> SET_ARRAY_IN_TPL
    SET_ARRAY_IN_TPL --> SET_END_MAKUM
    FOR_LOOP --> SET_END_MAKUM
```

**CRITICAL — Constant Resolution:**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `CALL_PTN_NO_4` | `"4"` | Call Pattern Number 4 — Service Contract Update Screen path |
| `FUNC_CODE_ONE` | `"1"` (from `JPCModelConstant.FUNC_CD_1`) | Function Code 1 — standard add/registration function |
| `IDO_RSN_CD_56` | `"56"` | Migration Reason Code 56 — Other (miscellaneous/default cancellation reason) |
| `REQ_PARAM_CALL_PTN_NO` | `"call_ptn_no"` | Key in trgt_data for the call pattern number |
| `REQ_PARAM_IDO_DIV` | `"ido_div"` | Key in trgt_data for migration/division type |
| `REQ_PARAM_PRG_STAT` | `"prg_stat"` | Key in trgt_data for program progress status |
| `MSKM_DTL_NO` | `"mskm_dtl_no"` | Key in workField for application detail number |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `template` | `CAANMsg` | The SIF input message template to be populated. This is a hierarchical message object representing the request to be sent to the EKK1091D010SC service component. It acts as the **output carrier** — all mapped data is written into this template. |
| 2 | `trgt_data` | `HashMap<String, Object>` | Target data map carrying **call context parameters** from the upstream caller (JKKCancelSvcKeiCC). Contains the call pattern number (`call_ptn_no`), migration division (`ido_div`), program progress status (`prg_stat`), and optionally the list of migration reason entries (`ido_rsn_data_list`). Controls which branch the mapper takes. |
| 3 | `inHash` | `HashMap<String, Object>` | Condition hash carrying **service contract input data**. Specifically contains the service contract number (`SVC_KEI_NO` = `svc_kei_no`) which identifies which service contract line item is being cancelled. This is the primary business entity being operated on. |
| 4 | `workField` | `HashMap<String,Object>` | Work area map carrying **cross-method state data**. Contains the application detail number (`mskm_dtl_no`) used to link this cancellation request to the original application/detail record. This field is carried across multiple service methods within a single transaction. |

**External state read:**

| Source | Description |
|--------|-------------|
| `JCCBPCommon.getSysDateTimeStamp()` | System date/time utility — provides the migration timestamp for the cancellation record |
| `fillCAANMSGNullMapping` (self) | Null-mapping helper — clears all fields in the template with the empty contents structure |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKCancelSvcKeiMapperCC.fillCAANMSGNullMapping` | - | - | Calls `fillCAANMSGNullMapping` in `JKKCancelSvcKeiMapperCC` to clear all fields in template with null values from empty EKK1091D010CBSMsg |
| R | `JCCBPCommon.getSysDateTimeStamp` | JCCBPCommon | - | Calls `getSysDateTimeStamp` to obtain the current system date-time stamp for the migration timestamp field |
| - | `JKKCancelSvcKeiMapperCC.getContents` | JKKCancelSvcKeiMapperCC | - | Calls `getContents` on an empty `EKK1091D010CBSMsg` instance to retrieve its default/null field structure for null-mapping |

**Notes:** This method is a pure data mapper — it does **not** perform any database CRUD operations itself. It constructs a CAANMsg template that will be sent to the EKK1091D010SC service component via `callScCmn` in the caller. The actual database operations are performed by the downstream service component.

## 5. Dependency Trace

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Service Component: JKKCancelSvcKeiCC | `callEKK1091D010SC` -> `cancelSvcKeiMapper.mappinEKK1091D010SCInMsg(template, trgt_data, inHash, workField)` | `callScCmn [R/SIF] EKK1091D010SC` |
| 2 | Service Component: JKKCancelSvcKeiCC | `callEKK1091D010SCwrib` -> `cancelSvcKeiMapper.mappinEKK1091D010SCInMsgWrib(template, trgt_data, inHash, workField)` | (variant — sets discount support flag) |
| 3 | Service Component: JKKSVUseFailAddCC | `mappinUseFailAddInfo` -> `useFailMapper.mappinEKK1091D010SCInMsg(template, inMap)` | `setNull [-]`, `getName [R]` |
| 4 | Service Component: JKKSVUseFailChgCC | `mappinUseFailChgInfo` -> `useFailMapper.mappinEKK1091D010SCInMsg(template, inMap)` | `setNull [-]`, `getName [R]` |

**Caller details:**

- **#1, #2**: `JKKCancelSvcKeiCC` is the **primary cancellation service controller**. It invokes this mapper to prepare the EKK1091D010SC input message before calling `callScCmn(param, handle, template)` to execute the service component via SIF. `callEKK1091D010SC` is the standard path; `callEKK1091D010SCwrib` is the variant for discount support scenarios.
- **#3, #4**: `JKKSVUseFailAddCC` and `JKKSVUseFailChgCC` are **service-use-fail handling components** for add and change scenarios. They use a different mapper instance (`useFailMapper` which is `JKKUseFailMapperCC`) that has its own overloaded version of this method with a simplified signature.

## 6. Per-Branch Detail Blocks

**Block 1** — [PROCESS] Extract and initialize (L2445)

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

**Block 2** — [EXEC] Null-mapping the template (L2449)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `fillCAANMSGNullMapping(template, new EKK1091D010CBSMsg().getContents())` // Clear all fields with null mappings (Japanese: まず全条件のNullマッピング = First, null-mapping all conditions) |

**Block 3** — [PROCESS] Set template header fields (L2452–2471)

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(TEMPLATEID, "EKK1091D010")` // Set template ID (Japanese: テンプレートID = Template ID) |
| 2 | SET | `template.set(FUNC_CODE, FUNC_CODE_ONE)` // Set function code = "1" (Japanese: 機能コード = Function Code) [-> FUNC_CODE_ONE = "1"] |
| 3 | SET | `template.set(SVC_KEI_NO, inHash.get("svc_kei_no"))` // Set service contract number from input hash (Japanese: +ORAN Service Contract Number) |
| 4 | SET | `template.set(IDO_DTM, JCCBPCommon.getSysDateTimeStamp())` // Set migration date/time via system timestamp (Japanese: +ORAN Migration Date/Time) |
| 5 | SET | `template.set(IDO_DIV, trgt_data.get("ido_div"))` // Set migration division type (Japanese: +ORAN Migration Division) |
| 6 | SET | `template.set(PRG_STAT, trgt_data.get("prg_stat"))` // Set program progress status (Japanese: +ORAN Progress Status) |

**Block 4** — [IF] Branch on call pattern number (L2472)

`callPtnNo.equals(CALL_PTN_NO_4)` where `CALL_PTN_NO_4 = "4"` (Service Contract Update Screen path) (Japanese: サービス呼び出し区分 = Service call pattern)

**Block 4.1** — [IF-TRUE] Call pattern equals "4" — List-based migration reason entries (L2473–2503)

> When the call pattern is "4", the method processes a list of migration reason entries provided in `trgt_data`. Each entry becomes a child message in the template array. (Japanese: サービス呼び出し区分 = Service call pattern)

| # | Type | Code |
|---|------|------|
| 1 | SET | `idoRsnDataList = (ArrayList) trgt_data.get(JKKCancelSvcKeiCC.REQ_PARAM_IDO_RSN_DATA_LIST)` // Extract migration reason data list (Japanese: 異動理由データリスト = Migration reason data list) |
| 2 | SET | `templateArray = template.getCAANMsgList(EKK1091D010CBSMsg.EKK1091D010CBSMSG1LIST)` // Get existing template child array |
| 3 | IF | `templateArray == null` |
| 3.1 | SET | `templateArray = new CAANMsg[idoRsnDataList.size()]` // Initialize array to match list size |
| 4 | FOR | `for (int i = 0; i < idoRsnDataList.size(); i++)` // Iterate over all migration reason entries (Japanese: 異動理由明細 = Migration reason details) |
| 4.1 | SET | `childMap = (HashMap) idoRsnDataList.get(i)` // Get child map for current iteration |
| 4.2 | SET | `childTemplate = templateArray[i]` // Get or null child template |
| 4.3 | IF | `childTemplate == null` |
| 4.3.1 | SET | `childTemplate = new CAANMsg(EKK1091D010CBSMsg1List.class.getName())` // Create new child message |
| 4.4 | EXEC | `childTemplate.setNull(IDO_RSN_CD)` // Clear migration reason code field (Japanese: 異動理由明細.異動理由コード) |
| 4.5 | SET | `childTemplate.set(IDO_RSN_CD, (String) childMap.get(JKKCancelSvcKeiCC.REQ_PARAM_IDO_RSN_CD))` // Set migration reason code from child map (Japanese: 異動理由明細.異動理由コード) |
| 4.6 | EXEC | `childTemplate.setNull(IDO_RSN_MEMO)` // Clear migration reason memo field (Japanese: 異動理由明細.異動理由メモ) |
| 4.7 | SET | `templateArray[i] = childTemplate` // Store child template back in array |
| 4.8 | SET | `template.set(EKK1091D010CBSMsg.EKK1091D010CBSMSG1LIST, templateArray)` // Set the full list back into parent template |
| 5 | SET | `template.set(EKK1091D010CBSMsg.EKK1091D010CBSMSG1LIST, templateArray)` // Set final list in template after loop |

**Block 4.2** — [IF-FALSE] Call pattern is NOT "4" — Default/fallback single reason entry (L2505–2523)

> When the call pattern is anything other than "4", the method creates a single default cancellation reason entry with reason code "56" (Other). This is the fallback path for standard cancellations not routed through the list-based update screen. (Japanese: その他 = Other)

| # | Type | Code |
|---|------|------|
| 1 | SET | `idoRsnTemp = new CAANMsg(EKK1091D010CBSMsg1List.class.getName())` // Create new migration reason child message |
| 2 | SET | `idoRsnTemp.set(IDO_RSN_CD, IDO_RSN_CD_56)` // Set reason code = "56" (Japanese: 異動理由コード(その他) = Migration reason code (other)) [-> IDO_RSN_CD_56 = "56"] |
| 3 | EXEC | `idoRsnTemp.setNull(IDO_RSN_MEMO)` // Clear reason memo field (Japanese: 異動理由明細.異動理由メモ) |
| 4 | SET | `list = new CAANMsg[1]` // Create single-element array |
| 5 | SET | `list[0] = idoRsnTemp` // Set the single entry |
| 6 | SET | `template.set(EKK1091D010CBSMsg.EKK1091D010CBSMSG1LIST, list)` // Set the list in template |

**Block 5** — [PROCESS] Set application detail number (L2526)

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(MSKM_DTL_NO, workField.get("mskm_dtl_no"))` // Set application detail number (Japanese: 申請明細番号 = Application detail number) |
| 2 | RETURN | `void` — method ends |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service contract number — the unique identifier for a telecom service contract line item (e.g., fiber, broadband, phone) |
| `ido_dtm` | Field | Migration date/time — the system timestamp recorded at the time of the service cancellation/migration operation (Japanese: 異動年月日時分秒) |
| `ido_div` | Field | Migration/division type — classifies the type of service change (e.g., addition, change, cancellation) (Japanese: 異動区分) |
| `prg_stat` | Field | Program progress status — the current stage of the cancellation workflow processing (Japanese: プログレスステータス) |
| `call_ptn_no` | Field | Call pattern number — determines which processing branch to follow in the mapper; "4" indicates the Service Contract Update screen path (Japanese: 呼び出しパターン番号) |
| `ido_rsn_cd` | Field | Migration reason code — the reason code for why a service is being cancelled/migrated (e.g., "56" for Other, "E8" for miscellaneous cancellation ticket) |
| `ido_rsn_memo` | Field | Migration reason memo — free-text memo field for the cancellation reason |
| `ido_rsn_data_list` | Field | Migration reason data list — a list of HashMap entries, each containing a reason code and memo, used when multiple cancellation reasons need to be recorded |
| `mskm_dtl_no` | Field | Application detail number — links this cancellation request to the original application/detail record for traceability (Japanese: 申請明細番号) |
| `template` | Field | CAANMsg template — the hierarchical SIF input message structure being built for the service component call |
| `templateArray` | Field | Array of CAANMsg child messages — the EKK1091D010CBSMSG1LIST child list within the template |
| `idoRsnDataList` | Field | List of HashMap entries containing migration reason data — source of per-entry cancellation reasons |
| EKK1091D010SC | SC Code | Service Component EKK1091D010 — handles service contract line item cancellation via SIF |
| EKK1091D010CBSMsg | Class | CBS message class defining the EKK1091D010SC input message structure (field names, types) |
| EKK1091D010CBSMsg1List | Class | CBS message child list class — defines the structure of each entry in the migration reason details list |
| CAANMsg | Class | Common Abstract Application Network message — Fujitsu's generic message wrapper for SIF service component calls |
| FUNC_CD_1 | Constant | Function code "1" — indicates standard add/registration operation in the CBS layer |
| IDO_RSN_CD_56 | Constant | Migration reason code "56" — "Other" (miscellaneous/default cancellation reason) |
| CALL_PTN_NO_4 | Constant | Call pattern number "4" — identifies the Service Contract Update screen processing path |
| SIF | Acronym | System Integration Framework — the middleware layer for service component invocation |
| SC | Acronym | Service Component — a business logic module invoked via SIF |
| CBS | Acronym | Component Business System — the service component message layer (CBSMsg) |
| CC | Acronym | Common Component — reusable Java classes shared across service controllers |
| K-Opticom | Business term | Fujitsu's integrated telecom service platform for broadband, phone, and IPTV services (JKK = Japan K-Opticom) |
| 異動 (Ido) | Japanese term | Migration/Change — refers to any change in service status (add, change, cancel, transfer) |
| 申請明細 (Shinsei Meisai) | Japanese term | Application detail — the detailed record of a service application/request |
| JCCBPCommon | Class | Common business utility providing system date/time and shared constants |
