---
title: Business Logic — JKKTvSvcKeiCourceChgCC.execWrisvcAutoAply()
file: source/koptBp/ejbModule/com/fujitsu/futurity/bp/custom/common/JKKTvSvcKeiCourceChgCC.java
fqn: com.fujitsu.futurity.bp.custom.common.JKKTvSvcKeiCourceChgCC.execWrisvcAutoAply
loc: 75
---

# Business Logic — JKKTvSvcKeiCourceChgCC.execWrisvcAutoAply() [75 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKTvSvcKeiCourceChgCC.execWrisvcAutoAply` |
| Layer | CC / Common Component (business coordination class in the custom BP module) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKTvSvcKeiCourceChgCC.execWrisvcAutoAply()

This method is the **discount service auto-application preparation coordinator** within the K-Opticom customer base system. Its business purpose is to assemble a complete service-contract data structure that describes a target subscription (shinsei — 申込) for automatic discount application, then delegate the actual discount logic to `JKKWrisvcAutoAplyCC.execute()`. The method does not perform discount calculations itself — instead it acts as a **data adapter** that transforms the incoming `curSvcKeiInfo` (current service detail information) and `ccMsg` (command context message) into the canonical map format expected by the `JKKWrisvcAutoAplyCC` processing engine.

The method follows a **builder + delegation** design pattern: it constructs a work data structure (`workSvcKeiArray`) containing all contract identifiers (system ID, service contract number, service code, pricing group, course, plan), sets the submission type code to `00007` (service contract — 契約種別), sets the change division to `02` (update/change — 変更区分), and then hands off to `JKKWrisvcAutoAplyCC` which evaluates discount eligibility, applies applicable discounts, and manages the discount lifecycle (application, release, recovery).

This method serves as a **shared utility** called by multiple screen-operation and BPM classes during subscription modification flows. It is invoked when a service contract change, recovery, customer addition, or settlement modification triggers the need to auto-apply or re-evaluate discounts. The calling class at the source (`JKKTvSvcKeiCourceChgCC`) handles service source changes — contract rewrites — but the call site is currently commented out with the note "予約データ作成時は割引CCを実行しない" (Do not execute discount CC during reservation data creation).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execWrisvcAutoAply start"])

    START --> STEP1["Set workWrisvcAutoAplyDataKey = WrisvcAutoAplyCC"]
    STEP1 --> STEP2["Create empty HashMap for work data"]
    STEP2 --> STEP3["Get ccMsg from param.getData dataMapKey"]
    STEP3 --> STEP4["Get outMap from param.getData workWrisvcAutoAplyDataKey"]
    STEP4 --> STEP5["Extract func_code and ido_div from ccMsg"]
    STEP5 --> STEP6["Set sysid in outMap from curSvcKeiInfo"]
    STEP6 --> STEP7["Set add_chge_div to Change indicator 02"]
    STEP7 --> STEP8["Set mskm_no from parameter"]
    STEP8 --> STEP9["Set mskm_sbt_cd to 00007 Service Contract"]
    STEP9 --> STEP10["Set ido_div from ccMsg"]
    STEP10 --> STEP11["Set func_code from ccMsg"]
    STEP11 --> STEP12["Build workSvcKeiArray with svc_kei_list"]
    STEP12 --> STEP13["Set svc_kei_grp_list in outMap"]
    STEP13 --> STEP14["Create JKKWrisvcAutoAplyCC instance"]
    STEP14 --> STEP15["Execute JKKWrisvcAutoAplyCC.execute"]
    STEP15 --> END_NODE(["Return next"])
```

**Processing Summary:**

The method has no conditional branches — it is a **linear pipeline** of data assembly followed by delegation:

1. **Preparation phase** (L320-L323): Creates a dedicated work data key (`WrisvcAutoAplyCC`) and initializes an empty `HashMap<String, Object>` in the parameter data map. Then retrieves the command context message (`ccMsg`) and the output map (`outMap`) from the parameter store.

2. **Field extraction phase** (L326-L327): Extracts `func_code` (function code) and `ido_div` (movement/division code) from the command context message map.

3. **Output map population phase** (L329-L342): Populates the `outMap` with system identifiers, change division (`02` = Change — 変更区分), submission number, submission type code (`00007` = service contract — 契約種別コード), movement division, and function code.

4. **Service contract list assembly phase** (L343-L369): Builds a nested list structure — `workSvcKeiArray` containing `workSvcKeiMap` (group division `00`) containing `workSvcKeiList` with individual service contract data objects. Each service contract data object includes: system ID, target contract identification code (`01` = target — 対象), service contract number, service contract status, service code, pricing group code, pricing course code, pricing plan code, and all "before-change" equivalents (service code, pricing group, course, plan).

5. **Delegation phase** (L371-L376): Instantiates `JKKWrisvcAutoAplyCC` and calls `execute(handle, param, workWrisvcAutoAplyDataKey)`, passing the prepared work data. The removed comment on line 375 indicates that `param.removeData(workWrisvcAutoAplyDataKey)` was intentionally commented out ("コメントアウト" — comment out) to preserve the return message from the discount auto-application CC.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Application session handle carrying user context, transaction scope, and system settings for the K-Opticom BP framework. Provides database connections and thread-local session state. |
| 2 | `param` | `IRequestParameterReadWrite` | Bidirectional parameter carrier (request/response) used to pass data between the calling screen, operation classes, and component classes. Acts as a shared data map where components register and retrieve work data via string keys. The method writes the assembled discount application data under key `WrisvcAutoAplyCC` and reads the command context from `dataMapKey`. |
| 3 | `curSvcKeiInfo` | `CAANMsg` | Current service detail information object containing the active service contract record. This is the source of truth for service contract number (svc_kei_no), system ID (sysid), service contract status (svc_kei_stat), service code (svc_cd), pricing group code (prc_grp_cd), pricing course code (pcrs_cd), and pricing plan code (pplan_cd). Represents the contract whose discounts need to be re-evaluated after a source change. |
| 4 | `dataMapKey` | `String` | The key used to retrieve the command context message (`ccMsg`) from `param.getData()`. This map contains control data including `func_code` (function code indicating which screen/operation invoked this), `ido_div` (movement/division code indicating the type of change), `prc_grp_cd`, `pcrs_cd`, and `pplan_cd` (the new pricing values that may trigger different discounts). |
| 5 | `mskmNo` | `String` | Submission number (申込番号) — the unique identifier for the subscription/order request. This is the top-level key for the customer's service contract in the system. Used to identify which order's discounts are being auto-applied. |

**External state / fields read:**

None — this method does not read any instance fields. It is a pure static-style method that operates entirely on its parameters and local variables.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `param.setData` | - | - | Sets work data `WrisvcAutoAplyCC` (HashMap) in parameter map [L322] |
| R | `param.getData` | - | - | Retrieves command context map from `dataMapKey` [L325] |
| R | `param.getData` | - | - | Retrieves output map from `workWrisvcAutoAplyDataKey` [L326] |
| R | `curSvcKeiInfo.getString` | `EKK0081A010CBS` | Service Contract Entity (K_OPTSVKEI_ISP) | Reads sysid, svc_kei_no, svc_kei_stat, svc_cd, prc_grp_cd, pcrs_cd, pplan_cd from current service detail [L329, L349, L354, L358, L362, L365, L368] |
| C | `JKKWrisvcAutoAplyCC.execute` | `JKKWrisvcAutoAplyCC` | Multiple discount-related tables | Delegates to discount auto-application CC which performs create/update operations on discount service contracts and discount lifecycle tables (internal to JKKWrisvcAutoAplyCC) [L375] |

**How to classify:**
- **`param.setData/getData`**: Internal parameter map operations — not CRUD but data flow within the component.
- **`curSvcKeiInfo.getString(...)`**: Read operations against the CBS message object (`EKK0081A010CBSMsg1List`), which carries data from the service contract entity (contract line items). The CBS code is `EKK0081A010CBS`.
- **`JKKWrisvcAutoAplyCC.execute`**: The terminal call. This method is documented in its own DD and performs the actual discount application, which involves Create/Update/Read operations on discount-related database tables (discount service contracts, discount application history, contract-disklink relations, etc.).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class:JKKTvSvcKeiCourceChgCC | `execSvcKeiSourceChg` -> `execWrisvcAutoAply` | `JKKWrisvcAutoAplyCC.execute [C/R/U] discount tables` |
| 2 | Class:JCKCustAddBnktUpdCC | `execCustBnktUpd` -> `execWrisvcAutoAply` (9-param overload) | `JKKWrisvcAutoAplyCC.execute [C/R/U] discount tables` |
| 3 | Class:JKKTVSvcKeiKaihukuCC | `execKaihuku` -> `execWrisvcAutoAply` (6-param overload) | `JKKWrisvcAutoAplyCC.execute [C/R/U] discount tables` |
| 4 | Class:JKKKisnUwHmdkAddCC | `execKisnUwHmdkAdd` -> `execWrisvcAutoAply` (4-param overload) | `JKKWrisvcAutoAplyCC.execute [C/R/U] discount tables` |
| 5 | Class:JKKSeikyKeiHenkoCC | `execSeikyKeiHenko` -> `execWrisvcAutoAply` (commented out) | `JKKWrisvcAutoAplyCC.execute [C/R/U] discount tables` |

**Notes:**
- The specific 5-parameter overload `execWrisvcAutoAply(SessionHandle, IRequestParameterReadWrite, CAANMsg, String, String)` is defined in `JKKTvSvcKeiCourceChgCC` and is called from `execSvcKeiSourceChg` (line 300, currently commented out with reason "Do not execute discount CC during reservation data creation").
- Other calling classes use different method signatures (overloads with additional parameters) defined in their own classes.
- The `JKKWrisvcAutoAplyCC` is ultimately invoked by multiple BPM operations (FUSV0134OPOperation, FUSV0160Operation, KKSV0202OP_00Operation) and web screens (FUW00928SFLogic, FUW00943SFLogic) via mapper configuration.

## 6. Per-Branch Detail Blocks

This method has **no conditional branches** (no if/else, switch, loops, or try-catch). It is a purely linear pipeline. Below is the block-by-block analysis of each processing step.

---

**Block 1** — [SET] `(data key preparation)` (L320)

> Prepare a dedicated work data key for the discount application CC and initialize the storage.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workWrisvcAutoAplyDataKey = "WrisvcAutoAplyCC"` // Dedicated key for discount CC work data |

**Block 2** — [EXEC] `(create work data)` (L322)

> Register an empty HashMap in the parameter data map under the work data key.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.setData(workWrisvcAutoAplyDataKey, new HashMap<String, Object>())` // Initialize empty work data store |

**Block 3** — [CALL] `(retrieve command context)` (L325)

> Extract the command context message map from the parameter using the provided dataMapKey.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMsg = (HashMap<String, Object>)param.getData(dataMapKey)` // Cast to HashMap for access to func_code, ido_div, pricing fields |

**Block 4** — [CALL] `(retrieve output map)` (L326)

> Get the work output map that was just created, for populating with the discount application request data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outMap = (HashMap<String, Object>)param.getData(workWrisvcAutoAplyDataKey)` // Retrieved from data key set in Block 2 |

**Block 5** — [CALL] `(extract control fields)` (L327-L328)

> Extract the function code and movement division from the command context message.

| # | Type | Code |
|---|------|------|
| 1 | SET | `funcCode = (String) ccMsg.get("func_code")` // Function code — identifies which screen/operation triggered this |
| 2 | SET | `ido_div = (String) ccMsg.get("ido_div")` // Movement/division code — indicates the type of change (e.g., new registration, modification) |

**Block 6** — [EXEC] `(populate output map - system info)` (L329-L330)

> Set the system ID in the output map from the current service detail info.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outMap.put("sysid", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SYSID))` // System ID — identifies the system instance [-> EKK0081A010CBSMsg1List.SYSID] |

**Block 7** — [EXEC] `(populate output map - change division)` (L331-L332)

> Set the change division to indicate this is an update/change operation (not a new registration).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outMap.put("add_chge_div", "02")` // Change division — "02" = Change/Update (変更区分), "01" would be new registration |

**Block 8** — [EXEC] `(populate output map - submission info)` (L333-L338)

> Set the submission number, submission type code, movement division, and function code.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outMap.put("mskm_no", mskmNo)` // Submission number — the order/subscription identifier passed as parameter [-> mskmNo] |
| 2 | EXEC | `outMap.put("mskm_sbt_cd", "00007")` // Submission type code — "00007" = Service Contract (契約種別コード) |
| 3 | EXEC | `outMap.put("ido_div", ido_div)` // Movement division — from ccMsg, indicates the type of business operation |
| 4 | EXEC | `outMap.put("func_code", funcCode)` // Function code — from ccMsg, identifies the invoking screen/operation |

**Block 9** — [EXEC] `(build service contract list structure)` (L339-L369)

> Build the nested list structure for service contract data that will be passed to the discount application CC. This involves creating three levels of nesting: array -> map (group) -> list -> map (individual contract).

| # | Type | Code |
|---|------|------|
| 1 | SET | `workSvcKeiArray = new ArrayList<HashMap<String, Object>>()` // Top-level array: service contract group list |
| 2 | SET | `workSvcKeiMap = new HashMap<String, Object>()` // Group-level map |
| 3 | EXEC | `workSvcKeiMap.put("grp_div", "00")` // Group division — "00" = standard group |
| 4 | SET | `workSvcKeiList = new ArrayList<HashMap<String, Object>>()` // List of individual service contracts within the group |
| 5 | SET | `workSvcKeiData = new HashMap<String, Object>()` // Individual service contract data object |
| 6 | EXEC | `workSvcKeiData.put("sysid", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SYSID))` // System ID from current service info |
| 7 | EXEC | `workSvcKeiData.put("tg_kei_skbt_cd", "01")` // Target contract identification code — "01" = Target (対象契約識別コード) |
| 8 | EXEC | `workSvcKeiData.put("svc_kei_no", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_KEI_NO))` // Service contract number |
| 9 | EXEC | `workSvcKeiData.put("svc_kei_stat", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_KEI_STAT))` // Service contract status |
| 10 | EXEC | `workSvcKeiData.put("svc_cd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_CD))` // Service code (e.g., FTTH, Mail, ENUM) |
| 11 | EXEC | `workSvcKeiData.put("prc_grp_cd", ccMsg.get("prc_grp_cd"))` // Pricing group code — NEW value from ccMsg (after change) |
| 12 | EXEC | `workSvcKeiData.put("pcrs_cd", ccMsg.get("pcrs_cd"))` // Pricing course code — NEW value from ccMsg |
| 13 | EXEC | `workSvcKeiData.put("pplan_cd", ccMsg.get("pplan_cd"))` // Pricing plan code — NEW value from ccMsg |
| 14 | EXEC | `workSvcKeiData.put("chge_bf_svc_cd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_CD))` // Before-change service code |
| 15 | EXEC | `workSvcKeiData.put("chge_bf_prc_grp_cd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.PRC_GRP_CD))` // Before-change pricing group code |
| 16 | EXEC | `workSvcKeiData.put("chge_bf_pcrs_cd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.PCRS_CD))` // Before-change pricing course code |
| 17 | EXEC | `workSvcKeiData.put("chge_bf_pplan_cd", curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.PPLAN_CD))` // Before-change pricing plan code |

**Block 9.1** — [EXEC] `(finalize service contract list)` (L370-L372)

> Assemble the nested structure: individual contract -> contract list -> group map -> group list array -> output map.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `workSvcKeiList.add(workSvcKeiData)` // Add individual service contract data to the list |
| 2 | EXEC | `workSvcKeiMap.put("svc_kei_list", workSvcKeiList)` // Register the contract list in the group map |
| 3 | EXEC | `workSvcKeiArray.add(workSvcKeiMap)` // Register the group in the array |
| 4 | EXEC | `outMap.put("svc_kei_grp_list", workSvcKeiArray)` // Register the group list in the output map |

**Block 10** — [CALL] `(delegation to discount CC)` (L374-L375)

> Instantiate and execute the discount auto-application CC with the prepared work data. This is the terminal business operation that performs the actual discount evaluation and application.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wrisvcAutoAplyCC = new JKKWrisvcAutoAplyCC()` // Create discount auto-application CC instance |
| 2 | CALL | `wrisvcAutoAplyCC.execute(handle, param, workWrisvcAutoAplyDataKey)` // Delegate to discount CC with prepared data. Returns void. The CC internally handles discount eligibility, application, release, and recovery logic. |

**Block 10.1** — [COMMENT] `(preserve return data)` (L376-L377)

> The removal of work data is intentionally commented out to preserve the return message from the discount CC in the parameter map.

| # | Type | Code |
|---|------|------|
| 1 | COMMENT | `// param.removeData(workWrisvcAutoAplyDataKey);` // ため、コメントアウト (comment out) — Preserve the return message from JKKWrisvcAutoAplyCC for downstream use |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `execWrisvcAutoAply` | Method | Discount auto-application execution — assembles service contract data and delegates to the discount CC |
| `WrisvcAutoAplyCC` | Work key | Work data key string for the discount auto-application component. Stands for "Wireless/Remote Service Auto-Apply CC" |
| `func_code` | Field | Function code — identifies which screen or operation triggered the discount application (e.g., service source change, recovery, customer addition) |
| `ido_div` | Field | Movement/division code (移動区分) — indicates the type of business operation or change being performed |
| `add_chge_div` | Field | Registration/Change division (登録/変更区分) — "01" = New Registration, "02" = Change/Update. This method always uses "02". |
| `mskm_no` | Field | Submission number (申込番号) — unique identifier for the order/subscription request. Top-level key for a customer's service bundle. |
| `mskm_sbt_cd` | Field | Submission type code (申込種別コード) — "00007" = Service Contract (契約). Classifies the type of submission. |
| `sysid` | Field | System ID — identifies the specific system instance in the K-Opticom multi-system environment |
| `tg_kei_skbt_cd` | Field | Target contract identification code (対象契約識別コード) — "01" = Target. Identifies which contract line items are subject to discount processing. |
| `svc_kei_no` | Field | Service contract number (サービス契約番号) — unique identifier for a specific service contract line item. |
| `svc_kei_stat` | Field | Service contract status (サービス契約ステータス) — current status of the service contract (e.g., active, suspended, terminated). |
| `svc_cd` | Field | Service code (サービスコード) — identifies the type of service (e.g., FTTH fiber internet, Mail, ENUM VoIP, STB). |
| `prc_grp_cd` | Field | Pricing group code (料金グループコード) — groups pricing plans that share certain billing characteristics. Changed value from ccMsg represents the new pricing after a source change. |
| `pcrs_cd` | Field | Pricing course code (料金コースコード) — the specific pricing course/tariff for the service. |
| `pplan_cd` | Field | Pricing plan code (料金プランコード) — the specific pricing plan within a course. |
| `chge_bf_*` | Field prefix | "Before change" prefix — captures the service/pricing values before the change for audit trail and comparison. `chge_bf_svc_cd` = before-change service code, etc. |
| `grp_div` | Field | Group division (グループ区分) — "00" = standard group. Used to categorize service contracts within the discount application data structure. |
| `svc_kei_grp_list` | Field | Service contract group list — the top-level key in outMap that holds the complete service contract data structure for the discount CC. |
| `ccMsg` | Field | Command context message — a HashMap containing control data passed from the calling screen/operation, including function code, movement division, and new pricing values. |
| `curSvcKeiInfo` | Parameter | Current service detail information — CAANMsg object carrying the active service contract record data from the CBS (EKK0081A010CBS). |
| `EKK0081A010CBS` | CBS Code | Service detail information CBS (サービス詳細情報CBS) — the CBS that provides the current service contract data. CBSMsg1List defines the field accessors. |
| `JKKWrisvcAutoAplyCC` | Class | Discount auto-application CC — the actual discount processing component that evaluates eligibility, applies discounts, and manages the discount lifecycle. The terminal business logic invoked by this method. |
| FTTH | Business term | Fiber To The Home — fiber-optic internet service offered by K-Opticom. |
| ENUM | Business term | ENUM VoIP service — internet telephony service using the ENUM (E.164 Number Mapping) protocol. |
| BP | Acronym | Business Process — the Fujuru Futurity BP framework used for business logic implementation in this system. |
| CC | Acronym | Common Component / Control Class — a reusable business coordination class in the K-Opticom architecture. |
| CBS | Acronym | Component Business Service — the data access component that interfaces with database tables. |
| SC | Acronym | Service Component — a data processing component layer between CBS and CC. |
