---

# Business Logic — JKKFmtcelMskmInfoTrkmCC.mappingEKK0351C250InMsg() [58 LOC]

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

## 1. Role

### JKKFmtcelMskmInfoTrkmCC.mappingEKK0351C250InMsg()

This method is a **message mapping routine** that populates the input message (`CAANMsg` template) for the **Option Service Contract Cancellation** SIF (System Interface) identified by `EKK0351C250`. It transforms work-context data from a HashMap into a structured CBS message, preparing it for invocation of the underlying Option Service Contract Cancellation service component. The method follows a **builder/fill pattern** — it begins by null-mapping all message fields to defaults, then sets each required field sequentially with business-specific values derived from the `work` HashMap and the optional judgment charge map (`jdgHiChrgMapSvcKei`).

Its role in the larger system is that of a **shared formatter** invoked by `callEKK0351C250SC()` before the service component call is dispatched. It bridges the gap between the in-memory work context (which carries operational data such as service contract number and transaction date) and the CBS-layer message schema required by the `EKK0351C250CBSMsg` data transfer object. The method also implements **conditional charge-end-date logic**: if no judgment charge mapping exists (`jdgHiChrgMapSvcKei == null`), it calculates the day before the operating date as the service charge end date; otherwise, it takes the pre-computed value from the judgment map. This branch allows the system to support both standard cancellations and judgment-driven cancellations with different charge termination dates.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["mappingEKK0351C250InMsg call"])
    
    START --> A1["fillCAANMSGNullMapping: Null mapping for all conditions"]
    A1 --> A2["Set TEMPLATEID = EKK0351C250"]
    A2 --> A3["Set FUNC_CODE = 1: Option Service Contract Cancellation"]
    A3 --> A4["Set OP_SVC_KEI_NO from work"]
    A4 --> A5["Set SVC_ENDYMD from work tran_date"]
    A5 --> COND1{jdgHiChrgMapSvcKei == null?}
    
    COND1 -->|Yes| B1["Set SVC_CHRG_ENDYMD = getDayOfBefore operateDate"]
    COND1 -->|No| B2["Set SVC_CHRG_ENDYMD from jdgHiChrgMapSvcKei"]
    
    B1 --> C1["chrgFlg = 0"]
    B2 --> C1
    
    C1 --> C2{jdgHiChrgMapSvcKei != null?}
    
    C2 -->|Yes| C3["chrgFlg from jdgHiChrgMapSvcKei"]
    C2 -->|No| C4["chrgFlg remains 0"]
    
    C3 --> D1["Set DSLJI_CHRG_FLG = chrgFlg"]
    C4 --> D1
    D1 --> D2["Set IDO_DIV = 00031"]
    D2 --> D3["Set UPD_DTM_BF from work upd_dtm"]
    D3 --> D4["Set SVC_DLRE_CD = 01: Normal Termination"]
    D4 --> END(["Return"])
```

**CRITICAL — Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|------------------|
| `EKK0351C250` | `"EKK0351C250"` | Template ID for Option Service Contract Cancellation SIF |
| `FUNC_CD_1` | `"1"` | Function code for Option Service Contract Cancellation |
| `IDO_DIV` value `"00031"` | `"00031"` | Movement section identifier |
| `SVC_DLRE_CD` value `"01"` | `"01"` | Service termination reason code: Normal Termination |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `template` | `CAANMsg` | The output message template being constructed for the EKK0351C250 CBS message. It serves as the carrier for all fields that will be sent to the service component. Fields are set via `template.set(fieldKey, value)` calls. |
| 2 | `work` | `HashMap<String, Object>` | The operational work context carrying runtime business data populated by the caller. Key fields extracted include `op_svc_kei_no` (option service contract number) and `tran_date` (transaction/service end date) and `upd_dtm` (update datetime before modification). This map represents the state of the business operation being executed. |
| 3 | `jdgHiChrgMapSvcKei` | `HashMap<String, Object>` | Judgment charge mapping for service contract — an optional map that contains pre-computed charge termination date (`svcChrgEndYmd`) and a charge flag (`chrgFlg`). When null, the system uses default logic (day before operating date). When present, it indicates a judgment-driven cancellation scenario (referenced in code comments: "SEP-0020-00-00 ICS... ADD START" and OM-2013-0000699 change). |

**External state / instance fields read:**
- None directly — this method is self-contained and does not read instance-level state from `JKKFmtcelMskmInfoTrkmCC`.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCBPCommon.getOpeDate` | JCCBPCommon | - | Retrieves the current operating date used for calculating the charge end date when no judgment charge map is provided |
| - | `JKKFmtcelMskmInfoTrkmCC.fillCAANMSGNullMapping` | JKKFmtcelMskmInfoTrkmCC | - | Sets all message fields to null/default values as a baseline mapping step, using the schema from `EKK0351C250CBSMsg.getContents()` |
| R | `JKKFmtcelMskmInfoTrkmCC.getDayOfBefore` | JKKFmtcelMskmInfoTrkmCC | - | Calculates the day before a given operating date string (YYYYMMDD format), used for default charge end date computation |
| - | `CAANMsg.set()` (multiple) | EKK0351C250CBSMsg | - | Sets individual message fields on the template: TEMPLATEID, FUNC_CODE, OP_SVC_KEI_NO, SVC_ENDYMD, SVC_CHRG_ENDYMD, DSLJI_CHRG_FLG, IDO_DIV, UPD_DTM_BF, SVC_DLRE_CD |

**Note:** This method does **not** directly invoke any service component (SC) or CBS (CBS message) to perform database CRUD. It is purely a **data mapping/filling** method — a preparation step that populates the message template before the actual SC call is made by `callEKK0351C250SC()`. The SC code `EKK0351C250` is referenced as the template ID but the actual DB operations (update/cancellation of option service contract records) are handled downstream by the CBS layer.

## 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: `getDayOfBefore` [R], `getOpeDate` [R], `fillCAANMSGNullMapping` [-], `set` [W] (multiple)  # NOSONAR

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class: `JKKFmtcelMskmInfoTrkmCC` | `callEKK0351C250SC(param, handle, work, resultHash, userData, jdgHiChrgMapSvcKei)` → `mappingEKK0351C250InMsg(template, work, jdgHiChrgMapSvcKei)` | `EKK0351C250 [C/R/U] Option Service Contract Cancellation CBS` |

**Caller Details:**

The method `callEKK0351C250SC()` within the same class (`JKKFmtcelMskmInfoTrkmCC`) is the direct caller. It:
1. Creates a `CAANMsg` template using `EKK0351C250CBSMsg.class.getName()`
2. Calls `mappingEKK0351C250InMsg()` to populate the template with mapped fields
3. Adds the template to the SIF request list
4. Invokes the service component via `ServiceComponentRequestInvoker`
5. Processes the result and error mappings

The method is a **utility/mapper** — not a screen entry point itself. It is called within the broader flow of option service contract cancellation processing, which may be triggered by screens such as `KKSV0211` or `KKSV0497` (these screens reference `EKK0351C250` mappers but do not directly call `mappingEKK0351C250InMsg`).

## 6. Per-Branch Detail Blocks

**Block 1** — [CALL] `fillCAANMSGNullMapping(template, ...)` (L1494)

> Null-maps all fields of the template using the schema from `EKK0351C250CBSMsg.getContents()`. This ensures every field in the CBS message has a default (null) value before specific values are assigned.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `fillCAANMSGNullMapping(template, new EKK0351C250CBSMsg().getContents())` // Sets all message fields to null defaults |

**Block 2** — [SET] `TEMPLATEID` (L1497)

> Sets the SIF template ID identifier on the message.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0351C250CBSMsg.TEMPLATEID, "EKK0351C250")` // EKK0351C250 = "EKK0351C250" (Template ID) |

**Block 3** — [SET] `FUNC_CODE` (L1500)

> Sets the function code indicating this is an option service contract cancellation operation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0351C250CBSMsg.FUNC_CODE, "1")` // FUNC_CD_1 = "1" (Option Service Contract Cancellation) |

**Block 4** — [SET] `OP_SVC_KEI_NO` (L1503)

> Sets the option service contract number from the work context.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0351C250CBSMsg.OP_SVC_KEI_NO, (String)work.get("op_svc_kei_no"))` // Option service contract number |

**Block 5** — [SET] `SVC_ENDYMD` (L1506)

> Sets the service end date (year/month/day) from the transaction date in the work context.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0351C250CBSMsg.SVC_ENDYMD, (String)work.get("tran_date"))` // Service end date |

**Block 6** — [SET] `SVC_CHRG_ENDYMD` with conditional branch (L1509–L1522)

> Sets the service charge end date. Two branches: if no judgment charge map exists, the charge end date is the day before the operating date (default behavior). If the judgment charge map exists (ICS-based scenario per OM-2013-0000699), the charge end date is taken directly from the judgment map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String operateDate = JCCBPCommon.getOpeDate(null)` // Get current operating date |
| 2 | IF | `jdgHiChrgMapSvcKei == null` (No judgment charge map provided) |

**Block 6.1** — [Nested IF-TRUE] Default charge end date (L1511–L1512)

> When no judgment charge map exists, use the day before the operating date as the service charge end date. This is the standard cancellation path.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0351C250CBSMsg.SVC_CHRG_ENDYMD, getDayOfBefore((String)operateDate))` // Day before operating date |

**Block 6.2** — [Nested IF-FALSE] Judgment-driven charge end date (L1514–L1520)

> When a judgment charge map exists (ICS scenario), take the pre-computed charge end date from the map. Code comment references "SEP-0020-00-00 ICS... ADD START" and "OM-2013-0000699 CHG START 2013/8/24". The previous implementation (commented out) called `getDayOfBefore` on the judgment map value; the current version uses the value directly without subtracting a day.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0351C250CBSMsg.SVC_CHRG_ENDYMD, jdgHiChrgMapSvcKei.get("svcChrgEndYmd"))` // From judgment charge map (OM-2013-0000699 change, no day subtraction) |

**Block 7** — [SET] `chrgFlg` initialization with conditional branch (L1523–L1529)

> Initializes the charge flag to "0" (no charge) by default, then overrides with the value from the judgment charge map if present.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String chrgFlg = "0"` // Default: no termination charge |
| 2 | IF | `jdgHiChrgMapSvcKei != null` (Judgment charge map exists) |

**Block 7.1** — [Nested IF-TRUE] Read charge flag from judgment map (L1526–L1527)

> When the judgment charge map is present, extract the charge flag that indicates whether termination charges apply.

| # | Type | Code |
|---|------|------|
| 1 | SET | `chrgFlg = (String)jdgHiChrgMapSvcKei.get("chrgFlg")` // Charge flag from judgment map |

**Block 8** — [SET] `DSLJI_CHRG_FLG` (L1530–L1532)

> Sets the termination charge flag on the template. This flag determines whether the customer will be charged termination fees for the option service contract.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0351C250CBSMsg.DSLJI_CHRG_FLG, chrgFlg)` // Termination charge flag |

**Block 9** — [SET] `IDO_DIV` (L1535–L1536)

> Sets the movement section identifier to "00031".

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0351C250CBSMsg.IDO_DIV, "00031")` // Movement section |

**Block 10** — [SET] `UPD_DTM_BF` (L1539–L1540)

> Sets the update datetime before modification, retrieved from the work context. This is used for version control and optimistic locking on the database records.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0351C250CBSMsg.UPD_DTM_BF, (String)work.get("upd_dtm"))` // Update datetime before modification |

**Block 11** — [SET] `SVC_DLRE_CD` (L1543–L1544)

> Sets the service termination reason code to "01", which represents "Normal Termination" (通常の解約). This was added per change request OM-2013-0005104 on 2013/12/18.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0351C250CBSMsg.SVC_DLRE_CD, "01")` // "01" = Normal Termination (OM-2013-0005104) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `EKK0351C250` | Constant | Template ID for the Option Service Contract Cancellation System Interface (SIF) |
| `FUNC_CD_1` | Constant | Function code "1" — denotes Option Service Contract Cancellation operation |
| `op_svc_kei_no` | Field | Option service contract number — the identifier of the option service contract being cancelled |
| `tran_date` | Field | Transaction date — the date of the service termination transaction (used as service end date) |
| `svc_endymd` | Field | Service end year/month/day — the date when the service officially terminates |
| `svc_chrg_endymd` | Field | Service charge end year/month/day — the date when service charges cease; differs from `svc_endymd` as it may be set to a prior date |
| `svc_dlre_cd` | Field | Service termination reason code — classifies the type of termination ("01" = Normal Termination) |
| `dslji_chrg_flg` | Field | Termination charge flag — indicates whether termination charges apply ("0" = no charge, other values = charges apply) |
| `ido_div` | Field | Movement section — a section identifier used for data routing ("00031") |
| `upd_dtm` | Field | Update datetime — the last modification timestamp before this operation, used for optimistic locking |
| `chrgFlg` | Field | Charge flag — runtime variable indicating whether termination charges are applicable |
| `jdgHiChrgMapSvcKei` | Parameter | Judgment charge mapping for service contract — optional map carrying pre-computed charge-related data for judgment-driven cancellations (ICS scenario) |
| `svcChrgEndYmd` | Field (in jdgHiChrgMapSvcKei) | Pre-computed service charge end date from the judgment charge map |
| SIF | Acronym | System Interface — the communication mechanism between the business layer and CBS (Central Business System) |
| CBS | Acronym | Central Business System — the backend system handling core business operations and database transactions |
| CAANMsg | Acronym | Common Application Access Network Message — Fujitsu's message envelope/data transfer object used for CBS communication |
| SC | Acronym | Service Component — the backend service layer that handles business logic and database operations |
| ICS | Acronym | Installation Completion Service — a system for managing installation completion judgments that affects charge calculations |
| Option Service | Business term | An add-on service bundled with a primary service contract (e.g., broadband, TV, phone extras) that can be independently cancelled |
| Option Service Contract Cancellation | Business term | The business operation of terminating an add-on/option service contract while potentially keeping the primary contract active |
| Normal Termination | Business term | Standard customer-initiated contract cancellation (code "01"), as opposed to forced termination or other special termination types |
| Judgment Charge | Business term | A charge determination based on pre-evaluated conditions (e.g., ICS installation status), affecting when and whether termination fees are applied |

---