# Business Logic — JBSbatKKAdChgTekkyoKjFinChsht.initial() [14 LOC]

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

## 1. Role

### JBSbatKKAdChgTekkyoKjFinChsht.initial()

This method performs the initialization routine for a batch process that handles extraction of items related to the completion of construction work for address-change cancellation tasks (住所変更撤去工事完了抽出部品). The class `JBSbatKKAdChgTekkyoKjFinChsht` is a batch service component in the K-Opticom Customer Backbone System (eo顧客基幹システム), specifically designed to extract and process data from tables associated with address changes (住所変更) and their details. The `initial` method serves as the shared initialization entry point defined by the batch service framework, ensuring that every batch execution begins with properly configured common parameters and initialized database access objects. It follows the **delegation pattern**, forwarding common batch parameter setup to its parent class `JBSbatBusinessService.setCommonInfo()`, and then instantiates three `JBSbatSQLAccess` objects — one for each of the working and business tables it will use during the main processing phase (`KK_T_KJ_FIN_WK`, `KK_T_ADCHG_DTL`, `KK_T_ADCHG`). This method does not perform any CRUD operations on its own; rather, it prepares the infrastructure (SQL access layers) that subsequent processing steps (e.g., `execute()`) will use to query and manipulate data.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial.commonItem"])
    CALL["setCommonInfo(commonItem)"]
    INIT1["db_KK_T_KJ_FIN_WK = new JBSbatSQLAccess(..., KK_T_KJ_FIN_WK)"]
    INIT2["db_KK_T_ADCHG_DTL = new JBSbatSQLAccess(..., KK_T_ADCHG_DTL)"]
    INIT3["db_KK_T_ADCHG = new JBSbatSQLAccess(..., KK_T_ADCHG)"]
    END_NODE(["Return / Next"])
    START --> CALL
    CALL --> INIT1
    INIT1 --> INIT2
    INIT2 --> INIT3
    INIT3 --> END_NODE
```

**Step-by-step processing:**

1. **COMMON PARAMETER SETUP** — Delegates to `super.setCommonInfo(commonItem)` to populate inherited fields (operation date, batch user ID, system code, log print object, job ID, etc.) from the incoming batch common parameter message.

2. **WORK TABLE SQL ACCESS INIT** — Creates a new `JBSbatSQLAccess` instance (`db_KK_T_KJ_FIN_WK`) bound to the `KK_T_KJ_FIN_WK` table (Construction Completion Work table). This provides the database access layer for reading/writing work data.

3. **ADDRESS CHANGE DETAIL SQL ACCESS INIT** — Creates a new `JBSbatSQLAccess` instance (`db_KK_T_ADCHG_DTL`) bound to the `KK_T_ADCHG_DTL` table (Address Change Detail table).

4. **ADDRESS CHANGE SQL ACCESS INIT** — Creates a new `JBSbatSQLAccess` instance (`db_KK_T_ADCHG`) bound to the `KK_T_ADCHG` table (Address Change table).

There are **no conditional branches** in this method. Execution is strictly sequential initialization.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | Batch common parameter message — carries operational metadata including operation date (`opeDate`), online operation date (`onlineOpeDate`), batch user ID (`batchUserId`), system code (`systemCode`), log print control object (`logPrint`), job ID (`jobid`), and free item data. This object is the central carrier of batch execution context shared across all batch service components. |

**Inherited instance fields written by called methods:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `opeDate` | (inherited) | Operation date — the business date for this batch run |
| `onlineOpeDate` | (inherited) | Online operation date — date for online transaction processing |
| `batchUserId` | (inherited) | Batch updater ID — the user ID performing the batch update |
| `systemCode` | (inherited) | System code — identifies the K-Opticom backbone system |
| `logPrint` | (inherited) | Log print control object — manages debug/log output routing |
| `jobid` | (inherited) | Job ID — batch job identifier for tracking |
| `freeItem` | (inherited) | Free item — flexible data carrier for batch extras |
| `commonItem` | (inherited) | Reference to the common item itself, stored for later access |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JBSbatBusinessService.setCommonInfo` | - | - | Calls `setCommonInfo` in parent class to set batch common parameters (operation date, user ID, system code, etc.) |

### Method call analysis:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| SET | `JBSbatSQLAccess` constructor | - | `KK_T_KJ_FIN_WK` | Initializes database access object for the Construction Completion Work table — sets up SQL access layer for subsequent data operations |
| SET | `JBSbatSQLAccess` constructor | - | `KK_T_ADCHG_DTL` | Initializes database access object for the Address Change Detail table — provides access to address change line-item data |
| SET | `JBSbatSQLAccess` constructor | - | `KK_T_ADCHG` | Initializes database access object for the Address Change table — provides access to address change header/master data |

**Classification rationale:** The `initial` method performs no actual data reads, writes, updates, or deletes. It creates `JBSbatSQLAccess` instances which are infrastructure objects (database connection/config wrappers). These objects do not perform I/O upon construction — they only establish the access context (table name, operation parameters) for later use by other methods. Therefore these are classified as **SET** (infrastructure setup) rather than CRUD operations. The actual CRUD operations against these tables occur in other methods of this service class (e.g., `execute()`, and the private processing methods it invokes).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKAdChgTekkyoKjFinChsht | `JBSbatBusinessService.initial` (template entry point) -> `JBSbatKKAdChgTekkyoKjFinChsht.initial` | `super.setCommonInfo` [SET] common parameters |

**Notes:**
- This method is a **framework entry point**. The batch service framework (template-generated) calls `initial()` as the initialization phase before delegating to the `execute()` method.
- No other classes in the codebase reference `JBSbatKKAdChgTekkyoKjFinChsht` directly — the class is instantiated and invoked through the batch framework's reflection/service-dispatch mechanism.
- The terminal endpoint is `setCommonInfo`, which populates inherited fields from `JBSbatCommonItem` but does not touch any database tables.

## 6. Per-Branch Detail Blocks

**Block 1** — [EXEC] `(super.setCommonInfo(commonItem))` (L99)

> Sets common batch parameters by delegating to the parent class. This ensures the batch service has access to operation date, system code, user ID, and logging context.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.setCommonInfo(commonItem);` // Sets inherited fields: opeDate, onlineOpeDate, batchUserId, systemCode, logPrint, jobid, freeItem, commonItem [-> JBSbatBusinessService.setCommonInfo] |

**Block 2** — [SET] `(db_KK_T_KJ_FIN_WK initialization)` (L101)

> Initializes the SQL access layer for the Construction Completion Work (工事完了ワーク) table.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_KK_T_KJ_FIN_WK = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_KJ_FIN_WK);` // Table name resolved: "KK_T_KJ_FIN_WK" (工事完了ワーク / Construction Completion Work) |

**Block 3** — [SET] `(db_KK_T_ADCHG_DTL initialization)` (L102)

> Initializes the SQL access layer for the Address Change Detail (住所変更明细) table.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_KK_T_ADCHG_DTL = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_ADCHG_DTL);` // Table name resolved: "KK_T_ADCHG_DTL" (住所変更明細 / Address Change Detail) |

**Block 4** — [SET] `(db_KK_T_ADCHG initialization)` (L103)

> Initializes the SQL access layer for the Address Change (住所変更) table.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_KK_T_ADCHG = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_ADCHG);` // Table name resolved: "KK_T_ADCHG" (住所変更 / Address Change) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_KJ_FIN_WK` | Table | Construction Completion Work table (工事完了ワーク) — Working table that stores construction completion work case numbers, service contract numbers, and construction implementation dates |
| `KK_T_ADCHG_DTL` | Table | Address Change Detail table (住所変更明細) — Stores detailed line-item records of address changes, including address change number and application number |
| `KK_T_ADCHG` | Table | Address Change table (住所変更) — Master table for address change operations |
| `kjfinwk_kojiakNo` | Field | Construction completion work case number (工事完了ワーク．工事案件番号) — Internal tracking ID for construction completion work cases |
| `kjfinwk_svc_kei_no` | Field | Construction completion work service contract number (工事完了ワーク．サービス契約番号) — Links work cases to service contracts |
| `kjfinwk_kojiak_jssi_ymd` | Field | Construction completion work construction implementation date (工事完了ワーク．工事案件実施年月日) — Date when the construction work was executed (added in fix OM-2014-0003696) |
| `adchgdtl_adchg_no` | Field | Address change detail address change number (住所変更明細．住所変更番号) — Unique identifier for address change detail records |
| `adchg_mskm_no` | Field | Address change application number (住所変更．申請番号) — Application tracking number for address change requests |
| `KOJIAK_NO` | Field | Case number field key — Column identifier for case number in `KK_T_KJ_FIN_WK` |
| `SVC_KEI_NO` | Field | Service contract number field key — Column identifier for service contract number in `KK_T_KJ_FIN_WK` |
| `KOJIAK_JSSI_YMD` | Field | Implementation date field key — Column identifier for construction implementation date in `KK_T_KJ_FIN_WK` |
| `MSKM_NO` | Recoded key | Application detail number recoded key (申請明細番号) — Used to extract application numbers from result sets |
| `ADCHG_NO` | Recoded key | Address change number recoded key (住所番号) — Used to extract address change numbers from result sets |
| `KK_SELECT_042` | SQL key | SQL definition key for queries against `KK_T_ADCHG_DTL` table |
| `KK_SELECT_021` | SQL key | SQL definition key for queries against `KK_T_ADCHG` table |
| `JBSbatCommonItem` | Class | Batch common parameter object — Carries operational metadata (dates, user IDs, system codes) shared across batch processing |
| `JBSbatSQLAccess` | Class | Database access abstraction layer — Wraps SQL operations for a specific table with common batch context |
| `JBSbatBusinessService` | Class | Abstract batch business service base class — Provides common batch service infrastructure including `setCommonInfo()` |
| 住所変更 (Jusho Henkou) | Domain | Address Change — The business domain; this batch extracts data related to address change cancellation work completion |
| 撤去工事 (Tekkyo Koji) | Domain | Demolition/Removal Construction — Construction work involving removal of equipment/lines, related to address changes |
| 抽出部品 (Chuushutsu Hinhin) | Domain | Extraction Component — A batch processing component that extracts/filter data from database tables |
| 工事完了 (Koji Kanryou) | Domain | Construction Completion — Status indicating construction work has been completed |
