# Business Logic — JBSbatKKEoTVChgeFix.insertHmpInKikiNewKiki() [213 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKEoTVChgeFix` |
| Layer | Service |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKEoTVChgeFix.insertHmpInKikiNewKiki()

This method performs **returned equipment information registration** for device provision (rental) service contracts within the K-Opticom customer base system. Its core business operation is to process return devices associated with a delivery record identified by a device provision service contract number, ensuring proper lifecycle management of rental equipment such as STBs, ONUs, and routers.

The method handles two distinct processing paths based on the **delivery status**:

1. **Delivery in progress (status "001" — Received):** When a delivery record exists with status "001" (受診済 / Received), the method locks the delivery record, updates its status to "005" (中止 / Canceled) with cancellation code "2" (キャンセル / Cancel), and sets the cancellation date to the operational date. This handles the case where a previously delivered device must be recalled before final handover.

2. **Non-received delivery status (else branch):** When the delivery status is not "001", the method evaluates the entity-level equipment data. If the **equipment provision type** is "02" (CD00212_KKTK_SBT_CD_02 — Rental), it generates a new return device (HMPIN_KIKI) record in the database with a newly allocated sequence number, pre-installation cancellation reason code "96", and all standard audit fields populated.

The method implements a **routing/dispatch pattern** where it branches its behavior based on the delivery status code, and a **builder pattern** when constructing the 90-field parameter array for return device insertion. It acts as a **shared utility** within `JBSbatKKEoTVChgeFix`, called by three other methods in the same class that handle different caller contexts (service contract add, return-STB, return-VONU).

Its role in the larger system is the critical bridge between the delivery logistics workflow and the equipment management lifecycle — ensuring that every rental device returned through the contract change process is properly recorded in the return equipment table with full traceability (equipment model, serial number, contract number, and cancellation reason).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["insertHmpInKikiNewKiki<br/>params"])
    
    START --> GET_PARAMS["Extract KKTK_SVC_KEI_NO and<br/>KIKI_CHG_NO from kktkSvcKeiMap"]
    
    GET_PARAMS --> EXEC_SELECT["executeDK_T_HAISO_KK_SELECT_013<br/>haisoParam"]
    
    EXEC_SELECT --> SELECT_NEXT["db_DK_T_HAISO.selectNext()<br/>haisoMap_013"]
    
    SELECT_NEXT --> CHECK_NULL{haisoMap_013<br/>== null?}
    
    CHECK_NULL -->|Yes| LOG_NO_RESULT["Debug log:<br/>No delivery info found"]
    LOG_NO_RESULT --> END_RETURN["Return / exit method"]
    
    CHECK_NULL -->|No| WHILE_LOOP["while haisoMap_013 != null"]
    
    WHILE_LOOP --> GET_HAISO_STAT["Get HAISO_STAT from map"]
    
    GET_HAISO_STAT --> CHECK_STAT{HAISO_STAT<br/>== '001'?<br/>CD00009_HAISO_STAT_001}
    
    CHECK_STAT -->|Yes| PROCESS_001["Delivery Status: Received<br/>(受診済)"]
    
    PROCESS_001 --> SET_WHERE["Create where_map<br/>set HAISO_NO"]
    SET_WHERE --> SELECT_PKEW["db_DK_T_HAISO.selectByPrimaryKeysForUpdateWait<br/>lock delivery record"]
    SELECT_PKEW --> CHECK_MAP{map != null?<br/>record exists?}
    
    CHECK_MAP -->|Yes| UPDATE_HAISO["Set value[0]='005'<br/>CD00009_HAISO_STAT_005<br/>value[1]='2' CD00022_HAISO_STP_CD_2<br/>value[2]=opeDate"]
    UPDATE_HAISO --> DEBUG_LOG["Debug log delivery number"]
    DEBUG_LOG --> EXEC_PKUPDATE["executeDK_T_HAISO_PKUPDATE<br/>update delivery record"]
    EXEC_PKUPDATE --> GET_NEXT
    
    CHECK_MAP -->|No| THROW_ERROR["throw JBSbatBusinessException<br/>EKKB0210CE - No matching record"]
    THROW_ERROR --> END_RETURN
    
    CHECK_STAT -->|No| ELSE_BRANCH["Delivery Status != '001'"]
    
    ELSE_BRANCH --> GET_ENTITY_FIELDS["Read entity fields:<br/>KKTK_SVC_KEI_NO, TAKNKIKI_MODEL_CD,<br/>KIKI_SEIZO_NO, KIKI_CHG_NO, KKTK_SBT_CD"]
    
    GET_ENTITY_FIELDS --> CHECK_SBT{KKTK_SBT_CD<br/>== '02'?<br/>CD00212_KKTK_SBT_CD_02<br/>Rental}
    
    CHECK_SBT -->|Yes| CREATE_RETURN["Generate return device record"]
    
    CREATE_RETURN --> GET_SEQ["JCCBatCommon.getFormatedNextSeq<br/>SEQ_HMPIN_KIKI_NO"]
    GET_SEQ --> GET_SYS_DATE["JCCBatCommon.getSysDateTimeStamp"]
    
    GET_SYS_DATE --> SET_PARAMS["Build setParam array (90 fields)<br/>return device data"]
    
    SET_PARAMS --> INSERT_RETURN["executeDK_T_HMPIN_KIKI_PKINSERT<br/>setParam"]
    INSERT_RETURN --> GET_NEXT
    
    CHECK_SBT -->|No| GET_NEXT["db_DK_T_HAISO.selectNext()<br/>next haisoMap_013"]
    
    GET_NEXT --> LOOP_CHECK{More records?}
    LOOP_CHECK -->|Yes| WHILE_LOOP
    LOOP_CHECK -->|No| END_DONE["END"]
    
    END_RETURN --> END_DONE
```

**CRITICAL — Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|-----------------|
| `CD00009_HAISO_STAT_001` | `"001"` | Delivery Status: Received (受診済) |
| `CD00009_HAISO_STAT_005` | `"005"` | Delivery Status: Canceled/Stopped (中止) |
| `CD00022_HAISO_STP_CD_2` | `"2"` | Delivery Cancellation Code: Cancel (キャンセル) |
| `CD00212_KKTK_SBT_CD_02` | `"02"` | Equipment Provision Type: Rental (レンタル) |
| `CD00296_HMPIN_KIKI_STAT_001` | `"001"` | Return Device Status: Received (受診済) |
| `CD00291_HMPIN_DIV_1` | `"1"` | Return Classification: Canceled Item (キャンセル品) |
| `CD00293_HMPIN_RSN_CD_96` | `"96"` | Return Reason Code: Pre-installation Cancellation (工事前キャンセル共通) |
| `MK_FLG_YK` | `"0"` | Invalid Flag: Valid (有効) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `kktkSvcKeiMap` | `JBSbatCommonDBInterface` | Input message map for equipment provision service contracts. Contains key entity fields including KKTK_SVC_KEI_NO (equipment provision service contract number), KIKI_CHG_NO (device change number), TAKNKIKI_MODEL_CD (indoor equipment model code), KIKI_SEIZO_NO (equipment serial number), and KKTK_SBT_CD (equipment provision type code). This map drives all data extraction in the method. |
| 2 | `svcKeiNo` | `String` | Root service contract number (読込親サービス契約番号). The parent/top-level service contract to which the returned device information will be associated. Stored in the return device record's svc_kei_no field for traceability back to the original contract. |
| 3 | `idoDtm` | `String` | Migration change registration year-month-day-hour-minute-second (異動登録年月日時分秒). The system timestamp of the contract change event. Passed through to the return device record's registration contract migration date-time field to establish the temporal context of the return. |
| 4 | `idoDiv` | `String` | Migration change classification (異動区分). Indicates the type of contract change triggering this return (e.g., contract modification, cancellation, transfer). Passed through to the return device record's registration contract change classification field. |

**Instance fields read:**
| Field | Type | Business Description |
|-------|------|---------------------|
| `db_DK_T_HAISO` | `JBSbatCommonDBInterface` | Database access interface for the delivery table (DK_T_HAISO). Used for querying and updating delivery records. |
| `commonItem` | `Object` | Common item configuration used for sequence generation. Passed to `getFormatedNextSeq` for generating the return device number. |
| `opeDate` | `String` | Operational date (運用年月日). The business date of the batch execution, used as the return receipt date and cancellation date. |
| `batchUserId` | `String` | Batch user ID (バッチ更新者ID). The system user identifier for batch updates, set as both registered and updated operator in audit fields. |
| `logPrint` | `Object` | Debug logging interface. Used to conditionally emit debug messages at DEBUG level. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKEoTVChgeFix.executeDK_T_HAISO_KK_SELECT_013` | EKK (Delivery Select) | DK_T_HAISO | Executes a SQL query to retrieve delivery records matching the equipment provision service contract number and device change number. Returns all delivery records associated with the given contract. |
| R | `db_DK_T_HAISO.selectByPrimaryKeysForUpdateWait` | (Internal Lock) | DK_T_HAISO | Performs a primary-key-based select with row-level lock (SELECT ... FOR UPDATE WAIT), acquiring an exclusive lock on the delivery record before updating its status. |
| U | `JBSbatKKEoTVChgeFix.executeDK_T_HAISO_PKUPDATE` | EKK (Delivery Update) | DK_T_HAISO | Updates the delivery record's status to "005" (Canceled/Stopped) with cancellation code "2" (Cancel) and sets the cancellation date to the operational date. |
| C | `JBSbatKKEoTVChgeFix.executeDK_T_HMPIN_KIKI_PKINSERT` | EKK (Return Device Insert) | DK_T_HMPIN_KIKI | Inserts a new return device record with 90 fields including return device number (allocated sequence), status "001" (Received), receipt date, return reason "96" (Pre-installation Cancellation), equipment model code, serial number, and all audit fields (register/update timestamps and user IDs). |
| R | `JCCBatCommon.getFormatedNextSeq` | Utility | DB Sequence | Allocates the next return device number (SEQ_HMPIN_KIKI_NO) with prefix "R" + 2-digit year and 7-digit length. |
| R | `JCCBatCommon.getSysDateTimeStamp` | Utility | System | Retrieves the current system timestamp for use as the return device registration timestamp. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JBSbatKKEoTVChgeFix.createKktkSvcKeiAddInfoKjCl()` | `createKktkSvcKeiAddInfoKjCl()` → `insertHmpInKikiNewKiki(kktkSvcKeiMap, svcKeiNo, idoDtm, idoDiv)` | `executeDK_T_HAISO_KK_SELECT_013 [R] DK_T_HAISO`, `executeDK_T_HAISO_PKUPDATE [U] DK_T_HAISO`, `executeDK_T_HMPIN_KIKI_PKINSERT [C] DK_T_HMPIN_KIKI` |
| 2 | `JBSbatKKEoTVChgeFix.createKokanAfSTBInfoKjCl()` | `createKokanAfSTBInfoKjCl()` → `insertHmpInKikiNewKiki(kktkSvcKeiMap, svcKeiNo, idoDtm, idoDiv)` | `executeDK_T_HAISO_KK_SELECT_013 [R] DK_T_HAISO`, `executeDK_T_HAISO_PKUPDATE [U] DK_T_HAISO`, `executeDK_T_HMPIN_KIKI_PKINSERT [C] DK_T_HMPIN_KIKI` |
| 3 | `JBSbatKKEoTVChgeFix.createKokanAfVONUInfoKjCl()` | `createKokanAfVONUInfoKjCl()` → `insertHmpInKikiNewKiki(kktkSvcKeiMap, svcKeiNo, idoDtm, idoDiv)` | `executeDK_T_HAISO_KK_SELECT_013 [R] DK_T_HAISO`, `executeDK_T_HAISO_PKUPDATE [U] DK_T_HAISO`, `executeDK_T_HMPIN_KIKI_PKINSERT [C] DK_T_HMPIN_KIKI` |

All three callers reside within the same class (`JBSbatKKEoTVChgeFix`) and represent different entry points for the same underlying business operation — processing return devices in the context of different contract change scenarios: general service contract add information, post-return STB (Set-Top Box) equipment, and post-return VONU (Voice-Over-ONU) equipment.

## 6. Per-Branch Detail Blocks

**Block 1** — SET (Initialization / Extract Key Fields from Input Map) (L11182)

> Extracts the equipment provision service contract number and device change number from the input map, preparing the parameters for delivery record search.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kktkSvcKeiNo = JBSbatStringUtil.Rtrim(kktkSvcKeiMap.getString(JBSbatKK_T_KKTK_SVC_KEI.KKTK_SVC_KEI_NO))` // Equipment Provision Service Contract Number |
| 2 | SET | `kikiChgNo = JBSbatStringUtil.Rtrim(kktkSvcKeiMap.getString(JBSbatKK_T_KKTK_SVC_KEI.KIKI_CHG_NO))` // Device Change Number |
| 3 | SET | `haisoParam = new String[]{kktkSvcKeiNo, kikiChgNo}` // Search parameters for delivery query |

**Block 2** — CALL (Execute Delivery Record Search) (L11196)

> Executes the SQL definition key DK_T_HAISO_SELECT_013 to query delivery records matching the contract number and device change number.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeDK_T_HAISO_KK_SELECT_013(haisoParam)` // Search delivery records by contract number and device change number |

**Block 3** — SET (Fetch First Delivery Record) (L11199)

> Retrieves the next row from the result set of the previous query.

| # | Type | Code |
|---|------|------|
| 1 | SET | `haisoMap_013 = db_DK_T_HAISO.selectNext()` // Get next delivery record from result set |

**Block 4** — IF (No Delivery Records Found — Early Exit) (L11202)

> If no delivery record is found for the given contract number and device change number, logs the absence and exits immediately. No further processing is performed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `null` // No delivery record found |
| 2 | EXEC | `super.logPrint.printDebugLog("配送に機器提供サービス契約番号：" + svcKeiNo + "、機器変更番号：" + kikiChgNo + "に該当する配送の中止情報が存在しません。")` // Debug log: No cancellation info exists for delivery |
| 3 | RETURN | `return` // Exit method — no further processing |

**Block 5** — WHILE (Process All Delivery Records) (L11211)

> Iterates over all delivery records returned by the search. Each record is processed through conditional branching based on its delivery status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `haisoMap_013` // Current delivery record being processed |

**Block 5.1** — GET (Extract Delivery Status) (L11222)

> Reads the delivery status from the current record's HAISO_STAT field.

| # | Type | Code |
|---|------|------|
| 1 | SET | `haisoStat_013 = JBSbatStringUtil.Rtrim(haisoMap_013.getString(JBSbatDK_T_HAISO.HAISO_STAT))` // Delivery Status |

**Block 5.2** — IF/ELSE-IF/ELSE (Delivery Status Branch: Status "001" = Received) (L11224)

> Checks whether the delivery status equals "001" (CD00009_HAISO_STAT_001 — 受診済 / Received). If yes, the method locks and updates the delivery record to cancel it. Otherwise, it proceeds to the entity-level processing path.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JBSbatKKConst.CD00009_HAISO_STAT_001.equals(haisoStat_013)` // == "001" (Delivery Status: Received) |

**Block 5.2.1** — IF (Status == "001") — Cancel In-Progress Delivery (L11225)

> When the delivery status is "001" (Received), the method acquires an exclusive lock on the delivery record and updates its status to "005" (Canceled/Stopped) with cancellation code "2" (Cancel).

| # | Type | Code |
|---|------|------|
| 1 | SET | `where_map = new JBSbatCommonDBInterface()` // Create where clause map |
| 2 | SET | `haisoNo = JBSbatStringUtil.Rtrim(haisoMap_013.getString(JBSbatDK_T_HAISO.HAISO_NO))` // Delivery Number |
| 3 | EXEC | `where_map.setValue(JBSbatDK_T_HAISO.HAISO_NO, haisoNo)` // Set delivery number as search key |
| 4 | CALL | `map = db_DK_T_HAISO.selectByPrimaryKeysForUpdateWait(where_map)` // Lock delivery record for update |
| 5 | IF | `null != map` // Record found with lock acquired |

**Block 5.2.1.1** — IF (Lock Successful: Record Found) (L11240)

> The delivery record was successfully locked. Prepare and execute the update to change the status to "005" (Canceled).

| # | Type | Code |
|---|------|------|
| 1 | SET | `value = new String[3]` // Update value array: [status, cancel code, cancel date] |
| 2 | SET | `param = new String[1]` // Update param array: [delivery number] |
| 3 | SET | `value[0] = JBSbatKKConst.CD00009_HAISO_STAT_005` // "005" — Delivery Status: Canceled (中止) |
| 4 | SET | `value[1] = JBSbatKKConst.CD00022_HAISO_STP_CD_2` // "2" — Delivery Cancel Code: Cancel (キャンセル) |
| 5 | SET | `value[2] = super.opeDate` // Delivery cancellation date = operational date (運用年月日) |
| 6 | SET | `param[0] = haisoNo` // Delivery number |
| 7 | IF | `super.logPrint.chkLogLevel(JBSbatLogUtil.MODE_DEBUG)` // If DEBUG level logging is enabled |
| 7.1 | EXEC | `super.logPrint.printDebugLog("配送更新対象 配送番号：" + param[0])` // Debug log: Delivery update target delivery number |
| 8 | CALL | `executeDK_T_HAISO_PKUPDATE(value, param)` // Update delivery record with cancellation info |

**Block 5.2.1.2** — ELSE (Lock Failed: Record Not Found) (L11263)

> The delivery record was expected but could not be locked — a concurrency conflict or data integrity error.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `throw new JBSbatBusinessException(JPCBatchMessageConstant.EKKB0210CE, new String[]{"配送", "配送番号" + haisoNo})` // Business exception: No matching delivery record (配送, 配送番号 + haisoNo) |

**Block 5.2.2** — ELSE (Status != "001") — Entity-Level Return Device Processing (L11271)

> When the delivery status is NOT "001" (i.e., not in "Received" state), the method reads entity-level fields from the input map to determine whether to create a return device record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kktkSvcKeiNo = JBSbatStringUtil.Rtrim(kktkSvcKeiMap.getString(JBSbatKK_T_KKTK_SVC_KEI.KKTK_SVC_KEI_NO))` // Re-read equipment provision service contract number |
| 2 | SET | `taknkikiModelCd = JBSbatStringUtil.Rtrim(kktkSvcKeiMap.getString(JBSbatKK_T_KKTK_SVC_KEI.TAKNKIKI_MODEL_CD))` // Indoor equipment model code (宅内機器型式コード) |
| 3 | SET | `kikiSeizoNo = JBSbatStringUtil.Rtrim(kktkSvcKeiMap.getString(JBSbatKK_T_KKTK_SVC_KEI.KIKI_SEIZO_NO))` // Equipment serial number (機器製造番号) |
| 4 | SET | `kktkChgNo = JBSbatStringUtil.Rtrim(kktkSvcKeiMap.getString(JBSbatKK_T_KKTK_SVC_KEI.KIKI_CHG_NO))` // Equipment change number (機器変更番号) |
| 5 | SET | `kktkSbtCd = JBSbatStringUtil.Rtrim(kktkSvcKeiMap.getString(JBSbatKK_T_KKTK_SVC_KEI.KKTK_SBT_CD))` // Equipment provision type code (機器提供種別コード) |

**Block 5.2.2.1** — IF (Equipment Provision Type == "02" / Rental) (L11285)

> Checks if the equipment provision type is "02" (CD00212_KKTK_SBT_CD_02 — Rental / レンタル). Only rental equipment triggers return device record creation.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JBSbatKKConst.CD00212_KKTK_SBT_CD_02.equals(kktkSbtCd)` // == "02" (Equipment Provision Type: Rental) |

**Block 5.2.2.1.1** — SET (Build Return Device Parameter Array — 90 Fields) (L11289)

> Generates the return device record fields by allocating a sequence number, obtaining the system timestamp, and building a 90-element parameter array with pre-filled values and NULLs for most optional fields. This is the core data assembly step.

| # | Type | Code |
|---|------|------|
| 1 | SET | `seqHenpinKikiNo = JCCBatCommon.getFormatedNextSeq(commonItem, "SEQ_HMPIN_KIKI_NO", "R" + super.opeDate.substring(2,4), 7)` // Return device number: prefix "R" + 2-digit year, 7 digits |
| 2 | SET | `sysDate = JCCBatCommon.getSysDateTimeStamp()` // System date-time stamp (システム日付) |
| 3 | SET | `setParam = new String[90]` // Build parameter array with 90 fields |
| 3.1 | SET | `setParam[0] = seqHenpinKikiNo` // Return device number (返品機器番号) |
| 3.2 | SET | `setParam[1] = JBSbatKKConst.CD00296_HMPIN_KIKI_STAT_001` // "001" — Return device status: Received (返品機器ステータス → 001 受診済) |
| 3.3 | SET | `setParam[2] = opeDate` // Return receipt date → operational date (返品受領年月日 → 運用日) |
| 3.4 | SET | `setParam[3] = ""` // Return warehouse entry date → NULL (返品倉入年月日 → NULL) |
| 3.5 | SET | `setParam[4] = JBSbatKKConst.CD00291_HMPIN_DIV_1` // "1" — Return classification: Canceled item (返品区分 → 1 キャンセル品) |
| 3.6 | SET | `setParam[5] = ""` // Construction company code → NULL (工事会社コード → NULL) |
| 3.7 | SET | `setParam[6] = ""` // Advance office office code → NULL (予領先オフィスコード → NULL) |
| 3.8–3.9 | SET | `setParam[7] = ""`, `setParam[8] = ""` // Place number → NULL, Warehouse code → NULL (場所番号 → NULL, 倉庫コード → NULL) |
| 3.10 | SET | `setParam[9] = ""` // Barrel code → NULL (柱コード → NULL) |
| 3.11 | SET | `setParam[10] = kktkSvcKeiNo` // Equipment provision service contract number (機器提供サービス契約番号) |
| 3.12 | SET | `setParam[11] = kktkChgNo` // Equipment change number (機器変更番号) |
| 3.13 | SET | `setParam[12] = taknkikiModelCd` // Indoor equipment model code (宅内機器型式コード) |
| 3.14 | SET | `setParam[13] = kikiSeizoNo` // Equipment serial number (機器製造番号) |
| 3.15–3.18 | SET | `setParam[14–17] = ""` // Attachment model code, logistics security number, return original individual flag, returner name → NULL (附属品型式コード, 物流保安番号, 返品元個別指定フラグ, 返品者名) |
| 3.19–3.26 | SET | `setParam[18–25] = ""` // Returner address code, postal code, prefecture, city/town/village, oaza-azana, chōchōme, banchi-go, address supplement/building name → NULL (返品者住所コード, 返品者郵便番号, 返品者都道府県名, 返品者市区町村名, 返品者大字通称名, 返品者字丁目名, 返品者番地号, 返品者住所補記・建物名) |
| 3.27–3.28 | SET | `setParam[26–27] = ""` // Returner room number, Returner phone number → NULL (返品者部屋番号, 返品者電話番号) |
| 3.29 | SET | `setParam[28] = JBSbatKKConst.CD00293_HMPIN_RSN_CD_96` // "96" — Return reason code: Pre-installation Cancellation (Common) (返品理由コード → 96 工事前キャンセル(共通)) |
| 3.30–3.34 | SET | `setParam[29–33] = ""` // Return reason memo, Return device approval date, Return device cancellation date, Return device cancellation reason code, Return device cancellation reason memo → NULL (返品理由メモ, 返品機器承認年月日, 返品機器取消年月日, 返品機器取消理由コード, 返品機器取消理由メモ) |
| 3.35–3.39 | SET | `setParam[34–38] = ""` // Failure content, Reproduction availability, Operation confirmation code, Return type code, Return receipt code → NULL (故障内容, 再現有無, 動作確認コード, 返品種別コード, 返品受入コード) |
| 3.40 | SET | `setParam[39] = idoDiv` // Registration contract change classification (登録契契約異動区分) |
| 3.41 | SET | `setParam[40] = idoDtm` // Registration contract change year-month-day-hour-minute-second (登録契契約異動年月日時分秒) |
| 3.42 | SET | `setParam[41] = "BATSERVICE"` // Return responsible user ID → BATSERVICE (返品担当ユーザID → BATSERVICE) |
| 3.43 | SET | `setParam[42] = svcKeiNo` // Root service contract number (読込親サービス契約番号) |
| 3.44–3.51 | SET | `setParam[43–50] = ""` // Product status code, Rental contract application YES/NO, Read-out lot return number, Customer device return date, HSTD return data status code, Return device memo, Return warehouse responsible user ID, Return device approval responsible user ID → NULL (商品状態コード, レンタル解約申請書有無, 読込出荷ロット番号, お客様機器返却年月日, HSTD返品データ状態コード, 返品機器備考, 返品倉入担当ユーザID, 返品機器承認担当ユーザID) |
| 3.52–3.55 | SET | `setParam[51–55] = ""` // Return device cancellation responsible user ID, WMS return number, WMS return record number, Provision type code, Return original contract holder name → NULL (返品機器取消担当ユーザID, WMS返品番号, WMS返品レコード通番, 提供種別コード, 返品元契約者名) |
| 3.56–3.58 | SET | `setParam[56–58] = ""` // Return target equipment error presence/absence, Work case number, Register date-time stamp (システム日時) → NULL or sysDate (返品対象機器エラー有無, 工事案件番号, 登録年月日時分秒 → システム日時) |
| 3.59 | SET | `setParam[59] = batchUserId` // Register operator account → Batch updater ID (登録オペレータアカウント → バッチ更新者ID) |
| 3.60 | SET | `setParam[60] = sysDate` // Update date-time stamp (システム日時) |
| 3.61 | SET | `setParam[61] = batchUserId` // Update operator account → Batch updater ID (更新オペレータアカウント → バッチ更新者ID) |
| 3.62–3.67 | SET | `setParam[62–67] = ""` // Delete date-time, Delete operator, Invalid flag → "0" (valid), Register operation date, Register processing ID, Update operation date, Update processing ID, Delete operation date, Delete processing ID → NULL or respective values (削除年月日時分秒, 削除オペレータアカウント, 無効フラグ → "0"(有効), 登録運用年月日, 登録処理ID, 更新運用年月日, 更新処理ID, 削除運用年月日, 削除処理ID) |
| 3.68 | SET | `setParam[68] = JBSbatKKConst.MK_FLG_YK` // "0" — Invalid flag: Valid (無効フラグ → "0"(有効)) |

**Block 5.2.2.1.2** — CALL (Execute Return Device Insert) (L11530)

> Inserts the constructed return device record into the DK_T_HMPIN_KIKI table using a primary-key (full-field) insert.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeDK_T_HMPIN_KIKI_PKINSERT(setParam)` // Register all fields of return device table |

**Block 5.2.2.2** — SET (Fetch Next Delivery Record) (L11536)

> Advances to the next row in the delivery result set for loop continuation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `haisoMap_013 = db_DK_T_HAISO.selectNext()` // Get next delivery record |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kktkSvcKeiNo` | Field | Equipment Provision Service Contract Number (機器提供サービス契約番号) — The unique identifier for a device provision service contract line item. |
| `svcKeiNo` | Field | Root Service Contract Number (読込親サービス契約番号) — The top-level service contract identifier that anchors all associated service lines. |
| `idoDtm` | Field | Migration Change Registration Date-Time (異動登録年月日時分秒) — The timestamp when the contract change event was registered. |
| `idoDiv` | Field | Migration Change Classification (異動区分) — The type of contract change (e.g., modification, cancellation, transfer). |
| `kikiChgNo` | Field | Device Change Number (機器変更番号) — A sequential identifier for device change operations. |
| `kikiSeizoNo` | Field | Equipment Serial Number (機器製造番号) — The manufacturer-assigned unique serial number of the device. |
| `taknkikiModelCd` | Field | Indoor Equipment Model Code (宅内機器型式コード) — The product model identifier for indoor customer-premises equipment. |
| `kktkSbtCd` | Field | Equipment Provision Type Code (機器提供種別コード) — Classifies the type of equipment provision (e.g., "02" for Rental). |
| `haisoNo` | Field | Delivery Number (配送番号) — Unique identifier for a logistics delivery record. |
| `haisoStat_013` | Field | Delivery Status (配送ステータス) — Current state of the delivery record. "001" = Received (受診済), "005" = Canceled (中止). |
| `seqHenpinKikiNo` | Field | Return Device Number (返品機器番号) — System-generated unique identifier for a returned device, allocated via SEQ_HMPIN_KIKI_NO sequence. |
| HAISO_STAT | Field | Delivery Status Code (配送ステータスコード) — Enumerated status of a delivery record: "001" (Received), "005" (Canceled). |
| `CD00009_HAISO_STAT_001` | Constant | "001" — Delivery Status: Received (配送ステータス 受診済). Indicates the device has been delivered to the customer. |
| `CD00009_HAISO_STAT_005` | Constant | "005" — Delivery Status: Canceled/Stopped (配送ステータス 中止). Indicates the delivery has been canceled. |
| `CD00022_HAISO_STP_CD_2` | Constant | "2" — Delivery Cancellation Code: Cancel (配送中止コード キャンセル). The specific reason code for the cancellation. |
| `CD00212_KKTK_SBT_CD_02` | Constant | "02" — Equipment Provision Type: Rental (機器提供種別 コード: レンタル). Indicates the device is provided on a rental basis. |
| `CD00296_HMPIN_KIKI_STAT_001` | Constant | "001" — Return Device Status: Received (返品機器ステータス: 受診済). The returned device has been received at the facility. |
| `CD00291_HMPIN_DIV_1` | Constant | "1" — Return Classification: Canceled Item (返品区分: キャンセル品). The device is being returned because the service was canceled. |
| `CD00293_HMPIN_RSN_CD_96` | Constant | "96" — Return Reason Code: Pre-installation Cancellation — Common (返品理由コード: 工事前キャンセル(共通)). The service was canceled before the installation work began. |
| `MK_FLG_YK` | Constant | "0" — Invalid Flag: Valid (無効フラグ: 有効). "0" means the record is valid (not invalidated). |
| DK_T_HAISO | DB Entity | Delivery Table (配送テーブル) — Stores logistics delivery records including delivery numbers, status, and cancellation information. |
| DK_T_HMPIN_KIKI | DB Entity | Return Device Table (返品機器テーブル) — Stores return device records with full equipment details, return reasons, and audit trail. |
| SEQ_HMPIN_KIKI_NO | Sequence | Return Device Number Sequence — Oracle sequence for generating unique return device identifiers with prefix "R" + 2-digit year. |
| K-Opticom | Business term | K-Opticom — The telecommunications service provider (K-Opticom Corporation) whose customer base system this code serves. |
| Rental (レンタル) | Business term | Equipment provided on a rental basis, as opposed to customer-owned equipment. Rental devices must be returned upon service cancellation. |
| STB | Acronym | Set-Top Box — A device that receives and decodes cable/satellite/digital television signals. |
| VONU | Acronym | Voice-over ONU — An optical network unit that also provides VoIP telephone service. |
| ONU | Acronym | Optical Network Unit — A device that terminates fiber optic lines and provides network connectivity to customer premises. |
| Pre-installation Cancellation (工事前キャンセル) | Business term | Cancellation of the service contract before the physical installation work has begun. The device has not been delivered or installed at the customer site. |
| Batch Service (BATSERVICE) | Business term | The system user ID used for batch processing operations. Distinguishes automated batch operations from manual screen operations. |
| JBSbatBusinessException | Exception | Business-level exception for non-technical errors (e.g., record not found during expected operations). Uses error code EKKB0210CE. |
| selectByPrimaryKeysForUpdateWait | Method | Optimistic/pessimistic locking query method that acquires an exclusive row lock (SELECT ... FOR UPDATE WAIT) on the delivery record. |
