# Business Logic — JBSbatTUBmpSwchSodTrn.initial() [18 LOC]

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

## 1. Role

### JBSbatTUBmpSwchSodTrn.initial()

This method is the initialization entry point for a **batch service that handles automatic phone number change (Number Portability / 番口切替) Service Order Data (SOD) processing**. When a customer requests to port their phone number to a new carrier or change within the same provider, this batch system orchestrates the entire SOD (Service Order Data) lifecycle — from order issuance to delivery and completion. The `initial` method is responsible for **setting up the batch processing context and establishing all required database access connections** before the main processing logic (`execute()`) begins.

Specifically, this method initializes four database access objects: (1) the primary phone number work transaction table (`TU_T_BMP_KOJI`), (2) a local log copy of the same table used for audit/retry tracking, (3) the service contract details table for eo Hikari Light Phone (`KK_T_SVKEIUW_EOH_TEL`) — introduced in version 28.00.00 for bilateral phone number change support (ANK-4494-00-00), and (4) the communication service provider master table (`TU_M_TUSHIN_JGYOSHA`) — also added in version 28.00.00 to look up information about the receiving/originating carrier during number portability operations. The method implements the **template method pattern**, serving as the setup phase of a batch service lifecycle where `initial()` prepares state, `execute()` performs the core work, and `terminal()` (inherited from `JBSbatBusinessService`) handles cleanup.

This is a **shared batch service component** — it does not belong to a specific UI screen but is invoked by the batch scheduler framework. It processes phone number change service orders in bulk, handling operations such as registration, cancellation, same-number reassignment, and service order issuance for delayed/succeeded SOD responses (as noted in version 28.00.00 changelog: "SOD response abnormality/retention — phone number cancellation/same phone number reassignment SOD issuance processing improvement").

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(commonItem)"])
    START --> A["Set common parameters
super.setCommonInfo(commonItem)"]
    A --> B["Create DB Access:
db_TU_T_BMP_KOJI
(table: TU_T_BMP_KOJI)"]
    B --> C["Create DB Access:
db_TU_T_BMP_KOJI_L
(table: TU_T_BMP_KOJI, local log)"]
    C --> D["Create DB Access:
db_KK_T_SVKEIUW_EOH_TEL
(table: KK_T_SVKEIUW_EOH_TEL)
[ANK-4494-00-00 ADD]"]
    D --> E["Create DB Access:
db_TU_M_TUSHIN_JGYOSHA
(table: TU_M_TUSHIN_JGYOSHA)
[ANK-4494-00-00 ADD]"]
    E --> END(["Return / Next"])
```

The processing flow is **linear and unconditional** — there are no conditional branches in this method. The method:

1. Delegates to the parent class `JBSbatBusinessService.setCommonInfo()` to set up the batch context (operation date, online operation date, batch user ID, system code, log print control, job ID, free item data, and the common item reference itself).
2. Instantiates four `JBSbatSQLAccess` objects, each wrapping a specific database table for batch SQL operations. These access objects are stored as instance fields for use by subsequent processing methods.

**Constant Resolution:** No branching logic exists in this method, so no constant value resolution is needed for control flow. The constants used here (e.g., `BMP_SWCH = "021"`, `CHK_ADD = "1"`) are defined as instance fields and referenced by other methods in the class, but not evaluated within `initial()` itself.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | Batch common parameter document (バッチ共通パラメータ電文) — carries the global batch execution context including operation date (`opeDate`), online operation date (`onlineOpeDate`), batch user ID (`batchUserId`), system code (`systemCode`), log print control object, job ID (`jobid`), and free item data. This is the central data carrier shared across all batch processing services in the system. |

**Instance fields read by this method:** None directly (the method only writes to instance fields).

**External state accessed:** The parent class `JBSbatBusinessService.setCommonInfo()` sets the following instance fields via `commonItem`:
- `batchUserId` — Batch update user ID (バッチ更新者ID)
- `opeDate` — Operation date (運用日)
- `onlineOpeDate` — Online operation date (オンライン運用日)
- `systemCode` — System code (システムコード)
- `logPrint` — Log print control object (ログ出力制御オブジェクト)
- `jobid` — Job ID (ジョブID)
- `freeItem` — Free item data (自由項目)
- `commonItem` — The common document itself (共通電文)

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JBSbatBusinessService.setCommonInfo` | JBSbatBusinessService | In-memory (batch context) | Sets batch common parameters (operation date, user ID, system code, job ID) into instance fields of the parent service class. This is a state initialization operation, not a database operation. |

### Method Call Details:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `new JBSbatSQLAccess(commonItem, "TU_T_BMP_KOJI")` | JBSbatSQLAccess | `TU_T_BMP_KOJI` (Phone Number Work / 番口工事) | Creates a database access handle for the phone number change work transaction table. This table tracks the lifecycle of phone number change (portability) work orders. |
| C | `new JBSbatSQLAccess(commonItem, "TU_T_BMP_KOJI")` | JBSbatSQLAccess | `TU_T_BMP_KOJI` (Phone Number Work / 番口工事 — local log) | Creates a second database access handle to the same table, used as a local log copy (番口工事ロック用 — for phone number work locking/audit purposes). |
| C | `new JBSbatSQLAccess(commonItem, "KK_T_SVKEIUW_EOH_TEL")` | JBSbatSQLAccess | `KK_T_SVKEIUW_EOH_TEL` (Service Contract Details <eo Hikari Light Phone> / サービス契約内詳＜eo光電話＞) | Creates a database access handle for the service contract details table specific to eo Hikari Light Phone. Added in ANK-4494-00-00 for bilateral phone number change support. Used to query/modify service contract line item information during phone number portability. |
| C | `new JBSbatSQLAccess(commonItem, "TU_M_TUSHIN_JGYOSHA")` | JBSbatSQLAccess | `TU_M_TUSHIN_JGYOSHA` (Communication Service Provider / 通信事業者) | Creates a database access handle for the communication service provider master table. Added in ANK-4494-00-00. Used to look up carrier information (MNP originating/receiving carrier codes, carrier names) during number portability processing. |

**Note:** All four operations are "creation" of SQL access handles (instantiation of `JBSbatSQLAccess` objects), not database CRUD operations. The actual database reads/writes occur later when these access handles are used by other methods (e.g., `execute()`) to perform SQL queries and updates against the respective tables.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatTUBmpSwchSodTrn | `JBSbatTUBmpSwchSodTrn.initial(commonItem)` | `setCommonInfo [U] batch context`; `db_TU_T_BMP_KOJI [C] TU_T_BMP_KOJI`; `db_KK_T_SVKEIUW_EOH_TEL [C] KK_T_SVKEIUW_EOH_TEL`; `db_TU_M_TUSHIN_JGYOSHA [C] TU_M_TUSHIN_JGYOSHA` |

**Note:** No external callers were found in the codebase that directly invoke `JBSbatTUBmpSwchSodTrn.initial()`. This method is a **protected entry point** designed to be called by the batch processing framework (scheduler) or by subclasses/extension mechanisms. The batch framework typically instantiates the service class and calls `initial()` followed by `execute()` and `terminal()` as part of the batch lifecycle template.

## 6. Per-Branch Detail Blocks

**Block 1** — [CALL] `(common parameter setup) (L162)`

> Sets common batch parameters by delegating to the parent class. This establishes the processing context (operation date, user ID, system code, etc.) for all downstream batch operations.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.setCommonInfo(commonItem);` // Sets batch common parameters (共通パラメータを設定します) [-> JBSbatBusinessService] |

**Block 2** — [CALL] `(auto-generated source — DB Access Class Generation Start) (L165)`

> Initializes the database access handle for the phone number work transaction table (番口工事). This is auto-generated scaffolding code from the development tool.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `// 共通パラメータを設定します` // comment: Sets common parameters |
| 2 | SET | `db_TU_T_BMP_KOJI = new JBSbatSQLAccess(commonItem, D_TBL_NAME_TU_T_BMP_KOJI);` // comment: DBアクセスクラスを生成します (Generate DB access class) [-> D_TBL_NAME_TU_T_BMP_KOJI="TU_T_BMP_KOJI"] |

**Block 3** — [CALL] `(auto-generated source — DB Access Class Generation End) (L168)`

> Initializes the local log database access handle (for phone number work locking/audit).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `// DBアクセスクラスを生成します` // comment: Generate DB access class |
| 2 | SET | `db_TU_T_BMP_KOJI_L = new JBSbatSQLAccess(commonItem, D_TBL_NAME_TU_T_BMP_KOJI);` // comment: DBアクセスクラスを生成します (Generate DB access class) [-> same table "TU_T_BMP_KOJI", different access handle for local log] |

**Block 4** — [CALL] `(ANK-4494-00-00 ADD: Bilateral Phone Number Change) (L170–L171)`

> Initializes database access handles for the eo Hikari Light Phone service contract details table and the communication service provider master table. Added in ANK-4494-00-00 to support bilateral (two-way) phone number change (番口対応).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `// ANK-4494-00-00 ADD START` // comment: ANK-4494-00-00 feature add |
| 2 | SET | `db_KK_T_SVKEIUW_EOH_TEL = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_SVKEIUW_EOH_TEL);` // DB access for service contract details <eo Hikari Light Phone> [-> D_TBL_NAME_KK_T_SVKEIUW_EOH_TEL="KK_T_SVKEIUW_EOH_TEL"] |
| 3 | SET | `db_TU_M_TUSHIN_JGYOSHA = new JBSbatSQLAccess(commonItem, D_TBL_NAME_TU_M_TUSHIN_JGYOSHA);` // DB access for communication service provider [-> D_TBL_NAME_TU_M_TUSHIN_JGYOSHA="TU_M_TUSHIN_JGYOSHA"] |
| 4 | EXEC | `// ANK-4494-00-00 ADD END` // comment: Feature add end marker |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| SOD | Acronym | Service Order Data — telecom order fulfillment entity representing a service order record in the customer base system |
| 番口切替 (Bankou Settei) | Business term | Phone Number Change / Number Portability — the process of allowing a customer to retain their phone number when switching service providers or plans |
| TU_T_BMP_KOJI | DB Table | Phone Number Work (番口工事) table — tracks the lifecycle of phone number change work orders including registration, validation, execution, and completion |
| KK_T_SVKEIUW_EOH_TEL | DB Table | Service Contract Details <eo Hikari Light Phone> (サービス契約内詳＜eo光電話＞) table — stores detailed service contract line item information for eo Hikari Light Phone plans |
| TU_M_TUSHIN_JGYOSHA | DB Table | Communication Service Provider (通信事業者) master table — master data for telecom carriers involved in number portability (MNP originating/receiving carriers) |
| JBSbatSQLAccess | Class | Database access handle — a framework class that wraps JDBC operations for batch processing, providing query/update capabilities tied to a specific batch context |
| JBSbatCommonItem | Class | Batch common parameter document (バッチ共通パラメータ電文) — the central data carrier for batch execution context (operation date, user ID, system code, etc.) |
| JBSbatBusinessService | Class | Abstract batch service base class — provides the template method lifecycle (`initial()`, `execute()`, `terminal()`) and common batch state management |
| BMP_SWCH | Constant | "021" — Phone Number Change flag/indicator (番口切替) |
| CHK_ADD | Constant | "1" — Check and Register operation code (チェック＆登録) |
| ANK-4494-00-00 | JIRIA Ticket | Feature ticket for bilateral phone number change support (双方向番口対応) added in version 72.00.00 (2024/04/09) |
| CC | Acronym | Common Component — shared business logic components (e.g., CC_TITLE_1 = "TUSV009701CC") |
| TUSV0097 | Screen/Module Code | The module code for the phone number change SOD automatic processing screen/function |
| IDO_DIV_ENUMDEL | Constant | "09001" — Displacement classification for ENUM deletion (ENUM消去) |
| BMP_SYORI_DIV | Field | Phone number processing classification (番口処理区分) |
| SJGS_CD | Field | Service provider code (事業者コード) — carrier identification code used in MNP processing |
