---

# (DD17) Business Logic — JFUSetVariTsushinKikiMskmCC.execOnuKokanKoji() [32 LOC]

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

## 1. Role

### JFUSetVariTsushinKikiMskmCC.execOnuKokanKoji()

This method orchestrates the registration processing for **ONU Exchange Construction Work** (ONU交換工事登録の処理). It serves as a specialized dispatcher within the telecom service contract management domain, handling the end-to-end workflow required when a customer's optical network unit (ONU) device needs to be swapped during a service transition. Specifically, it initializes the service contract agreement inquiry by clearing the input field set, performs a unique search to resolve the correct service contract record, executes the Service Component (SC) to fetch the current service contract details (including the pricing course code `pcrsCd`), and then delegates the actual construction work registration to `execOnuKokankojiAdd()`. The method implements a **delegation pattern** — it prepares the context (data extraction, flag setting, SC invocation) and then delegates the heavy construction work registration to a dedicated sub-method. Its role in the larger system is as an internal utility called by the main equipment scheduling controller (`KikiKakuCC`) during the equipment scheduling screen processing, specifically triggered when the system detects an ONU exchange construction scenario via the `isOnuKokanKoji()` flag check.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execOnuKokanKoji called from KikiKakuCC"])
    STEP1["Read userData from param.getData fixedText"]
    STEP2["Set onuKokanFlg flag in inMap"]
    STEP3["Get svcKeiNo from inMap"]
    STEP4["Initialize data initData param fixedText IN_COLUMN_LIST_2"]
    STEP5["Map service contract setInMapSvcKeiUniqueSearch"]
    STEP6["Execute SC EKK0081A010 Service IF"]
    STEP7["Get pcrsCd from template list"]
    STEP8["Register ONU exchange execOnuKokankojiAdd"]
    END_NODE(["Return next method"])

    START --> STEP1 --> STEP2 --> STEP3 --> STEP4 --> STEP5 --> STEP6 --> STEP7 --> STEP8 --> END_NODE
```

**Processing Flow:**

1. **Data Extraction** — The method retrieves the user data `HashMap` from the request parameter using `param.getData(fixedText)`, where `fixedText` serves as the service message key.
2. **Flag Setting** — Sets the `onuKokanFlg` flag to `"1"` in the `inMap` to signal that an ONU exchange operation is in progress.
3. **Service Contract Number Retrieval** — Extracts the service contract number (`svcKeiNo`) from the map using the internal parameter key `KK0081_svc_kei_no`.
4. **Data Initialization** — Calls `initData()` to clear and prepare the input column list for the service contract agreement inquiry SC.
5. **Unique Search Mapping** — Calls `setInMapSvcKeiUniqueSearch()` to set up the unique search conditions for the service contract number.
6. **Service Component Execution** — Executes SC `EKK0081A010` (Service Contract Agreement Inquiry) to retrieve the current service contract details.
7. **Pricing Course Code Extraction** — Extracts the pricing course code (`pcrsCd`) from the SC response template list.
8. **ONU Exchange Work Registration** — Delegates to `execOnuKokankojiAdd()` to perform the actual construction work registration with the resolved pricing course code.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing transaction and connection context for executing service component calls. Enables the method to interact with the underlying data layer. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object carrying request-scoped data including the user data `HashMap`, input/output field mappings, and template data structures used throughout the service contract workflow. |
| 3 | `fixedText` | `String` | Service message identifier / key used to access the user data map within `param`. Acts as the entry point key (`fixedText`) for retrieving the `inMap` from request parameters. Corresponds to the screen's data area identifier. |
| 4 | `lastUpdDtm` | `String` | Last update date/time — the timestamp of the most recent modification to the service contract record. Used for optimistic concurrency control during the ONU exchange registration. (最終更新年月日) |
| 5 | `idoDiv` | `String` | Transfer/division classification code — indicates the type of service transfer operation being performed (e.g., new connection, line swap, device exchange). Determines routing behavior in downstream registration logic. (異動区分) |
| 6 | `mskmNo` | `String` | Order/subscription number — the unique identifier for the customer's service order. This is the primary key for correlating all service contract line items under a single order. (申込番号) |
| 7 | `mskmDetailNo` | `String` | Order detail number — the line-item-level identifier within a service order, distinguishing individual service contract entries. (申込明細番号) |
| 8 | `kktkSvcKeiNoList` | `List<HashMap<String, Object>>` | Delivery-accepted equipment provision service contract list — a list of maps containing service contract numbers and associated device provision details for equipment that has been accepted for delivery. Contains equipment change tracking data. (配送受付用機器提供サービス契約リスト) |

**Instance fields / external state:**
- No instance fields are directly read by this method. All state is passed through parameters or accessed via method calls on `param` and `handle`.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `initData` | (framework) | - | Initializes the input column list for the SC call by clearing and setting up the request parameter template structure |
| - | `setInMapSvcKeiUniqueSearch` | (internal) | - | Sets up unique search conditions in the request map for the service contract number to query the service contract agreement table |
| R | `executeSC` (EKK0081A010) | EKK0081A010SC | Service Contract Agreement Table (KK_T_SVC_KEI agreement) | Executes the Service Contract Agreement Inquiry SC to retrieve current service contract details including pricing course code. Template ID: `EKK0081A010`. Input columns: service contract number, installation date, reservation application date. |
| - | `getTemplateListValue` | (framework) | - | Extracts a specific field value from the SC response template list by template key and column name |
| - | `getMaxTempTempleteKey` | (framework) | - | Retrieves the maximum temporary template key for iterating over SC result rows |
| R | `execOnuKokankojiAdd` | (internal CC) | ONU Exchange Construction Registration tables | Delegates the actual ONU exchange construction work registration, handling creation of construction work records, device change tracking, and related service contract updates. |

**SC Details:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `EKK0081A010` (Service Contract Agreement Inquiry) | EKK0081A010SC | KK_T_SVC_KEI (Service Contract Table) | Queries the service contract agreement table to retrieve the current service contract record including pricing course code (`pcrsCd`), installation date, and reservation application date. Template ID: `EKK0081A010`. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `KikiKakuCC` (Equipment Scheduling CC) | `KikiKakuCC.process` -> checks `isOnuKokanKoji()` -> `execOnuKokanKoji(handle, param, fixedText, lastUpdDtm, idoDiv, mskmNo, mskmDetailNo, kktkSvcKeiNoList)` | `execOnuKokankojiAdd` [-] |

**Call chain detail:** The method is invoked from `JFUSetVariTsushinKikiMskmCC` itself at approximately line 1548, where the calling logic is within the same class's broader equipment scheduling processing flow. The caller checks `isOnuKokanKoji(inMap)` before invoking this method, meaning it only runs when the system identifies an ONU exchange construction scenario.

**Terminal operations reached from this method:**
- `initData` [-] — Data initialization framework call
- `setInMapSvcKeiUniqueSearch` [-] — Internal map setup
- `executeSC` with SC `EKK0081A010` [R] — Service Contract Agreement Inquiry
- `getTemplateListValue` [R] — Template data extraction
- `getMaxTempTempleteKey` [R] — Template key resolution
- `execOnuKokankojiAdd` [-] — ONU Exchange Construction Work Registration (delegated)

## 6. Per-Branch Detail Blocks

**Block 1** — [SEQUENCE] Data extraction and flag setup (L4222–L4228)

> This block reads user data from the request parameter, sets the ONU exchange flag, and retrieves the service contract number for subsequent processing.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `HashMap inMap = (HashMap) param.getData(fixedText)` // Reads user data HashMap from request parameter using service message key [-> fixedText parameter] |
| 2 | SET | `inMap.put("onuKokanFlg", "1")` // Sets ONU exchange flag to indicate exchange operation is in progress. Flag value `"1"` signals downstream processing that this is an ONU device swap scenario. |
| 3 | SET | `String svcKeiNo = (String) inMap.get(IN_PARAM_KK0081_SVC_KEI_NO)` // Retrieves service contract number from map [-> IN_PARAM_KK0081_SVC_KEI_NO = "KK0081_svc_kei_no"] |

**Block 2** — [SEQUENCE] Service Contract Agreement Inquiry Preparation (L4230–L4233)

> This block prepares and executes the service contract agreement inquiry to fetch current contract details.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `initData(param, fixedText, IN_COLUMN_LIST_2)` // Initializes input column list for service contract inquiry SC [-> IN_COLUMN_LIST_2 = ["svc_kei_no", "gene_add_dtm", "rsv_aply_ymd"] from EKK0081A010CBSMsg.KEY_SVC_KEI_NO, EKK0081A010CBSMsg.KEY_GENE_ADD_DTM, EKK0081A010CBSMsg.KEY_RSV_APLY_YMD] |
| 2 | CALL | `setInMapSvcKeiUniqueSearch(param, fixedText, svcKeiNo)` // Sets up unique search condition in request map for the service contract number to query the service contract agreement table |
| 3 | CALL | `executeSC(handle, param, fixedText, TEMPLATE_ID_2, TEMPLATE_ID_2_DETAIL, IN_COLUMN_LIST_2, ERROR_COLUMN_2)` // Executes Service Contract Agreement Inquiry SC [-> TEMPLATE_ID_2 = "EKK0081A010", TEMPLATE_ID_2_DETAIL = "EKK0081A010CBSMSG1LIST" from EKK0081A010CBSMsg.EKK0081A010CBSMSG1LIST, ERROR_COLUMN_2 = EKK0081A010CBSMsg.KEY_SVC_KEI_NO_ERR] |

**Block 3** — [SEQUENCE] Pricing Course Code Extraction (L4235–L4237)

> This block extracts the pricing course code (`pcrsCd`) from the SC response, which is needed by the downstream registration method to determine the appropriate pricing/billing configuration for the ONU exchange.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String pcrsCd = getTemplateListValue(inMap, getMaxTempTempleteKey(inMap, TEMP_TEMPLATE_KEY_2), TEMPLATE_ID_2_DETAIL, EKK0081A010CBSMsg1List.PCRS_CD, JFUStrConst.I_ZERO)` // Extracts pricing course code from the first row of SC response template [-> TEMP_TEMPLATE_KEY_2 = TEMP_TEMPLATE_PRIFIX + "EKK0081A010" + TEMP_TEMPLATE_PRIFIX_SEP, PCRS_CD = EKK0081A010CBSMsg1List.PCRS_CD, I_ZERO = "0" default fallback] |

**Block 4** — [SEQUENCE] ONU Exchange Work Registration Delegation (L4240)

> This block delegates the actual construction work registration to a dedicated method, passing the resolved service contract details, transfer classification, order identifiers, pricing course code, and equipment provision list.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `execOnuKokankojiAdd(handle, param, fixedText, idoDiv, mskmNo, mskmDetailNo, pcrsCd, kktkSvcKeiNoList)` // Registers the ONU exchange construction work with the resolved pricing course code and all order/equipment context |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `onuKokanFlg` | Field | ONU Exchange Flag — internal flag set to `"1"` to indicate the current processing is an ONU device swap operation |
| `svc_kei_no` | Field | Service Contract Number — unique identifier for a service contract line item in the telecom provisioning system |
| `gene_add_dtm` | Field | Equipment Installation Date — the date/time when the service equipment was installed or activated |
| `rsv_aply_ymd` | Field | Reservation Application Date — the date when the service reservation was applied for |
| `pcrs_cd` | Field | Pricing Course Code — the billing/pricing plan code associated with the service contract, used to determine charges for the device exchange |
| `ido_div` | Field | Transfer Division — classification code indicating the type of service transfer (new connection, device exchange, line swap, etc.) |
| `mskm_no` | Field | Order Number — the primary key for a customer's service order encompassing one or more service contract line items |
| `mskm_dtl_no` | Field | Order Detail Number — line-item identifier within an order, distinguishing individual service contracts |
| `kktk_svc_kei_no_list` | Field | Delivery-Accepted Equipment Provision Service Contract List — list of service contracts where equipment has been delivered/accepted and is ready for provisioning |
| EKK0081A010 | SC | Service Contract Agreement Inquiry — Service Component that retrieves current service contract agreement details including pricing course, installation date, and reservation data |
| ONU | Business term | Optical Network Unit — the customer-premises device that converts optical signals for home network access in fiber-to-the-home (FTTH) deployments |
| ONU Exchange Construction | Business term | ONU交換工事 — the physical work process of replacing a customer's ONU device during a service transition (e.g., GPON to GPON equipment upgrade) |
| KK0081_svc_kei_no | Field | Internal parameter key for retrieving the service contract number from the request parameter map |
| EKK0081A010CBSMSG1LIST | Field | Template detail key for the Service Contract Agreement Inquiry response data structure |
| `onukokan` | Abbreviation | Short for ONU Exchange (ONU交換) — refers to the device swap operation |
| `kojiak` | Abbreviation | Short for Construction Registration (工事登録) — refers to the work of registering construction/installation jobs |

---