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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKBndWdtUpdFile` |
| Layer | Batch (Package: `eo.business.service`, extends `JBSbatBusinessService`) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKBndWdtUpdFile.initial()

This method performs the **initialization phase** for the batch job responsible for registering domain control download file information (`ZM_T_DL_FILE_KANRI`). As described in the Javadoc, it is the "初期処理" (initial processing) step that prepares the service context and establishes the database connectivity needed for the main execution phase.

The method implements the **delegation pattern** by first calling `super.setCommonInfo(commonItem)` on its parent class `JBSbatBusinessService`, which populates shared batch metadata fields (operation date, online operation date, batch user ID) from the incoming `commonItem` parameter. It then creates a dedicated `JBSbatSQLAccess` database access handle to the `ZM_T_DL_FILE_KANRI` table (the Download File Management table), which is used for all subsequent read/write operations during the batch run.

Finally, it extracts the input file path from the `commonItem`'s free item storage — this path points to the postcard file containing "ハガキ用通信量超過通知情報" (Postcard Communication Volume Overlimit Notification Information, a notification file for customers exceeding their data usage limits).

As a lifecycle hook, `initial()` is called by the batch framework before the main `execute()` method. It serves as the entry point for this batch module, which is specifically designed for the "領域制御ファイルダウンロード登録部品" (Domain Control File Download Registration component).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(commonItem)"])
    START --> SET_COMMON["setCommonInfo(commonItem)
Set batch metadata
(opDate, onlineOpeDate, batchUserId)"]
    SET_COMMON --> CREATE_DB["Create db_ZM_T_DL_FILE_KANRI
JBSbatSQLAccess
Table: ZM_T_DL_FILE_KANRI"]
    CREATE_DB --> READ_PATH["Read in_postcard_file_path
from commonItem.getFreeItem()"]
    READ_PATH --> END_NODE(["Return / Next"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | Batch common parameter message — carries shared batch execution context including operation date, online operation date, batch user ID, and a free item map that stores the domain control file path (specifically the postcard file path for communication volume overlimit notifications) |

**Instance fields / external state read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `D_TBL_NAME_ZM_T_DL_FILE_KANRI` | `String` (constant = `"ZM_T_DL_FILE_KANRI"`) | Table name constant for the Download File Management table — defines which DB table the SQL access handle targets |
| `in_postcard_file_path` | `String` (instance field, default `""`) | Postcard file path — stores the file system path to the input file containing postcard-type communication overlimit notification data |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JBSbatBusinessService.setCommonInfo` | (framework) | (batch metadata fields) | Sets common batch information (operation date, online operation date, batch user ID) from the common parameter object |
| C | `JBSbatSQLAccess` constructor | (framework) | `ZM_T_DL_FILE_KANRI` | Creates a new database access handle to the Download File Management table for use in subsequent operations |
| R | `JBSbatCommonItem.getFreeItem` | (framework) | (in-memory) | Retrieves the free item map from the common parameter to obtain the postcard file path |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKBndWdtUpdFile` | Batch framework -> `JBSbatKKBndWdtUpdFile.initial` | `setCommonInfo [U] batch metadata fields` |
| 2 | Batch: `JBSbatKKBndWdtUpdFile` | Batch framework -> `JBSbatKKBndWdtUpdFile.initial` | `JBSbatSQLAccess [C] ZM_T_DL_FILE_KANRI` |
| 3 | Batch: `JBSbatKKBndWdtUpdFile` | Batch framework -> `JBSbatKKBndWdtUpdFile.initial` | `getFreeItem [R] in-memory` |

**Note:** `initial()` is a lifecycle hook method invoked by the batch execution framework before the main `execute()` method. It is not called directly from external screen or CBS classes. The batch framework orchestrates the call chain through the parent class `JBSbatBusinessService`'s execution template.

## 6. Per-Branch Detail Blocks

### Block 1 — CALL `(super.setCommonInfo)` (L68)

> Sets common batch parameter information by delegating to the parent class.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.setCommonInfo(commonItem);` // 共通パラメータを設定します (Set common parameters) -> populates `opeDate`, `onlineOpeDate`, `batchUserId` in parent `JBSbatBusinessService` |

### Block 2 — SET `(db_ZM_T_DL_FILE_KANRI creation)` (L71)

> Generates a DB access class from the tool to connect to the Download File Management table.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_ZM_T_DL_FILE_KANRI = new JBSbatSQLAccess(commonItem, D_TBL_NAME_ZM_T_DL_FILE_KANRI);` // DBアクセスクラスを生成します (Generate DB access class) [-> `D_TBL_NAME_ZM_T_DL_FILE_KANRI = "ZM_T_DL_FILE_KANRI"`] |

### Block 3 — EXEC `(in_postcard_file_path read)` (L75)

> Reads the input file path for postcard notification data from the common item's free item storage.

| # | Type | Code |
|---|------|------|
| 1 | SET | `in_postcard_file_path = super.commonItem.getFreeItem();` // 入力ファイルパスを取得 (Get input file path) -> stores the free item map containing the postcard file path |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ZM_T_DL_FILE_KANRI` | Table | Download File Management table — stores information about domain control files used for download registration |
| 初期処理 (Shokishi) | Process | Initial processing — the startup phase of a batch service where connections and parameters are prepared |
| 領域制御ファイルダウンロード登録部品 (Ryiki Seigyo File Download Registration Component) | Module | Domain Control File Download Registration component — a batch module that registers domain control file download records |
| ハガキ用通信量超過通知情報 (Hagaki-yo Tsushin-ryou Chouka Tsuuchi Jouhou) | Business term | Postcard Communication Volume Overlimit Notification Information — notification data sent to customers who have exceeded their allocated data usage, distributed via postcard mail |
| 共通パラメータ電文 (Kyoutsuu Parameter Denbun) | Business term | Batch common parameter message — a standardized message object carrying shared batch execution context (dates, user IDs, free-form storage) across all batch service methods |
| バッチ共通パラメータ (Batch Kyoutsuu Parameter) | Field | Batch common parameter — the `JBSbatCommonItem` object containing operation date, online operation date, batch user ID, and free item storage |
| OpeDate | Field | Operation date — the business date on which the batch is executed |
| OnlineOpeDate | Field | Online operation date — the date for online system operations |
| BatchUserId | Field | Batch user ID — the identifier of the user or system initiating the batch job |
| getFreeItem | Method | Retrieves the free item map from `JBSbatCommonItem` — a flexible map storage used to pass arbitrary key-value pairs between batch components |
| JBSbatSQLAccess | Class | SQL Access framework class — provides database connectivity and CRUD operations for a specified table within the batch framework |
| JBSbatInputFileUtil | Class | Input File Utility framework class — handles file reading operations for batch input files |
| SJIS | Constant | Shift-JIS encoding — Japanese character encoding specified by `JKKBatConst.SJIS` for file I/O |
| FILE_CD_POSTCARD_TIIK_LMT_INFO | Constant | Postcard Area Limit Info code (`"000000000066"`) — a file code identifying the communication volume overlimit notification file type |
| SEQ_LEN_SEQ_FILE_NO | Constant | Sequence file number length (`12`) — the fixed width of file number sequences |
