# Business Logic — JKKKyoseiDslRunMapperCC.mappingEKK0351C250InMsg() [61 LOC]

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

## 1. Role

### JKKKyoseiDslRunMapperCC.mappingEKK0351C250InMsg()

This method constructs the SIF (Service Integration Framework) input message for the **Option Service Contract Cancellation Confirmation** process (SC Code: `EKK0351C250`). It maps business data from caller-provided hash maps into a `CAANMsg` template that will be sent to the backend service component. The method implements a **message builder pattern** — it initializes a blank message template via null-mapping, then populates every required field with values extracted from the request context, pre-computed option service results, and non-taxable charge judgment results. It serves as the shared translation layer in the DSL (Domain-Specific Language) run framework, enabling the option service cancellation confirmation screen to prepare a fully-formed SIF request.

The method handles two conditional data sources for service charge end date (when a non-taxable judgment exists for services) and two conditional sources for the cancellation-time charge flag (when optional service judgment results are available). All fixed fields — function code, forced cancellation reason code, and migration division code — are hard-coded to enforce the business semantics of an option service cancellation operation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["mappingEKK0351C250InMsg"])
    START --> NULL_MAP["fillCAANMSGNullMapping"]
    NULL_MAP --> SET_TEMPLATEID["Set TEMPLATE_ID = EKK0351C250"]
    SET_TEMPLATEID --> SET_FUNC["Set FUNC_CODE = 1 (Check + Update)"]
    SET_FUNC --> GET_OPTION["Get eKK0351A010Hash from resultHash"]
    GET_OPTION --> SET_OP_SVC["Set OP_SVC_KEI_NO from eKK0351A010Hash"]
    SET_OP_SVC --> SET_SVC_END["Set SVC_ENDYMD from REQYMD"]
    SET_SVC_END --> SET_SVC_CHRG{"jdgHiChrgMapSvcKei == null?"}
    SET_SVC_CHRG -- Yes --> SET_CHRG_FROM_IN["Set SVC_CHRG_ENDYMD from SVC_CHRG_ENDYMD inHash"]
    SET_SVC_CHRG -- No --> SET_CHRG_FROM_MAP["Set SVC_CHRG_ENDYMD from jdgHiChrgMapSvcKei"]
    SET_CHRG_FROM_IN --> SET_DLRE["Set SVC_DLRE_CD = 02 (Forced Cancellation)"]
    SET_CHRG_FROM_MAP --> SET_DLRE
    SET_DLRE --> SET_IDO["Set IDO_DIV = 00064 (Forced Cancellation Migration)"]
    SET_IDO --> SET_UPD_DTM["Set UPD_DTM_BF from svcKeiUpdDtm"]
    SET_UPD_DTM --> INIT_CHRG["Set chrgFlg = 0"]
    INIT_CHRG --> CHECK_OP_CHRG{"jdgHiChrgMapOpSvcKei != null?"}
    CHECK_OP_CHRG -- Yes --> GET_CHRG_FLG["Get chrgFlg from jdgHiChrgMapOpSvcKei"]
    CHECK_OP_CHRG -- No --> SET_DSLJI["Set DSLJI_CHRG_FLG = chrgFlg"]
    GET_CHRG_FLG --> SET_DSLJI
    SET_DSLJI --> END_NODE(["Return (void)"])
    CHECK_OP_CHRG --> SET_DSLJI
```

**Branches:**

| Condition | Constant / Branch | Business Meaning |
|-----------|-------------------|------------------|
| `jdgHiChrgMapSvcKei == null` | N/A | Branch on whether non-taxable judgment results for services exist |
| `jdgHiChrgMapSvcKei != null` | N/A | Non-taxable judgment exists — use pre-computed charge end date |
| `jdgHiChrgMapOpSvcKei != null` | N/A | Branch on whether non-taxable judgment results for optional services exist |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `template` | `CAANMsg` | The SIF message template to populate. This is the output carrier — all mapped fields are set on this object, which is later passed to the service component as the inbound request. |
| 2 | `inHash` | `HashMap<String, Object>` | Request parameters from the screen/application layer. Contains fields such as `REQYMD` (request date, used for service end date) and `SVC_CHRG_ENDYMD` (service charge end date, used when no non-taxable judgment exists for services). |
| 3 | `resultHash` | `HashMap<String, Object>` | Application-specific result parameter hash. Pre-computed results from prior SC calls are stored here under template IDs. The method retrieves the option service contract cancellation result (`EKK0351A010`) from this map to extract the option service contract number (`op_svc_kei_no`). |
| 4 | `jdgHiChrgMapSvcKei` | `HashMap<String, Object>` | Non-taxable judgment component result for **services** (非課金判定部品結果＜サービス＞). When non-null, it contains a `svcChrgEndYmd` field that overrides the default charge end date with a pre-judged value. Used for business logic that may exempt certain services from charges. |
| 5 | `jdgHiChrgMapOpSvcKei` | `HashMap<String, Object>` | Non-taxable judgment component result for **optional services** (非課金判定部品結果＜オプションサービス＞). When non-null, it contains a `chrgFlg` field indicating whether cancellation-time charges apply. This flag is used for optional service-specific billing decisions. |
| 6 | `svcKeiUpdDtm` | `String` | Service detail update datetime (before update). The timestamp of the most recent update to the service detail record, used for optimistic concurrency control in the cancellation request. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKKyoseiDslRunMapperCC.fillCAANMSGNullMapping` | JKKKyoseiDslRunMapperCC | - | Initializes all fields of the `CAANMsg` template to null by mapping against a fresh `EKK0351C250CBSMsg` schema contents. This ensures a clean slate before populating required fields. |
| R | `EKK0371CBMMsg.getContents` | EKK0371CBMMsg | - | Schema accessor (called internally by `fillCAANMSGNullMapping` via the CBSMsg factory chain). Returns the field definition schema. |
| R | `EKK0381CBMMsg.getContents` | EKK0381CBMMsg | - | Schema accessor. Returns the field definition schema for the 0381 message. |
| R | `EKK0391CBMMsg.getContents` | EKK0391CBMMsg | - | Schema accessor. Returns the field definition schema for the 0391 message. |
| R | `EKK0401CBMMsg.getContents` | EKK0401CBMMsg | - | Schema accessor. Returns the field definition schema for the 0401 message. |
| R | `EKK0411CBMMsg.getContents` | EKK0411CBMMsg | - | Schema accessor. Returns the field definition schema for the 0411 message. |

**Detailed analysis of the called methods within this method:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKKKyoseiDslRunMapperCC.fillCAANMSGNullMapping` | - | CAANMsg template | Initializes every field of the `EKK0351C250CBSMsg` template to null, providing a clean message structure before field population. |
| R | `EKK0351C250CBSMsg.getContents` | - | CAANMsg schema | Creates a fresh instance and extracts its schema fields (templateID, func_code, op_svc_kei_no, svc_endymd, svc_chrg_endymd, svc_dlre_cd, ido_div, upd_dtm_bf, dslji_chrg_flg, etc.) for null-mapping. |
| R | `EKK0351A010CBSMsg1List.getContents` | - | CAANMsg schema | Provides field definitions for extracting `op_svc_kei_no` (option service contract number) from the pre-computed result hash. |
| - | `CAANMsg.set` | - | CAANMsg template | Sets individual fields on the `template` object. Each call writes one field (e.g., `template.set("templateID", "EKK0351C250")`). There are 10 such setter calls. |
| R | `HashMap.get` (on `resultHash`) | - | In-memory data | Retrieves the pre-computed `EKK0351A010` result hash from `resultHash` using the template ID key. |
| R | `HashMap.get` (on `eKK0351A010Hash`) | - | In-memory data | Extracts the `op_svc_kei_no` (option service contract number) from the option service result hash. |
| R | `HashMap.get` (on `inHash`) | - | In-memory data | Extracts `REQYMD` (request date) and optionally `SVC_CHRG_ENDYMD` (service charge end date) from the request parameter hash. |
| R | `HashMap.get` (on `jdgHiChrgMapSvcKei`) | - | In-memory data | Extracts `svcChrgEndYmd` (service charge end date from non-taxable judgment) when the map is non-null. |
| R | `HashMap.get` (on `jdgHiChrgMapOpSvcKei`) | - | In-memory data | Extracts `chrgFlg` (cancellation-time charge flag) when the map is non-null. |

## 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.callEKK0351C250SC()` | `callEKK0351C250SC` -> `mappingEKK0351C250InMsg` | `fillCAANMSGNullMapping` [-], `getContents` [R] |

The caller `JKKKyoseiDslRunCC.callEKK0351C250SC()` is the direct orchestration method that prepares data, invokes this mapping method to build the SIF request, and then calls the backend service component for the option service contract cancellation confirmation.

## 6. Per-Branch Detail Blocks

**Block 1** — [EXEC] `fillCAANMSGNullMapping(template, ...)` (L1580)

> Creates a fresh EKK0351C250CBSMsg schema instance and null-maps all its fields into the template. This ensures a clean message structure before field population.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `fillCAANMSGNullMapping(template, new EKK0351C250CBSMsg().getContents())` | Null-map all template fields using EKK0351C250CBSMsg schema |

**Block 2** — [SET] Set template ID (L1583)

> Sets the SIF template ID to identify this as an EKK0351C250 message.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(TEMPLATEID, JKKKyoseiDslRunCC.TEMPLATE_ID_EKK0351C250)` | Set SIF template ID = "EKK0351C250" (Option Service Contract Cancellation Confirmation) |

**Block 3** — [SET] Set function code (L1586)

> Hard-codes function code "1" to indicate a check-and-update operation.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(FUNC_CODE, "1")` | Set function code = "1" (Check + Update) |

**Block 4** — [SET] Get option service contract number (L1589-L1591)

> Retrieves the pre-computed result from the prior `EKK0351A010` (Option Service Contract Cancellation) call stored in `resultHash`, extracting the option service contract number.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `eKK0351A010Hash = null` | Initialize local variable |
| 2 | SET | `eKK0351A010Hash = (HashMap)resultHash.get(TEMPLATE_ID_EKK0351A010)` | Retrieve EKK0351A010 result hash from pre-computed results |

**Block 5** — [SET] Set option service contract number (L1594)

> Maps the option service contract number from the pre-computed result into the template.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(OP_SVC_KEI_NO, eKK0351A010Hash.get(EKK0351A010CBSMsg1List.OP_SVC_KEI_NO))` | Set option service contract number from EKK0351A010 result hash |

**Block 6** — [SET] Set service end date (L1597-L1598)

> Sets the service end date from the request date parameter (REQYMD). This was added under a KT change request in July 2013.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(SVC_ENDYMD, inHash.get(JKKKyoseiDslRunCC.REQYMD))` | Set service end date = request date (REQYMD) from inHash |

**Block 7** — [IF/ELSE] Service charge end date determination (L1601-L1608)

> Branches on whether non-taxable judgment results for services exist. If no judgment map is provided, falls back to the default service charge end date from the request hash. If judgment exists, uses the pre-computed value.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | COND | `jdgHiChrgMapSvcKei == null` | Check if non-taxable judgment map for services is absent |
| 2 | SET | `template.set(SVC_CHRG_ENDYMD, inHash.get(JKKKyoseiDslRunCC.SVC_CHRG_ENDYMD))` | **YES**: Set charge end date from request hash SVC_CHRG_ENDYMD |
| 3 | SET | `template.set(SVC_CHRG_ENDYMD, jdgHiChrgMapSvcKei.get("svcChrgEndYmd"))` | **NO**: Set charge end date from pre-computed non-taxable judgment result |

**Block 8** — [SET] Set service cancellation reason code (L1611)

> Hard-codes the forced cancellation reason code.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(SVC_DLRE_CD, JKKKyoseiDslRunCC.SVC_DLRE_CD_KYOSEI)` | Set cancellation reason = "02" (Forced Cancellation) |

**Block 9** — [SET] Set migration division code (L1614)

> Hard-codes the migration division for forced cancellation operations.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(IDO_DIV, JKKKyoseiDslRunCC.IDO_DIV_KYOSEI)` | Set migration division = "00064" (Forced Cancellation Migration) |

**Block 10** — [SET] Set pre-update timestamp (L1617)

> Records the current service detail update timestamp for optimistic concurrency control.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(UPD_DTM_BF, svcKeiUpdDtm)` | Set pre-update datetime from caller-provided timestamp |

**Block 11** — [IF] Cancellation-time charge flag initialization and extraction (L1620-L1628)

> Initializes a default charge flag value of "0" (no charge). If non-taxable judgment results for optional services exist, overrides with the judgment result's `chrgFlg` value.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `chrgFlg = "0"` | Initialize charge flag to "0" (no cancellation charge) |
| 2 | COND | `jdgHiChrgMapOpSvcKei != null` | Check if non-taxable judgment map for optional services exists |
| 3 | SET | `chrgFlg = (String)jdgHiChrgMapOpSvcKei.get("chrgFlg")` | **YES**: Override charge flag from optional service judgment result |

**Block 12** — [SET] Set cancellation-time charge flag (L1631)

> Maps the final charge flag value (either default or judgment-derived) into the template.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template.set(DSLJI_CHRG_FLG, chrgFlg)` | Set cancellation-time charge flag (0 = no charge, 1 = charge applies) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `op_svc_kei_no` | Field | Option service contract number — the unique identifier for an option service contract line item (e.g., additional services attached to a primary broadband contract) |
| `svc_endymd` | Field | Service end date/year-month-day — the date on which the service contract terminates |
| `svc_chrg_endymd` | Field | Service charge end date/year-month-day — the date up to which the service remains billable |
| `svc_dlre_cd` | Field | Service cancellation reason code — classifies why a service was cancelled (e.g., "02" = Forced Cancellation) |
| `ido_div` | Field | Migration division — distinguishes the type of migration operation (e.g., "00064" = Forced Cancellation Migration) |
| `upd_dtm_bf` | Field | Update datetime before — the timestamp of the last update to the service detail record, used for optimistic concurrency control |
| `dslji_chrg_flg` | Field | DSL termination charge flag — indicates whether charges apply upon DSL/service cancellation ("0" = no charge, "1" = charge applies) |
| `chrgFlg` | Field | Charge flag — internal flag used to determine if cancellation-time charges should be applied |
| `REQYMD` | Field | Request year-month-day — the date of the service request, used as the service end date in this context |
| `SVC_CHRG_ENDYMD` | Field | Service charge end date — the date service charges cease, sourced from either the request hash or pre-computed judgment |
| TEMPLATE_ID_EKK0351C250 | Constant | Template ID = "EKK0351C250" — identifies this message as the Option Service Contract Cancellation Confirmation SIF |
| SVC_DLRE_CD_KYOSEI | Constant | Cancellation reason code = "02" — Forced Cancellation (強制作解約), a system-initiated cancellation typically triggered by contract changes or data corrections |
| IDO_DIV_KYOSEI | Constant | Migration division = "00064" — Forced Cancellation Migration (強制異動), used to flag migration operations initiated by the system |
| FUNC_CODE = "1" | Constant | Function code = "1" — Check + Update (チェック＆更新), indicating the operation validates existing data before performing an update |
| TEMPLATE_ID_EKK0351A010 | Constant | Template ID = "EKK0351A010" — Option Service Contract Cancellation result, pre-computed before this method is called |
| Non-taxable judgment (非課金判定) | Business term | A pre-processing step that determines whether a service or optional service should be exempt from charges based on business rules (e.g., promotional periods, customer status) |
| SIF | Acronym | Service Integration Framework — the integration middleware layer that routes messages between the web/transaction layer and backend service components |
| CAANMsg | Technical type | A message carrier object used in the Fujitsu Futurity framework for building structured request/response messages with typed fields |
| CBS | Acronym | Component Business Service — a backend service component that performs business logic and data access |
| SC | Acronym | Service Component — a unit of backend business logic, identified by codes like EKK0351C250 |
| Option Service | Business term | Additional services attached to a primary broadband/telecom contract (e.g., optional add-ons, premium features) that can be cancelled independently |
| Forced Cancellation (強制作解約) | Business term | A system-initiated service cancellation, as opposed to customer-requested cancellation. Typically triggered by data corrections, contract changes, or business rule enforcement |
