---
# Business Logic — JBSbatKKCourseChgeTstaDayChsht.initial() [41 LOC]

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

## 1. Role

### JBSbatKKCourseChgeTstaDayChsht.initial()

This method performs the batch initialization routine for the **Course Change Applicable Start Date Extraction** service (`JKCourseChgeTstaDayChsht`). Its primary business purpose is to prepare the runtime environment before the main `execute()` processing begins. Specifically, it instantiates SQL access objects for **10 underlying database tables** — including master data tables (`KK_T_MSKM_DTL`, `KK_T_SVC_KEI_UCWK`, `KK_T_IDO_RSV`) and work tables (`KK_T_KJ_CL_WK`, `KK_T_KJ_FIN_WK`, `ZM_M_WORK_PARAM_KNRI`) — and queries the work parameter management table to populate a `HashSet` with **external NTT subscription fee codes (typeN)**. The method also parses the `freeItem` configuration string (delimited by semicolons) into a string array for use by downstream processing. As the template method's initialization hook, it is called automatically by the batch framework's execution pipeline, making this a shared entry point for all batch processing that extends `JBSbatBusinessService`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(JBSbatCommonItem)"])
    START --> SET_COMMON["setCommonInfo(commonItem)"]
    SET_COMMON --> INIT_DB9["Initialize 9 DB access objects<br/>KK_T_MSKM_DTL, KK_T_SVKEI_EXC_CTRL,<br/>KU_T_MSKM_DTL_KOJIAK, KK_T_SVC_KEI_UCWK,<br/>KK_T_IDO_RSV, KU_T_KOJIAK,<br/>KU_T_SETTE_KOJI, KK_T_KJ_CL_WK,<br/>KK_T_KJ_FIN_WK"]
    INIT_DB9 --> SPLIT_FREE["Split freeItem by S_PARAM_DELIM ';'"]
    SPLIT_FREE --> ASSIGN_ARRAY["Assign result to fleeItemArray"]
    ASSIGN_ARRAY --> INIT_DB10["Initialize DB access for ZM_M_WORK_PARAM_KNRI"]
    INIT_DB10 --> INIT_HSET["Initialize nttOrsPcrsList as new HashSet"]
    INIT_HSET --> BUILD_PARAMS["Build param array with<br/>WORK_PARAM_ID_PCRS_TPN and opeDate"]
    BUILD_PARAMS --> CALL_SELECT["Execute selectBySqlDefine<br/>(query ZM_M_WORK_PARAM_KNRI)"]
    CALL_SELECT --> WHILE_CHECK{"selectNext()<br/>returns null?"}
    WHILE_CHECK --> |"No"| ADD_TO_SET["Add WORK_PARAM_SETTE_VALUE<br/>to nttOrsPcrsList"]
    ADD_TO_SET --> WHILE_CHECK
    WHILE_CHECK --> |"Yes"| END_NODE(["Return / Next"])
```

**Processing flow:**

1. **Delegate common info setup** — `super.setCommonInfo(commonItem)` copies batch common parameters from the input `JBSbatCommonItem` into the service's shared state (accessible via `super` fields like `opeDate`, `freeItem`, etc.).
2. **Initialize 9 database access objects** — `JBSbatSQLAccess` instances are created for the core processing tables (`KK_T_MSKM_DTL`, `KK_T_SVKEI_EXC_CTRL`, `KU_T_MSKM_DTL_KOJIAK`, `KK_T_SVC_KEI_UCWK`, `KK_T_IDO_RSV`, `KU_T_KOJIAK`, `KU_T_SETTE_KOJI`, `KK_T_KJ_CL_WK`, `KK_T_KJ_FIN_WK`).
3. **Parse free item configuration** — The `freeItem` string (set by `setCommonInfo`) is split by the semicolon delimiter (`;`) into a `String[]` and stored in `fleeItemArray`.
4. **Initialize work parameter DB access** — Creates `db_ZM_M_WORK_PARAM_KNRI` for querying the work parameter management table.
5. **Initialize fee code container** — Creates `nttOrsPcrsList` as a new `HashSet<String>` to hold external NTT subscription fee codes.
6. **Query work parameter for typeN fee codes** — Executes a SQL select against `ZM_M_WORK_PARAM_KNRI` using the parameter ID prefix `KK_HTGAI_PCRS_TPN_` and the operation date. Iterates through all matching rows, adding each `WORK_PARAM_SETTE_VALUE` to `nttOrsPcrsList`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | Batch common parameters envelope — carries shared batch execution context including operation date (`opeDate`), free item configuration string (`freeItem`), user credentials, company ID, and other cross-cutting batch metadata. This parameter is set once at batch start and inherited by all processing steps. |

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

| Field | Type | Business Description |
|-------|------|---------------------|
| `freeItem` (inherited from `JBSbatBusinessService`) | `String` | Free item configuration string — semicolon-delimited list of item codes passed from the batch framework entry point |
| `opeDate` (inherited from `JBSbatBusinessService`) | `Object` | Operation date — the processing date set by the batch framework |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JBSbatBusinessService.setCommonInfo` | JBSbatBusinessService | (in-memory state) | Calls `setCommonInfo` to populate shared service fields (opeDate, freeItem, companyCd, etc.) from the input common parameters |
| C | `new JBSbatSQLAccess(commonItem, "KK_T_MSKM_DTL")` | - | KK_T_MSKM_DTL | Creates SQL access object for master detail table |
| C | `new JBSbatSQLAccess(commonItem, "KK_T_SVKEI_EXC_CTRL")` | - | KK_T_SVKEI_EXC_CTRL | Creates SQL access object for service contract exception control table |
| C | `new JBSbatSQLAccess(commonItem, "KU_T_MSKM_DTL_KOJIAK")` | - | KU_T_MSKM_DTL_KOJIAK | Creates SQL access object for master detail customer separate table |
| C | `new JBSbatSQLAccess(commonItem, "KK_T_SVC_KEI_UCWK")` | - | KK_T_SVC_KEI_UCWK | Creates SQL access object for service detail work table |
| C | `new JBSbatSQLAccess(commonItem, "KK_T_IDO_RSV")` | - | KK_T_IDO_RSV | Creates SQL access object for relocation reservation table |
| C | `new JBSbatSQLAccess(commonItem, "KU_T_KOJIAK")` | - | KU_T_KOJIAK | Creates SQL access object for customer separate table |
| C | `new JBSbatSQLAccess(commonItem, "KU_T_SETTE_KOJI")` | - | KU_T_SETTE_KOJI | Creates SQL access object for contract history table |
| C | `new JBSbatSQLAccess(commonItem, "KK_T_KJ_CL_WK")` | - | KK_T_KJ_CL_WK | Creates SQL access object for settlement classification work table |
| C | `new JBSbatSQLAccess(commonItem, "KK_T_KJ_FIN_WK")` | - | KK_T_KJ_FIN_WK | Creates SQL access object for settlement final work table |
| R | `String.split(";")` | - | - | Parses the freeItem configuration string into an array of item codes |
| C | `new JBSbatSQLAccess(commonItem, "ZM_M_WORK_PARAM_KNRI")` | - | ZM_M_WORK_PARAM_KNRI | Creates SQL access object for work parameter management table |
| C | `new HashSet<String>()` | - | - | Initializes an empty set to hold NTT external subscription fee codes |
| EXEC | `executeZM_M_WORK_PARAM_KNRI_KK_SELECT_026(Object[])` | ZM_M_WORK_PARAM_KNRI | ZM_M_WORK_PARAM_KNRI | Invokes SQL select to retrieve work parameter rows matching the typeN fee code prefix and operation date |
| R | `JBSbatCommonDBInterface.selectNext()` | - | ZM_M_WORK_PARAM_KNRI | Iterates through the result set of the select query, returning each row |
| R | `JBSbatCommonDBInterface.getString(WORK_PARAM_SETTE_VALUE)` | - | ZM_M_WORK_PARAM_KNRI | Reads the commitment value field from the current result row |

## 5. Dependency Trace

This method is an abstract template method hook defined in `JBSbatBusinessService.initial()`. It is called automatically by the batch framework's execution pipeline when any batch service extending `JBSbatBusinessService` is invoked.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch Framework | `JBSbatBusinessService.execute()` -> `initial(commonItem)` | `setCommonInfo [U] in-memory state`, `db_ZM_M_WORK_PARAM_KNRI.selectBySqlDefine [R] ZM_M_WORK_PARAM_KNRI` |

**Notes:** No other application classes directly reference `JBSbatKKCourseChgeTstaDayChsht` or its `initial()` method. The batch class is instantiated and driven entirely by the batch execution framework (likely via a batch configuration / job definition that references this class by name).

## 6. Per-Branch Detail Blocks

### Block 1 — [SET] `super.setCommonInfo(commonItem)` (L262)

> Delegate common parameter setting to the parent batch service class. This populates shared fields like `opeDate`, `freeItem`, `companyCd`, `userCd` etc.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.setCommonInfo(commonItem)` // Sets shared batch context (opeDate, freeItem, companyCd, etc.) |

### Block 2 — [SET] Initialize 9 DB Access Objects (L265–L274)

> Instantiate `JBSbatSQLAccess` objects for the core database tables required by the course change start date extraction batch. Each access object wraps a specific table and provides query/update capabilities via SQL define mappings.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_KK_T_MSKM_DTL = new JBSbatSQLAccess(commonItem, "KK_T_MSKM_DTL")` // Master detail table [-> `D_TBL_NAME_KK_T_MSKM_DTL`="KK_T_MSKM_DTL"] |
| 2 | SET | `db_KK_T_SVKEI_EXC_CTRL = new JBSbatSQLAccess(commonItem, "KK_T_SVKEI_EXC_CTRL")` // Service contract exception control table [-> `D_TBL_NAME_KK_T_SVKEI_EXC_CTRL`="KK_T_SVKEI_EXC_CTRL"] |
| 3 | SET | `db_KU_T_MSKM_DTL_KOJIAK = new JBSbatSQLAccess(commonItem, "KU_T_MSKM_DTL_KOJIAK")` // Master detail customer separate [-> `D_TBL_NAME_KU_T_MSKM_DTL_KOJIAK`="KU_T_MSKM_DTL_KOJIAK"] |
| 4 | SET | `db_KK_T_SVC_KEI_UCWK = new JBSbatSQLAccess(commonItem, "KK_T_SVC_KEI_UCWK")` // Service detail work table [-> `D_TBL_NAME_KK_T_SVC_KEI_UCWK`="KK_T_SVC_KEI_UCWK"] |
| 5 | SET | `db_KK_T_IDO_RSV = new JBSbatSQLAccess(commonItem, "KK_T_IDO_RSV")` // Relocation reservation [-> `D_TBL_NAME_KK_T_IDO_RSV`="KK_T_IDO_RSV"] |
| 6 | SET | `db_KU_T_KOJIAK = new JBSbatSQLAccess(commonItem, "KU_T_KOJIAK")` // Customer separate table [-> `D_TBL_NAME_KU_T_KOJIAK`="KU_T_KOJIAK"] |
| 7 | SET | `db_KU_T_SETTE_KOJI = new JBSbatSQLAccess(commonItem, "KU_T_SETTE_KOJI")` // Contract history [-> `D_TBL_NAME_KU_T_SETTE_KOJI`="KU_T_SETTE_KOJI"] |
| 8 | SET | `db_KK_T_KJ_CL_WK = new JBSbatSQLAccess(commonItem, "KK_T_KJ_CL_WK")` // Settlement classification work [-> `D_TBL_NAME_KK_T_KJ_CL_WK`="KK_T_KJ_CL_WK"] |
| 9 | SET | `db_KK_T_KJ_FIN_WK = new JBSbatSQLAccess(commonItem, "KK_T_KJ_FIN_WK")` // Settlement final work [-> `D_TBL_NAME_KK_T_KJ_FIN_WK`="KK_T_KJ_FIN_WK"] |

### Block 3 — [SET] Parse freeItem Configuration (L278, ANK-3136-00-00)

> Split the semicolon-delimited free item configuration string into an array. This was added in ticket ANK-3136 to support configurable free item processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `fleeItemArray = super.freeItem.split(";")` // Parse free item config // [-> `JKKBatConst.S_PARAM_DELIM`=";"] |

### Block 4 — [SET] Initialize Work Parameter DB Access (L282, ANK-4427-40-00)

> Create SQL access object for the work parameter management table. Added in ANK-4427 to support typeN fee code lookup.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_ZM_M_WORK_PARAM_KNRI = new JBSbatSQLAccess(commonItem, "ZM_M_WORK_PARAM_KNRI")` // Work parameter management table [-> `D_TBL_NAME_ZM_M_WORK_PARAM_KNRI`="ZM_M_WORK_PARAM_KNRI"] |

### Block 5 — [SET] Initialize Fee Code Container (L285, ANK-4427-40-00)

> Create an empty HashSet to collect external NTT subscription fee codes (typeN).

| # | Type | Code |
|---|------|------|
| 1 | SET | `nttOrsPcrsList = new HashSet<String>()` // Empty set for NTT external subscription fee codes (typeN) |

### Block 6 — [EXEC] Query TypeN Fee Codes (L288–L296, ANK-4427-40-00)

> Execute a parameterized SQL select against `ZM_M_WORK_PARAM_KNRI` to retrieve all commitment values (fee codes) associated with the typeN subscription parameter ID prefix. Iterates through all matching rows and adds each value to the `nttOrsPcrsList`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workParamKnriParam1 = new Object[] { "KK_HTGAI_PCRS_TPN_", opeDate }` // Param array: [workParamIdPrefix, operationDate] [-> `WORK_PARAM_ID_PCRS_TPN`="KK_HTGAI_PCRS_TPN_"] |
| 2 | CALL | `executeZM_M_WORK_PARAM_KNRI_KK_SELECT_026(workParamKnriParam1)` // Execute selectBySqlDefine on ZM_M_WORK_PARAM_KNRI using SQL define KK_SELECT_026 |
| 3 | SET | `workParamKnriMap1 = db_ZM_M_WORK_PARAM_KNRI.selectNext()` // Get first row of result set |
| 4 | WHILE | `while (workParamKnriMap1 != null)` // Iterate through all matching rows |

#### Block 6.1 — [SET] Add fee code to HashSet (L292)

> Inside the while loop: extract the commitment value field and add it to the fee code set.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `nttOrsPcrsList.add(workParamKnriMap1.getString("WORK_PARAM_SETTE_VALUE"))` // Extract commitment value and add to fee code set |
| 2 | SET | `workParamKnriMap1 = db_ZM_M_WORK_PARAM_KNRI.selectNext()` // Advance to next row |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `JBSbatCommonItem` | Field/Class | Batch common parameters envelope — carries shared batch execution context including operation date, company ID, user ID, and free item configuration |
| `JBSbatBusinessService` | Class | Abstract base class for batch services — provides common batch execution infrastructure including `initial()`, `execute()`, and `setCommonInfo()` |
| `JBSbatSQLAccess` | Class | Database access wrapper — provides SQL execution capabilities via SQL define mappings for specific tables |
| `KK_T_MSKM_DTL` | Table | Master detail table — stores master detail information for service contracts |
| `KK_T_SVKEI_EXC_CTRL` | Table | Service contract exception control table — manages exceptions in service contract detail processing |
| `KU_T_MSKM_DTL_KOJIAK` | Table | Master detail customer separate table — customer-isolated master detail data |
| `KK_T_SVC_KEI_UCWK` | Table | Service detail work table — work table for service detail information |
| `KK_T_IDO_RSV` | Table | Relocation reservation table — stores relocation reservation records |
| `KU_T_KOJIAK` | Table | Customer separate table — customer-isolated data table |
| `KU_T_SETTE_KOJI` | Table | Contract history table — stores contract execution history records |
| `KK_T_KJ_CL_WK` | Table | Settlement classification work table — work table for settlement classification processing |
| `KK_T_KJ_FIN_WK` | Table | Settlement final work table — work table for final settlement processing |
| `ZM_M_WORK_PARAM_KNRI` | Table | Work parameter management table — stores configurable work parameter ID-to-value mappings used across multiple batch services |
| `S_PARAM_DELIM` | Constant | Parameter delimiter — semicolon character (`";"`) used to separate items in configuration strings |
| `WORK_PARAM_ID_PCRS_TPN` | Constant | Work parameter ID prefix for NTT external subscription fees (typeN) — value `"KK_HTGAI_PCRS_TPN_"` is used to query fee codes for external NTT contracts |
| `fleeItemArray` | Field | Free item array — parsed array of configuration item codes from the `freeItem` string |
| `nttOrsPcrsList` | Field | NTT external subscription fee code list — a `HashSet` of fee codes (typeN) retrieved from work parameter management for use in main processing |
| `freeItem` | Field | Free item configuration — semicolon-delimited string of item codes passed from batch framework entry point |
| `opeDate` | Field | Operation date — the batch processing date, set by the batch framework |
| `WORK_PARAM_SETTE_VALUE` | Field | Work parameter commitment value — the configured value stored against a work parameter ID in the work parameter management table |
| `KK_SELECT_026` | SQL Define | SQL definition key for selecting work parameter records by parameter ID prefix and operation date |
| typeN | Business term | Fee type N — a category of NTT subscription fee codes used for external contracts, stored in work parameter management for configuration-driven fee processing |
| ANK-3136 | Change ticket | Development ticket that added free item configuration parsing |
| ANK-4427 | Change ticket | Development ticket that added typeN fee code loading from work parameter management |
| KOJIAK | Japanese abbreviation | 個別 — "separate" or "customer-isolated" — indicates a customer-specific data partition |
| SETTE | Japanese abbreviation | 契約 — "contract" — as in contract history |
| KJ | Japanese abbreviation | 決金 — "settlement" — as in settlement classification and settlement final processing |
| IDO | Japanese abbreviation | 移動 — "relocation" — as in relocation reservation |
| SVKEI | Japanese abbreviation | サービス契約 — "service contract" — as in service contract exception control |
| MSKM | Japanese abbreviation | マスタ詳細 — "master detail" — as in master detail tables |
| UCWK | Japanese abbreviation | 業務作業 — "business work" — as in service detail work |
