---

# Business Logic — JBSbatKKSkaLckDteEdit.execute() [29 LOC]

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

## 1. Role

### JBSbatKKSkaLckDteEdit.execute()

This method performs the **Skipper Key Closing Linkage Year/Month Edit** operation (スケーパー鍵閉め連替年月編集), which is the core batch processing entry point for updating skipper key information associated with migration reservations in the telecom customer core system. A "skipper key" (スケーパー鍵) is an internal system identifier used in K-Opticom's infrastructure to manage and close out service migration records during the year/month-end processing cycle.

The method implements a **Query-Then-Conditional-Update** pattern. It first queries the migration reservation table (`KK_T_IDO_RSV`) to retrieve pending migration records, then conditionally applies CAS (Customer Account System) information updates based on the result of a check operation. Specifically, if a migration reservation record exists, it first performs a CAS information check; if the check passes (returns true), it proceeds to update the CAS information with the new co-swap year/month.

Its **role in the larger system** is that of a batch routing/dispatch service. It is called from the batch framework (`JBSbatBusinessService`) and delegates the actual CAS update work to the `execSvc` method. The method acts as a controlled entry point that ensures migration data is present and validated before attempting any CAS modifications, making it a critical component in the service migration data pipeline.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute(inMap)"])
    START --> LOG_START["Print Debug Log: execute_START"]
    LOG_START --> CREATE_MAP["Create idoDivDataMap (JBSbatCommonDBInterface)"]
    CREATE_MAP --> CREATE_KEY["Create keyParam from inMap.getString(IDO_RSV_NO)"]
    CREATE_KEY --> EXEC_SELECT["executeKK_T_IDO_RSV_KK_SELECT_114(keyParam)"]
    EXEC_SELECT --> SELECT_NEXT["idoDivDataMap = db_KK_T_IDO_RSV.selectNext()"]
    SELECT_NEXT --> CHECK_NULL{idoDivDataMap != null?}
    CHECK_NULL -->|true| EXEC_CHK["execSvc(FUNC_CD_CHK=2, SHORI_CD_CRS_CHG, idoDivDataMap)"]
    CHECK_NULL -->|false| LOG_END["Print Debug Log: execute_END"]
    EXEC_CHK --> CHK_RESULT{execSvc returns true?}
    CHK_RESULT -->|true| EXEC_UPD["execSvc(FUNC_CD_UPD=1, SHORI_CD_CRS_CHG, idoDivDataMap)"]
    CHK_RESULT -->|false| LOG_END
    EXEC_UPD --> LOG_END
    LOG_END --> RETURN["Return null"]
    RETURN --> END(["execute_END"])
```

**Constant Resolution:**
- `FUNC_CD_CHK = "2"` — Function Code for check-only operation (機能コード：チェックのみ)
- `FUNC_CD_UPD = "1"` — Function Code for update operation (機能コード：更新)
- `SHORI_CD_CRS_CHG = "2"` — Processing Code for co-swap change (処理コード：コス変更)

**Processing flow:**
1. Log the start of execution for debug tracing.
2. Instantiate an empty `JBSbatCommonDBInterface` to hold SQL query results for migration reservation data (異動予約データ).
3. Extract the migration reservation number (`IDO_RSV_NO`) from the input map and wrap it in a `String[]` array as the query key parameter.
4. Execute the SQL select operation `KK_SELECT_114` against the `KK_T_IDO_RSV` table using the key parameter.
5. Retrieve the next result row from the database access object.
6. If the result is not null, perform a CAS information check (機能コード "2") via `execSvc`. If the check passes (returns true), proceed to CAS information update (機能コード "1") via `execSvc`.
7. Log the end of execution and return null.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input message carrying batch processing parameters. Specifically contains the migration reservation number (`IDO_RSV_NO`) used to query the `KK_T_IDO_RSV` table for pending migration records. |

**Instance fields / external state read by this method:**

| # | Field Name | Type | Business Description |
|---|-----------|------|---------------------|
| 1 | `db_KK_T_IDO_RSV` | `JBSbatSQLAccess` | Database access handle for the `KK_T_IDO_RSV` table, initialized in the `initial()` method. Provides `selectNext()` for reading migration reservation records. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKIFM151.getString` | JBSbatKKIFM151 | - | Reads the migration reservation number (`IDO_RSV_NO`) from the input map `inMap` |
| R | `executeKK_T_IDO_RSV_KK_SELECT_114` | - | `KK_T_IDO_RSV` | Executes SQL select (KK_SELECT_114) to query the migration reservation table by reservation number key |
| R | `db_KK_T_IDO_RSV.selectNext` | - | `KK_T_IDO_RSV` | Fetches the next row from the query result cursor of the migration reservation table |
| - | `JBSbatKKSkaLckDteEdit.execSvc` | JBSbatKKSkaLckDteEdit | CAS / Migration Reservation Data | Delegates to the service method for CAS information check (funcCd="2") or update (funcCd="1") with co-swap change processing code |

**CRUD classification:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `inMap.getString(IDO_RSV_NO)` | JBSbatKKIFM151 | - | Reads the migration reservation number from the input parameter map |
| R | `executeKK_T_IDO_RSV_KK_SELECT_114(keyParam)` | - | `KK_T_IDO_RSV` | Queries the migration reservation table for records matching the given reservation number |
| R | `db_KK_T_IDO_RSV.selectNext()` | - | `KK_T_IDO_RSV` | Advances the result cursor and retrieves the next migration reservation record |
| R | `execSvc(FUNC_CD_CHK, SHORI_CD_CRS_CHG, ...)` | JBSbatKKSkaLckDteEdit | - | Performs a CAS information check operation (funcCd="2") on migration reservation data with co-swap change processing |
| U | `execSvc(FUNC_CD_UPD, SHORI_CD_CRS_CHG, ...)` | JBSbatKKSkaLckDteEdit | - | Performs a CAS information update operation (funcCd="1") on migration reservation data with co-swap change processing |

**Key observations:**
- This method performs **Read-heavy** operations: it primarily queries the `KK_T_IDO_RSV` (Migration Reservation) table.
- The actual update to CAS data is delegated to `execSvc`, which internally checks and updates skipper key information.
- There are **no direct Create or Delete** operations in this method.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKSkaLckDteEdit | `JBSbatBusinessService.execute(inMap)` | `selectNext [R] KK_T_IDO_RSV` → `execSvc [R/U] CAS Migration` |

**Notes:**
- `JBSbatKKSkaLckDteEdit` is a batch-only service class extending `JBSbatBusinessService`. It does not appear to be called directly from any screen (no `KKSV*` callers found).
- The method is invoked by the batch framework, likely as part of the nightly/monthly batch processing cycle for skipper key operations.
- The terminal operations it reaches: reads from `KK_T_IDO_RSV` and delegates CAS check/update through `execSvc`.

## 6. Per-Branch Detail Blocks

**Block 1** — [EXEC] `(debug logging)` (L89)

> Log the start of the execute method for debug traceability.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printDebugLog("execute_START")` // Print debug log marking start of main processing |

**Block 2** — [EXEC] `(create SQL result map)` (L91)

> Generate a map to hold SQL execution results for the migration reservation data fetch.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface idoDivDataMap = new JBSbatCommonDBInterface()` // SQL execution result get map (異動予約スキーマ取得) |

**Block 3** — [EXEC] `(extract migration reservation number key)` (L93)

> Extract the migration reservation number from the input message and wrap it as the query key.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String[] keyParam = {inMap.getString(JBSbatKKIFM151.IDO_RSV_NO)}` // Array key parameter from input message |

**Block 4** — [CALL] `(execute SQL select on KK_T_IDO_RSV)` (L95)

> Execute the SQL select operation KK_SELECT_114 against the migration reservation table using the reservation number key.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_IDO_RSV_KK_SELECT_114(keyParam)` // SQL execution on KK_T_IDO_RSV table |

**Block 5** — [CALL] `(fetch next migration reservation record)` (L96)

> Retrieve the next row from the query result cursor.

| # | Type | Code |
|---|------|------|
| 1 | SET | `idoDivDataMap = db_KK_T_IDO_RSV.selectNext()` // SQL execution result get |

**Block 6** — [IF] `(idoDivDataMap != null)` (L98)

> Check whether a migration reservation record was found. If found, proceed with CAS information processing. If null, skip directly to end logging.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `// CAS情報の更新チェックを行う` // Perform CAS information update check |

**Block 6.1** — [IF-THEN] `(condition: idoDivDataMap != null → true)` (L101)

> CAS information check processing. Call `execSvc` with function code "2" (check-only) and processing code "2" (co-swap change).

| # | Type | Code |
|---|------|------|
| 1 | SET | `boolean result = execSvc(FUNC_CD_CHK, SHORI_CD_CRS_CHG, idoDivDataMap)` // Check result: true=normal, false=error |
| 2 | CALL | `execSvc("2", "2", idoDivDataMap)` // [-> FUNC_CD_CHK="2" (機能コード：チェックのみ), SHORI_CD_CRS_CHG="2" (処理コード：コス変更)] |

**Block 6.1.1** — [IF] `(result == true)` (L103)

> If the CAS check passes, proceed to update the CAS information with the new co-swap year/month data.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `// CAS情報の登録を行う` // Register CAS information |

**Block 6.1.2** — [IF-THEN] `(condition: result == true → true)` (L105)

> Call `execSvc` with function code "1" (update) and processing code "2" (co-swap change) to commit the CAS information update.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `execSvc(FUNC_CD_UPD, SHORI_CD_CRS_CHG, idoDivDataMap)` // [-> FUNC_CD_UPD="1" (機能コード：更新)] |

**Block 7** — [EXEC] `(end logging)` (L108)

> Log the end of the execute method.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printDebugLog("execute_END")` // Print debug log marking end of main processing |

**Block 8** — [RETURN] `(return null)` (L109)

> Return null as the output item. This method does not produce structured output data; it performs side-effect updates only.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `IDO_RSV_NO` | Field | Migration Reservation Number — unique identifier for a service migration reservation record in the `KK_T_IDO_RSV` table |
| `KK_T_IDO_RSV` | Table | Migration Reservation Table — database table storing pending service migration reservation records (異動予約) |
| Skipper Key (スケーパー鍵) | Business term | Internal system identifier used in K-Opticom's telecom core system to manage and close out service migration records during year/month-end processing cycles |
| CAS (Customer Account System) | Acronym | Customer Account System — the core billing and customer management system whose records are updated during migration |
| `FUNC_CD_CHK` | Constant | Function Code for check-only operation (機能コード：チェックのみ), value = "2" |
| `FUNC_CD_UPD` | Constant | Function Code for update operation (機能コード：更新), value = "1" |
| `SHORI_CD_CRS_CHG` | Constant | Processing Code for co-swap change (処理コード：コス変更), value = "2" |
| Co-swap (コス変更) | Business term | Co-swap — a service migration operation where billing/contract data is swapped between services during migration processing |
| `JBSbatServiceInterfaceMap` | Type | Service Interface Map — the batch framework's input message container carrying parameters between batch components |
| `JBSbatCommonDBInterface` | Type | Common Database Interface — a generic data container holding query result rows (column name → value mappings) |
| `JBSbatBusinessService` | Class | Base batch business service class — provides common batch processing infrastructure including debug logging and common info handling |
| KK_SELECT_114 | SQL Key | SQL definition key for selecting migration reservation records from `KK_T_IDO_RSV` by reservation number |
| Batch (バッチ) | Term | Nightly/monthly automated background processing job run by the K-Opticom batch framework |
| `JBSbatKKIFM151` | Class | Input message field definition — contains field constants for batch input messages, including `IDO_RSV_NO` |

---
