# Business Logic — JBSbatKKAdChgTekkyoKjFinChsht.executeKK_T_ADCHG_KK_SELECT_021() [21 LOC]

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

## 1. Role

### JBSbatKKAdChgTekkyoKjFinChsht.executeKK_T_ADCHG_KK_SELECT_021()

This method performs a **database read operation** to retrieve the **application number (MSKM_NO)** from the address change master table (`KK_T_ADCHG`) using the address change number as the lookup key. It is a dedicated SQL SELECT helper method, identified by the SQLKEY `KK_SELECT_021`. Within the batch processing pipeline for address change withdrawal work completion (住所変更中撤去工事完了 — "address change mid-process removal work completion"), this method serves as the data retrieval bridge between the address change detail records and the master application records. The caller method `execute()` passes an address change number (`adchgdtl_adchg_no`), which was previously resolved from the work completion work table (`KK_T_KJ_FIN_WK`), and this method fetches the corresponding application number from the address change master. If no matching record is found, the method logs a debug message indicating the application number is unavailable and returns `null`, which causes the caller to skip further processing for the current record.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeKK_T_ADCHG_KK_SELECT_021(param)"])
    B1["Create JBSbatCommonDBInterface paramList<br/>Bind param[0] (address change number)"]
    B2["Execute SQL access:<br/>db_KK_T_ADCHG.selectBySqlDefine(paramList, KK_SELECT_021)"]
    B3["Retrieve record:<br/>svInfo = db_KK_T_ADCHG.selectNext()"]
    COND{"svInfo is null?"}
    B4["Log: address change<br/>application number not found<br/>Log: skip processing for unobtainable application number"]
    RETN["Return null"]
    B5["Log: address change<br/>application number: msKM_NO value"]
    B6["Return svInfo.getString(MSKM_NO)"]
    END(["End"])

    START --> B1
    B1 --> B2
    B2 --> B3
    B3 --> COND
    COND -- true --> B4
    B4 --> RETN
    RETN --> END
    COND -- false --> B5
    B5 --> B6
    B6 --> END
```

**CRITICAL — Constant Resolution:**
- `KK_T_ADCHG_KK_SELECT_021 = "KK_SELECT_021"` — SQL definition key identifying the SELECT query to execute against the `KK_T_ADCHG` table.
- `MSKM_NO = "MSKM_NO"` — Record key constant used to extract the application number (申請番号) from the retrieved database record.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `Object[]` | Array containing bind variable values. Index `param[0]` holds the **address change number** (住所変更番号, `ADCHG_NO`) — the primary key used to look up the record in the address change master table (`KK_T_ADCHG`). This value is passed from the caller's resolved `adchgdtl_adchg_no` field, which was itself obtained from the address change detail table (`KK_T_ADCHG_DTL`). |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_KK_T_ADCHG` | `JBSbatSQLAccess` | Database access handler for the address change master table (`KK_T_ADCHG`). Initialized by the parent class to execute SQL queries against this table. |
| `logPrint` (inherited) | — | Debug logging utility. Used to log address change application number status and skip conditions. |

## 4. CRUD Operations / Called Services

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

No direct method calls to other service components (SC/CBS) were found in the source code. The method performs its operations through the `JBSbatSQLAccess` framework class, which handles low-level database interactions via SQL definition files.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `db_KK_T_ADCHG.selectBySqlDefine` | - | `KK_T_ADCHG` (Address Change Master) | Executes the SQL query identified by `KK_SELECT_021` against the address change master table, binding the address change number from the input param array. |
| R | `db_KK_T_ADCHG.selectNext` | - | `KK_T_ADCHG` (Address Change Master) | Retrieves the next row from the result set of the previously executed SQL query. Returns a `JBSbatCommonDBInterface` record containing the address change master fields, or `null` if no record is found. |
| R | `svInfo.getString(MSKM_NO)` | - | In-memory record | Extracts the application number (申請番号, MSKM_NO) value from the retrieved record. |
| - | `paramList.setValue` | - | In-memory bind variable | Binds the address change number from the input parameter array into the database interface bind variable list for SQL execution. |
| - | `super.logPrint.printDebugLog` | JACBatCommon | - | Debug logging utility. Logs the application number found or the skip condition when no record exists. |

## 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: `selectBySqlDefine` [R], `selectNext` [R], `getString` [R], `setValue` [-], `printDebugLog` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKAdChgTekkyoKjFinChsht.execute()` | `JBSbatKKAdChgTekkyoKjFinChsht.execute()` -> `executeKK_T_ADCHG_KK_SELECT_021(new String[]{adchgdtl_adchg_no})` | `selectBySqlDefine [R] KK_T_ADCHG`, `selectNext [R] KK_T_ADCHG`, `getString [R] MSKM_NO` |

**Call chain detail:** The caller `execute()` method resolves the address change detail number (`adchgdtl_adchg_no`) from the address change detail table (`KK_T_ADCHG_DTL`) by querying with the work completion work table's construction case number (`kjfinwk_kojiakNo`). It then passes this address change number to `executeKK_T_ADCHG_KK_SELECT_021()` to look up the corresponding application number from the address change master (`KK_T_ADCHG`). The returned application number (`adchg_mskm_no`) is stored in an output map for downstream processing.

## 6. Per-Branch Detail Blocks

**Block 1** — [PROCESS] Bind bind variable and execute SQL (L261)

> Creates the database interface bind variable list and populates it with the address change number from the input parameter array, then executes the SQL SELECT query against the address change master table.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramList = new JBSbatCommonDBInterface();` // Create bind variable list |
| 2 | SET | `svInfo = null;` // Initialize record reference |
| 3 | SET | `paramList.setValue(param[0].toString());` // Bind address change number [-> ADCHG_NO] |
| 4 | CALL | `db_KK_T_ADCHG.selectBySqlDefine(paramList, KK_T_ADCHG_KK_SELECT_021);` // Execute SQL [KK_SELECT_021] against KK_T_ADCHG |

**Block 2** — [PROCESS] Record retrieval (L269)

> Retrieves the next row from the SQL result set.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svInfo = db_KK_T_ADCHG.selectNext();` // Get next record from result set |

**Block 3** — [IF] Null check on retrieved record (L270)

> Determines whether a matching record was found. If `svInfo` is `null`, the address change number does not exist in the master table — logs diagnostic information and returns `null` to signal the caller to skip further processing.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (svInfo == null)` [L270] |
| 1.1 | EXEC | `super.logPrint.printDebugLog(" 住所変更.申請番号：該当無し");` // Log: Address change application number: not found |
| 1.2 | EXEC | `super.logPrint.printDebugLog("----申請番号が取得できない処理をスキップします");` // Log: Skip processing for unobtainable application number |
| 1.3 | RETURN | `return null;` |

**Block 4** — [ELSE-IMPLIED] Record found — extract and return (L274)

> The record was found. Logs the application number (MSKM_NO) as debug output and returns it to the caller for downstream use.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printDebugLog(" 住所変更.申請番号：" + svInfo.getString(MSKM_NO));` // Log: Address change application number: [MSKM_NO value] |
| 2 | RETURN | `return svInfo.getString(MSKM_NO);` // Return application number string [-> MSKM_NO] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_ADCHG` | Table | Address Change Master Table — core master table storing address change records, each linked to a customer application |
| `KK_T_ADCHG_DTL` | Table | Address Change Detail Table — stores line-item details of address changes, linked to the master table by address change number |
| `KK_T_KJ_FIN_WK` | Table | Work Completion Work Table — temporary work table holding completed construction job data for address change withdrawal processing |
| `MSKM_NO` | Field | Application Number (申請番号) — unique identifier for a customer's service application/order |
| `ADCHG_NO` | Field | Address Change Number (住所変更番号) — key identifier for an address change record in the master table |
| `KK_SELECT_021` | SQL Key | SQL definition identifier for the SELECT query that retrieves an address change master record by its address change number |
| `param[0]` | Parameter | Address change number passed as a bind variable — the lookup key for the address change master table query |
| `JBSbatSQLAccess` | Class | Database access framework class — handles SQL execution, result set navigation, and bind variable management for batch services |
| `JBSbatCommonDBInterface` | Class | Common database interface — holds bind variables for SQL parameterization and retrieved record fields |
| `db_KK_T_ADCHG` | Field | Database access handler for the `KK_T_ADCHG` table — instance of `JBSbatSQLAccess` configured to operate on the address change master |
| `adchgdtl_adchg_no` | Field | Address change number resolved from the address change detail table — intermediate lookup key between work completion and address change master |
| `adchg_mskm_no` | Field | Application number resolved from the address change master — the final output value of this method's processing chain |
| `JBSbatKKAdChgTekkyoKjFinChsht` | Class | Address Change Delivery Work Completion Retrieval Item — batch service class for retrieving data during address change withdrawal work completion processing |
| 住所変更 (Jusho Henko) | Business term | Address Change — the business process of changing a customer's registered address, including creation, modification, and withdrawal |
| 申請番号 (Shinsei Bangou) | Business term | Application Number — the primary identifier for a customer service application, linking address changes back to the original order |
| 中撤去工事完了 (Chutei Koji Kanryo) | Business term | Mid-Process Removal Work Completion — batch process that finalizes and retrieves data for address change operations that involve removal of equipment/service lines during an active contract period |