# Business Logic — JKKKikiIchiranKkUpdCC.execKikiUpdateWrisvc() [88 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKKikiIchiranKkUpdCC` |
| Layer | CC / Common Component (Controller Component layer within the custom business package) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKKikiIchiranKkUpdCC.execKikiUpdateWrisvc()

This method is a **discount common component dispatcher** responsible for invoking the appropriate discount calculation and processing routines after equipment provision service contract data has been updated. It operates at the intersection of the equipment registration update flow and the discount billing subsystem, acting as a post-update orchestration point. The method first gathers service contract status and equipment change context from pre-loaded temporary data (loaded by the calling CBS as part of the agreement meeting flow), then branches into two main processing paths. When the system detects a planned service contract processing scenario — specifically, equipment changes from STB to STB with a TV course fee modification — it calls the **service contract details agreement meeting** (EKK0161A010) and subsequently invokes the **discount CC for processing mid-fees plan change** (`execSvcKeiUcwkTetudukiPplan`). There is a dormant second path gated by `FUNC_CODE_1 = "1"` (check & registration mode) which is currently commented out but was designed to handle equipment provision service contract cancellation and registration discount calculations. The method implements a **routing/dispatch design pattern**, delegating domain-specific discount logic to specialized CC methods while maintaining a single entry point for the equipment update flow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execKikiUpdateWrisvc"])
    READ_CC_MSG["Read ccMsg from param.getData"]
    EXTRACT_FUNC["Extract func_code from ccMsg"]
    READ_WORK_MAP["Read workMap from param.getMappingWorkArea"]
    READ_SVC_CONTRACT["Read service contract template EKK0081A010"]
    GET_SVC_STAT["Get svcKeiStat from contract message"]
    GET_MSKM["Get mskmNo via getMskmNoSvcKei"]
    READ_EQUIP_CONTRACT["Read equipment provision contract template EKK0341A010"]
    CHECK_PPLAN{"isSvcKeiUcwkTetudukiPplan"}
    GET_SVC_UCWK_NO["Get svcKeiUcwkNo from EKK0341A010"]
    CALL_MEETING["Call EKK0161A010 SC - Service Contract Agreement Meeting"]
    CALL_DISCOUNT_PLAN["Call execSvcKeiUcwkTetudukiPplan - Discount CC for processing mid-fees"]
    CHECK_FUNC1{"FUNC_CODE_1"}
    END_NODE(["Return"])

    START --> READ_CC_MSG --> EXTRACT_FUNC --> READ_WORK_MAP
    READ_WORK_MAP --> READ_SVC_CONTRACT --> GET_SVC_STAT --> GET_MSKM
    GET_MSKM --> READ_EQUIP_CONTRACT --> CHECK_PPLAN
    CHECK_PPLAN --> |true| GET_SVC_UCWK_NO --> CALL_MEETING --> CALL_DISCOUNT_PLAN --> CHECK_FUNC1
    CHECK_PPLAN --> |false| CHECK_FUNC1
    CHECK_FUNC1 --> |true| END_NODE
    CHECK_FUNC1 --> |false| END_NODE
```

**Processing Summary:**

The method executes a linear data-gathering phase followed by two conditional dispatch branches. First, it extracts the function code from the CC message map, retrieves the work area mapping, and reads two pre-loaded template messages from temporary data: the service contract agreement meeting (EKK0081A010) and the equipment provision service contract (EKK0341A010). It fetches the service contract status and a master key serial number via `getMskmNoSvcKei`.

**Branch 1 — Service Contract Processing Plan Check (line 1536):** If `isSvcKeiUcwkTetudukiPplan()` returns true (indicating the equipment change involves STB-to-STB transfer with a TV course modification), the method extracts the service contract details work number (`svcKeiUcwkNo`) from the pre-update equipment provision contract, calls the service contract details agreement meeting SC (EKK0161A010) with function code "2" to obtain updated agreement data, then invokes the discount CC for processing mid-fees plan change with the results.

**Branch 2 — Check & Registration Mode (line 1578):** When `FUNC_CODE_1` equals `"1"` (the check & registration function code), the method enters a dormant code block. All logic within this branch is commented out, including equipment cancellation checks, discount calculations for equipment provision service contract registration, and STB-specific service contract registration.

**Dormant branches (commented out):** There are two additional commented-out branches: (a) `isTvCancelUpdateCondition` for STB-to-non-STB equipment changes triggering a service contract details cancellation discount, and (b) `isKktkSvcKeiCancel` within the FUNC_CODE_1 block for equipment provision service contract cancellation and subsequent registration discount processing.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transaction and database connection context for SC invocations within this method. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service component invocation gateway used to dispatch the EKK0161A010 SC call for the service contract details agreement meeting. |
| 3 | `param` | `IRequestParameterReadWrite` | Request parameter carrier carrying the CC message map (`ccMsg`) containing `func_code` and operational date, plus the work area mapping for inter-component data exchange. |
| 4 | `dataMapKey` | `String` | Key identifier used to retrieve and store data within the request parameter's internal data map — the namespace for `ccMsg` and other CC-specific data blocks. |
| 5 | `temporaryData` | `HashMap<String, Object>` | Pre-populated transient data store holding template messages pre-loaded by the calling CBS. Contains `EKK0081A010` (service contract agreement data with `svc_kei_stat`) and `EKK0341A010` (pre-update equipment provision contract with `svc_kei_ucwk_no` and `kktk_svc_cd`). |

**External state read by the method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `TEMPLATE_ID_EKK0081A010` | `static final String` | Constant `"EKK0081A010"` — template ID for the service contract agreement meeting, used to retrieve pre-loaded service contract data from `temporaryData`. |
| `TEMPLATE_ID_EKK0341A010` | `static final String` | Constant `"EKK0341A010"` — template ID for the equipment provision service contract agreement meeting, used to retrieve pre-update equipment and service code data. |
| `TEMPLATE_ID_EKK0161A010` | `static final String` | Constant `"EKK0161A010"` — template ID for the service contract details agreement meeting, used as the template ID in the EKK0161A010 SC call. |
| `FUNC_CODE_1` | `static final String` | Constant `"1"` — represents the "check & registration" function code mode; triggers a dormant discount CC dispatch path. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKKikiIchiranKkUpdCC.getNullToStr` | - | - | Utility null-to-empty-string conversion for extracted values |
| R | `JKKKikiIchiranKkUpdCC.getMskmNoSvcKei` | - | - | Retrieves the master key serial number for service contract identification |
| R | `JKKKikiIchiranKkUpdCC.isSvcKeiUcwkTetudukiPplan` | - | - | Checks whether service contract processing plan conditions are met (STB-to-STB with TV course change) |
| R | `EKK0161A010CBSMsg.getString` | EKK0161A010 | EKK_SVC_KEI_UCWK (Service Contract Details Work table) | Reads `SVC_KEI_STAT` (service contract status) from pre-loaded agreement meeting data |
| R | `EKK0341A010CBSMsgMsg1List.getString` | EKK0341A010 | EKK_KKTK_SVC (Equipment Provision Service Contract table) | Reads `SVC_KEI_UCWK_NO` (service contract details work number) from pre-update equipment provision contract |
| C/R | `EKK0161A010SC` (via `callSC`) | EKK0161A010 | EKK_SVC_KEI_UCWK, EKK_SVC_KEI_UCWK_DTL (Service Contract Details Work / Detail tables) | Calls the service contract details agreement meeting SC with function code "2" (inquiry), retrieving updated agreement meeting data list including processing mid-fee plan change records. Input: `TEMPLATE_ID`, `FUNC_CODE="2"`, `KEY_SVC_KEI_UCWK_NO` (from pre-update contract), `KEY_GENE_ADD_DTM` (empty), `KEY_RSV_APLY_YMD` (operational date from ccMsg). |
| - | `JKKKikiIchiranKkUpdCC.execSvcKeiUcwkTetudukiPplan` | - | - | Invokes the discount CC for service contract details processing mid-fees plan change — calculates and applies discount pricing when TV course fees change during STB-to-STB equipment replacement |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class:JKKKikiIchiranKkUpdCC | `JKKKikiIchiranKkUpdCC.execKikiIchiranKikiUpd()` -> `execKikiUpdateWrisvc()` | `callSC [R] EKK0161A010 (EKK_SVC_KEI_UCWK)`, `execSvcKeiUcwkTetudukiPplan [-]` |

**Note:** No direct screen (KKSV) or batch (KKSV/KKB) entry points were found within 8 hops of this method. It is a private/common component method called exclusively by its owning class's `execKikiIchiranKikiUpd()` method, which is the main equipment registration update coordinator.

## 6. Per-Branch Detail Blocks

### Block 1 — SETUP `(data extraction phase)` (L1510-L1534)

> Extract function code, work area mapping, service contract status, and master key serial number from parameters and temporary data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMsg = (HashMap)param.getData(dataMapKey)` // Retrieve CC message map |
| 2 | SET | `func_code = (String)ccMsg.get("func_code")` // Extract function code identifier |
| 3 | SET | `workMap = param.getMappingWorkArea()` // Read work area mapping (unused locally) |
| 4 | SET | `ekk0081a010cbsMsg = (CAANMsg)temporaryData.get(TEMPLATE_ID_EKK0081A010)` // [-> "EKK0081A010"] Service contract agreement meeting message |
| 5 | SET | `svcKeiStat = getNullToStr(ekk0081a010cbsMsg.getString(EKK0081A010CBSMsg1List.SVC_KEI_STAT))` // Service contract status |
| 6 | CALL | `mskmNo = getMskmNoSvcKei(handle, scCall, param, dataMapKey, temporaryData)` // Retrieve master key serial number |
| 7 | SET | `ekk0341a010cbsMsg = (CAANMsg)temporaryData.get(TEMPLATE_ID_EKK0341A010)` // [-> "EKK0341A010"] Equipment provision service contract message |

### Block 2 — IF `isSvcKeiUcwkTetudukiPplan(param, dataMapKey, temporaryData)` `(STB-to-STB with TV course change processing)` (L1536)

> When service contract processing plan conditions are met (equipment change from STB to STB with TV course fee modification), execute the service contract details agreement meeting and discount plan CC.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiUcwkNo = getNullToStr(ekk0341a010cbsMsg.getString(EKK0341A010CBSMsg1List.SVC_KEI_UCWK_NO))` // Pre-update service contract details work number |
| 2 | SET | `ekk0161a010IN = { {TEMPLATEID, TEMPLATE_ID_EKK0161A010}, {FUNC_CODE, "2"}, {KEY_SVC_KEI_UCWK_NO, svcKeiUcwkNo}, {KEY_GENE_ADD_DTM, ""}, {KEY_RSV_APLY_YMD, ccMsg.get("unyo_ymd")} }` // [-> "EKK0161A010"] Agreement meeting SC input array |
| 3 | CALL | `ekk0161a010cbsMsg1list = callSC(handle, scCall, param, dataMapKey, ekk0161a010IN).getCAANMsgList(EKK0161A010CBSMsg.EKK0161A010CBSMSG1LIST)` // [EKK0161A010] SC call — service contract details agreement meeting |
| 4 | CALL | `execSvcKeiUcwkTetudukiPplan(handle, scCall, param, dataMapKey, temporaryData, ekk0161a010cbsMsg1list[0], mskmNo)` // Discount CC — processing mid-fees plan change |

### Block 3 — IF `isTvCancelUpdateCondition(...)` `(DORMANT: STB-to-non-STB cancellation discount)` (L1558)

> Dormant branch: would handle equipment changes from STB to non-STB, triggering service contract details cancellation discount. Commented out — no longer supported.

### Block 4 — IF `FUNC_CODE_1.equals(func_code)` `(check & registration mode)` (L1578)

> When the function code is "1" (check & registration mode), enter a code path for equipment provision service contract cancellation and registration discounts. All logic within this block is currently commented out.

| # | Type | Code |
|---|------|------|
| 1 | — | *(All code is commented out — dormant)* |
| 1.1 | — | `isKktkSvcKeiCancel(...)` — would check for equipment provision service contract cancellation |
| 1.2 | — | `execKktkSvcKeiCancel(...)` — would call discount CC for equipment provision service contract cancellation |
| 1.3 | — | Retrieve `create_list` from `KIKI_CREATE_CC_PARAM` — would fetch equipment registration data |
| 1.4 | — | `getKktkSvcKeiData(...)` — would extract equipment provision service contract data |
| 1.5 | — | `execKktkSvcKeiInfoToroku(...)` — would call discount CC for equipment provision service contract information registration |
| 1.6 | — | `isStb(...)` — would check if equipment is STB type |
| 1.7 | — | `execSvcKeiUcwkEoTvToroku(...)` — would register service contract details for <eo optical TV> if STB |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `func_code` | Field | Function code — distinguishes between "1" (check & registration) and "2" (inquiry/update) operational modes in the CC message |
| `svc_kei_stat` | Field | Service contract status — indicates the current state of a service contract (e.g., completed, in progress) |
| `svc_kei_ucwk_no` | Field | Service contract details work number — internal tracking ID for service contract line item processing |
| `kktk_svc_cd` | Field | Equipment provision service code — classifies the type of equipment service provided to the customer |
| `mskm_no` | Field | Master key serial number — unique identifier linking all service contracts for a single customer |
| `unyo_ymd` | Field | Operational date — the date when the service change takes effect |
| `tv_course` | Field | TV course/plan — the television service plan/fee tier the customer subscribes to |
| `EKK0081A010` | Template ID | Service contract agreement meeting — CBS template for reading the master service contract status |
| `EKK0341A010` | Template ID | Equipment provision service contract agreement meeting — CBS template for pre-update equipment and service code data |
| `EKK0161A010` | Template ID / SC Code | Service contract details agreement meeting — SC invoked to process service contract detail agreement when processing mid-fees change |
| `EKK0161C100` | Template ID | Service contract details processing mid-fees plan change — template for the discount CC that handles plan changes |
| `STB` | Acronym | Set-Top Box — the customer premise equipment for receiving television/broadband services |
| `ccMsg` | Field | CC (Common Component) message map — carries function code, operational date, and TV course data between CC components |
| `temporaryData` | Field | Transient data store — holds template messages pre-loaded by the calling CBS before CC execution |
| `isSvcKeiUcwkTetudukiPplan` | Method | Service contract details processing plan check — determines if the equipment change involves STB-to-STB with TV course fee modification, triggering the discount CC |
| `execSvcKeiUcwkTetudukiPplan` | Method | Service contract details processing mid-fees plan change — discount CC that calculates and applies discount pricing for processing mid-fees when TV course fees change |
| `execKikiIchiranKikiUpd` | Method | Equipment registration list update — the calling CBS method that coordinates the overall equipment registration update flow |
| PPlan | Abbreviation | Processing Plan — refers to "processing mid-fees" (処理途中料金) charges associated with service contract changes |
