# Business Logic — JKKUseFailMapperCC.mappingEKK0401A010SCInMsg() [47 LOC]

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

## 1. Role

### JKKUseFailMapperCC.mappingEKK0401A010SCInMsg()

This method prepares the inbound message (`CAANMsg`) for the **EKK0401A010SC** service component, which is invoked when performing **service contract cancellation** operations in the K-Opticom customer base system. The EKK0401A010SC service handles cancelling a customer's service contract, and this mapper method populates the message template with all the condition fields required by the service component before it is called.

The method follows a **data mapping / template-filling pattern**. It starts by null-mapping the template against a blank `EKK0401A010CBSMsg` to ensure all fields are initialized to safe defaults, then systematically sets each field from the input hash. It also implements a **conditional dispatch** based on the `FUNC_CODE`: when the function code equals `"1"` (the cancellation operation code defined by `FUNC_CODE_ONE`), the method sets the registration date/time (`KEY_GENE_ADD_DTM`); for all other function codes, it sets the reservation application date (`KEY_RSV_APLY_YMD`) instead.

This is a **shared utility mapper** called by multiple cancellation-related CBS classes (e.g., `JKKCancelSvcKeiCC`, `JKKCancelSvcKeiMapperCC`), `JKKHakkoSODCC`, `JKKAdchgHakkoSODCC`, and `JKKAdchgCancelHakkoSODCC`. Its role in the larger system is to bridge the screen-layer or CBS-layer input hash with the SIF-level message structure consumed by the EKK0401A010SC service component.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["mappingEKK0401A010SCInMsg"])
    START --> CALL1["fillCAANMSGNullMapping: Null-map template"]
    CALL1 --> SET1["set TEMPLATEID: EKK0401A010"]
    SET1 --> GET1["get FUNC_CODE from inHash"]
    GET1 --> COND_FUNC{"funcCode == null?"}
    COND_FUNC -->|true| SET_DEFAULT["set funcCode = FUNC_CODE_ONE"]
    COND_FUNC -->|false| SET_FUNC["set FUNC_CODE on template"]
    SET_DEFAULT --> SET_FUNC
    SET_FUNC --> SET_OP["set KEY_OP_SVC_KEI_NO from inHash"]
    SET_OP --> SET_SBOP["set KEY_SBOP_SVC_KEI_NO from inHash"]
    SET_SBOP --> COND_FUNC_CODE{"FUNC_CODE_ONE.equals(funcCode)?"}
    COND_FUNC_CODE -->|true funcCode equals 1| SET_ADD["set KEY_GENE_ADD_DTM from inHash"]
    COND_FUNC_CODE -->|false| SET_RSV["set KEY_RSV_APLY_YMD from inHash"]
    SET_ADD --> END_RETURN(["Return void"])
    SET_RSV --> END_RETURN
```

### Constant Resolution

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `FUNC_CODE_ONE` | `"1"` (via `JPCModelConstant.FUNC_CD_1`) | Function code representing the primary cancellation operation |
| `EKK0401A010CBSMsg.TEMPLATEID` | `"EKK0401A010"` | SIF template identifier for the service contract cancellation SC |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `template` | `CAANMsg` | The SIF message template (output) being constructed. It is an instance of `EKK0401A010CBSMsg.class` created by the caller before invocation. This object carries all fields required by the EKK0401A010SC service component for the cancellation operation. |
| 2 | `inHash` | `HashMap<String, Object>` | Input hash map carrying condition data extracted from the screen request. Contains keys such as `FUNC_CODE` (function code), `OP_SVC_KEI_NO` (option service contract number), `SBOP_SVC_KEI_NO` (sub-option service contract number), and either `GENE_ADD_DTM` (registration date/time) or `KEY_RSV_APLY_YMD` (reservation application date) depending on the function code. |

**External state / instance fields used:**
- `FUNC_CODE_ONE` — private static final String constant (value: `"1"` via `JPCModelConstant.FUNC_CD_1`). Represents the default/primary function code for cancellation operations.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| EXEC | `JKKUseFailMapperCC.fillCAANMSGNullMapping` | - | - | Calls `fillCAANMSGNullMapping` to null-map all fields of the template against a blank `EKK0401A010CBSMsg` instance, ensuring safe defaults. |
| R | `JKKUseFailMapperCC.getContents` | - | - | Called internally by `fillCAANMSGNullMapping` — retrieves the default/empty contents of an `EKK0401A010CBSMsg` instance for null-mapping. |

**Note:** This method does not directly call any service components (SC/CBS) that perform database CRUD operations. It is purely a message-mapping (builder) method. The actual SC invocation (`EKK0401A010SC`) happens in the caller (e.g., `JKKCancelSvcKeiCC.callEKK0401A010SC`), which calls this mapper first, then invokes `callScCmn` to execute the SIF.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKCancelSvcKeiCC.callEKK0401A010SC` | `callEKK0401A010SC` -> `cancelSvcKeiMapper.mappingEKK0401A010SCInMsg` | `EKK0401A010SC [R] Service contract cancellation query` |
| 2 | CBS: `JKKCancelSvcKeiMapperCC` | `cancelSvcKeiMapper` (same class instance) | `EKK0401A010SC [R] Service contract cancellation query` |
| 3 | CBS: `JKKHakkoSODCC.callEKK0401A010SC` | `callEKK0401A010SC` -> `mappingEKK0401A010SCInMsg(template, inHash, funcCode)` | `EKK0401A010SC [R] Service contract cancellation query` |
| 4 | CBS: `JKKAdchgHakkoSODCC.callEKK0401A010SC` | `callEKK0401A010SC` -> `mappingEKK0401A010SCInMsg(template, inHash, funcCode)` | `EKK0401A010SC [R] Service contract cancellation query` |
| 5 | CBS: `JKKAdchgCancelHakkoSODCC.callEKK0401A010SC` | `callEKK0401A010SC` -> `mappingEKK0401A010SCInMsg(template, inHash, funcCode)` | `EKK0401A010SC [R] Service contract cancellation query` |

**Notes:**
- Rows 1 and 2 represent the cancellation workflow where `JKKCancelSvcKeiCC` uses `cancelSvcKeiMapper` (an instance of `JKKCancelSvcKeiMapperCC`) to map the message before calling the SIF.
- Rows 3, 4, and 5 represent service order data (SOD) issuance workflows (regular issuance, add/change issuance, add/change cancellation issuance) that also need to pass condition data to EKK0401A010SC. These classes use an overloaded version of the method with an extra `funcCode` parameter (`mappingEKK0401A010SCInMsg(CAANMsg, HashMap, String)`), which is a different overload defined in each respective class.
- The `JKKSVUseFailAddCC` and `JKKSVUseFailChgCC` classes contain commented-out references to this method (previously used in screen-level add/change cancellation flows).

## 6. Per-Branch Detail Blocks

**Block 1** — EXEC (null-mapping) (L310)

> First, perform null-mapping on all fields of the template by calling `fillCAANMSGNullMapping`. This initializes every field to a safe null/default value based on the blank `EKK0401A010CBSMsg` message contents.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `fillCAANMSGNullMapping(template, new EKK0401A010CBSMsg().getContents())` // Null-map all template fields against blank message contents [-> "Initialize template with safe defaults"] |

---

**Block 2** — SET (template ID assignment) (L313)

> Set the SIF template ID field on the template to identify this as an EKK0401A010SC message.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0401A010CBSMsg.TEMPLATEID, "EKK0401A010")` // Set SIF template ID [-> "EKK0401A010"] |

---

**Block 3** — IF (function code retrieval with null default) (L320)

> Retrieve the function code from the input hash. If the caller did not provide a function code, default to `FUNC_CODE_ONE` ("1", the primary cancellation operation code). This is a null-coalescing fallback to ensure the template always has a valid function code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `funcCode = (String)inHash.get(EKK0401A010CBSMsg.FUNC_CODE)` // Extract function code from inHash |
| 2 | IF | `funcCode == null` [DEFAULT: FUNC_CODE_ONE = "1"] |
| 2.1 | SET | `funcCode = FUNC_CODE_ONE` [-> FUNC_CODE_ONE = "1"] // Apply default function code |
| 3 | SET | `template.set(EKK0401A010CBSMsg.FUNC_CODE, funcCode)` // Set function code on template |

---

**Block 4** — SET (option service contract number) (L327)

> Set the K-Opticom option service contract number from the input hash. This identifies the main option service contract associated with the cancellation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0401A010CBSMsg.KEY_OP_SVC_KEI_NO, inHash.get(EKK0401B001CBSMsg1List.OP_SVC_KEI_NO))` // Set K-Opticom option service contract number [from inHash key OP_SVC_KEI_NO] |

---

**Block 5** — SET (sub-option service contract number) (L330)

> Set the K-Opticom sub-option service contract number from the input hash. This identifies a sub-option service contract linked to the cancellation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0401A010CBSMsg.KEY_SBOP_SVC_KEI_NO, inHash.get(EKK0401B001CBSMsg1List.SBOP_SVC_KEI_NO))` // Set K-Opticom sub-option service contract number [from inHash key SBOP_SVC_KEI_NO] |

---

**Block 6** — IF/ELSE (conditional date field based on function code) (L332)

> Branch on the function code. When the function code equals `"1"` (primary cancellation operation, `FUNC_CODE_ONE`), set the **registration date/time** (`KEY_GENE_ADD_DTM`). For any other function code, set the **reservation application date** (`KEY_RSV_APLY_YMD`) instead. This allows the same message template to carry either field depending on the context of the cancellation operation.

| # | Type | Code |
|---|------|------|
| 1 | IF | `FUNC_CODE_ONE.equals(funcCode)` [FUNC_CODE_ONE = "1"] (L332) |
| 1.1 | SET | `template.set(EKK0401A010CBSMsg.KEY_GENE_ADD_DTM, inHash.get(EKK0401B001CBSMsg1List.GENE_ADD_DTM))` // Set K-Opticom registration date/time [from inHash key GENE_ADD_DTM] |
| 1.2 | ELSE | funcCode is not "1" |
| 1.3 | SET | `template.set(EKK0401A010CBSMsg.KEY_RSV_APLY_YMD, inHash.get(EKK0401A010CBSMsg.KEY_RSV_APLY_YMD))` // Set K-Opticom reservation application date [from inHash key KEY_RSV_APLY_YMD] |

---

**Block 7** — RETURN (L344)

> Method returns void. The template is now fully populated and ready for the caller to pass to the SIF invocation.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | (void) // template is fully mapped and returned by side-effect |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `funcCode` | Field | Function code — identifies the type of operation being performed (e.g., cancellation = "1") |
| `OP_SVC_KEI_NO` | Field | Option service contract number — the primary K-Opticom option service contract line item number associated with this cancellation |
| `SBOP_SVC_KEI_NO` | Field | Sub-option service contract number — the sub-option service contract line item number, used when a contract has nested sub-options |
| `GENE_ADD_DTM` | Field | Generation registration date/time — the timestamp when the service contract line item was originally registered, used when function code is "1" (primary cancellation) |
| `KEY_RSV_APLY_YMD` | Field | Reservation application date — the date on which a reservation or application is made, used for non-primary cancellation operations |
| `TEMPLATEID` | Field | SIF template ID — the identifier string ("EKK0401A010") that tells the SIF framework which message template class to use |
| `FUNC_CODE` | Field | Function code — an operation discriminator passed between layers to indicate what specific action the service component should perform |
| EKK0401A010SC | Service Component | Service Contract Cancellation SC — the backend service component that processes service contract cancellation requests in the K-Opticom system |
| EKK0401A010CBSMsg | Entity / Message | CBS message class for EKK0401A010SC — defines the field structure of the inbound message for the cancellation service component |
| CAANMsg | Data Structure | Custom message container — a flexible key-value message object used throughout the SIF (Service InterFramework) layer to carry request and response data |
| FUNC_CODE_ONE | Constant | Primary function code constant (value: "1") — represents the main/primary cancellation operation code across the system |
| JPCModelConstant | Constant Class | System-wide constant definitions — shared constants used across all model layers, including `FUNC_CD_1 = "1"` |
| SIF | Acronym | Service InterFramework — the framework layer that handles invocation and result mapping between CBS components and the SIF service components |
| K-Opticom | Business term | Fujitsu's telecommunications service provider brand in Japan — the domain context for service contract, option service, and reservation operations |
| inHash | Parameter | Input hash — a HashMap carrying all condition parameters extracted from the screen request or calling CBS layer |
| template | Parameter | Output message template — the CAANMsg being constructed by this mapper, which the caller will then pass to the SIF invocation |
