# Business Logic — JBSbatKKCourseChgFileBnkt.initial() [24 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKCourseChgFileBnkt` |
| Layer | Batch (Service Layer — batch processing entry point) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKCourseChgFileBnkt.initial()

This method serves as the **initialization entry point** for a batch process that handles **course change (service contract modification) file splitting** for K-Opticom's customer base system (eo customer core system). The class itself is documented as the "Course Change File Split Component" (コース変更ファイル分割部品), meaning this batch receives raw course change data files and prepares them for downstream processing.

In business terms, this method performs **parameter validation and path resolution**: it extracts four file paths from the batch common parameter payload (`commonItem`), validates that exactly four paths are provided, and distributes them into instance-level fields. These four paths are: (1) the input course change file path (source data to be read and split), (2) the work-completion file path (output for successfully completed records), (3) the work-completion-cancel file path (output for completed records that are subsequently cancelled), and (4) the work-cancel file path (output for cancelled records).

The method follows a **delegation + validation** design pattern: it delegates common batch parameter initialization to its parent class (`JBSbatBusinessService.setCommonInfo`) and performs strict input validation before any processing begins. As the initialization phase of a batch lifecycle, this method must complete successfully before `execute()` (the main processing method) can proceed to read, parse, and route course change records to their respective output files.

This is a **shared batch entry method** — it is the first method invoked in the batch processing chain. The class extends `JBSbatBusinessService` (an abstract batch service base class), indicating it operates within K-Opticom's standardized batch execution framework. There are no conditional branches by service type or category; this method always performs the same four-step initialization regardless of input content.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(commonItem)"])
    START --> SET_COMMON["setCommonInfo(commonItem)"]
    SET_COMMON --> GET_FREE["getFreeItem()"]
    GET_FREE --> SPLIT["Split by S_PARAM_DELIM (;)"]
    SPLIT --> CHECK_LEN{"free_item.length == 4?"}
    CHECK_LEN --> |"No (S_PARAM_DELIM != 4 parts)"| THROW["throw JBSbatBusinessException(EKKB0130CE, \"FREE\")"]
    CHECK_LEN --> |"Yes (4 parts)"| ASSIGN["Assign 4 fields from free_item[]"]
    ASSIGN --> A_IN["in_file_path = free_item[0]"]
    ASSIGN --> A_KJ["kj_fin_file_path = free_item[1]"]
    ASSIGN --> A_KJCL["kj_fin_cl_file_path = free_item[2]"]
    ASSIGN --> A_CL["kj_cl_file_path = free_item[3]"]
    A_IN --> END_NODE(["Return / Next"])
    A_KJ --> END_NODE
    A_KJCL --> END_NODE
    A_CL --> END_NODE
    THROW --> END_NODE
```

**Constant Resolution:**
- `JKKBatConst.S_PARAM_DELIM = ";"` — Shell parameter delimiter character (colon). Used as the field separator in the free-form parameter string passed via `commonItem.getFreeItem()`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | Batch common parameter message — carries all shared batch metadata including operation date, batch user ID, system code, and the free-form parameter string (`freeItem`) that contains the four semicolon-separated file paths required for course change file splitting. |

**Instance Fields Read/Written:**

| Field | Type | Access | Business Description |
|-------|------|--------|---------------------|
| `in_file_path` | `String` | Write | Input source file path — path to the raw course change data file that will be read and parsed by the `execute()` method. Initially empty string `""`. |
| `kj_fin_file_path` | `String` | Write | Work completion file path — output file for records where service changes were successfully completed (工事完了ファイルパス). Initially empty string `""`. |
| `kj_fin_cl_file_path` | `String` | Write | Work completion cancel file path — output file for records where completion was later cancelled (工事完了取消ファイルパス). Initially empty string `""`. |
| `kj_cl_file_path` | `String` | Write | Work cancel file path — output file for records where the work order was cancelled (工事取消ファイルパス). Initially empty string `""`. |

**Constants Used:**

| Constant | Value | Business Description |
|----------|-------|---------------------|
| `JKKBatConst.S_PARAM_DELIM` | `";"` | Shell parameter delimiter — the semicolon character used to separate fields in the free-form parameter string |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JBSbatBusinessService.setCommonInfo` | (Parent base class) | JBSbatBusiness (session state) | Calls `setCommonInfo` in parent `JBSbatBusinessService` to populate batch metadata fields (opeDate, onlineOpeDate, batchUserId, systemCode) from the incoming `commonItem` parameter. This is an Update (U) operation on the service instance's internal state. |

**Analysis:** This method does not perform any direct Create/Read/Update/Delete operations on database tables or persistent entities. It delegates parent state initialization and performs in-memory parameter extraction and validation. All data manipulation occurs within Java objects and instance fields, not against the database.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKCourseChgFileBnkt | `BatchEntry.invoke()` -> `JBSbatKKCourseChgFileBnkt.initial(commonItem)` | `setCommonInfo [U] JBSbatBusiness (session state)` |

**Notes on callers:**
- This method is the **batch initialization entry point** for the `JBSbatKKCourseChgFileBnkt` batch process. It is called by the standard batch execution framework (inherited from `JBSbatBusinessService`) during the batch lifecycle before `execute()` is invoked.
- No screen-level or CBS-level callers were found in the codebase that directly invoke this method — it is exclusively a batch-level entry point.

## 6. Per-Branch Detail Blocks

**Block 1** — [CALL] Parent state initialization (L89)

> Delegates to the parent batch service to set common operational metadata from the incoming parameter object.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.setCommonInfo(commonItem);` // Set batch common info (operation date, batch user ID, system code) [-> parent: JBSbatBusinessService.setCommonInfo] |

---

**Block 2** — [EXEC] Get and split free-form parameter string (L100)

> Extracts the free-item string from the batch common parameter and splits it into an array using the semicolon delimiter.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `String[] free_item = commonItem.getFreeItem().split(JKKBatConst.S_PARAM_DELIM);` // Get free-item array split by ";" [-> JKKBatConst.S_PARAM_DELIM=";"] |

---

**Block 3** — [IF] Parameter count validation (L103)

> Validates that exactly 4 semicolon-delimited values were provided. If not, throws a business exception indicating missing FREE parameters.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if(free_item.length != 4)` [S_PARAM_DELIM produced != 4 fields] |
| 2 | EXEC | `throw new JBSbatBusinessException(JPCBatchMessageConstant.EKKB0130CE, new String[]{"FREE"});` // Throw business exception for invalid FREE parameter count [-> JPCBatchMessageConstant.EKKB0130CE="EKKB0130CE"] |

---

**Block 4** — [ELSE] Field assignment from split array (L108-L111)

> Assigns each of the four validated split values to instance-level file path fields. These fields are then consumed by the `execute()` method for file I/O operations.

| # | Type | Code |
|---|------|------|
| 1 | SET | `in_file_path = free_item[0];` // Input source file path (分割元ファイルパス) [-> file path for raw course change data input] |
| 2 | SET | `kj_fin_file_path = free_item[1];` // Work completion file path (工事完了ファイルパス) [-> output path for successfully completed records] |
| 3 | SET | `kj_fin_cl_file_path = free_item[2];` // Work completion cancel file path (工事完了取消ファイルパス) [-> output path for cancelled completions] |
| 4 | SET | `kj_cl_file_path = free_item[3];` // Work cancel file path (工事取消ファイルパス) [-> output path for cancelled work orders] |

---

**Block 5** — [END] Method exit (L112)

> Returns control to the caller (batch execution framework). No explicit return value (void method). Instance fields are now populated and ready for `execute()`.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return;` // Implicit void return — control returns to batch entry |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `in_file_path` | Field | Input source file path — path to the raw course change data file that contains service contract modification records to be processed |
| `kj_fin_file_path` | Field | Work completion file path — output file for records where service changes were successfully completed (工事完了) |
| `kj_fin_cl_file_path` | Field | Work completion cancel file path — output file for records where previously completed work was subsequently cancelled (工事完了取消) |
| `kj_cl_file_path` | Field | Work cancel file path — output file for records where the work order was cancelled (工事取消) |
| `free_item` | Field | Free-form parameter array — parsed result of the semicolon-delimited string from the batch parameter message |
| `S_PARAM_DELIM` | Constant | Parameter delimiter — the semicolon (`;`) character used as a field separator in batch input parameter strings |
| `EKKB0130CE` | Constant | Error code — batch validation error for incorrect number of FREE parameters |
| `JBSbatCommonItem` | Entity | Batch common parameter object — carries shared batch metadata (operation date, user ID, system code) and free-form parameters across the batch processing pipeline |
| `JBSbatBusinessService` | Class | Abstract batch service base class — provides shared batch execution infrastructure including `setCommonInfo()`, logging, and file reading utilities |
| `JBSbatBusinessException` | Class | Business exception class — thrown when business rule validation fails during batch processing |
| Course Change (コース変更) | Business term | Service contract modification — a telecom business process for modifying existing customer service contracts (e.g., plan changes, feature additions/cancellations) |
| K-Opticom | Business term | K-Opticom — a Japanese telecommunications company providing fiber-optic (FTTH), DSL, and other broadband services |
| eo System | Business term | eo customer core system — Fujitsu's customer management platform used by K-Opticom for managing subscriber data, service contracts, and billing |
| 工事 (Kouji) | Business term | Work order / field installation work — physical installation or modification work performed by field technicians for telecom services |
| 完了 (Kanryou) | Business term | Completion — status indicating work has been successfully finished |
| 取消 (Torikeshi) | Business term | Cancellation — status indicating work or completion was cancelled/reversed |
| バッチ共通パラメータ電文 | Business term | Batch common parameter message — the standardized data structure carrying all shared parameters for a batch process execution |
| フリー項目 (Free Item) | Business term | Free-form parameter — an extensible string field in the batch parameter that can carry arbitrary semicolon-separated values as needed by the batch |
