# Business Logic — JBSbatKKAdHenkoHoyuDataChstuOtr.initial() [16 LOC]

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

## 1. Role

### JBSbatKKAdHenkoHoyuDataChstuOtr.initial()

This method serves as the **initialization routine** for the "Changed Target Address Code Work" batch service (`JBSbatKKAdHenkoHoyuDataChstuOtr`). It prepares the service layer for subsequent data extraction and insertion processing by establishing database access object instances for the five tables involved in the batch operation. The batch as a whole operates on the "address mask latest record extraction" product — it extracts address data from changed-target address code work tables and inserts it into the changed address registration work table, deriving from address mask latest record data.

The `initial` method follows a **delegation and preparation pattern**: it creates `JBSbatSQLAccess` instances (the batch framework's database access abstraction) for each of the five working/intermediate tables required during execution, and delegates common batch parameter setup to its parent class `JBSbatBusinessService.setCommonInfo()`. This is a standard lifecycle method in the batch service framework — it is not called directly by application screens but is invoked internally by the batch runtime during service initialization, before the `execute()` method performs the actual business logic (selecting data from `CK_T_PROSCST` and `DK_T_YBKIKI_HAISO`, generating sequence numbers, and inserting into `KK_T_CHG_AD_JGRTWK`).

Since this method contains no conditional branches, it executes the same initialization sequence regardless of input parameters. Its role is purely infrastructural: setting up the database access layer so that the `execute()` method can subsequently query and insert address change work records.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(commonItem)"])
    START --> INIT["Initialize DB Access Objects"]
    INIT --> S1["db_CHGTGAD_CD_WK = new JBSbatSQLAccess(commonItem, KK_T_CHGTGAD_CD_WK)"]
    S1 --> S2["db_CHG_AD_JGRTWK = new JBSbatSQLAccess(commonItem, KK_T_CHG_AD_JGRTWK)"]
    S2 --> S3["db_CK_T_PROSCST = new JBSbatSQLAccess(commonItem, CK_T_PROSCST)"]
    S3 --> S4["db_DK_T_YBKIKI_HAISO = new JBSbatSQLAccess(commonItem, DK_T_YBKIKI_HAISO)"]
    S4 --> S5["db_KU_T_SENKO_DSGN = new JBSbatSQLAccess(commonItem, KU_T_SENKO_DSGN)"]
    S5 --> SET["setCommonInfo(commonItem)"]
    SET --> END(["Return / Next"])
```

This method performs a linear, branchless initialization sequence:

1. **Create DB Access Objects**: Five `JBSbatSQLAccess` instances are created, each bound to a specific database table. These objects wrap JDBC-level operations (select, insert, update, delete) for the batch's working and intermediate tables.
2. **Set Common Batch Parameters**: Delegates to the parent class `JBSbatBusinessService.setCommonInfo(commonItem)` to propagate batch common parameters (such as connection, process date, batch ID) to the service instance.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | Batch common parameters — carries the batch execution context including database connection, process date, batch ID, and other framework-level configuration shared across all batch service components. This is the standard entry-point parameter for all `initial()` methods in the batch service hierarchy. |

**Instance fields initialized by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_CHGTGAD_CD_WK` | `JBSbatSQLAccess` | DB access layer for `KK_T_CHGTGAD_CD_WK` (Changed Target Address Code Work) — holds the source address change code work data to be extracted |
| `db_CHG_AD_JGRTWK` | `JBSbatSQLAccess` | DB access layer for `KK_T_CHG_AD_JGRTWK` (Changed Address Registration Work) — holds the destination work records where extracted address data is inserted |
| `db_CK_T_PROSCST` | `JBSbatSQLAccess` | DB access layer for `CK_T_PROSCST` (Process Cost / Address Mask Source) — source table for inquiry customer (問合わせ客) address data extraction via SQL define `KK_SELECT_003` |
| `db_DK_T_YBKIKI_HAISO` | `JBSbatSQLAccess` | DB access layer for `DK_T_YBKIKI_HAISO` (Preparation Equipment Delivery) — source table for preparation equipment delivery address data extraction via SQL define `KK_SELECT_001` |
| `db_KU_T_SENKO_DSGN` | `JBSbatSQLAccess` | DB access layer for `KU_T_SENKO_DSGN` (Delivery Design) — available for delivery design related data access (not actively used in `execute()`; reserved for future or extended processing) |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JBSbatBusinessService.setCommonInfo` | - | - | Calls `setCommonInfo` in the parent batch service class to propagate common batch parameters (connection, process date, batch ID) to the service instance |

**Notes:** This method performs no direct database reads, writes, updates, or deletes. It only creates `JBSbatSQLAccess` wrapper instances (which are lightweight Java objects, not SQL operations) and delegates parameter setup to the parent class. All actual CRUD operations occur in the `execute()` method of this class.

## 5. Dependency Trace

The `initial()` method follows a standard batch service lifecycle pattern. In the K-Opticom batch framework, `initial()` is called by the batch runtime framework itself (not by direct application screens or CBS classes). The batch process entry point is typically a batch job configuration (e.g., in `koptBp` or `koptBatch`) that instantiates the service class and invokes its lifecycle methods in order: `initial()` → `execute()` → `postProcess()`.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKAdHenkoHoyuDataChstuOtr | `BatchScheduler` -> `JBSbatBusinessService.executeBatch()` -> `JBSbatKKAdHenkoHoyuDataChstuOtr.initial` | `setCommonInfo [No-op - parameter setup]` |

**Notes:** Direct caller search for `initial(` in Java files found no external invocations of this method. The method is part of the batch service lifecycle hook — it is invoked by the framework's batch scheduler/runtime, which instantiates the service and calls `initial()` before the `execute()` method. This is a standard pattern for all `JBSbatBusinessService` subclasses in the `eo.business.service` package. The method itself does not call any downstream service components (SC/CBS), database queries, or entity operations beyond the parent class's `setCommonInfo` delegation.

## 6. Per-Branch Detail Blocks

Since this method contains no conditional branches, loops, or switch statements, there is a single linear block:

**Block 1** — [LINEAR EXECUTION] (no conditions) (L56)

> Initialize database access objects and set common batch parameters. The Javadoc comments indicate this is the tool-generated initialization block (`ツールから生成された初期化のソースです`) and contains the business service initialization logic (`業務サービスの初期処理を記述してください`).

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_CHGTGAD_CD_WK = new JBSbatSQLAccess(commonItem, "KK_T_CHGTGAD_CD_WK")` // Create DB access for Changed Target Address Code Work table [コメント: DBアクセスクラスを生成します - "Generate DB access class"] (L58) |
| 2 | SET | `db_CHG_AD_JGRTWK = new JBSbatSQLAccess(commonItem, "KK_T_CHG_AD_JGRTWK")` // Create DB access for Changed Address Registration Work table (L59) |
| 3 | SET | `db_CK_T_PROSCST = new JBSbatSQLAccess(commonItem, "CK_T_PROSCST")` // Create DB access for Process Cost / Address Mask Source table (L60) |
| 4 | SET | `db_DK_T_YBKIKI_HAISO = new JBSbatSQLAccess(commonItem, "DK_T_YBKIKI_HAISO")` // Create DB access for Preparation Equipment Delivery table (L61) |
| 5 | SET | `db_KU_T_SENKO_DSGN = new JBSbatSQLAccess(commonItem, "KU_T_SENKO_DSGN")` // Create DB access for Delivery Design table (L62) |
| 6 | CALL | `super.setCommonInfo(commonItem)` // Set common batch parameters [コメント: 共通パラメータを設定します - "Set common parameters"] (L65) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `CHG_AD_JGRTWK` | Table | Changed Address Registration Work — intermediate work table where extracted address data is inserted with generated sequence numbers and change-type metadata |
| `CHGTGAD_CD_WK` | Table | Changed Target Address Code Work — source table holding address code change records; the batch extracts records from this to populate the registration work table |
| `CK_T_PROSCST` | Table | Process Cost (Address Mask Source) — source table for inquiry customer address data; the execute method queries this via SQL define `KK_SELECT_003` to extract address records with schema ID "CK0051" |
| `DK_T_YBKIKI_HAISO` | Table | Preparation Equipment Delivery — source table for preparation equipment delivery address data; the execute method queries this via SQL define `KK_SELECT_001` to extract address records with schema ID "DK0061" |
| `KU_T_SENKO_DSGN` | Table | Delivery Design — delivery design related table; DB access instance is initialized in `initial()` but not actively used in the current `execute()` implementation (reserved for extended processing) |
| `JBSbatSQLAccess` | Class | Batch framework SQL access wrapper — provides select, insert, update, delete operations against a specific table, parameterized by a `JBSbatCommonItem` for connection and transaction context |
| `JBSbatCommonItem` | Class | Batch common item — carries batch execution context (database connection, process date, batch ID) shared across all batch service components |
| `JBSbatBusinessService` | Class | Parent batch service class — provides common batch lifecycle methods including `setCommonInfo()` for parameter propagation |
| `SEQ_CHG_AD_JGRTWK_NO` | Constant | Oracle sequence name for generating unique change address registration work record numbers |
| `JZMBatCommon` | Class | Batch common utility class — provides helper methods such as `getInMapData()` for extracting data from service interface maps |
| `JCCOracleSeqUtil` | Class | Oracle sequence utility — provides `getFormatedNextSeq()` for generating formatted next sequence numbers using `JKKBatConst.SEQ_KETA` as the digit width |
| `JKKBatConst` | Class | K-Opticom Batch constants — defines constant values such as `SEQ_KETA` (sequence digit width) and `HENKO_ADD_CD_MI` (change address code: not changed) |
| `AD_CD` | Field | Address Code — the primary address identifier used as a filter key when querying source tables (PROSCST and YBKIKI_HAISO) |
| `PROSCST_NO` | Field | Process Cost Number — internal tracking number for address mask source records |
| `YBKIKI_HAISO_NO` | Field | Preparation Equipment Delivery Number — tracking number for delivery equipment records |
| `CHG_AD_JGRTWK_NO` | Field | Changed Address Registration Work Number — unique sequence-generated identifier for each work record |
| `CHG_TG_SCHEMA_ID` | Field | Change Target Schema ID — identifies the source data schema type ("CK0051" for PROSCST inquiry customer, "DK0061" for YBKIKI_HAISO preparation equipment) |
| `CHG_TG_KMK_NM_EINM` | Field | Change Target Customer Name EINM — English internal name of the change target (e.g., "PROSCST_AD_CD", "YBKIKI_HISOS_AD_CD") |
| `AD_SHUSEI_CD` | Field | Address Modification Code — code indicating the type of address modification performed |
| `NEW_AD_CD` / `OLD_AD_CD` | Field | New / Old Address Code — the before and after values of the address code change |
| `PCD` / `NEW_PCD` / `OLD_PCD` | Field | Postal Code — the before and after postal code values |
| `STATE_NM` / `CITY_NM` / `OAZTSU_NM` / `AZCHO_NM` | Field | Prefecture Name / City Name / District Name / Block Number — components of the Japanese address hierarchy (before and after values) |
| `AD_TOHAIGO_TRN_STAT_CD` | Field | Address To Destination Transfer Status Code — transfer status flag for address change records; set to `HENKO_ADD_CD_MI` indicating "not changed" |
| `PROSCST_AD_CD` | Field | Original (Old) Address Code from PROSCST — preserves the pre-change address code for audit trail |
| `HENKO_ADD_CD_MI` | Constant | Change Address Code: Not Applied — indicates the address has not yet been transferred/changed (ミ = 未 = not yet) |
| `KK_SELECT_001` | SQL Define | SQL define key for querying `DK_T_YBKIKI_HAISO` table by address code |
| `KK_SELECT_003` | SQL Define | SQL define key for querying `CK_T_PROSCST` table by address code |
| 住所マスタ最新レコード抽出部品 | Japanese field name | Address Mask Latest Record Extraction Product — the batch's functional scope: extracting the latest records from address mask (住所マスタ) data |
| 変更対象住所コードワーク | Japanese field name | Changed Target Address Code Work — the source work table containing address code change records |
| 変更保留住所データ抽出クラス | Japanese field name | Changed Reservation Address Data Extraction Class — the class's descriptive name; this batch class extracts changed reservation address data |
| 問合わせ客 | Japanese field name | Inquiry Customer — customer type whose address data is sourced from the PROSCST (Process Cost) table |
| 予備機器配送 | Japanese field name | Preparation Equipment Delivery — the delivery type whose address data is sourced from the YBKIKI_HAISO table |
