# Business Logic — JKKKyoseiDslRunMapperCC.mappingEKK0401C180InMsg() [60 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKKyoseiDslRunMapperCC` |
| Layer | CC / Common Component (custom service-level data mapping layer) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKKyoseiDslRunMapperCC.mappingEKK0401C180InMsg()

This method configures an inbound message template (`CAANMsg`) for service contract cancellation processing, specifically for the mandatory cancellation screen flow identified by SC code `EKK0401C180`. It acts as a data assembler / mapper that extracts relevant business parameters from prior result hashes, input hashes, and judgment maps, then populates the template with field values that the downstream service component (`EKK0401C180CBS`) will persist. The method implements a **builder pattern** — it prepares the message structure in a sequential, deterministic fashion before the CBS layer consumes it.

The method handles two distinct business scenarios around service charge end dates: when the non-taxable/judgment map for service details (`jdgHiChrgMapSvcKei`) is null (falling back to the raw input hash value) versus when it contains computed charge end date information. It also resolves the termination billing flag from the sub-option judgment map, defaulting to `"0"` if the map is absent. This method is a **shared mapper** called by `JKKKyoseiDslRunCC.callEKK0401C180SC()`, serving the mandatory cancellation operation within a larger DSL (Domain-Specific Language) execution framework.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["mappingEKK0401C180InMsg"])

    START --> NullMap["fillCAANMSGNullMapping"]
    NullMap --> SetTemplateID["Set TEMPLATE_ID"]
    SetTemplateID --> SetFuncCode["Set FUNC_CODE to '1'"]
    SetFuncCode --> GetPrevResult["Get EKK0401A010 result from resultHash"]
    GetPrevResult --> SetSvcKeiNo["Set OP_SVC_KEI_NO"]
    SetSvcKeiNo --> SetSbopSvcKeiNo["Set SBOP_SVC_KEI_NO"]
    SetSbopSvcKeiNo --> SetSvcEndYmd["Set SVC_ENDYMD from REQYMD"]
    SetSvcEndYmd --> CheckJdgHiChrg["jdgHiChrgMapSvcKei == null?"]

    CheckJdgHiChrg -- "Yes (null)" --> SetChrgEndFromInHash["Set SVC_CHRG_ENDYMD from inHash"]
    CheckJdgHiChrg -- "No (not null)" --> SetChrgEndFromMap["Set SVC_CHRG_ENDYMD from jdgHiChrgMapSvcKei"]

    SetChrgEndFromInHash --> SetSvcDlre["Set SVC_DLRE_CD to '02' (Mandatory Cancellation)"]
    SetChrgEndFromMap --> SetSvcDlre
    SetSvcDlre --> SetUpdtDtm["Set UPD_DTM_BF from svcKeiUpdDtm"]
    SetUpdtDtm --> GetChrgFlg["Get chrgFlg from jdgHiChrgMapSbopSvcKei (default '0')"]
    GetChrgFlg --> SetDsljiChrg["Set DSLJI_CHRG_FLG"]
    SetDsljiChrg --> END(["Return void"])
```

**CRITICAL — Constant Resolution:**

| Constant Reference | Resolved Value | Business Meaning |
|--------------------|---------------|------------------|
| `TEMPLATE_ID_EKK0401C180` | `"EKK0401C180"` | Template identifier for mandatory cancellation inbound message |
| `TEMPLATE_ID_EKK0401A010` | `"EKK0401A010"` | Prior result hash key for service contract agreement data (sub-option) |
| `REQYMD` | `"REQYMD"` | Request year-month-day — the requested service end date |
| `SVC_CHRG_ENDYMD` | `"SVC_CHRG_ENDYMD"` | Service charge end date |
| `SVC_DLRE_CD_KYOSEI` | `"02"` | Mandatory cancellation reason code |
| `jdgHiChrgMapSvcKei` | null or populated | Non-taxable judgment result map for service details — indicates if service-level charge exemption has been evaluated |
| `jdgHiChrgMapSbopSvcKei` | null or populated | Non-taxable judgment result map for sub-option — contains termination billing flag |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `template` | `CAANMsg` | The outbound message template being constructed. It is pre-populated with null-safe defaults, then filled with concrete field values for the mandatory cancellation request. This object is passed downstream to the CBS layer for database operations. |
| 2 | `inHash` | `HashMap<String, Object>` | Input parameter map containing request-level data from the caller, including the requested service end date (`REQYMD`) and the service charge end date (`SVC_CHRG_ENDYMD`). Used as a fallback when the judgment map is null. |
| 3 | `resultHash` | `HashMap<String, Object>` | Application-specific parameter map that holds results from prior service component calls. It is queried for the `EKK0401A010` key to retrieve the sub-option service agreement number and service contract number produced by a preceding step. |
| 4 | `jdgHiChrgMapSvcKei` | `HashMap<String, Object>` | Judgment map from the non-taxable/judgment component for service-level charge items. If not null, contains `svcChrgEndYmd` — the computed service charge end date. If null, the method falls back to reading from `inHash`. |
| 5 | `jdgHiChrgMapSbopSvcKei` | `HashMap<String, Object>` | Judgment map from the non-taxable/judgment component for sub-option charge items. If not null, contains `chrgFlg` — the termination billing flag (a string, typically `"0"` or `"1"`). Default value is `"0"` if the map is null. |
| 6 | `svcKeiUpdDtm` | `String` | The service detail update date/time stamp **before** the current update. This is used for optimistic concurrency control, allowing the CBS layer to detect stale data conflicts. |

**External/Instance Fields:**
- None directly accessed. All constants are resolved via fully-qualified references (e.g., `JKKKyoseiDslRunCC.TEMPLATE_ID_EKK0401C180`).

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JKKKyoseiDslRunMapperCC.fillCAANMSGNullMapping` | - | - | Fills null-safe default mappings on the template using the `EKK0401C180CBSMsg` contents structure |
| R | `EKK0401A010CBSMsg1List.get(OP_SVC_KEI_NO)` | EKK0401A010 | - | Reads the operation service contract number from the prior result hash |
| R | `EKK0401A010CBSMsg1List.get(SBOP_SVC_KEI_NO)` | EKK0401A010 | - | Reads the sub-option service contract number from the prior result hash |
| R | `inHash.get(REQYMD)` | - | - | Reads the requested service end year-month-day from the input hash |
| R | `inHash.get(SVC_CHRG_ENDYMD)` | - | - | Reads the service charge end year-month-day from the input hash (fallback branch) |
| R | `jdgHiChrgMapSvcKei.get("svcChrgEndYmd")` | - | - | Reads the computed service charge end date from the judgment map (non-null branch) |

### Method Call Analysis:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `fillCAANMSGNullMapping` | JKKKyoseiDslRunMapperCC | - | Sets null-safe default field mappings on the template, ensuring the message structure is populated with empty/nullable placeholders before concrete values are set |
| SET | `template.set(TEMPLATEID)` | - | - | Sets the SIF (Service Integration Framework) template ID to `"EKK0401C180"` |
| SET | `template.set(FUNC_CODE)` | - | - | Sets the function code to `"1"` — indicates this is a check-and-update operation |
| SET | `template.set(OP_SVC_KEI_NO)` | - | - | Sets the operation service contract number, extracted from the prior EKK0401A010 step result |
| SET | `template.set(SBOP_SVC_KEI_NO)` | - | - | Sets the sub-option service contract number, extracted from the prior EKK0401A010 step result |
| SET | `template.set(SVC_ENDYMD)` | - | - | Sets the service end year-month-day from the request parameter `REQYMD` |
| SET | `template.set(SVC_CHRG_ENDYMD)` | - | - | Sets the service charge end date — resolves from either the judgment map or input hash depending on null status |
| SET | `template.set(SVC_DLRE_CD)` | - | - | Sets the service cancellation reason code to `"02"` (mandatory cancellation — a fixed literal) |
| SET | `template.set(UPD_DTM_BF)` | - | - | Sets the update date/time before this operation, used for optimistic concurrency control |
| SET | `template.set(DSLJI_CHRG_FLG)` | - | - | Sets the termination billing flag from the sub-option judgment map (defaults to `"0"`) |

**Note:** This method does **not** directly perform database operations. It is a pure mapping/assembler method that populates a `CAANMsg` template. The actual CRUD operations (database inserts/updates) are performed by the CBS layer (`EKK0401C180CBS`) that consumes the populated template. The `fillCAANMSGNullMapping` call is the only side-effecting operation, modifying the template object in place.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `fillCAANMSGNullMapping` [-], `getContents` [R], `getContents` [R], `getContents` [R], `getContents` [R], `getContents` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKKyoseiDslRunCC.callEKK0401C180SC()` | `callEKK0401C180SC()` → `mapper.mappingEKK0401C180InMsg(template, inHash, resultHash, jdgHiChrgMapSvcKei, jdgHiChrgMapSbopSvcKei, svcKeiUpdDtm)` | `fillCAANMSGNullMapping` [U] -, `getContents` [R] - |

**Call chain details:**
1. `JKKKyoseiDslRunCC.callEKK0401C180SC()` — This is the direct caller. It is a service component method within the DSL runtime execution framework that orchestrates the mandatory cancellation flow. It prepares the `template`, `inHash`, `resultHash`, judgment maps, and update timestamp, then invokes this mapper to populate the inbound message before forwarding to the CBS layer.

**Downstream trace:** This method ultimately delegates to `fillCAANMSGNullMapping` which reads `EKK0401C180CBSMsg.getContents()` to obtain the message structure template. No entity/database tables are directly accessed — this is a pure data assembly step.

## 6. Per-Branch Detail Blocks

**Block 1** — [EXEC] Null mapping initialization (L1656)

> Initializes the template with null-safe default mappings by comparing its fields against the EKK0401C180CBSMsg structure. This ensures all expected message fields have default values before concrete data is set.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `fillCAANMSGNullMapping(template, new EKK0401C180CBSMsg().getContents())` | Sets null-safe default mappings on the template |

**Block 2** — [EXEC] Template ID assignment (L1659)

> Assigns the SIF (Service Integration Framework) template identifier that uniquely identifies this mandatory cancellation message type.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(EKK0401C180CBSMsg.TEMPLATEID, JKKKyoseiDslRunCC.TEMPLATE_ID_EKK0401C180)` | `[-> TEMPLATE_ID_EKK0401C180="EKK0401C180"]` Sets the template ID for the CBS routing layer |

**Block 3** — [EXEC] Function code assignment (L1662)

> Sets the function code to indicate the type of operation this message represents.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(EKK0401C180CBSMsg.FUNC_CODE, "1")` | Sets function code to `"1"` — check-and-update operation type |

**Block 4** — [EXEC] Retrieve prior agreement data (L1665–L1666)

> Queries the `resultHash` for the result of the preceding EKK0401A010 step, which contains the sub-option service agreement information. This is a prerequisite — the mandatory cancellation requires a valid service contract number.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `eKK0401A010Hash = null` | Initializes the local variable |
| 2 | SET | `eKK0401A010Hash = (HashMap)resultHash.get(JKKKyoseiDslRunCC.TEMPLATE_ID_EKK0401A010)` | `[-> TEMPLATE_ID_EKK0401A010="EKK0401A010"]` Retrieves the prior step's result map containing service and sub-option contract numbers |

**Block 5** — [EXEC] Set operation service contract number (L1669)

> Extracts the primary service contract number from the prior EKK0401A010 step result and assigns it to the template.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(EKK0401C180CBSMsg.OP_SVC_KEI_NO, eKK0401A010Hash.get(EKK0401A010CBSMsg1List.OP_SVC_KEI_NO))` | Sets the operation service contract number (the primary service being cancelled) |

**Block 6** — [EXEC] Set sub-option service contract number (L1672)

> Extracts the sub-option service contract number and assigns it to the template. This allows the CBS layer to process both the main service and any associated sub-options.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(EKK0401C180CBSMsg.SBOP_SVC_KEI_NO, eKK0401A010Hash.get(EKK0401A010CBSMsg1List.SBOP_SVC_KEI_NO))` | Sets the sub-option service contract number (any add-on/sub services being cancelled alongside the main service) |

**Block 7** — [EXEC] Set service end date (L1675–L1676)

> Sets the service end year-month-day from the original request parameter. This was added per KT1-2013-0000691 (2013/07/06).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(EKK0401C180CBSMsg.SVC_ENDYMD, inHash.get(JKKKyoseiDslRunCC.REQYMD))` | `[-> REQYMD="REQYMD"]` Sets the service end date from the user's request parameters |

**Block 8** — [IF] Service charge end date resolution (L1679–L1686)

> Branches based on whether the non-taxable judgment map for service-level charge items has been populated. If the judgment component has not run (map is null), falls back to the raw input hash value. Otherwise, uses the computed judgment result.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `jdgHiChrgMapSvcKei == null` | Non-taxable judgment map for service — checks if charge computation has been performed |

**Block 8.1** — [ELSE] Judgment map is null (L1681) (L1680)

> When the judgment map is absent, use the raw service charge end date from the input hash. This is the fallback path when the non-taxable/judgment component was not invoked or returned no data.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(EKK0401C180CBSMsg.SVC_CHRG_ENDYMD, inHash.get(JKKKyoseiDslRunCC.SVC_CHRG_ENDYMD))` | `[-> SVC_CHRG_ENDYMD="SVC_CHRG_ENDYMD"]` Uses raw input charge end date as fallback |

**Block 8.2** — [ELSE] Judgment map is not null (L1683–L1685) (L1682)

> When the judgment map contains computed data, use the `svcChrgEndYmd` value derived from the non-taxable judgment component. This provides the authoritative, system-computed charge end date.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(EKK0401C180CBSMsg.SVC_CHRG_ENDYMD, jdgHiChrgMapSvcKei.get("svcChrgEndYmd"))` | Uses the computed service charge end date from the judgment component result |

**Block 9** — [EXEC] Set mandatory cancellation reason code (L1688)

> Sets a fixed literal indicating this cancellation is a mandatory (forced) cancellation by the provider, not a voluntary customer-initiated cancellation. The reason code `"02"` (`SVC_DLRE_CD_KYOSEI`) denotes mandatory cancellation.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(EKK0401C180CBSMsg.SVC_DLRE_CD, JKKKyoseiDslRunCC.SVC_DLRE_CD_KYOSEI)` | `[-> SVC_DLRE_CD_KYOSEI="02"]` Fixed code for mandatory/forced service cancellation |

**Block 10** — [EXEC] Set pre-update timestamp (L1691)

> Records the service detail's last update date/time stamp from before this operation. This is used for optimistic locking — the CBS layer will verify this timestamp matches the database value to prevent stale-write conflicts.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(EKK0401C180CBSMsg.UPD_DTM_BF, svcKeiUpdDtm)` | Sets the pre-update timestamp for optimistic concurrency control |

**Block 11** — [IF] Termination billing flag resolution (L1694–L1701)

> Resolves the termination billing flag by first defaulting to `"0"`, then checking the sub-option non-taxable judgment map. If the judgment map exists, extracts the `chrgFlg` value. This flag indicates whether termination fees apply to the cancelled service.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `String chrgFlg = "0"` | Default: no termination billing |
| 2 | IF | `jdgHiChrgMapSbopSvcKei != null` | Non-taxable judgment map for sub-option — checks if termination billing has been evaluated |

**Block 11.1** — [ELSE] Judgment map is not null (L1696–L1697) (L1695)

> When the sub-option judgment map contains data, extract the termination billing flag. A value of `"1"` would indicate termination fees apply; `"0"` indicates no fees.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `chrgFlg = (String)jdgHiChrgMapSbopSvcKei.get("chrgFlg")` | Retrieves the termination billing flag from the sub-option judgment map |

**Block 12** — [EXEC] Set DSL termination billing flag (L1700–L1701)

> Sets the termination billing flag on the template. This is added per SEP-0020-00-00. The flag determines whether termination fees should be charged when cancelling the service.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(EKK0401C180CBSMsg.DSLJI_CHRG_FLG, chrgFlg)` | Sets whether termination billing fees apply when cancelling the service contract |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `template` | Parameter | CAANMsg message template — the structured data object being built for the mandatory cancellation service component |
| `inHash` | Parameter | Input parameter map carrying request-level data from the calling screen/business component |
| `resultHash` | Parameter | Output/result map carrying data from previously executed service component steps |
| `jdgHiChrgMapSvcKei` | Parameter | Non-taxable judgment map for service-level charge items — result of a prior charge-exemption evaluation step |
| `jdgHiChrgMapSbopSvcKei` | Parameter | Non-taxable judgment map for sub-option charge items — result of a prior charge-exemption evaluation for add-on/sub-option services |
| `svcKeiUpdDtm` | Parameter | Service detail update date/time stamp — the last-known update time for optimistic concurrency control |
| `TEMPLATE_ID_EKK0401C180` | Constant | Template identifier `"EKK0401C180"` — uniquely identifies the mandatory cancellation inbound message type |
| `TEMPLATE_ID_EKK0401A010` | Constant | Template identifier `"EKK0401A010"` — key to retrieve the prior sub-option service agreement step's result |
| `REQYMD` | Constant | Field key `"REQYMD"` — the requested service end year-month-day, typically provided by the user/screen |
| `SVC_CHRG_ENDYMD` | Constant | Field key `"SVC_CHRG_ENDYMD"` — the service charge end year-month-day |
| `SVC_DLRE_CD_KYOSEI` | Constant | Cancellation reason code `"02"` — mandatory/forced cancellation by the service provider (as opposed to voluntary customer cancellation) |
| `FUNC_CODE` | Field | Function code in the message — `"1"` indicates check-and-update operation type |
| `OP_SVC_KEI_NO` | Field | Operation service contract number — the primary service contract being cancelled |
| `SBOP_SVC_KEI_NO` | Field | Sub-option service contract number — associated add-on/sub-option service contracts being cancelled alongside the main service |
| `SVC_ENDYMD` | Field | Service end year-month-day — the date when the service contract officially ends |
| `SVC_CHRG_ENDYMD` | Field | Service charge end year-month-day — the last date on which service charges apply |
| `SVC_DLRE_CD` | Field | Service cancellation reason code — classifies the type of cancellation |
| `UPD_DTM_BF` | Field | Update date/time before operation — timestamp of the last record modification, used for optimistic locking |
| `DSLJI_CHRG_FLG` | Field | DSL (service contract) termination billing flag — indicates whether termination fees apply to the cancelled service |
| `chrgFlg` | Variable | Termination billing flag — `"0"` means no termination fees, `"1"` means termination fees apply |
| `svcChrgEndYmd` | Field Key | Service charge end date key within the judgment map |
| EKK0401C180 | SC Code | Mandatory cancellation service component — handles service contract cancellation with forced cancellation reason |
| EKK0401A010 | SC Code | Sub-option service agreement service component — executed prior to cancellation to establish the service contract baseline |
| CBS | Acronym | Core Business Service — the layer that persists data to the database |
| CAANMsg | Type | Message/parameter object used for communication between CBS layers |
| CAANMSG | Acronym | Fujitsu's middleware message format (CAAN = Cloud Application Architecture Network) |
| SIF | Acronym | Service Integration Framework — the integration layer for service component routing |
| OPT | Acronym | Optimistic Locking — a concurrency control mechanism using version/timestamp comparison |
| KT1-2013-0000691 | Change Ticket | Change ticket that added SVC_ENDYMD mapping for mandatory cancellation (2013/07/06) |
| SEP-0020-00-00 | Change Ticket | Change ticket that added DSL termination billing flag mapping (termination fees for service cancellation) |
| JKKKyoseiDslRunCC | Class | DSL execution control component — orchestrates the mandatory cancellation business flow across multiple service components |
| JKKKyosei | Japanese | 課外 (Kagai) — "Additional" or "Non-standard" (refers to non-standard/additional processing outside the core DSL framework) |
| Mandatory Cancellation | Business term | 強制解約 (Kyousei Kaikai) — service cancellation initiated by the provider (e.g., for non-payment), as opposed to voluntary customer-initiated cancellation |
| Non-taxable Judgment | Business term | 非課金判定 (Hi-Kakin Handan) — the process of determining whether a service or charge should be exempt from billing |
| Termination Billing | Business term | 解約時課金 (Kaishiji Kakin) — billing (fees) applied at the time of service contract cancellation |
| Sub-option | Business term | サブオプション (Sub-option) — additional/add-on services linked to a primary service contract |
| Service Contract Line | Business term | サービス契約 linea (SVC_KEI_NO) — a line item within a service contract, identifying a specific service offering |
