# Business Logic — JBSbatKKAdHenkoErrOutput.initial() [12 LOC]

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

## 1. Role

### JBSbatKKAdHenkoErrOutput.initial()

This method serves as the **initialization entry point** for the `JBSbatKKAdHenkoErrOutput` batch service class. The class itself is a batch processor whose business purpose is to **extract unavailable-change data from the changeable address list** (変更住所一覧ワークから変更不可データ抽出). When a batch job invokes `initial()`, it sets up the database access infrastructure by creating two `JBSbatSQLAccess` instances targeting the `KK_T_CHG_AD_JGRTWK` table (the Change Address Join Work table), and then delegates to the inherited `setCommonInfo()` method to configure shared batch parameters — including operation date, batch user ID, system code, job ID, and log output control — across both the service instance and a global interface map. This method follows the **delegation pattern**: it does not contain business logic of its own; instead, it wires up the infrastructure state that the batch's `execute()` method will use during its main processing phase. As a shared utility within the batch subsystem, it is the standard initialization hook called at the start of every batch run for this service.

> Javadoc: 初期処理 — "Initial processing"
>
> Javadoc: バッチ共通パラメータ電文 — "Batch common parameter message"

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(JBSbatCommonItem commonItem)"])
    START --> DB_ACCESS1["Create dbAccess = new JBSbatSQLAccess(commonItem, KK_T_CHG_AD_JGRTWK)"]
    DB_ACCESS1 --> DB_ACCESS2["Create db_CHG_AD_JGRTWK = new JBSbatSQLAccess(commonItem, KK_T_CHG_AD_JGRTWK)"]
    DB_ACCESS2 --> SET_COMMON["Call super.setCommonInfo(commonItem)"]
    SET_COMMON --> END_NODE(["Return void / Next"])
```

The `initial()` method executes a linear, unconditional sequence of three steps:

1. **DB Access Object Creation** — Instantiates a `JBSbatSQLAccess` object and assigns it to the instance field `dbAccess`, connecting it to the `KK_T_CHG_AD_JGRTWK` (Change Address Join Work) table via the provided batch common parameters.
2. **Duplicate DB Access Object Creation** — Instantiates a second `JBSbatSQLAccess` object and assigns it to the instance field `db_CHG_AD_JGRTWK`, connecting it to the same `KK_T_CHG_AD_JGRTWK` table. This gives the batch two independent database access handles for the same work table (e.g., one for reads and one for writes, or two separate query contexts).
3. **Common Parameter Setup** — Delegates to `super.setCommonInfo(commonItem)` (inherited from `JBSbatBusinessService`), which extracts shared batch context — operation date, online operation date, batch user ID, system code, log print control, job ID, and free items — from the `commonItem` and propagates them to both the service instance and the global `JBSbatInterface.commonItem` static field.

There are **no conditional branches** in this method. It always executes all three steps in the same order regardless of input.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | Batch common parameter message — carries the shared batch execution context including the operation date (運用日), online operation date (オンライン運用日), batch user ID (バッチ更新者ID), system code (システムコード), log output control object (ログ出力制御オブジェクト), job ID (ジョブID), and free item fields. This object determines which batch run this initialization belongs to and seeds all downstream processing with consistent operational metadata. |

**Instance fields read by this method:** None (this method writes to instance fields; it does not read any).

**Instance fields written by this method:**

| Field | Type | Description |
|-------|------|-------------|
| `dbAccess` | `JBSbatSQLAccess` | Primary database access handle for the `KK_T_CHG_AD_JGRTWK` table |
| `db_CHG_AD_JGRTWK` | `JBSbatSQLAccess` | Secondary (dedicated) database access handle for the `KK_T_CHG_AD_JGRTWK` table |

## 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 `JBSbatBusinessService` (super class) to propagate batch common parameters |

### Per-call classification:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `new JBSbatSQLAccess(commonItem, "KK_T_CHG_AD_JGRTWK")` (×2) | - | `KK_T_CHG_AD_JGRTWK` | Creates two database access instances for the Change Address Join Work table; prepares the connection context for subsequent read/write operations in the batch main processing phase |
| - | `super.setCommonInfo(commonItem)` | - | - | Sets batch common parameters (operation date, job ID, user ID, system code, log control) from the input commonItem into the service instance and global interface |

**Note:** No actual CRUD (C/R/U/D) operations occur within `initial()` itself. This method is purely an infrastructure setup phase — it creates database access handles and seeds shared state but does not execute any SQL queries or data mutations. The actual data operations happen in the subsequent `execute()` method of this class.

## 5. Dependency Trace

Based on the search across the codebase (59,002 Java files), `JBSbatKKAdHenkoErrOutput` is referenced only within its own definition file. This indicates it is a batch service class instantiated and invoked through a batch framework or batch job configuration (not via direct Java method calls from other application classes). In K-Opticom batch architectures, batch service classes are typically invoked by a batch dispatcher or job definition file (e.g., COBOL batch steps, shell scripts, or a batch scheduler) rather than by other Java classes.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch Dispatcher | `BatchFramework.invoke()` -> `JBSbatKKAdHenkoErrOutput.initial(commonItem)` | `setCommonInfo [U] (batch params)` |

**Downstream dependencies from this method:**

| # | Called Method | Returns To | Purpose |
|---|--------------|------------|---------|
| 1 | `new JBSbatSQLAccess(commonItem, "KK_T_CHG_AD_JGRTWK")` | — | Creates two DB access handles for the Change Address Join Work table |
| 2 | `super.setCommonInfo(commonItem)` | `JBSbatBusinessService` | Propagates batch common parameters to service instance and global interface |
| 3 | (indirect) `JBSbatInterface.commonItem = item` | `JBSbatInterface` (static) | Sets the common item on the global interface for cross-component access |

## 6. Per-Branch Detail Blocks

This method has no conditional branches (no if/else, switch, or loops). The entire method is a single linear execution block.

**Block 1** — [LINEAR EXECUTION] `(no condition)` (L79)

> Create two `JBSbatSQLAccess` instances for the `KK_T_CHG_AD_JGRTWK` table.
>
> DB: `KK_T_CHG_AD_JGRTWK` — Change Address Join Work table. This is a work table used during batch processing to store intermediate results when extracting change-unavailable data from the changeable address list. Having two handles (`dbAccess` and `db_CHG_AD_JGRTWK`) allows the batch to maintain separate read and write contexts or distinct query handles for the same table.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbAccess = new JBSbatSQLAccess(commonItem, "KK_T_CHG_AD_JGRTWK");` // Create primary DB access handle [-> TABLE = "KK_T_CHG_AD_JGRTWK" (Change Address Join Work)] |
| 2 | SET | `db_CHG_AD_JGRTWK = new JBSbatSQLAccess(commonItem, "KK_T_CHG_AD_JGRTWK");` // Create secondary (dedicated) DB access handle for the same work table |

**Block 2** — [LINEAR EXECUTION] `(no condition)` (L81)

> Set common batch parameters by delegating to the parent class.
>
> `setCommonInfo` (inherited from `JBSbatBusinessService`) extracts and assigns the following fields from `commonItem`: `opeDate` (operation date / 運用日), `onlineOpeDate` (online operation date / オンライン運用日), `batchUserId` (batch updater ID / バッチ更新者ID), `systemCode` (system code / システムコード), `logPrint` (log output control / ログ出力制御), `jobid` (job ID / ジョブID), `freeItem` (free items / フリー項目), and `commonItem` itself. It also writes `commonItem` to the static field `JBSbatInterface.commonItem` for cross-component access. Finally, it calls `setPgidToLogPrintObj()` to set the program group ID on the log print object.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.setCommonInfo(commonItem);` // Propagate batch common parameters to service instance and global interface [-> JBSbatBusinessService.setCommonInfo()] |
| 2 | RETURN | `// Return void` // No explicit return statement (void method) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_CHG_AD_JGRTWK` | DB Table | Change Address Join Work table — a temporary work table used during batch processing to store intermediate results when joining address change data with eligibility information |
| `dbAccess` | Field | Primary database access handle — the main `JBSbatSQLAccess` instance used for executing SQL operations against the work table |
| `db_CHG_AD_JGRTWK` | Field | Secondary database access handle — a dedicated `JBSbatSQLAccess` instance for the same work table, providing an independent query context |
| `commonItem` | Field | Batch common parameter message — the central data carrier that holds all shared batch execution metadata |
| `opeDate` | Field | Operation date (運用日) — the business date for which the batch is being executed |
| `onlineOpeDate` | Field | Online operation date (オンライン運用日) — the date used for online (real-time) system operations |
| `batchUserId` | Field | Batch user ID (バッチ更新者ID) — the identifier of the user who initiated or owns this batch run |
| `systemCode` | Field | System code (システムコード) — the identifier of the system component in the K-Opticom ecosystem |
| `jobid` | Field | Job ID (ジョブID) — the identifier of the batch job within the batch scheduler |
| `logPrint` | Field | Log output control (ログ出力制御) — the object responsible for controlling debug and operational log output |
| `freeItem` | Field | Free item (フリー項目) — customizable fields available for batch-specific metadata |
| `JBSbatBusinessService` | Class | Base batch business service class — provides common batch processing infrastructure including `setCommonInfo()`, logging, and database access utilities |
| `JBSbatSQLAccess` | Class | SQL database access wrapper — a framework class that encapsulates database connection and query execution for a specific table |
| `JBSbatCommonItem` | Class | Batch common item — the standard data structure carrying batch execution context across all batch services |
| `JBSbatInterface` | Class | Global batch interface — a static holder for shared batch data accessible across components |
| `setCommonInfo` | Method | Sets common batch parameters — inherited method that extracts and assigns operational metadata from `commonItem` |
| KK | Acronym | K-Opticom (契約管理 — Contract Management) — the contract management subsystem of the eo customer backbone system |
| KKSV | Acronym | K-Opticom Screen (Vision?) — screen/batch class naming prefix for K-Opticom modules |
| KKSV0004 | Screen | A K-Opticom screen (KKSV0004) that may reference this batch service |
| 変更住所一覧ワーク | Business term | Changeable Address List Work — a work table or view that contains the list of addresses eligible for change processing |
| 変更不可データ | Business term | Change-unavailable data — address records that cannot be modified, extracted from the changeable address list during batch processing |
| 初期処理 | Business term | Initial processing — the initialization phase of a batch service that sets up infrastructure before main processing |
| バッチ共通パラメータ電文 | Business term | Batch common parameter message — the standard data structure carrying shared batch context |
| DBアクセスクラス | Business term | Database access class — the `JBSbatSQLAccess` wrapper used to perform database operations |
| ツールから生成された初期化のソース | Business term | Tool-generated initialization source — this code block was auto-generated by a code generation tool |
| 業務サービスの初期処理 | Business term | Initial processing of business service — a placeholder comment indicating where custom business service initialization should be described |
| 共通パラメータを設定します | Business term | Set common parameters — comment describing the `setCommonInfo` delegation |
| プログラムID | Business term | Program ID (pgid) — the identifier of the current program, set on the log print object for traceability |
