# Business Logic — JBSbatTUBmpSwchSodTrn.executeTU_T_BMP_KOJI_TU_SELECT_003() [11 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatTUBmpSwchSodTrn` |
| Layer | Service (Package: `eo.business.service`, module in `koptBatch`) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatTUBmpSwchSodTrn.executeTU_T_BMP_KOJI_TU_SELECT_003()

This method performs a **record-lock select** on the **Phone Construction (BMP) table** (`TU_T_BMP_KOJI`) to verify the existence and immutability of a specific phone construction record before it is updated. It is part of the **Phone Change SOD Auto Processing** module (`JBSbatTUBmpSwchSodTrn`), which automates Service Order Data (SOD) creation during customer number portability (MNP / 番ポ = 番号ポータビリティ) scenarios.

The method receives an array of three bind variables — the Phone Construction Number (`BMP_KOJI_NO`), the Generation Registration DateTime (`GENE_ADD_DTM`), and the Phone Construction Confirmation Date — and constructs a parameter list that is passed to a SQL-based select operation. Its primary business purpose is **optimistic/pessimistic record locking**: by executing a locked read (SELECT ... FOR UPDATE or equivalent) against the target record, it ensures no other concurrent process modifies the same construction record while the calling method proceeds to update the Phone Construction Status (`BMP_KOJI_STAT`) to `SOD_HAKKO_ZUMI` ("040" — SOD Issuance Complete).

This method follows a **delegation pattern**: it does not contain SQL logic itself but delegates to `db_TU_T_BMP_KOJI_L.selectBySqlDefine()`, which is a SQL mapping accessor initialized against the `TU_T_BMP_KOJI` table. It acts as a **private helper** called exclusively by `JBSbatTUBmpSwchSodTrn.execute()`, the main batch entry point for the phone change SOD auto-processing routine.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeTU_T_BMP_KOJI_TU_SELECT_003(param)"])
    STEP1["Generate bind variable list (paramList)"]
    STEP2["Set param[0] - Phone Construction Number (BMP_KOJI_NO)"]
    STEP3["Set param[1] - Generation Registration DateTime (GENE_ADD_DTM)"]
    STEP4["Set param[2] - Phone Construction Confirmation Date"]
    STEP5["Execute DB select via db_TU_T_BMP_KOJI_L.selectBySqlDefine()"]
    STEP6["SQLKEY: TU_SELECT_003"]
    END_NODE(["Return (void)"])

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

**Processing summary (translated from Javadoc):**

1. **Bind variable setup (バインド変数の設定):** Generate a `JBSbatCommonDBInterface` object (`paramList`) to hold the bind variables extracted from the `param` array.
2. **DB access execution (DBアクセスの実行):** Call `db_TU_T_BMP_KOJI_L.selectBySqlDefine()` with the prepared parameter list and the SQL key `TU_SELECT_003` to perform a locked read on the `TU_T_BMP_KOJI` table.

There are no conditional branches, loops, or error-handling blocks within this method. It is a straightforward linear pass-through from input parameters to database query.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `Object[]` | An array of three bind variable values used as WHERE clause parameters for the `TU_T_BMP_KOJI` record-lock select. The elements are: (0) Phone Construction Number (`BMP_KOJI_NO`), (1) Generation Registration DateTime (`GENE_ADD_DTM`), (2) Phone Construction Confirmation Date. These values define the unique identity of the construction record to lock. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_TU_T_BMP_KOJI_L` | `JBSbatSQLAccess` | SQL access accessor initialized against the `TU_T_BMP_KOJI` table. Used to execute the locked SELECT query. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `db_TU_T_BMP_KOJI_L.selectBySqlDefine` | - | `TU_T_BMP_KOJI` | Performs a SELECT (record-lock read) on the Phone Construction table using the SQL key `TU_SELECT_003`. This is the primary database operation, retrieving and locking the target construction record for subsequent update. |

### Detailed classification:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `db_TU_T_BMP_KOJI_L.selectBySqlDefine` | - | `TU_T_BMP_KOJI` | Record-lock SELECT on the Phone Construction (番号工事) table. Uses SQL key `TU_SELECT_003` to execute a locked read, ensuring the record is available for the concurrent update that follows in the caller (`executeTU_T_BMP_KOJI_TU_UPD_001`). |

**Classification rationale:** This method performs **one operation** — a database SELECT with locking semantics (R). It is invoked as part of a lock-then-update sequence in the parent `execute()` method, where: (1) this select locks the record, (2) `selectNext()` checks if the record was found, and (3) if found, the record is updated via `executeTU_T_BMP_KOJI_TU_UPD_001` which sets `BMP_KOJI_STAT` to `SOD_HAKKO_ZUMI` ("040" — SOD Issuance Complete).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatTUBmpSwchSodTrn.execute()` | `executeTU_T_BMP_KOJI_TU_SELECT_003(whereParamLock)` called from `execute()` within the phone change SOD auto-processing flow | `selectBySqlDefine [R] TU_T_BMP_KOJI` |

**Call chain description:** The `execute()` method of `JBSbatTUBmpSwchSodTrn` is the batch entry point. It constructs a `whereParamLock` array of three elements (Phone Construction Number, Generation Registration DateTime, Phone Construction Confirmation Date), then calls `executeTU_T_BMP_KOJI_TU_SELECT_003(whereParamLock)`. The result of this select determines whether the record exists and is lockable — if `selectNext()` returns null, processing is skipped; if it returns a row, the record is updated to mark SOD issuance as complete.

**Terminal operations from this method:**
- `db_TU_T_BMP_KOJI_L.selectBySqlDefine` → `TU_T_BMP_KOJI` [R] — Record-lock SELECT for the phone construction record.

## 6. Per-Branch Detail Blocks

### Block 1 — [PROCESSING] `(bind variable list generation)` (L535)

> Generate the bind variable list object and populate it with the three bind variable values extracted from the input parameter array.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `JBSbatCommonDBInterface paramList = new JBSbatCommonDBInterface()` | Create a new bind variable list container for the SQL query parameters. [-> `new JBSbatCommonDBInterface()`] |
| 2 | EXEC | `paramList.setValue(param[0].toString())` | Set Phone Construction Number (番号工事番号) as the first bind variable. |
| 3 | EXEC | `paramList.setValue(param[1].toString())` | Set Generation Registration DateTime (世代登録年月日時分秒) as the second bind variable. |
| 4 | EXEC | `paramList.setValue(param[2].toString())` | Set Phone Construction Confirmation Date (番号工事確定年月日時) as the third bind variable. |

### Block 2 — [PROCESSING] `(DB access execution)` (L540)

> Execute the locked SELECT against the `TU_T_BMP_KOJI` table using the SQL key `TU_SELECT_003`.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `db_TU_T_BMP_KOJI_L.selectBySqlDefine(paramList, TU_T_BMP_KOJI_TU_SELECT_003)` | Execute SQL SELECT with lock. SQLKEY=`TU_SELECT_003`. Target table: `TU_T_BMP_KOJI`. This locks the record for the subsequent update in the caller. |
| 2 | RETURN | `void` | Return to caller. No return value; the lock is maintained on the DB connection. |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `BMP_KOJI_NO` | Field | Phone Construction Number — unique identifier for a phone portability construction work item in the system |
| `BMP_KOJI_STAT` | Field | Phone Construction Status — indicates the current processing state of a phone construction record (e.g., "040" = SOD Issuance Complete) |
| `GENE_ADD_DTM` | Field | Generation Registration DateTime — timestamp when the construction record version/generation was registered; used as a concurrency control key |
| `SOD_HAKKO_ZUMI` | Constant | "040" — SOD Issuance Complete flag, indicating that the Service Order Data has been successfully issued for this construction |
| `TU_SELECT_003` | SQL Key | SQL definition key for the record-lock SELECT on the `TU_T_BMP_KOJI` table |
| `TU_T_BMP_KOJI` | Table | Phone Construction table — stores phone portability (MNP) construction work records, including customer details, service contracts, and construction status |
| MNP / 番ポ (Bango Portable) | Business term | Number Portability — allows customers to retain their phone number when switching telecommunications providers |
| SOD | Acronym | Service Order Data — the order document created for a customer service change/registration in the telecom ordering system |
| 番号工事 (Bango Kouji) | Business term | Phone Number Construction — the process of setting up or modifying a customer's phone number service, particularly during portability |
| 世代 (Sedai) | Business term | Generation/Version — a versioning concept used in this system to track record generations for optimistic/pessimistic concurrency control |
| `JBSbatCommonDBInterface` | Class | Common database interface for bind variable management — used to construct parameter lists for SQL execution |
| `JBSbatSQLAccess` | Class | SQL access abstraction layer — provides methods like `selectBySqlDefine()` and `selectNext()` for executing database queries |
| `JBSbatTUBmpSwchSodTrn` | Class | Phone Change SOD Auto Processing Service — the batch service that automates SOD creation during phone number portability |
| `JBSbatTU_T_BMP_KOJI` | Class | Constants class for the `TU_T_BMP_KOJI` table — defines column name constants (e.g., `BMP_KOJI_NO`, `GENE_ADD_DTM`) |
| `JTUStrConst.SOD_HAKKO_ZUMI` | Constant | "040" — string constant representing the "SOD Issuance Complete" status value |
| Record Lock | Concept | A database mechanism that prevents concurrent modifications to a record during a transaction, implemented here via `selectBySqlDefine` followed by `selectNext()` |

---

*Document generated from source: `source/koptBatch/src/eo/business/service/JBSbatTUBmpSwchSodTrn.java` (lines 533–543).*
*Class: `eo.business.service.JBSbatTUBmpSwchSodTrn extends JBSbatBusinessService`*
*Module: Phone Change SOD Auto Processing (番号切替SOD自動処理品目)*
