# Business Logic — JKKEmailInfoAddCfmCC.mappingEKK0411D010SCInMsg() [109 LOC]

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

## 1. Role

### JKKEmailInfoAddCfmCC.mappingEKK0411D010SCInMsg()

This method assembles and populates a CBS (Center Business System) inbound message template (`CAANMsg`) for the **Sub-Option Service Contract &lt;ISP&gt; Registration** screen (SC Code: `EKK0411D010`). It acts as a **data assembler** that transforms disparate input parameters and pre-screen result data into a single structured message destined for the EKK0411D010 CBS handler.

The method performs three core business operations: first, it initializes the template with default null mappings; second, it sets structural metadata (template ID, function code, service contract numbers, pricing codes, migration type, and service start date); third, it conditionally processes email-specific data — extracting the email address for E-mail plans (`pcrsCd = "D01"`) or calculating additional mailbox capacity for Docomo plans (`pcrsCd = "D02"`) — while skipping all email/capacity fields for Wireshake Check plans (`pcrsCd = "D03"`).

It implements a **builder pattern**: starting with a blank schema and incrementally setting each field of the `EKK0411D010CBSMsg` message. It serves as a shared data transformation utility called from `callEKK0411D010SC()`, bridging the screen-level confirmation logic (`KKSV0002`) and the CBS registration layer.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["mappingEKK0411D010SCInMsg"])
    START --> STEP1["fillCAANMSGNullMapping: Initialize template with empty schema"]
    STEP1 --> STEP2["Set TEMPLATEID to EKK0411D010"]
    STEP2 --> STEP3["Set FUNC_CODE from inHash"]
    STEP3 --> STEP4["Retrieve EKK0361D010Hash from resultHash using TEMPLATE_ID_EKK0361D010"]
    STEP4 --> STEP5["Set OP_SVC_KEI_NO from EKK0361D010Hash"]
    STEP5 --> STEP6["Set SBOP_SVC_CD from inHash"]
    STEP6 --> STEP7["Set PCRS_CD from pcrsCd parameter"]
    STEP7 --> STEP8["Set PPLAN_CD from pplanCd parameter"]
    STEP8 --> STEP9["Set IDO_DIV from inHash"]
    STEP9 --> STEP10["Set SVC_USE_STA_KIBO_YMD via getStrymd()"]
    STEP10 --> STEP11["Extract JKKEmailInfoAddCfmCCList from inHash using wK_INDEX"]
    STEP11 --> STEP12["Parse sCapa and sShkCapa - remove MG suffix"]
    STEP12 --> COND1{pcrsCd equals D03 Wireshake Check?}
    COND1 -->|No - pcrsCd is NOT D03| COND2{pcrsCd equals D01 E-mail?}
    COND1 -->|Yes - pcrsCd is D03| SKIP1["Skip: No email alias or capacity set"]
    SKIP1 --> POST_PROC
    COND2 -->|Yes - pcrsCd is D01| SET_EMAIL["Set mailadAccount from jKKEmailInfoAddCfmCC"]
    COND2 -->|No - pcrsCd is neither D01 nor D02| POST_PROC
    SET_EMAIL --> POST_PROC2["Proceed to post-processing"]
    POST_PROC2 --> POST_PROC
    POST_PROC --> COND3{pcrsCd equals D02 Docomo?}
    COND3 -->|Yes - pcrsCd is D02| SET_CAPA["Calculate addCapa = sCapa - sShkCapa"]
    COND3 -->|No| POST_PROC3["Proceed to post-processing"]
    SET_CAPA --> POST_PROC3
    POST_PROC3 --> STEP13["Set ALIAS if mailadAccount is not empty"]
    STEP13 --> STEP14["Set ADD_CAPA if addCapa is not empty"]
    STEP14 --> STEP15["Set SEIKY_KEI_NO from KKSV000201CC resultHash"]
    STEP15 --> STEP16["Set MSKM_DTL_NO from resultHash using TEMPLATE_ID_EKK0021D010"]
    STEP16 --> STEP17["Set UPD_DTM_BF from inHash"]
    STEP17 --> END_NODE(["Return - void"])
    END_NODE --> RESULT["EKK0411D010 template fully populated"]
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `template` | `CAANMsg` | The output CBS message template to be populated. This is the `EKK0411D010` service IF message that will be sent to the center business system for sub-option service contract registration. It acts as the builder target for all field assignments. |
| 2 | `inHash` | `HashMap<String, Object>` | Input parameter map carrying screen-level data: function code, sub-option service code, migration division, initial capacity (`shk_capa`), update datetime (`ex_svc_upd_dtm`), and the email info confirmation list (`JKKEmailInfoAddCfmCCList`). Keys are string constants defined in `KKSV0002_KKSV0002OP_KKSV000201CC`. |
| 3 | `resultHash` | `HashMap<String, Object>` | Result map from prior screen processing. Contains the Option Service Contract (ISP) registration result keyed by `TEMPLATE_ID_EKK0361D010` (yielding `op_svc_kei_no`), and the application details acceptance registration result keyed by `TEMPLATE_ID_EKK0021D010` (yielding `mskm_dtl_no`). |
| 4 | `pplanCd` | `String` | Pricing plan code — identifies which pricing plan the customer has selected. Passed directly to the CBS template's `pplan_cd` field. Value depends on the customer's plan selection at the screen. |
| 5 | `pcrsCd` | `String` | Pricing course code — the critical branching key that determines service type. Valid values: `"D01"` (E-mail service), `"D02"` (Docomo Wireshake Check), `"D03"` (Wireshake Check — skips all email/capacity fields). This code drives the conditional branch logic for email address and mailbox capacity processing. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `wK_INDEX` | `int` | Index into the email info confirmation list. Set by the calling method (`callEKK0411D010SC()`) before invoking this method, indicating which list element to process. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKEmailInfoAddCfmCC.fillCAANMSGNullMapping` | - | - | Sets null mappings on the template using the `EKK0411D010CBSMsg` schema as a reference — initializes all template fields to empty/null |
| R | `JKKEmailInfoAddCfmCC.getStrymd` | - | - | Returns the current service start date as a string (year-month-day format) for the `svc_use_sta_kibo_ymd` field |
| R | `resultHash.get(TEMPLATE_ID_EKK0361D010)` | EKK0361D010 | KK_T_OP_SVC_KEI (inferred) | Retrieves the Option Service Contract &lt;ISP&gt; registration result containing `op_svc_kei_no` |
| R | `resultHash.get(TEMPLATE_ID_EKK0021D010)` | EKK0021D010 | KK_T_MSKM (inferred) | Retrieves the Application Details Acceptance Registration result containing `mskm_dtl_no` |
| R | `KKSV0002_KKSV0002OP_KKSV000201CC` (inHash key) | KKSV000201CC | - | Accesses billing contract number (`seiky_kei_no`) from the KKSV0002 screen's result hash |

The method primarily performs **data assembly** — reading from input/result hashes and writing to the `template` object. It does not directly invoke any SC (Service Component) or CBS (Center Business System) methods for database operations. The actual DB interaction occurs upstream in the caller `callEKK0411D010SC()`, which receives the populated template and sends it to the center.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Caller: `JKKEmailInfoAddCfmCC.callEKK0411D010SC()` | `callEKK0411D010SC()` -> `mappingEKK0411D010SCInMsg(template, inHash, resultHash, pplanCd, pcrsCd)` | `getStrymd [R]`, `fillCAANMSGNullMapping [-]`, `getContents [R]` (from template schemas), `resultHash.get [R]` |

**Call chain detail:**
- `callEKK0411D010SC()` (in the same class `JKKEmailInfoAddCfmCC`) constructs the `CAANMsg` template, initializes `inHash` and `resultHash`, and then calls `mappingEKK0411D010SCInMsg()` to populate the template. After mapping, it invokes `callEKK0411D010SC()` (the SC-side caller) to transmit the message to the center business system.

**Terminal operations reached from this method:**
- `fillCAANMSGNullMapping` [-] — Template field initialization (no DB access)
- `getStrymd` [R] — Retrieves current date string (no DB access, system time)
- `resultHash.get(TEMPLATE_ID_EKK0361D010)` [R] — Reads Option Service Contract number from prior screen processing
- `resultHash.get(TEMPLATE_ID_EKK0021D010)` [R] — Reads Application Details acceptance number from prior screen processing
- `KKSV000201CC.SEIKY_KEI_NO` [R] — Reads billing contract number from screen result

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialize template with null mappings (L1914)

> Sets up the template with default null values using the EKK0411D010 CBS message schema.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `fillCAANMSGNullMapping(template, new EKK0411D010CBSMsg().getContents())` // Initialize template with empty schema [-> EKK0411D010] |

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

> Assigns the SIF (Service IF) template identifier to the template.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0411D010CBSMsg.TEMPLATEID, TEMPLATE_ID_EKK0411D010)` // TEMPLATE_ID_EKK0411D010 = "EKK0411D010" — Service IF ID |

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

> Copies the function code from the input hash into the template.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0411D010CBSMsg.FUNC_CODE, inHash.get(FUNC_CODE))` // FUNC_CODE = "func_code" |

**Block 4** — [SET] Retrieve Option Service Contract result (L1923-L1925)

> Fetches the Option Service Contract &lt;ISP&gt; registration result from `resultHash` using the template ID `EKK0361D010`. This data was previously populated when the option service contract was registered.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0361D010Hash = (HashMap<String, Object>)resultHash.get(TEMPLATE_ID_EKK0361D010)` // TEMPLATE_ID_EKK0361D010 = "EKK0361D010" |

**Block 5** — [SET] Set Option Service Contract number (L1928-L1929)

> Copies the option service contract number (the primary key from the prior registration) into the template.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0411D010CBSMsg.OP_SVC_KEI_NO, eKK0361D010Hash.get(EKK0361D010CBSMsg.OP_SVC_KEI_NO))` // Option service contract number |

**Block 6** — [SET] Set sub-option service code (L1932-L1933)

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0411D010CBSMsg.SBOP_SVC_CD, inHash.get(SBOP_SVC_CD))` // SBOP_SVC_CD = "sbop_svc_cd" |

**Block 7** — [SET] Set pricing course code (L1936-L1938)

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0411D010CBSMsg.PCRS_CD, pcrsCd)` // Pricing course code parameter |

**Block 8** — [SET] Set pricing plan code (L1941-L1943)

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0411D010CBSMsg.PPLAN_CD, pplanCd)` // Pricing plan code parameter |

**Block 9** — [SET] Set migration division (L1946-L1948)

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0411D010CBSMsg.IDO_DIV, inHash.get(IDO_DIV))` // IDO_DIV = "ido_div" — Migration division (new contract = "00001", service addition = "00002") |

**Block 10** — [SET] Set service start preferred date (L1951-L1953)

> Retrieves the current date using `getStrymd()` (service start date method).

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0411D010CBSMsg.SVC_USE_STA_KIBO_YMD, getStrymd())` // Service start preferred year-month-day |

**Block 11** — [SET] Extract email info confirmation list (L1958-L1966)

> Reads the list of email info confirmation items from `inHash` using the index `wK_INDEX` set by the caller. This list contains email address and mailbox capacity data entered at the screen.

| # | Type | Code |
|---|------|------|
| 1 | SET | `jKKEmailInfoAddCfmCCList = (ArrayList<HashMap<String, Object>>)inHash.get(JKKEMAILINFOADDCFMCCLIST)` // JKKEMAILINFOADDCFMCCLIST = "JKKEmailInfoAddCfmCCList" |
| 2 | SET | `jKKEmailInfoAddCfmCC = jKKEmailInfoAddCfmCCList.get(wK_INDEX)` // Get current list element |
| 3 | SET | `mladAccount = ""` // Initialize email account variable |

**Block 12** — [SET] Parse capacity values (L1969-L1972)

> Strips the "MG" unit suffix from capacity strings to prepare for integer arithmetic.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sCapa = jKKEmailInfoAddCfmCC.get(ML_BOX_CAPA).toString().replace("MG", "")` // ML_BOX_CAPA = "ml_box_capa" — Email boxes total capacity |
| 2 | SET | `sShkCapa = inHash.get(SHK_CAPA).toString().replace("MG", "")` // SHK_CAPA = "shk_capa" — Initial capacity |

**Block 13** — [IF] Check if pricing course is NOT Wireshake Check (L1975)
Condition: `!pcrsCd.equals("D03")` — `pcrsCd = "D03"` means Wireshake Check, which requires no email alias or capacity fields.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (!pcrsCd.equals("D03"))` // Not Wireshake Check — proceed with email/capacity processing |

**Block 13.1** — [IF] Check if pricing course is E-mail (L1978)
Nested inside Block 13. Condition: `pcrsCd = "D01"` — E-mail service type requires the email alias (address).

| # | Type | Code |
|---|------|------|
| 1 | IF | `if ("D01".equals(pcrsCd))` // D01 = E-mail pricing course |
| 2 | SET | `mailadAccount = jKKEmailInfoAddCfmCC.get(MLAD_ACCOUNT).toString()` // MLAD_ACCOUNT = "mlad_account" — Email address account (e.g., "user") |

**Block 13.2** — [IF] Check if pricing course is Docomo (L1983)
Nested inside Block 13. Condition: `pcrsCd = "D02"` — Docomo Wireshake Check service type requires additional capacity calculation.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if ("D02".equals(pcrsCd))` // D02 = Docomo pricing course |
| 2 | SET | `capa = Integer.parseInt(sCapa)` // Parse total capacity as integer |
| 3 | SET | `shkCapa = Integer.parseInt(sShkCapa)` // Parse initial capacity as integer |
| 4 | SET | `addCapa = String.valueOf(capa - shkCapa)` // Additional capacity = total - initial |

**Block 14** — [IF] Set email alias (L1990)
Condition: `mladAccount` is not empty — only set alias if the E-mail course was selected and an address was provided.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (!mailadAccount.equals(""))` // Set email alias if populated |
| 2 | SET | `template.set(EKK0411D010CBSMsg.ALIAS, mailadAccount)` // ALIAS = "alias" — Email address |

**Block 15** — [IF] Set additional capacity (L1997)
Condition: `addCapa` is not empty — only set additional capacity if the Docomo course was selected and a capacity delta was calculated.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (!addCapa.equals(""))` // Set additional capacity if calculated |
| 2 | SET | `template.set(EKK0411D010CBSMsg.ADD_CAPA, addCapa)` // ADD_CAPA = "add_capa" — Additional capacity (MB) |

**Block 16** — [SET] Set billing contract number (L2004-L2005)

> Retrieves the billing contract number from the KKSV0002 screen's result hash. This is the parent billing contract that the sub-option service registration is tied to.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0411D010CBSMsg.SEIKY_KEI_NO, inHash.get(KKSV0002_KKSV0002OP_KKSV000201CC.SEIKY_KEI_NO))` // SEIKY_KEI_NO = "seiky_kei_no" — Billing contract number |

**Block 17** — [SET] Set application detail number (L2008-L2010)

> Retrieves the application detail number from `resultHash` using `TEMPLATE_ID_EKK0021D010`. This links the sub-option service registration to the original application details acceptance record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0021d010Msg = (HashMap<?, ?>)resultHash.get(TEMPLATE_ID_EKK0021D010)` // TEMPLATE_ID_EKK0021D010 — Application Details Acceptance Registration |
| 2 | SET | `mskm_dtl_no = ekk0021d010Msg.get(EKK0021D010CBSMsg.MSKM_DTL_NO)` // MSKM_DTL_NO = "mskm_dtl_no" — Application detail number |
| 3 | SET | `template.set(EKK0411D010CBSMsg.MSKM_DTL_NO, mskm_dtl_no)` |

**Block 18** — [SET] Set last update datetime (L2013-L2014)

> Copies the service update datetime from the input hash. Used for optimistic concurrency control at the center.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK0411D010CBSMsg.UPD_DTM_BF, inHash.get(EX_SVC_UPD_DTM))` // EX_SVC_UPD_DTM = "ex_svc_upd_dtm" — Last update datetime before update |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `op_svc_kei_no` | Field | Option Service Contract Number — internal tracking ID for the top-level option service contract, registered via prior SC `EKK0361D010` |
| `sbop_svc_cd` | Field | Sub-Option Service Code — identifies the type of sub-option service being registered (e.g., email, wireshake check) |
| `pcrs_cd` | Field | Pricing Course Code — classifies the pricing plan type. Key branching values: `"D01"` (E-mail), `"D02"` (Docomo), `"D03"` (Wireshake Check) |
| `pplan_cd` | Field | Pricing Plan Code — specific pricing plan selection within a course |
| `ido_div` | Field | Migration Division — distinguishes the type of service change: `"00001"` (New Contract / SINKI), `"00002"` (Service Addition / TSUIKA) |
| `svc_use_sta_kibo_ymd` | Field | Service Start Preferred Year-Month-Day — the date the customer wishes for the service to begin |
| `mskm_dtl_no` | Field | Application Detail Number — links the sub-option registration to the original application details acceptance record (SC `EKK0021D010`) |
| `seiky_kei_no` | Field | Billing Contract Number — the parent billing contract to which this sub-option service is attached |
| `add_capa` | Field | Additional Capacity — calculated difference between total mailbox capacity and initial capacity (in MB) |
| `alias` | Field | Email Alias — the email address account portion (e.g., "user" in "user@example.com") |
| `upd_dtm_bf` | Field | Update Datetime Before — the last known update timestamp for optimistic concurrency control at the center |
| `mlad_account` | Field | Mail Address Account — the email account name extracted from the email info confirmation list |
| `ml_box_capa` | Field | Mail Boxes Capacity — total mailbox capacity including "MG" unit suffix (e.g., "1024MG") |
| `shk_capa` | Field | Initial Capacity — the starting mailbox capacity including "MG" unit suffix |
| `wK_INDEX` | Field | Working Key Index — instance field tracking the current index in the email info list during iteration |
| `TEMPLATE_ID_EKK0411D010` | Constant | Template ID = "EKK0411D010" — Service IF ID for Sub-Option Service Contract &lt;ISP&gt; Registration |
| `TEMPLATE_ID_EKK0361D010` | Constant | Template ID = "EKK0361D010" — Option Service Contract &lt;ISP&gt; Registration template ID, used to retrieve prior registration result |
| `TEMPLATE_ID_EKK0021D010` | Constant | Template ID = "EKK0021D010" — Application Details Acceptance Registration template ID |
| `FUNC_CODE` | Constant | Function Code = "func_code" — identifies the function being invoked |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity |
| ISP | Business term | Internet Service Provider — the sub-option service category for internet-related add-on services |
| CBS | Acronym | Center Business System — the central mainframe-based business system that processes service registrations |
| SC | Acronym | Service Component — a service-tier component that handles communication with the CBS |
| CAANMsg | Type | Fujitsu middleware message class used as the template/data carrier for CBS requests |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband service (relevant to the broader K-Opticom service portfolio) |
| D01 | Constant | Pricing course code for E-mail service |
| D02 | Constant | Pricing course code for Docomo Wireshake Check service |
| D03 | Constant | Pricing course code for Wireshake Check — skips all email alias and capacity fields |
| MG | Unit | Megabyte — unit suffix for capacity values that must be stripped before numeric comparison |
| KKSV0002 | Screen | The screen module for sub-option service contract &lt;ISP&gt; confirmation |
| KKSV000201CC | CC | Custom Component for KKSV0002 screen's operation processing |
| SINKI | Japanese term | SINKI (沉降) = Migration/Contract establishment — new contract migration |
| TSUIKA | Japanese term | TSUIKA (追加) = Addition — service addition migration |
