# (DD08) Business Logic — JFUSetVariTsushinKikiMskmCC.setInMapWrSvAtAplyNoPlanChg() [59 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JFUSetVariTsushinKikiMskmCC` |
| Layer | CC (Common Component) — a shared business logic utility class within the `bp.custom` layer |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JFUSetVariTsushinKikiMskmCC.setInMapWrSvAtAplyNoPlanChg()

This method populates a nested map structure used for **discount service automatic registration** (割引サービス自動登録CC用マップ設定). It is part of the equipment provision service contract application workflow (機器提供サービス契約申請処理) where, after registering an equipment provision service contract and its verification, the system automatically applies eligible discount services to the customer's subscription plan without requiring a separate plan change process.

The method constructs a hierarchical data structure consisting of a work map (`wrSvMap`) containing a service contract group list (`svc_kei_grp_list`), where each group contains a list of service contract details. This structure encodes all the information needed by downstream components (specifically the `FUSV013409CC` mapping layer) to automatically register discount services against the customer's equipment provision service contract.

It handles a **single service type**: equipment provision service (機器提供サービス, code `C015`), with sub-type `02`. The method does not branch by service type — it always builds the same fixed structure. Its role in the larger system is as a **data preparation/transformer** step, called after equipment provision service contract registration (`setInMapKktkRegist` / `executeSC`) and contract verification (`setInMapKktkShosa` / `executeSC`) complete, feeding the discount service registration pipeline with pre-assembled data.

The method includes an **early-exit guard**: if the work map is not yet initialized (null), it returns immediately without processing. This ensures the method is safe to call at any point during the application flow, not only after the work map has been explicitly prepared.

The `pcrsCd` (price course code) and `pplanCd` (price plan code) parameters were added as part of modification `ANK-3825-00-00`, enabling the discount service registration to be aware of the specific pricing configuration for the subscription plan.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setInMapWrSvAtAplyNoPlanChg"])
    START --> GET_MAP["Get wrSvMap from param.getData"]
    GET_MAP --> CHECK_NULL{wrSvMap is null}
    CHECK_NULL -->|Yes| EARLY_RETURN["Return early null guard"]
    CHECK_NULL -->|No| CREATE_LISTS["Create svcKeiGrpList and svcKeiList ArrayLists"]
    CREATE_LISTS --> SET_COMMON["Set common items in wrSvMap"]
    SET_COMMON --> CREATE_GRP["Create svcKeiGrpMap set grp_div standard"]
    CREATE_GRP --> CREATE_SVC["Create svcKeiMap set service contract fields"]
    CREATE_SVC --> SET_PRICING["Set pricing fields pcrs_cd pplan_cd"]
    SET_PRICING --> BUILD_NESTED["Build nested structure list and map nesting"]
    BUILD_NESTED --> SET_RESULT["Set svcKeiGrpList in wrSvMap put svc_kei_grp_list"]
    SET_RESULT --> END_NODE(["Return Next"])
    EARLY_RETURN --> END_NODE
    START --> GET_MAP
    GET_MAP --> CHECK_NULL
    CHECK_NULL --> EARLY_RETURN
    CHECK_NULL --> CREATE_LISTS
    CREATE_LISTS --> SET_COMMON
    SET_COMMON --> CREATE_GRP
    CREATE_GRP --> CREATE_SVC
    CREATE_SVC --> SET_PRICING
    SET_PRICING --> BUILD_NESTED
    BUILD_NESTED --> SET_RESULT
    SET_RESULT --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Request parameter container holding application-scoped data. Used to retrieve the discount service work map via key `FUSV013409CC` and to populate the final `svc_kei_grp_list` for downstream consumption. |
| 2 | `fixedText` | `String` | Service message string (used for logging/error messages in the caller; not directly used within this method but passed for consistency with other map-setting methods). |
| 3 | `mskmNo` | `String` | Application number (申込番号) — the unique identifier for the equipment application/proposal. Used as `mskm_no` in the discount service registration map. |
| 4 | `sendKktkSvcKeiNo` | `String` | Equipment provision service contract number (機器提供サービス契約番号) — the contract ID assigned when the equipment provision service was registered. Used as `kktk_svc_kei_no` to identify the target service contract for discount registration. |
| 5 | `pcrsCd` | `String` | Price course code (料金コースコード) — the tariff/course classification for the service. Added in modification ANK-3825-00-00 to enable pricing-aware discount application. |
| 6 | `pplanCd` | `String` | Price plan code (料金プランコード) — the specific pricing plan applied to the subscription. Added in modification ANK-3825-00-00 alongside `pcrsCd` to pass complete pricing context to the discount service auto-registration. |

### Instance fields / external state accessed:
- **None directly** — this method is pure in its external dependencies. All state flows through the `param` parameter (specifically the `FUSV013409CC` key in its data store).

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `param.getData("FUSV013409CC")` | — | — | Reads the discount service work map from the request parameter data store. The key `FUSV013409CC` references the mapping component responsible for discount service data. |

**Note:** This method performs **no direct database operations**. It is a pure in-memory data preparation step. The `param.getData()` call reads a HashMap that was previously populated by the `FUSV013409_FUSV0134OPDBMapper` component (which handles the actual database mapping for discount service registration). All `put()` and `add()` operations in this method manipulate local `HashMap` and `ArrayList` objects before storing the result back into `param`'s data store for downstream consumption.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0004 | `KKSV0004Logic` -> `...` -> `JFUSetVariTsushinKikiMskmCC.setKkOpSvcKeiToroku` -> `setInMapWrSvAtAplyNoPlanChg` | `param.getData(FUSV013409CC) [R] —` |

**Call chain detail:**
The method `setInMapWrSvAtAplyNoPlanChg(IRequestParameterReadWrite, String, String, String, String, String)` at line 3451 is called from within `JFUSetVariTsushinKikiMskmCC` at line 1433, from the same class. It is invoked during the equipment provision service contract registration flow, after the contract registration (`setInMapKktkRegist` / `executeSC`) and contract verification (`setInMapKktkShosa` / `executeSC`) have completed successfully. The calling context is inside a loop processing equipment provision service contract details (lines ~1191–1433), and this call is one of the final data preparation steps before returning from the equipment provision service registration processing block.

The caller at line 1433: `setInMapWrSvAtAplyNoPlanChg(param, fixedText, mskmNo, sendKktkSvcKeiNo, inParamPcrsCd, inParamPplanCd);`

**Note:** There are similarly named overloaded methods `setInMapWrSvAtAplyNoPlanChg` in `JFUSmartLinkAddCC`, `JFUAddStkStbCC`, and `JFUEoMusenRtMskmCC`, but these have different method signatures (fewer parameters) and are separate implementations. The 6-parameter version documented here is unique to `JFUSetVariTsushinKikiMskmCC`.

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(wrSvMap == null null-guard)` (L3459)

> Null guard: if the work map for discount service registration has not been initialized by the caller, exit early to avoid NullPointerException.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `HashMap wrSvMap = (HashMap)param.getData("FUSV013409CC")` // Retrieve work map from param |
| 2 | IF | `if (wrSvMap == null)` // Null guard for work map existence |
| 3 | RETURN | `return;` // Exit early if work map is not initialized |

---

**Block 2** — PROCESSING (L3463–L3465)

> Create the list containers for the nested service contract group structure.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ArrayList svcKeiGrpList = new ArrayList();` // Service contract group list |
| 2 | SET | `ArrayList svcKeiList = new ArrayList();` // Service contract detail list |

---

**Block 3** — PROCESSING: Set Common Items (L3469–L3477)

> Populate the work map with common/discriminator fields that apply across all discount service registration scenarios.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wrSvMap.put("add_chge_div", JFUStrConst.WRISVC_ADD_CHGE_DIV_TOROKU)` // add_chge_div = "01" (Registration) [-> WRISVC_ADD_CHGE_DIV_TOROKU="01" (JFUStrConst.java:11136)] |
| 2 | SET | `wrSvMap.put("mskm_no", mskmNo)` // Application number from caller parameter |
| 3 | SET | `wrSvMap.put("mskm_sbt_cd", JFUStrConst.KK0971_MSKM_SBT_CD_00022)` // Application type = "00022" (Equipment contract change application) [-> KK0971_MSKM_SBT_CD_00022="00022" (JFUStrConst.java:8424)] |
| 4 | SET | `wrSvMap.put("ido_div", JFUStrConst.CD00576_00026)` // Modification division = "00026" (Equipment contract change) [-> CD00576_00026="00026" (JFUStrConst.java:3922)] |

---

**Block 4** — PROCESSING: Create Service Contract Group Map (L3479–L3483)

> Build the group-level map with the standard contract group discriminator.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap svcKeiGrpMap = new HashMap();` // Service contract group map |
| 2 | SET | `svcKeiGrpMap.put("grp_div", JFUStrConst.WRISVC_GRP_DIV_KIJYUN)` // grp_div = "00" (Standard Contract) [-> WRISVC_GRP_DIV_KIJYUN="00" (JFUStrConst.java:11138)] |

---

**Block 5** — PROCESSING: Create Service Contract Map (L3485–L3495)

> Build the service contract detail map with fields identifying the equipment provision service contract and its state.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap svcKeiMap = new HashMap();` // Service contract detail map |
| 2 | SET | `svcKeiMap.put("tg_kei_skbt_cd", JFUStrConst.WRISVC_TG_KEI_SKBT_CD_KKTK)` // tg_kei_skbt_cd = "06" (Equipment provision service contract) [-> WRISVC_TG_KEI_SKBT_CD_KKTK="06" (JFUStrConst.java:11140)] |
| 3 | SET | `svcKeiMap.put("kktk_svc_kei_no", sendKktkSvcKeiNo)` // Equipment provision service contract number from caller |
| 4 | SET | `svcKeiMap.put("kktk_svc_kei_stat", JFUStrConst.CD00056_020)` // Service status = "020" [-> CD00056_020="020" (JFUStrConst.java:944)] |
| 5 | SET | `svcKeiMap.put("kktk_svc_cd", JFUStrConst.KK0771_KKTK_SVC_CD_C015)` // Service code = "C015" (Equipment provision service) [-> KK0771_KKTK_SVC_CD_C015="C015"] |
| 6 | SET | `svcKeiMap.put("kktk_sbt_cd", JFUStrConst.CD00212_02)` // Service sub-type = "02" [-> CD00212_02="02" (JFUStrConst.java:2191)] |

---

**Block 6** — PROCESSING: Set Pricing Fields (L3496–L3499) // ANK-3825-00-00 MOD START/END

> Set pricing-specific fields passed from the caller. This block was added by modification ANK-3825-00-00 to enable pricing-aware discount service registration.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiMap.put("pcrs_cd", pcrsCd)` // Price course code from caller [ANK-3825-00-00] |
| 2 | SET | `svcKeiMap.put("pplan_cd", pplanCd)` // Price plan code from caller [ANK-3825-00-00] |

---

**Block 7** — PROCESSING: Build Nested Structure (L3501–L3508)

> Assemble the hierarchical data structure and attach it to the work map. The nesting is: svcKeiMap -> svcKeiList -> svcKeiGrpMap -> svcKeiGrpList -> wrSvMap.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `svcKeiList.add(svcKeiMap)` // Attach service contract detail to list |
| 2 | SET | `svcKeiGrpMap.put("svc_kei_list", svcKeiList)` // Attach list to group map |
| 3 | EXEC | `svcKeiGrpList.add(svcKeiGrpMap)` // Attach group map to group list |
| 4 | SET | `wrSvMap.put("svc_kei_grp_list", svcKeiGrpList)` // Store final structure in work map |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `wrSvMap` | Field | Work Service Map — temporary data structure for assembling discount service registration information |
| `svc_kei_grp_list` | Field | Service Contract Group List — top-level list containing service contract group entries for discount registration |
| `svc_kei_list` | Field | Service Contract List — nested list containing individual service contract detail maps within a group |
| `add_chge_div` | Field | Add/Change Division — discriminator for whether this is a registration ("01") or modification ("02") operation |
| `mskm_no` | Field | Application Number (申込番号) — unique identifier for the equipment application/proposal in the system |
| `mskm_sbt_cd` | Field | Application Sub-type Code (申込種別コード) — classifies the type of application; "00022" means Equipment Contract Change Application (機器契約変更申請) |
| `ido_div` | Field | Modification Division (異動区分) — identifies the type of modification; "00026" means Equipment Contract Change (機器契約変更) |
| `grp_div` | Field | Group Division (グループ区分) — classifies the service contract group; "00" means Standard Contract (基本契約) |
| `tg_kei_skbt_cd` | Field | Target Service Contract Sub-type Code (対象契約識別コード) — identifies the target contract type; "06" means Equipment Provision Service Contract (機器提供サービス契約) |
| `kktk_svc_kei_no` | Field | Equipment Provision Service Contract Number (機器提供サービス契約番号) — the contract ID assigned to the equipment provision service |
| `kktk_svc_kei_stat` | Field | Equipment Provision Service Contract Status (機器提供サービス契約ステータス) — current status of the service contract; "020" is the active/processing status |
| `kktk_svc_cd` | Field | Equipment Provision Service Code (機器提供サービスコード) — service classification code; "C015" identifies the Equipment Provision Service (機器提供サービス) |
| `kktk_sbt_cd` | Field | Equipment Provision Sub-type Code (機器提供種別コード) — sub-type of equipment provision service; "02" identifies a specific service variant |
| `pcrs_cd` | Field | Price Course Code (料金コースコード) — the tariff/course classification for the service contract |
| `pplan_cd` | Field | Price Plan Code (料金プランコード) — the specific pricing plan applied to the subscription |
| `FUSV013409CC` | Constant/Key | Work map key referencing the discount service registration mapping component (割引サービス自動登録CC) |
| WRISVC_ADD_CHGE_DIV_TOROKU | Constant | "01" — Registration mode (登録) for add/change division |
| KK0971_MSKM_SBT_CD_00022 | Constant | "00022" — Application type code for Equipment Contract Change Application (機器契約変更申請) |
| CD00576_00026 | Constant | "00026" — Modification division code for Equipment Contract Change (機器契約変更) |
| WRISVC_GRP_DIV_KIJYUN | Constant | "00" — Group division code for Standard Contract (基本契約) |
| WRISVC_TG_KEI_SKBT_CD_KKTK | Constant | "06" — Target service contract sub-type code for Equipment Provision Service Contract (機器提供サービス契約) |
| CD00056_020 | Constant | "020" — Service contract status code (active/processing state) |
| KK0771_KKTK_SVC_CD_C015 | Constant | "C015" — Equipment Provision Service Code (機器提供サービスコード) |
| CD00212_02 | Constant | "02" — Equipment Provision Service Sub-type Code (機器提供種別コード) |
| ANK-3825-00-00 | Change ticket | Modification that added `pcrsCd` and `pplanCd` parameters to enable pricing-aware discount service registration |
