# Business Logic — JBSbatKKAdChgTekkyoKjFinUpd.getIdoRsv() [31 LOC]

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

## 1. Role

### JBSbatKKAdChgTekkyoKjFinUpd.getIdoRsv()

This method retrieves **transfer reservation information** (異動予約情報) from the database by searching the `KK_T_IDO_RSV` table using a detail-level service contract line item number (`mskmdtl_mskm_dtl_no`) as the search key. The business operation centers on the telecom domain concept of "ido" (異動, transfer/migration), which refers to reservation records that track pending or scheduled transfer/migration operations on customer service contracts — for example, when a customer's phone line, fiber broadband service, or other telecom product is scheduled to be moved to a different physical location or reconfigured.

The method acts as a **data retrieval bridge** between the batch processing entry point (`execute()`) and the database. It executes a SQL-based query against the transfer reservation table, iterates over all matching records using a cursor-style `selectNext()` pattern, and accumulates the results into the instance-level collection field `ido_rsv_inf_list`. This list is then consumed by the caller, which performs **service contract disposition control** checks (サービス契約排制制御) to verify that no conflicting or invalid disposition control records exist in `KK_T_SVKEI_EXC_CTRL` for the found transfer reservations.

The method implements a **simple sequential scan** pattern: it does not branch on condition codes or service types, but instead performs a uniform fetch-and-collect loop over all transfer reservation records matching the given detail number. Its role in the larger system is to provide the batch process with the complete set of transfer reservations associated with a specific service detail line item, enabling downstream business validation (conflict detection and timestamp-based concurrency checks) before the batch proceeds with its core update operations.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getIdoRsv msKmdtlMskmDtlNo"])
    START --> LOG_START["Debug log: 異動予約情報を検索_Start"]
    LOG_START --> INIT_LIST["ido_rsv_inf_list = new ArrayList"]
    INIT_LIST --> SET_PARAM["param = msKmdtlMskmDtlNo, super.opeDate"]
    SET_PARAM --> CALL_SELECT["executeKK_T_IDO_RSV_KK_SELECT_083 param"]
    CALL_SELECT --> NEXT_RECORD["db_map_inf_ido_rsv = db_KK_T_IDO_RSV.selectNext"]
    NEXT_RECORD --> CHECK_NULL{db_map_inf_ido_rsv != null?}
    CHECK_NULL -->|true| ADD_LIST["ido_rsv_inf_list.add db_map_inf_ido_rsv"]
    ADD_LIST --> FETCH_NEXT["db_map_inf_ido_rsv = db_KK_T_IDO_RSV.selectNext"]
    FETCH_NEXT --> CHECK_NULL
    CHECK_NULL -->|false| LOG_COUNT["Debug log: 異動予約件数 size"]
    LOG_COUNT --> LOG_END["Debug log: 異動予約情報を検索_End"]
    LOG_END --> END_NODE(["Return / Next"])
```

**Processing Description:**

1. **Entry and Initialization** — The method receives a detail-level service contract line item number (`mskmdtl_mskm_dtl_no`). It logs the start of the transfer reservation retrieval operation and initializes the instance field `ido_rsv_inf_list` as a fresh `ArrayList` to hold retrieved records.

2. **Parameter Construction** — A two-element parameter array is built containing the search key (`mskmdtl_mskm_dtl_no`) and the current operation date (`super.opeDate`). This parameter pair is passed to the SQL execution method.

3. **SQL Query Execution** — The method delegates to `executeKK_T_IDO_RSV_KK_SELECT_083(param)`, which creates a `JBSbatCommonDBInterface` parameter object, maps the two array values onto it, and executes the SQL defined by the `KK_T_IDO_RSV_KK_SELECT_083` SQL definition file. This populates the `db_KK_T_IDO_RSV` cursor.

4. **Cursor Iteration (Fetch Loop)** — The method enters a `while` loop that repeatedly calls `db_KK_T_IDO_RSV.selectNext()` to fetch one record at a time from the query result set. Each non-null record is appended to `ido_rsv_inf_list`. The loop continues until `selectNext()` returns `null`, indicating no more matching records exist.

5. **Completion Logging** — After the loop exits, the method logs the total number of transfer reservation records found, then logs the end marker, and returns.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `mskmdtl_mskm_dtl_no` | `String` | Service detail line item number — the unique identifier for a specific line item within a service contract. This is the primary search key used to find transfer reservation records associated with this particular service line. The value is typically derived from the `KK_T_MSKM_DTL` (service detail master) table during the batch processing flow in `execute()`. |

**Instance fields accessed:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ido_rsv_inf_list` | `ArrayList<JBSbatCommonDBInterface>` | Instance-level collection that holds all retrieved transfer reservation records. Populated by this method and consumed by the caller (`execute()`). |
| `db_KK_T_IDO_RSV` | `JBSbatSQLAccess` | Database access object (SQL cursor) for the `KK_T_IDO_RSV` table. Initialized during class construction, used by `selectNext()` to iterate query results. |
| `super.opeDate` | Field in parent class | The operation date for the batch run — used as the second query parameter, likely for date-range filtering or audit purposes in the SQL definition. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `printDebugLog` (x8 calls) | JACBatCommon / JACbatDebugLogUtil / JCKLcsRenkeiUtil / JKKHttpCommunicator / JBSbatKKCashPostAddMail | - | Debug logging calls for start/end markers, record count, and operational state. |
| R | `executeKK_T_IDO_RSV_KK_SELECT_083` | KK_T_IDO_RSV_KK_SELECT_083 | `KK_T_IDO_RSV` | Executes a SQL SELECT query against the transfer reservation table using the detail number and operation date as parameters. Populates the `db_KK_T_IDO_RSV` cursor. |
| R | `db_KK_T_IDO_RSV.selectNext()` | - | `KK_T_IDO_RSV` | Fetches the next row from the pre-executed query result set one at a time. Returns null when all rows are consumed. |

### CRUD Classification:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `executeKK_T_IDO_RSV_KK_SELECT_083(Object[])` | KK_T_IDO_RSV_KK_SELECT_083 | `KK_T_IDO_RSV` | Executes a SQL SELECT defining the transfer reservation search query. Maps parameter array values (detail number, operation date) into a parameter object and invokes the SQL access layer to populate the result cursor. |
| R | `db_KK_T_IDO_RSV.selectNext()` | - | `KK_T_IDO_RSV` | Iterative row fetch — retrieves the next row of the active result set as a `JBSbatCommonDBInterface` map. Called repeatedly in a while loop until null is returned. |

No Create, Update, or Delete operations are performed by this method. It is a pure **Read** operation.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `executeKK_T_IDO_RSV_KK_SELECT_083` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKAdChgTekkyoKjFinUpd.execute()` | `execute()` -> `getIdoRsv(mskmdtl_mskm_dtl_no)` | `executeKK_T_IDO_RSV_KK_SELECT_083 [R] KK_T_IDO_RSV`, `selectNext [R] KK_T_IDO_RSV` |

**Caller Context:** The `execute()` method iterates over service detail records (`mskm_dtl_inf_list`), extracts each `mskmdtl_mskm_dtl_no`, and calls `getIdoRsv()` to retrieve any associated transfer reservation records. If transfer reservations are found, the caller proceeds to check service contract disposition control (`searchSvkeiExcCtrl`) and timestamp concurrency checks (`timeStampCheckSvcExecHaita`). If `getIdoRsv()` returns no records, the loop simply continues to the next detail line item.

## 6. Per-Branch Detail Blocks

**Block 1** — [INITIALIZATION] `(setup)` (L588)

> Sets up the debug entry marker and initializes the result collection.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printDebugLog("異動予約情報を検索_START")` // Log: Transfer reservation search START |
| 2 | SET | `db_map_inf_ido_rsv = null` // Initialize cursor holder variable |
| 3 | EXEC | `ido_rsv_inf_list = new ArrayList<JBSbatCommonDBInterface>()` // Init: Transfer reservation result list |

**Block 2** — [PARAMETER CONSTRUCTION] `(L592)`

> Builds the two-element parameter array for the SQL query.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param = {mskmdtl_mskm_dtl_no, super.opeDate}` // [-> param[0]=detail line item number, param[1]=operation date] |

**Block 3** — [SERVICE CALL] `(SQL query execution)` (L595)

> Delegates to the SQL execution method which sets up the parameter object and executes the SELECT query.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_IDO_RSV_KK_SELECT_083(param)` // Calls SQL SELECT on KK_T_IDO_RSV |

**Block 4** — [WHILE LOOP: CURSOR ITERATION] `(fetch and collect records)` (L598–L605)

> Iterates over the result set, collecting all matching transfer reservation records into `ido_rsv_inf_list`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_map_inf_ido_rsv = db_KK_T_IDO_RSV.selectNext()` // Fetch first record |
| 2 | IF | `while (null != db_map_inf_ido_rsv)` // Condition: record exists |

**Block 4.1** — [WHILE BODY: RECORD COLLECTION] `(add record to list)` (L600–L602)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `ido_rsv_inf_list.add(db_map_inf_ido_rsv)` // Add: Record to transfer reservation info list |
| 2 | SET | `db_map_inf_ido_rsv = db_KK_T_IDO_RSV.selectNext()` // Fetch: Next record from cursor |

**Block 5** — [COMPLETION LOGGING] `(L606–L608)`

> Logs the total number of records found and the end marker.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printDebugLog("----異動予約件数: " + ido_rsv_inf_list.size())` // Log: Transfer reservation record count |
| 2 | EXEC | `super.logPrint.printDebugLog("異動予約情報を検索_END")` // Log: Transfer reservation search END |
| 3 | RETURN | `return` (void) // Returns control to caller |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mskmdtl_mskm_dtl_no` | Field | Service detail line item number — unique identifier for a specific line item within a service contract hierarchy (mskm = service detail header, mskm_dtl_no = line item sequence) |
| `ido` (異動) | Field / Term | Transfer / Migration — refers to the act of moving or reconfiguring a telecom service (e.g., relocating a phone line, changing service attributes). `ido_rsv` = transfer reservation |
| `RSV` (予約) | Field / Acronym | Reservation — pending/scheduled record that has not yet been fully executed or finalized |
| `ido_rsv_inf_list` | Field | Transfer reservation information list — instance-level ArrayList holding all `JBSbatCommonDBInterface` records retrieved from the transfer reservation table for the given detail number |
| `db_KK_T_IDO_RSV` | Field | Database access cursor object for the `KK_T_IDO_RSV` table — provides `selectBySqlDefine()` and `selectNext()` methods for query execution and row-by-row iteration |
| `KK_T_IDO_RSV` | DB Table | Transfer Reservation Table — stores records of pending transfer/migration operations on customer service contracts. Also appears in partition lock lists (`PMP_LOCKTBL_*`), indicating it is part of batch processing transaction locks |
| `KK_T_MSKM_DTL` | DB Table | Service Detail Master Table — stores line-item level details of service contracts; `mskmdtl_mskm_dtl_no` is sourced from this table |
| `KK_T_SVKEI_EXC_CTRL` | DB Table | Service Contract Disposition Control Table — tracks disposition control rules for service contracts; queried after transfer reservations are found to validate no conflicts exist |
| `super.opeDate` | Field | Operation date — the processing date of the current batch run, inherited from the parent class and used as a query parameter for date-filtered SQL |
| `KK_T_IDO_RSV_KK_SELECT_083` | SQL Definition | SQL SELECT definition file/constant that defines the query to fetch transfer reservation records by detail number and operation date |
| `JBSbatCommonDBInterface` | Class | Common database interface — interface used to represent a single database row as a key-value map during query result iteration |
| `JBSbatSQLAccess` | Class | SQL access layer — provides cursor-style database operations (`selectBySqlDefine`, `selectNext`) used for batch-oriented row-by-row data retrieval |
| `JBSbatKKAdChgTekkyoKjFinUpd` | Class | Service contract change delivery final update batch — the batch processing service class that handles final update operations for service contract delivery changes |
