
# Business Logic — JKKKikiIchiranKkOpKyUpdCC.execKikiOptSvcKeiCreate_tnmt() [107 LOC]

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

## 1. Role

### JKKKikiIchiranKkOpKyUpdCC.execKikiOptSvcKeiCreate_tnmt()

This method registers a **Terminal Equipment Provisioning Service Contract** (機器提供サービス契約) for a residential equipment model in a telecommunications service fulfillment system. It operates within the kiki-ichiran (equipment inquiry/listing) screen workflow (KKSV0004) and serves as the core contract creation entry point for adding a new service line item associated with a customer's home gateway/router equipment.

The method follows a **delegation/routing pattern**: it gathers prerequisite data from prior CBS responses (stored in `temporaryData`), determines the appropriate pricing plan (PPLAN_CD) by querying terminal supplementary cost information, registers the service contract via CBS, and then dispatches to state-dependent downstream operations — contract inspection, contract finalization, and service activation — based on the contract's current status.

If the equipment pricing code (`kikiOptSvcKinoCd`) is empty, the method performs a no-op early return (`true`), allowing the surrounding screen controller to proceed without error. When executed, it always returns `true`, making it a fire-and-forget coordination step in the larger contract registration flow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execKikiOptSvcKeiCreate_tnmt"])

    START --> L1["L5999: Get ccMsg from param.getData(dataMapKey)"]
    L1 --> L2["L6002: Get EKK0341A010 template from temporaryData"]
    L2 --> L3["L6005: Get tk_kiki_model from CBS message"]
    L3 --> L4["L6009: Get updStat via getUpdateStat"]
    L4 --> L5["L6012: Get kikiOptSvcKinoCd from temporaryData"]
    L5 --> L6{L6014: kinoCd empty?}

    L6 -->|"Yes"| EARLY["L6016: Return true"]
    L6 -->|"No"| L7["L6023: Call execEZM0491B010 with tk_kiki_model"]
    L7 --> L8{L6026: ezm0491b010CBSMsgList valid?}

    L8 -->|"Yes"| L9["L6029: Set PPLAN_CD from TNMT_COMPS_PPLAN_CD"]
    L8 -->|"No"| L10["PPLAN_CD remains empty"]
    L9 --> L11["L6035: Call execEKK2801A010 to get service info"]
    L10 --> L11

    L11 --> L12["L6038: Call serResetTimeStamp"]
    L12 --> L13["L6041: Call execEKK2811D010_2 — register contract"]
    L13 --> L14{L6043: func_code == FUNC_CODE_1 "1"?}

    L14 -->|"No"| RET_TRUE["Return true"]
    L14 -->|"Yes"| L15{KIKISV_STAT_SHOSAZUMI "020" equals updStat?}

    L15 -->|"Yes"| L16["L6052: Call execEKK2811C030 — contract inspection"]
    L15 -->|"No"| L17{updStat >= KIKISV_STAT_TEIKETSUZUMI "030"?}

    L17 -->|"Yes"| L18["L6057: Call execEKK2811C050 — finalize contract"]
    L18 --> L19{updStat >= KIKISV_STAT_TEIKYOCHU "100"?}

    L19 -->|"Yes"| L20["L6062: Call execEKK2811C070 — start service"]
    L19 -->|"No"| L21["L6065: Call setEkk2811A010AfData — get updated data"]
    L20 --> L21

    L17 -->|"No"| L21
    L16 --> L21
    L21 --> RET_TRUE

    RET_TRUE --> END(["Return true"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle for CBS invocation — carries the transactional context and connection to the back-end DB. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service component call invoker — used internally by delegation methods (`callSC`) to route CBS requests to the appropriate service tier. |
| 3 | `param` | `IRequestParameterReadWrite` | Request parameter object that holds screen input data, work area mappings, and CBS input/output messages keyed by `dataMapKey`. |
| 4 | `dataMapKey` | `String` | Key used to retrieve the message map (`ccMsg`) from `param.getData()`. Typically identifies the screen/transaction context within the data map. |
| 5 | `temporaryData` | `HashMap<String, Object>` | Shared transient data carrier between CBS steps. Contains prior CBS responses (e.g., `EKK0341A010` template), intermediate values like `updStat`, `prm_kino_cd`, `prm_kkop_svc_cd`. |
| 6 | `scrnItemMap` | `HashMap<String, Object>` | Screen item map carrying UI-bound field values. Currently unused in this method (passed only to delegate methods). |

**Instance fields / constants read by this method:**

| Field | Type | Value | Business Description |
|-------|------|-------|---------------------|
| `TEMPLATE_ID_EKK0341A010` | `String` | `"EKK0341A010"` | Template ID for the equipment provision service contract data fetch. |
| `PRM_KIKI_OPT_SVC_KINO_CD` | `String` | `"prm_kino_cd"` | Parameter key for the equipment pricing code (service cost plan). |
| `PRM_KKOP_SVC_CD` | `String` | `"prm_kkop_svc_cd"` | Parameter key for the equipment option service code. |
| `FUNC_CODE_1` | `String` | `"1"` | Function code — indicates a create/add operation (vs. delete/cancel). |
| `KIKISV_STAT_SHOSAZUMI` | `String` | `"020"` | Service contract status: "inspection completed" — means equipment service has already been provisioned. |
| `KIKISV_STAT_TEIKETSUZUMI` | `String` | `"030"` | Service contract status: "agreed/contracted" — contract has been agreed upon. |
| `KIKISV_STAT_TEIKYOCHU` | `String` | `"100"` | Service contract status: "in service" — service is actively being provided. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `execEZM0491B010` | EZM0491B010SC | KK_T_TAKNKIKI_MST (Terminal Equipment Model Master) | Fetches terminal equipment model related info and supplementary cost pricing plan (TNMT_COMPS_PPLAN_CD) for the given model code. |
| R | `execEKK2801A010` | EKK2801A010SC | KK_T_KKOP_SVC_KEI (Equipment Option Service Contract) | Retrieves equipment option service agreement details by service code (KKOP_SVC_CD) — one-time consultation/inquiry. |
| W | `serResetTimeStamp` | - | KK_T_KKOP_SVC_KEI | Resets update timestamp stamp for the equipment contract record (pessimistic lock release). |
| C/U | `execEKK2811D010_2` | EKK2811D010SC | KK_T_KKOP_SVC_KEI (Equipment Option Service Contract) | Registers (inserts/updates) the equipment option service contract with pricing plan, model info, and penalty conditions. |
| C/U | `execEKK2811C030` | EKK2811C030SC | KK_T_KKOP_SVC_KEI | Performs contract inspection (照架) — verifies contract details and updates status for inspection-completed state. |
| C/U | `execEKK2811C050` | EKK2811C050SC | KK_T_KKOP_SVC_KEI | Finalizes the contract (照架締結) — marks the agreement as formally contracted (agreed status). |
| C/U | `execEKK2811C070` | EKK2811C070SC | KK_T_KKOP_SVC_KEI | Activates the service (契約開始) — transitions contract to active service status. |
| R | `setEkk2811A010AfData` | EKK2811A010SC | KK_T_KKOP_SVC_KEI | Fetches post-update contract data to refresh the screen with the newly created contract record. |
| R | `getKikiOptSvcKeiMapData` | - | - | Reads a value from `temporaryData` by parameter key — internal data accessor. |
| R | `getNullToStr` | - | - | Utility — converts null to empty string to prevent NPE. |
| R | `getUpdateStat` | - | - | Extracts the current update status from `temporaryData`. |
| R | `getUpdateStat` | - | - | Extracts the current update status from `temporaryData`. |
| R | `getUpdateStat` | - | - | Internal utility to retrieve the latest update status string. |
| R | `getUpdateStat` | - | - | Extracts the current update status from `temporaryData`. |

### How classified:

**C (Create):** `execEKK2811D010_2` — the D010 SC code pattern denotes "registration" (登録), which inserts or upserts contract records.

**R (Read):** `execEKK2801A010` (A010 = consultation/inquiry), `execEZM0491B010` (B010 = master data fetch), `setEkk2811A010AfData` (A010 = post-update retrieval), `getKikiOptSvcKeiMapData` (internal data accessor).

**U (Update):** `execEKK2811C030` (contract inspection — status update), `execEKK2811C050` (contract finalization — status update), `execEKK2811C070` (service start — status update), `serResetTimeStamp` (timestamp update).

**D (Delete):** None. This method handles creation and status transitions, not cancellation.

### DB Table Inference:
All EKK28xx CBS methods reference the `KK_T_KKOP_SVC_KEI` table (Equipment Option Service Contract Line Item), confirmed by batch processor usages (e.g., `JBSbatKKMiStcKikiCncl`, `JBSbatKKVaCrsChgRun`). The EZM0491B010 method references terminal equipment model data, which maps to `KK_T_TAKNKIKI_MST` or equivalent terminal equipment master table.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0004 (Equipment Inquiry List) | `isTnmtOptSvcKei` → `execKikiOptSvcKeiCreate_tnmt` | `execEKK2811D010_2 [C/U] KK_T_KKOP_SVC_KEI` |

**Notes:** The only pre-extracted caller is `JKKKikiIchiranKkOpKyUpdCC.isTnmtOptSvcKei()`, which acts as a guard method determining whether this method should be invoked. This is invoked from the **KKSV0004** (Equipment Inquiry List) screen's business logic, where a user is registering a new equipment option service contract line item during equipment provisioning.

### Full call chain from entry point:
Screen KKSV0004 → `isTnmtOptSvcKei()` → `execKikiOptSvcKeiCreate_tnmt()`

The `isTnmtOptSvcKei()` method validates whether the current context involves a terminal (home equipment) option service, acting as a conditional gate before contract creation proceeds.

## 6. Per-Branch Detail Blocks

**Block 1** — SET (data extraction) (L5999)

Extracts the screen message map and prerequisite CBS responses from the request context.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `ccMsg = (HashMap) param.getData(dataMapKey)` // Get the screen operation message map |
| 2 | SET | `ekk0341a010cbsMsg = (CAANMsg) temporaryData.get(TEMPLATE_ID_EKK0341A010)` [-> TEMPLATE_ID_EKK0341A010="EKK0341A010"] // Equipment provision service contract template from temporary data |
| 3 | SET | `tk_kiki_model = getNullToStr(ekk0341a010cbsMsg.getString(EKK0341A010CBSMsg1List.TAKNKIKI_MODEL_CD))` // Residential equipment model code (e.g., "SGPT111JPS", "FARTM933KZ") |
| 4 | SET | `updStat = getUpdateStat(temporaryData)` // Post-registration status update reference [v7.00.05 change] |
| 5 | SET | `kikiOptSvcKinoCd = getKikiOptSvcKeiMapData(temporaryData, PRM_KIKI_OPT_SVC_KINO_CD)` [-> PRM_KIKI_OPT_SVC_KINO_CD="prm_kino_cd"] // Equipment pricing code |

**Block 2** — IF (pricing code check) (L6014)

Early return if no pricing code is set — no service to register.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"".equals(kikiOptSvcKinoCd)` |
| 1.1 | RETURN | `return true;` // No pricing code; skip contract creation |

**Block 3** — SET (PPLAN_CD initialization) (L6023)

Initializes the pricing plan code variable. The commented-out model-based PPLAN_CD assignment (ANK-2689-00-00) was replaced by dynamic lookup via execEZM0491B010.

| # | Type | Code |
|---|------|------|
| 1 | SET | `PPLAN_CD = ""` // Pricing plan code — defaults to empty |

**Block 4** — IF-ELSE (terminal supplementary cost pricing) (L6023)

Calls the terminal supplementary cost CBS to determine the pricing plan based on the equipment model type. The commented-out model-based PPLAN_CD assignment (SGPT111JPS→PG0502, SGPT121JPS→PG0503, SGP311J2/B→PG0501, FARTM933KZ→PG0504, THY-B0SD17027→PG0505) was replaced with a dynamic lookup via `execEZM0491B010`.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `ezm0491b010CBSMsgList = execEZM0491B010(handle, scCall, param, dataMapKey, tk_kiki_model)` // Get terminal supplementary cost plan |
| 2 | IF | `ezm0491b010CBSMsgList != null && length > 0` |
| 2.1 | SET | `PPLAN_CD = getNullToStr(ezm0491b010CBSMsgList[0].getString(EZM0491B010CBSMsg1List.TNMT_COMPS_PPLAN_CD))` // Endpoint supplementary cost pricing plan code |

**Block 5** — SET (service info fetch) (L6035)

Retrieves equipment option service agreement details to pass to the contract registration.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `ekk2801a010CBSMsg = execEKK2801A010(handle, scCall, param, dataMapKey, getKikiOptSvcKeiMapData(temporaryData, PRM_KKOP_SVC_CD))` [-> PRM_KKOP_SVC_CD="prm_kkop_svc_cd"] // Get equipment option service info by service code |

**Block 6** — SET (timestamp reset) (L6038)

Resets the pessimistic lock timestamp for the equipment contract record, as lock management is handled globally for all equipment items.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `serResetTimeStamp(handle, scCall, param, dataMapKey, temporaryData)` // Reset update timestamp stamp (lock control) |

**Block 7** — SET (contract registration) (L6041)

Core operation: registers the equipment option service contract with all gathered parameters.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `ekk2811d010Msg = execEKK2811D010_2(handle, scCall, param, dataMapKey, temporaryData, PPLAN_CD, ekk2801a010CBSMsg)` // Equipment option service contract registration |

**Block 8** — IF (function code dispatch) (L6043)

Dispatches to status-dependent downstream operations. Only processes when the function code indicates a create/add operation (`FUNC_CODE_1 = "1"`).

| # | Type | Code |
|---|------|------|
| 1 | IF | `FUNC_CODE_1.equals((String)ccMsg.get("func_code"))` [-> FUNC_CODE_1="1"] |
| 1.1 | IF | (L6050) `KIKISV_STAT_SHOSAZUMI.equals(updStat)` [-> "020"] // Inspection completed |
| 1.1.1 | CALL | `execEKK2811C030(handle, scCall, param, dataMapKey, temporaryData, ekk2811d010Msg)` // Contract inspection (照架) |
| 1.2 | ELSE IF | (L6055) `KIKISV_STAT_TEIKETSUZUMI.compareTo(updStat) <= 0` [-> "030"] // >= agreed status |
| 1.2.1 | CALL | `execEKK2811C050(handle, scCall, param, dataMapKey, temporaryData, ekk2811d010Msg)` // Contract finalization (照架締結) |
| 1.2.2 | IF | (L6060) `KIKISV_STAT_TEIKYOCHU.compareTo(updStat) <= 0` [-> "100"] // >= in-service status |
| 1.2.2.1 | CALL | `execEKK2811C070(handle, scCall, param, dataMapKey, temporaryData, ekk2811d010Msg)` // Service activation (契約開始) |
| 1.3 | ELSE | // Fall-through to data refresh |
| 1.3.1 | CALL | (L6065) `setEkk2811A010AfData(handle, scCall, param, dataMapKey, temporaryData, ekk2811d010Msg.getString(EKK2811D010CBSMsg.KKOP_SVC_KEI_NO))` // Fetch post-update data |

**Block 9** — RETURN (L6067)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true;` // Always returns true — no error propagation |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kikiOptSvcKeiCreate_tnmt` | Method | Equipment Provision Service Contract Registration — creates a new service contract line item for terminal equipment |
| `tk_kiki_model` | Field | Residential (home) equipment model code — the model identifier of the customer's home gateway/router (e.g., SGPT111JPS, FARTM933KZ) |
| `kikiOptSvcKinoCd` | Field | Equipment pricing code — identifies the service cost plan/price tier for the equipment option service |
| `kko_svc_cd` | Field | Equipment option service code — classifies the type of equipment option service (e.g., router rental, premium support) |
| `PPLAN_CD` | Field | Pricing plan code — determines the monthly charge plan for the equipment service (e.g., PG0501, PG0502) |
| `TNMT_COMPS_PPLAN_CD` | Field | Terminal supplementary cost pricing plan code — pricing plan derived from terminal equipment supplementary cost table |
| `updStat` | Field | Update status — the current state of the contract record, used to determine which downstream operation to execute |
| `FUNC_CODE_1` | Constant | Function code value "1" — indicates a create/add operation (as opposed to delete/cancel) |
| `KIKISV_STAT_SHOSAZUMI` | Constant | "020" — Service contract status "inspection completed" — the equipment service has been provisioned and inspected |
| `KIKISV_STAT_TEIKETSUZUMI` | Constant | "030" — Service contract status "agreed/contracted" — the contract has been formally agreed upon by the customer |
| `KIKISV_STAT_TEIKYOCHU` | Constant | "100" — Service contract status "in service" — the service is actively being provided to the customer |
| `SHOSA` | Acronym | 照架 — Contract inspection; the process of verifying contract details before finalization |
| `TEIKETSU` | Acronym | 締結 — Contract finalization; formally closing the agreement |
| `TEIKYOCHU` | Acronym | 提供中 — In service; the service is actively running |
| EKK0341A010 | CBS | Equipment provision service contract data fetch — retrieves the service contract template and terminal model code |
| EKK2801A010 | CBS | Equipment option service one-time consultation — queries equipment option service details by service code |
| EKK2811A010 | CBS | Equipment option service contract registration (re-registration) — core contract registration/upsert operation |
| EKK2811C030 | CBS | Equipment option service contract inspection — performs contract inspection status update |
| EKK2811C050 | CBS | Equipment option service contract finalization — performs contract finalization status update |
| EKK2811C070 | CBS | Equipment option service contract activation — starts service delivery |
| EKK2811D010 | CBS | Equipment option service contract registration (insert) — creates new contract records |
| EZM0491B010 | CBS | Terminal equipment model related information inquiry — fetches pricing plan for the given equipment model |
| KK_T_KKOP_SVC_KEI | Table | Equipment Option Service Contract Line Item — stores equipment option service contract records |
| CAANMsg | Type | Common Application Annotated Message — Fujitsu's enterprise message wrapper for CBS communication |
| `ccMsg` | Variable | Screen command message map — carries screen-level parameters like `func_code` and `ido_div` |
| `temporaryData` | Variable | Temporary data storage — cross-step data carrier between CBS calls in the same screen transaction |
| `dataMapKey` | Parameter | Data map key — identifies which message map within `param` to use for the current screen context |
| `ido_div` | Field | Movement division — indicates the type of screen transition (add, edit, etc.) |
