# Business Logic — JKKTvSvcKeiCourceChgCC.addMkjAddfKeiRvStarCh2() [57 LOC]

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

## 1. Role

### JKKTvSvcKeiCourceChgCC.addMkjAddfKeiRvStarCh2()

This method registers a **"registration-impossible-at-order-time contract reservation"** (申込時登録不可契約予約) for a service contract during a course change operation. It handles the business scenario where a service contract cannot be immediately registered at the time the order is placed — for example, when the customer subscribes to a Digital/BS channel set and the contract activation must be deferred until a later timing (such as when the course change completes).

The method follows a **two-phase SC query-then-register** pattern. First, it performs a read operation on the order detail confirmation table (EKK0021A010) to retrieve the latest update timestamp (`last_upd_dtm`) of the order detail, ensuring data consistency for the subsequent write. Then, it constructs a comprehensive reservation payload (EKK2931D010) that captures all attributes of the deferred contract — service type code (Digital/BS channel set = `01`), service contract number, discount service code, pricing plan, reservation count, and reflection timing (course change completion = `02`).

This method is a **shared common component utility** called from `courceChange()` within the same class. It serves as the bridge between the course-change orchestration logic and the underlying service component layer, translating business-level course-change intents into concrete contract reservation records.

## 2. Processing Pattern (Detailed Business Logic)

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

    GET_MAPP["Get JKKAdchgMapperCC instance"]
    GET_SC["New ServiceComponentRequestInvoker"]
    COND_EKK0021["EKK0021A010 Read
Order details inquiry"]
    SET_EKK0021["Set EKK0021A010 request
condMap with mskm_dtl_no"]
    RUN_EKK0021["Run EKK0021A010 SC via scCall"]
    GET_EKK0021["Get EKK0021A010 response
kk0021_a010 map"]
    CHK_EKK0021["scResultCheck param"]

    INIT_2931["Init kk2931_d010_map
new HashMap"]
    POP_MKJ_2931["Put mkj_addf_kei_rv_sbt_cd
value 01
Digital and BS Channel Set"]
    POP_DTL_2931["Put mskm_dtl_no from workMap"]
    POP_SETE_2931["Put setE_tg_kei_skbt_cd
value 01
Service Contract"]
    POP_SVCNO_2931["Put setE_tg_kei_no
Service contract number"]
    POP_WRIB_2931["Put wrib_svc_cd
value W00000009
Digital and BS Channel Set"]
    POP_PCRS_2931["Put pcrs_cd
value F05
Discount service code"]
    POP_PPLAN_2931["Put pplan_cd
value PF0501
RSS Channel Set pricing plan"]
    POP_CNT_2931["Put rsv_kei_cnt
value 1
Reservation contract count"]
    POP_WAY_2931["Put mkj_addf_kei_rvhne_way_cd
value 1
Manual reflection"]
    POP_TMG_2931["Put mkj_addf_kei_rvhne_tmg_cd
value 02
CRS change completion timing"]
    POP_UPD_2931["Put upd_dtm_bf from EKK0021
Update timestamp before"]

    SET_EKK2931["Set EKK2931D010 request
KKAdchgMapper"]
    RUN_EKK2931["Run EKK2931D010 SC via scCall"]
    GET_EKK2931["Get EKK2931D010 response"]
    CHK_EKK2931["scResultCheck param"]

    END_NODE(["Return Next"])

    START --> GET_MAPP
    GET_MAPP --> GET_SC
    GET_SC --> COND_EKK0021
    COND_EKK0021 --> SET_EKK0021
    SET_EKK0021 --> RUN_EKK0021
    RUN_EKK0021 --> GET_EKK0021
    GET_EKK0021 --> CHK_EKK0021
    CHK_EKK0021 --> INIT_2931
    INIT_2931 --> POP_MKJ_2931
    POP_MKJ_2931 --> POP_DTL_2931
    POP_DTL_2931 --> POP_SETE_2931
    POP_SETE_2931 --> POP_SVCNO_2931
    POP_SVCNO_2931 --> POP_WRIB_2931
    POP_WRIB_2931 --> POP_PCRS_2931
    POP_PCRS_2931 --> POP_PPLAN_2931
    POP_PPLAN_2931 --> POP_CNT_2931
    POP_CNT_2931 --> POP_WAY_2931
    POP_WAY_2931 --> POP_TMG_2931
    POP_TMG_2931 --> POP_UPD_2931
    POP_UPD_2931 --> SET_EKK2931
    SET_EKK2931 --> RUN_EKK2931
    RUN_EKK2931 --> GET_EKK2931
    GET_EKK2931 --> CHK_EKK2931
    CHK_EKK2931 --> END_NODE
```

**Processing summary:** The method executes a linear two-phase flow with no conditional branches:
1. **Phase 1 — Read order detail (EKK0021A010):** Retrieves the `mskm_dtl_no` (order detail number) from `workMap`, queries the SC for the order confirmation details, and extracts the `last_upd_dtm` (last update timestamp) for later use.
2. **Phase 2 — Build and register reservation (EKK2931D010):** Constructs a 12-field payload describing the deferred contract reservation with hardcoded constant values (service type = Digital/BS channel set, reflection timing = course change completion, etc.), then submits it to the SC for registration.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying the order context and serving as the conduit for passing data to/from the SC layer through the mapper. |
| 2 | `fixedText` | `String` | A fixed text identifier used by the mapper to construct and resolve SC request/response payloads (e.g., naming conventions for CBS message keys). |
| 3 | `handle` | `SessionHandle` | The session handle providing the SC invocation context (connection, transaction boundary, security context) for running service component calls. |
| 4 | `workMap` | `Map` | An in-memory work area holding transient business data shared across method calls; contains `mskm_dtl_no` (Order Detail Number) used as the query condition for EKK0021A010. |
| 5 | `curSvcKeiInfo` | `CAANMsg` | A message object representing the current service contract record; provides the service contract number (`svc_kei_no`) used as the target of the deferred reservation. |

**External/Instance fields:** None — the method is self-contained and creates all state locally.

## 4. CRUD Operations / Called Services

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

Analyzed method calls within `addMkjAddfKeiRvStarCh2()`:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `setEKK0021A010` / `run` / `getEKK0021A010` | EKK0021A010SC | EKK0021A010 (Order Detail Confirmation Table) | Reads order detail confirmation data using `mskm_dtl_no` as key; retrieves `last_upd_dtm` for consistency check |
| C | `setEKK2931D010` / `run` / `getEKK2931D010` | EKK2931D010SC | EKK2931D010 (Registration-Impossible-at-Order-Time Contract Reservation Table) | Creates a deferred contract reservation record for Digital/BS channel set; registers with service type code `01`, reflection timing `02` (course change completion) |
| - | `scResultCheck` | - | - | Validates SC execution result; throws Exception on error |

**How classified:**
- **EKK0021A010** — The method uses `setEKK0021A010` to build a request, `run` to execute, `getEKK0021A010` to read the response, and `scResultCheck` to verify. This is a Read operation on the order detail confirmation entity.
- **EKK2931D010** — The method constructs a full 12-field `kk2931_d010_map`, calls `setEKK2931D010`, `run`, `getEKK2931D010`, and `scResultCheck`. This is a Create (registration) operation for the contract reservation entity.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKTvSvcKeiCourceChgCC.courceChange()` | `courceChange()` → `addMkjAddfKeiRvStarCh2()` | `setEKK2931D010 [C] EKK2931D010 (Contract Reservation)`, `setEKK0021A010 [R] EKK0021A010 (Order Detail Confirmation)` |

**Instructions applied:**
- The direct caller is `courceChange()` in the same class `JKKTvSvcKeiCourceChgCC`, which orchestrates the course-change business flow.
- Terminal operations from this method: `scResultCheck` (validation), `getEKK2931D010` (Read response), `run` (CRUD execution for both EKK0021A010 and EKK2931D010), `setEKK2931D010` (Create request), `getString` (extract svc_kei_no from curSvcKeiInfo), `getEKK0021A010` (Read response).

## 6. Per-Branch Detail Blocks

This method has **no conditional branches** — it executes as a single linear flow. Below is the complete block analysis.

---

**Block 1** — [SET] `(variable declaration and initialization)` (L711-L717)

> Initialize local variables: a condition map for the EKK0021 query, a request map for SC invocations, a result map for SC responses, and a mapper instance.

| # | Type | Code |
|---|------|------|
| 1 | SET | `condMap = new HashMap<String, String>()` // Condition map for EKK0021 query [new HashMap] |
| 2 | SET | `reqMap` // Declarative: request map for SC invocation [declared, not yet initialized] |
| 3 | SET | `resMap` // Declarative: response map from SC invocation [declared, not yet initialized] |
| 4 | CALL | `mapper = JKKAdchgMapperCC.getInstance()` // Get mapper singleton instance [-> mapper] |
| 5 | SET | `scCall = new ServiceComponentRequestInvoker()` // Create SC request invoker [-> scCall] |

---

**Block 2** — [EXEC] `(EKK0021A010 — Order Details Inquiry)` (L719-L724)

> Queries the order detail confirmation table (EKK0021A010) using the `mskm_dtl_no` from `workMap` as the condition key. This read is performed to obtain the `last_upd_dtm` (last update datetime) which serves as a data-consistency check value for the subsequent reservation registration. The comment reads: "EKK0021A010 — Order Detail Confirmation" (申込明細照会).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `condMap.clear()` // Clear the condition map before reuse |
| 2 | SET | `condMap.put(JKKAdchgMapperCC.COND_KEY_MSKM_DTL_NO, (String)workMap.get("mskm_dtl_no"))` // Set query condition to mskm_dtl_no [-> COND_KEY_MSKM_DTL_NO from workMap] |
| 3 | SET | `reqMap = mapper.setEKK0021A010(param, fixedText, condMap)` // Build EKK0021A010 request payload [-> setEKK0021A010] |
| 4 | CALL | `resMap = scCall.run(reqMap, handle)` // Execute EKK0021A010 SC invocation [-> EKK0021A010SC] |
| 5 | SET | `kk0021_a010 = mapper.getEKK0021A010(param, fixedText, resMap)` // Extract EKK0021A010 response as HashMap [-> getEKK0021A010] |
| 6 | EXEC | `mapper.scResultCheck(param)` // Validate SC result; throws Exception on error |

---

**Block 3** — [SET] `(kk2931_d010_map initialization)` (L726-L727)

> Creates a new HashMap to hold all 12 fields for the contract reservation registration payload. The comment reads: "Registration-impossible-at-order-time contract reservation type code → 01: Digital/BS Channel Set" (申込時登録不可契約予約種類コード → 01: デジット・BS スターチャンネルセット).

| # | Type | Code |
|---|------|------|
| 1 | SET | `kk2931_d010_map = new HashMap<String, Object>()` // Create reservation payload map [new HashMap] |

---

**Block 4** — [EXEC] `(Populate kk2931_d010_map — 12-field reservation payload)` (L728-L745)

> Populates the reservation payload with all required fields for the EKK2931D010 contract reservation. Each field is set sequentially.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.MKJ_ADDF_KEI_RV_SBT_CD, JKKAdchgConstCC.MKJ_ADDF_KEI_RV_SBT_CD_01)` | [-> MKJ_ADDF_KEI_RV_SBT_CD_01 = "01"] Contract reservation type code: Digital/BS Channel Set |
| 2 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.MSKM_DTL_NO, workMap.get("mskm_dtl_no"))` | Order detail number from workMap — links this reservation to the original order |
| 3 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.SETE_TG_KEI_SKBT_CD, JKKAdchgConstCC.SETE_TG_KEI_SKBT_CD_SVC_KEI)` | [-> SETE_TG_KEI_SKBT_CD_SVC_KEI = "01"] Setting target contract identification code: Service Contract |
| 4 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.SETE_TG_KEI_NO, curSvcKeiInfo.getString(EKK0081A010CBSMsg1List.SVC_KEI_NO))` | Service contract number extracted from curSvcKeiInfo |
| 5 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.WRIB_SVC_CD, JKKAdchgConstCC.WRIB_SVC_CD_STACH_SET)` | [-> WRIB_SVC_CD_STACH_SET = "W00000009"] Discount service code: Digital/BS Channel Set |
| 6 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.PCRS_CD, PCRS_CD.F05_STACH)` | [-> F05_STACH = "F05"] Pricing code: Discount service code |
| 7 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.PPLAN_CD, PPLAN_CD.PF0501)` | [-> PF0501 = "PF0501"] Pricing plan code: RSS Channel Set |
| 8 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.RSV_KEI_CNT, "1")` | Reservation contract count: 1 (single contract reservation) |
| 9 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.MKJ_ADDF_KEI_RVHNE_WAY_CD, JKKAdchgConstCC.MKJ_ADDF_KEI_RVHNE_WAY_CD_SYUDO)` | [-> MKJ_ADDF_KEI_RVHNE_WAY_CD_SYUDO = "1"] Reflection method code: Manual reflection |
| 10 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.MKJ_ADDF_KEI_RVHNE_TMG_CD, JKKAdchgConstCC.MKJ_ADDF_KEI_RVHNE_TMG_CD_CRS_CHG)` | [-> MKJ_ADDF_KEI_RVHNE_TMG_CD_CRS_CHG = "02"] Reflection timing code: Course change completion |
| 11 | SET | `kk2931_d010_map.put(EKK2931D010CBSMsg.UPD_DTM_BF, kk0021_a010.get(EKK0021A010CBSMsg1List.LAST_UPD_DTM))` | Update timestamp before — pulled from EKK0021A010 response for data consistency |

---

**Block 5** — [EXEC] `(EKK2931D010 — Registration-Impossible-at-Order-Time Contract Reservation Registration)` (L748-L752)

> Submits the fully-populated reservation payload to the EKK2931D010 SC for contract reservation registration. This is the primary create/registration operation. The comment reads: "EKK2931D010 — Registration-impossible-at-order-time contract reservation registration" (EKK2931D010 申込時登録不可契約予約登録).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `reqMap = mapper.setEKK2931D010(param, fixedText, kk2931_d010_map)` | Build EKK2931D010 request payload from the populated map [-> setEKK2931D010] |
| 2 | CALL | `resMap = scCall.run(reqMap, handle)` | Execute EKK2931D010 SC for reservation registration [-> EKK2931D010SC] |
| 3 | CALL | `mapper.getEKK2931D010(param, fixedText, resMap)` | Extract EKK2931D010 response data |
| 4 | EXEC | `mapper.scResultCheck(param)` | Validate SC result; throws Exception on error |

---

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mkj_addf_kei_rv_sbt_cd` | Field | Contract reservation type code — classifies the type of deferred contract reservation (01 = Digital/BS Channel Set) |
| `mskm_dtl_no` | Field | Order detail number — internal key identifying a specific line item within an order |
| `setE_tg_kei_skbt_cd` | Field | Setting target contract identification code — identifies the target contract type (01 = Service Contract) |
| `setE_tg_kei_no` | Field | Setting target contract number — the service contract number being targeted by the reservation |
| `wrib_svc_cd` | Field | Discount service code — identifies the discount-related service (W00000009 = Digital/BS Channel Set) |
| `pcrs_cd` | Field | Pricing code — the discount pricing code (F05 = discount service) |
| `pplan_cd` | Field | Pricing plan code — the pricing plan associated with the reservation (PF0501 = RSS Channel Set) |
| `rsv_kei_cnt` | Field | Reservation contract count — number of contracts in this reservation (set to 1) |
| `mkj_addf_kei_rvhne_way_cd` | Field | Reflection method code — how the deferred contract is reflected (1 = Manual reflection) |
| `mkj_addf_kei_rvhne_tmg_cd` | Field | Reflection timing code — when the deferred contract takes effect (02 = Course change completion) |
| `upd_dtm_bf` | Field | Update datetime before — the last update timestamp prior to this operation, used for data consistency |
| `svc_kei_no` | Field | Service contract number — the unique identifier of the service contract |
| `last_upd_dtm` | Field | Last update datetime — the timestamp of the most recent update to the order detail record |
| MKJ_ADDF_KEI_RV_SBT_CD_01 | Constant | "01" — Digital/BS Channel Set contract reservation type |
| SETE_TG_KEI_SKBT_CD_SVC_KEI | Constant | "01" — Service Contract as the setting target |
| WRIB_SVC_CD_STACH_SET | Constant | "W00000009" — Digital/BS Channel Set discount service code |
| MKJ_ADDF_KEI_RVHNE_WAY_CD_SYUDO | Constant | "1" — Manual reflection method |
| MKJ_ADDF_KEI_RVHNE_TMG_CD_CRS_CHG | Constant | "02" — Reflection timing: Course change completion |
| F05_STACH | Constant | "F05" — Discount service pricing code for Digital/BS channel set |
| PF0501 | Constant | "PF0501" — Pricing plan: RSS Channel Set |
| EKK0021A010 | Entity | Order Detail Confirmation Table — holds the order confirmation details including update timestamps |
| EKK2931D010 | Entity | Registration-Impossible-at-Order-Time Contract Reservation Table — holds deferred contract reservations |
| EKK0021A010SC | SC | Service Component for Order Detail Confirmation — reads order detail records |
| EKK2931D010SC | SC | Service Component for Contract Reservation Registration — creates deferred contract reservations |
| SC | Acronym | Service Component — Fujitsu's middleware layer for business logic execution and database interaction |
| CBS | Acronym | CBS (Customer Business System) — the core telecommunications billing and service management system |
| CRS | Acronym | Course Reservation System — the system managing service course/plan changes |
| Channel Set | Business term | A bundled TV service package (Digital and BS channels) in the Japanese pay-TV offering |
| RSS | Business term | Residential Service System — the system managing residential customer service plans and subscriptions |
| JKKAdchgConstCC | Class | Constant definition class for address-change-related business constants |
| JKKAdchgMapperCC | Class | Mapper class that translates between Java objects and SC request/response message formats |
| ServiceComponentRequestInvoker | Class | Invoker that executes SC calls with the provided session handle and request map |
| CAANMsg | Class | Message object carrying business data (e.g., service contract information) |
| IRequestParameterReadWrite | Interface | Interface for request parameter objects that carry order context between layers |
| SessionHandle | Class | Session handle providing transaction and connection context for SC invocations |
| 申込時登録不可契約予約 | Japanese term | Registration-impossible-at-order-time contract reservation — a contract that cannot be immediately registered at order time and must be deferred to a later activation point |
| コース変更 | Japanese term | Course change — the business process of modifying a customer's subscribed service plan/course |
| 住所変更登録 | Japanese term | Address change registration — a related but distinct workflow; the mapper comment references this context |
