# Business Logic — JKKFmtcelMskmInfoTrkmCC.mappingEKK0361D010InMsg() [61 LOC]

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

## 1. Role

### JKKFmtcelMskmInfoTrkmCC.mappingEKK0361D010InMsg()

This method is a **message mapping (input message assembly) method** that prepares the SIF (Service Integration Framework) input message template for the **Option Service Contract Registration (ISP)** Service Component `EKK0361D010`. The method takes a pre-allocated `CAANMsg` template object and populates it with all required fields for registering or updating a home telecom service provider (FTTH/hometel) option service contract entry.

The method implements the **Builder / Template Population pattern** — it does not make any database calls or invoke remote services directly. Instead, it resolves business values from the `work` HashMap (driven by a conditional branch on the application type), then sequentially sets each field on the `template` message object using the strongly-typed constants from `EKK0361D010CBSMsg`. It delegates to `fillCAANMSGNullMapping` to pre-populate every field with null defaults before selectively overwriting the relevant ones.

It operates as a **shared utility method** within the home telecom service information tracking component (`JKKFmtcelMskmInfoTrkmCC`). It is exclusively called by the sibling `callEKK0361D010SC()` method, which handles the actual SIF invocation of `EKK0361D010` (Option Service Contract <ISP> Agreement Consultation). The conditional branch distinguishes between the **new-type application** (registration subtype `2`, introduced in ANK-2184 for the new-style FTTH registration) and all other registration/subscription types, adjusting billing codes accordingly — the new-type uses premium billing codes (`BC5`, `PBC501`), while legacy types use standard codes (`B78`, `PB7801`).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["mappingEKK0361D010InMsg"])
    A["Null Map all fields"]
    B["Set TEMPLATEID"]
    C{Condition}
    D["pcrsCd = BC5"]
    E["pplanCd = PBC501"]
    F["pcrsCd = B78"]
    G["pplanCd = PB7801"]
    H["Set FUNC_CODE = 1"]
    I["Set OP_SVC_CD"]
    J["Set PCRS_CD"]
    K["Set PPLAN_CD"]
    L["Set OYA_SKBT_CD"]
    M["Set SVC_KEI_NO"]
    N["Set SVC_KEI_UCWK_NO"]
    O["Set SYSID"]
    P["Set MSKM_DTL_NO"]
    Q["Set SVC_USE_STA_KIBO_YMD"]
    R["Set IDO_DIV"]
    S["Set SEIKY_KEI_NO"]
    T["Set UPD_DTM_BF"]
    U["Set FMTCEL_JGS_CD"]
    V["Set FMTCEL_JGS_USE_CD"]
    W["Set FMTCEL_SYOGO_TG_CD"]
    END(["Return void"])
    START --> A
    A --> B
    B --> C
    C -->|Yes| D
    C -->|No| F
    D --> E
    F --> G
    E --> H
    G --> H
    H --> I
    I --> J
    J --> K
    K --> L
    L --> M
    M --> N
    N --> O
    O --> P
    P --> Q
    Q --> R
    R --> S
    S --> T
    T --> U
    U --> V
    V --> W
    W --> END
```

**Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|-----------------|
| `MSKM_DIV_ADD_NEW` | `"2"` | Application division — New-type registration |
| `JKKStrConst.CD00134_BC5` | `"BC5"` | Billing code — FTTH LTE (new-type premium billing) |
| `JKKStrConst.CD00134_B78` | `"B78"` | Billing code — Basic/Standard (legacy billing) |
| `JKKStrConst.CD00565_FMTCEL_NEW` | `"PBC501"` | Billing plan code — FTTH New billing plan |
| `JKKStrConst.CD00565_FMTCEL` | `"PB7801"` | Billing plan code — FTTH standard billing plan |
| `FUNC_CD_1` | `"1"` | Function code — Check and Registration |
| `IDO_DIV` | `"00031"` | Movement division — Fixed/Standard change code |

**Processing Flow:**

1. **Null Mapping** — Populates every field in the template with null values via `fillCAANMSGNullMapping(template, new EKK0361D010CBSMsg().getContents())`, ensuring no field is left unpopulated.
2. **Template ID** — Sets the SIF template identifier to `"EKK0361D010"` (Option Service Contract <ISP> Registration).
3. **Conditional Billing Resolution** — Branches on the `mskm_div` (application division) value from the work context:
   - **True** (`mskm_div == "2"`): Uses new-type billing codes `BC5` and `PBC501`. This path handles the new-style FTTH registration introduced in ANK-2184.
   - **False** (all other types): Uses standard billing codes `B78` and `PB7801` for legacy registrations or contract cancellations.
4. **Fixed Field Population** — Sets function code, option service code, parent contract classification, movement division, and other static values.
5. **Dynamic Field Population** — Reads values from the `work` HashMap for service contract number, service detail work number, SYSID, application detail number, billing operator date, billing contract number, update timestamp, and home telecom provider codes.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `template` | `CAANMsg` | The SIF input message template for SC `EKK0361D010`. This object holds all fields that will be serialized and sent to the Option Service Contract <ISP> Registration Service Component. It is pre-allocated by the caller (`callEKK0361D010SC`) and passed in for population. |
| 2 | `work` | `HashMap<String, Object>` | The work context map carrying business data extracted from the screen or upstream processing. It contains keys such as `mskm_div` (application division — determines billing codes), `svc_kei_no` (service contract number), `svc_kei_ucwk_no` (service detail work number), `sysid` (system ID), `mskm_dtl_no` (application detail number), `last_upd_dtm` (last update timestamp), `jgs_cd` (provider code), `jgs_use_cd` (provider usage code), `fmtcel_shogo_tg_cd` (home telecom protection target code), `seiky_kei_no` (billing contract number). |

**External state read by this method:**

| Field / Source | Type | Business Description |
|---------------|------|---------------------|
| `MSKM_DIV_ADD_NEW` (constant) | `String = "2"` | Application division value for new-type registration |
| `FUNC_CD_1` (constant) | `String = "1"` | Function code — Check and Registration |
| `EKK0361D010` (constant) | `String = "EKK0361D010"` | Service Component identifier for Option Service Contract <ISP> Registration |
| `JCCBPCommon.getOpeDate()` | method call | Retrieves the current business operator date (YYYYMMDD format) used for service start date |
| `fillCAANMSGNullMapping` | sibling method | Fills all fields of the template with null defaults based on `EKK0361D010CBSMsg` field structure |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `fillCAANMSGNullMapping` | - | - | Calls `fillCAANMSGNullMapping` in `JKKFmtcelMskmInfoTrkmCC` — maps all fields of the template to null using the contents metadata from `EKK0361D010CBSMsg` |
| R | `JCCBPCommon.getOpeDate` | JCCBPCommon | - | Calls `getOpeDate(null)` to retrieve the current business operator date (YYYYMMDD), used as the service start request date (`SVC_USE_STA_KIBO_YMD`) |

**Note:** This method itself performs no direct database operations (no C/R/U/D). It is purely a **message mapping/assembly** method. The actual SC invocation (`EKK0361D010`) is performed by the caller `callEKK0361D010SC()`, which in turn invokes the Service Component that handles the underlying entity operations (Create/Update on Option Service Contract <ISP> tables).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `callEKK0361D010SC()` | `JKKFmtcelMskmInfoTrkmCC.callEKK0361D010SC` -> `mappingEKK0361D010InMsg` | `EKK0361D010 [R] Option Service Contract <ISP>` |

**Notes on the caller:**
- `callEKK0361D010SC()` is a private method in `JKKFmtcelMskmInfoTrkmCC` that orchestrates the full SIF call lifecycle: it calls `mappingEKK0361D010InMsg()` to populate the message template, then invokes `ServiceComponentRequestInvoker` to execute `EKK0361D010` (Option Service Contract <ISP> Agreement Consultation), performs result error mapping, and extracts the status code.

**Terminal operations reachable from this method:**
- `fillCAANMSGNullMapping` [-] — Null field population (internal)
- `JCCBPCommon.getOpeDate` [R] — Retrieves operator date
- The `EKK0361D010CBSMsg` fields written to `template` are consumed by the caller `callEKK0361D010SC()` which passes the template to the SIF layer.

## 6. Per-Branch Detail Blocks

**Block 1** — [CALL] `fillCAANMSGNullMapping` (L917)

> Null-maps all fields of the template to default null values using the EKK0361D010CBSMsg field metadata. This ensures every field in the message is populated (even if null) before selectively setting actual values.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `fillCAANMSGNullMapping(template, new EKK0361D010CBSMsg().getContents())` // Populates all template fields with null defaults |

**Block 2** — [EXEC] `template.set(TEMPLATEID)` (L920)

> Sets the SIF template identifier so the downstream SC knows which message format is being sent.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0361D010CBSMsg.TEMPLATEID, EKK0361D010)` // Sets TEMPLATEID = "EKK0361D010" |

**Block 3** — [IF/ELSE] `mskm_div` conditional billing resolution (L922–927)

> Determines the billing code and billing plan code based on the application division type. Introduced in ANK-2184 to support new-style FTTH registration with different billing structures.

| # | Type | Code |
|---|------|------|
| 1 | SET | `pcrsCd = MSKM_DIV_ADD_NEW.equals((String)work.get("mskm_div")) ? JKKStrConst.CD00134_BC5 : JKKStrConst.CD00134_B78` // Resolves billing code: "BC5" for new-type, "B78" for all others [-> MSKM_DIV_ADD_NEW="2"] |
| 2 | SET | `pplanCd = MSKM_DIV_ADD_NEW.equals((String)work.get("mskm_div")) ? JKKStrConst.CD00565_FMTCEL_NEW : JKKStrConst.CD00565_FMTCEL` // Resolves billing plan: "PBC501" for new-type, "PB7801" for all others [-> MSKM_DIV_ADD_NEW="2"] |

**Block 3.1** — [IF branch: true — New-type registration] (L922)

> When `mskm_div` equals `"2"` (new-type registration), the method selects premium/new-style billing codes.

| # | Type | Code |
|---|------|------|
| 1 | SET | `pcrsCd = JKKStrConst.CD00134_BC5` // "BC5" — Billing code: FTTH LTE (new-type) [-> CD00134_BC5="BC5"] |
| 2 | SET | `pplanCd = JKKStrConst.CD00565_FMTCEL_NEW` // "PBC501" — Billing plan: FTTH New [-> CD00565_FMTCEL_NEW="PBC501"] |

**Block 3.2** — [ELSE branch: false — All other types] (L923, L926)

> For all other application divisions (e.g., standard registration `"0"`, cancellation `"1"`, new-type cancellation `"3"`), the method selects standard/legacy billing codes.

| # | Type | Code |
|---|------|------|
| 1 | SET | `pcrsCd = JKKStrConst.CD00134_B78` // "B78" — Billing code: Basic/Standard [-> CD00134_B78="B78"] |
| 2 | SET | `pplanCd = JKKStrConst.CD00565_FMTCEL` // "PB7801" — Billing plan: FTTH Standard [-> CD00565_FMTCEL="PB7801"] |

**Block 4** — [EXEC] Fixed field population — Function code and Service code (L931–934)

> Sets the function code to `"1"` (Check & Registration) and the option service code to `"B075"` (Option Service). These are hardcoded constants specific to the EKK0361D010 SC interface.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0361D010CBSMsg.FUNC_CODE, FUNC_CD_1)` // [-> FUNC_CD_1="1", meaning: Check & Registration] |
| 2 | SET | `template.set(EKK0361D010CBSMsg.OP_SVC_CD, "B075")` // Option service code |

**Block 5** — [EXEC] Dynamic PCRS_CD and PPLAN_CD assignment (L939–940)

> Writes the resolved billing codes (from Block 3's conditional) onto the template, replacing the hardcoded commented-out values from the pre-ANK-2184 era.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0361D010CBSMsg.PCRS_CD, pcrsCd)` // Writes computed billing code ("BC5" or "B78") |
| 2 | SET | `template.set(EKK0361D010CBSMsg.PPLAN_CD, pplanCd)` // Writes computed billing plan ("PBC501" or "PB7801") |

**Block 6** — [EXEC] Parent contract and service identifiers (L943–949)

> Sets fixed and dynamic identifiers for the service contract hierarchy.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0361D010CBSMsg.OYA_KEI_SKBT_CD, "01")` // Parent contract classification code |
| 2 | SET | `template.set(EKK0361D010CBSMsg.SVC_KEI_NO, (String)work.get("svc_kei_no"))` // Service contract number from work context |
| 3 | SET | `template.set(EKK0361D010CBSMsg.SVC_KEI_UCWK_NO, (String)work.get("svc_kei_ucwk_no"))` // Service detail work number (internal line item ID) |
| 4 | SET | `template.set(EKK0361D010CBSMsg.SYSID, (String)work.get("sysid"))` // System ID |

**Block 7** — [EXEC] Application detail and start date (L950–954)

> Sets the application detail number and the requested service start date derived from the operator date.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0361D010CBSMsg.MSKM_DTL_NO, (String)work.get("mskm_dtl_no"))` // Application detail number |
| 2 | SET | `template.set(EKK0361D010CBSMsg.SVC_USE_STA_KIBO_YMD, JCCBPCommon.getOpeDate(null))` // Service start request date (YYYYMMDD from operator date) |

**Block 8** — [EXEC] Movement division and billing contract (L956–958)

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0361D010CBSMsg.IDO_DIV, "00031")` // Movement division code (fixed: "00031" — standard change) |
| 2 | SET | `template.set(EKK0361D010CBSMsg.SEIKY_KEI_NO, (String)work.get("seiky_kei_no"))` // Billing contract number |

**Block 9** — [EXEC] Update timestamp and provider codes (L960–963)

> Sets the last update timestamp (for optimistic concurrency control or audit) and the home telecom provider classification.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0361D010CBSMsg.UPD_DTM_BF, (String)work.get("last_upd_dtm"))` // Update datetime before modification |
| 2 | SET | `template.set(EKK0361D010CBSMsg.FMTCEL_JGS_CD, (String)work.get("jgs_cd"))` // Home telecom provider code |
| 3 | SET | `template.set(EKK0361D010CBSMsg.FMTCEL_JGS_USE_CD, (String)work.get("jgs_use_cd"))` // Home telecom provider usage code |

**Block 10** — [EXEC] SBM protection target code (L965–966)

> Sets the home telecom protection target code. Added in ANK-1187 for SBM (Shared Band Modem?) FTTH support, dated 2012/09/18.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0361D010CBSMsg.FMTCEL_SYOGO_TG_CD, (String)work.get("fmtcel_shogo_tg_cd"))` // Home telecom protection target code |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `EKK0361D010` | SC Code | Option Service Contract <ISP> Registration — Service Component for registering option service contracts for ISP (Internet Service Provider) subscriptions |
| `mskm_div` | Field | Application division — classifies the type of application: "0" = standard registration, "1" = contract cancellation, "2" = new-type registration, "3" = new-type cancellation |
| `svc_kei_no` | Field | Service contract number — the primary identifier for a service contract line |
| `svc_kei_ucwk_no` | Field | Service detail work number — internal tracking ID for service contract line items / sub-lines |
| `mskm_dtl_no` | Field | Application detail number — sequence number identifying a specific application record |
| `seiky_kei_no` | Field | Billing contract number — links the service contract to a billing cycle |
| `last_upd_dtm` | Field | Last update timestamp — used for optimistic concurrency control; captures the state before modification |
| `jgs_cd` | Field | Home telecom provider code (FTTEL/JGS_CD) — identifies the home telecom service provider |
| `jgs_use_cd` | Field | Home telecom provider usage code — categorizes how the provider is used (e.g., primary, secondary) |
| `fmtcel_shogo_tg_cd` | Field | Home telecom protection target code — identifies which endpoints are protected under shared bandwidth (SBM) configuration |
| `PCRS_CD` | Field | Billing code — classifies the billing tier/type (e.g., "BC5" = FTTH LTE premium, "B78" = basic standard) |
| `PPLAN_CD` | Field | Billing plan code — identifies the specific billing plan (e.g., "PBC501" = new FTTH plan, "PB7801" = standard FTTH plan) |
| `FUNC_CODE` | Field | Function code — operation mode: "1" = Check & Registration, "2" = Check Only |
| `OP_SVC_CD` | Field | Option service code — identifies the type of option service ("B075" = Option Service in general) |
| `OYA_KEI_SKBT_CD` | Field | Parent contract classification code — identifies hierarchical relationship to a parent contract ("01" = primary) |
| `IDO_DIV` | Field | Movement division — classifies the type of change/movement ("00031" = standard change) |
| `SVC_USE_STA_KIBO_YMD` | Field | Service usage start request date — the date from which the customer requests service activation |
| `TEMPLATEID` | Field | SIF template identifier — tells the SC which message format/version to expect |
| `FUNC_CD_1` | Constant | Function code value "1" — Check and Registration mode |
| `MSKM_DIV_ADD_NEW` | Constant | Application division value "2" — New-type registration (added in ANK-2184) |
| `CD00134_BC5` | Constant | Billing code "BC5" — FTTH LTE billing (new-style premium) |
| `CD00134_B78` | Constant | Billing code "B78" — Basic/standard billing (legacy) |
| `CD00565_FMTCEL_NEW` | Constant | Billing plan "PBC501" — FTTH new-style billing plan |
| `CD00565_FMTCEL` | Constant | Billing plan "PB7801" — FTTH standard billing plan |
| SIF | Acronym | Service Integration Framework — the middleware layer for invoking Service Components |
| SC | Acronym | Service Component — a stateless business logic unit invoked via SIF |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service |
| FMTCEL | Acronym | Home Tel (Fuetel) — Fujitsu's home telecom service brand |
| SBM | Acronym | Shared Band Modem — FTTH variant with shared bandwidth configuration |
| ANK-2184 | Change Request | Software change request for new-style FTTH registration support (2014/11/10) |
| ANK-1187 | Change Request | Software change request for SBM FTTH support (2012/09/18) |
| CAANMsg | Class | Message wrapper class — generic message container used throughout the SIF framework for passing structured data |
