# Business Logic — JBSbatKKCourseChgFileBnkt.setKjFinStr() [74 LOC]

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

## 1. Role

### JBSbatKKCourseChgFileBnkt.setKjFinStr()

This method performs **construction completion string assembly** — it transforms a raw 23-element data array (`String[]`) extracted from a course change batch input file into a single, comma-delimited output record ready to be written to the **construction completion file** (`kj_fin_file_path`). In the broader system, `JBSbatKKCourseChgFileBnkt` is the core batch batch (course change file splitter) that processes telecom service order change records. When a work result (`koji_rslt`) indicates the job was completed (`"1"`: Work Completed, `"2"`: Work Scheduled, `"6"`: Mobile, or `"0"`: No Work), this method formats the relevant fields into a structured CSV-like line for downstream consumption by field service or billing systems.

The method follows the **Builder pattern**: it receives a pre-instantiated `StringBuilder` accumulator, sequentially appends each data element interleave by a comma delimiter (`CONMA` = `","`), and returns the populated builder for write-out by the caller. It handles two feature-flagged extension blocks (ANK-2765 for old plan code, ANK-3949 for cost course codes related to Netflix introduction), demonstrating evolution through versioned change requests. The method is private, exclusively called from `JBSbatKKCourseChgFileBnkt.execute()` as a data formatting sub-routine.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setKjFinStr(StringBuilder, String[])"])
    START --> STEP1["Append data[0] - Service contract number"]
    STEP1 --> STEP2["Append CONMA separator"]
    STEP2 --> STEP3["Append data[1] - Update datetime"]
    STEP3 --> STEP4["Append CONMA separator"]
    STEP4 --> STEP5["Append data[2] - Anomaly contract No. 1"]
    STEP5 --> STEP6["Append CONMA separator"]
    STEP6 --> STEP7["Append data[3] - Update datetime 1"]
    STEP7 --> STEP8["Append CONMA separator"]
    STEP8 --> STEP9["Append data[4] - Service code"]
    STEP9 --> STEP10["Append CONMA separator"]
    STEP10 --> STEP11["Append data[5] - Service contract detail No. 1"]
    STEP11 --> STEP12["Append CONMA separator"]
    STEP12 --> STEP13["Append data[6] - Registration date 1"]
    STEP13 --> STEP14["Append CONMA separator"]
    STEP14 --> STEP15["Append data[7] - Service contract detail No. 2"]
    STEP15 --> STEP16["Append CONMA separator"]
    STEP16 --> STEP17["Append data[8] - Registration date 2"]
    STEP17 --> STEP18["Append CONMA separator"]
    STEP18 --> STEP19["Append data[9] - Anomaly contract No. 2 (cancellation detail)"]
    STEP19 --> STEP20["Append CONMA separator"]
    STEP20 --> STEP21["Append data[10] - Update datetime 2 (cancellation detail)"]
    STEP21 --> STEP22["Append CONMA separator"]
    STEP22 --> STEP23["Append data[11] - Construction result"]
    STEP23 --> STEP24["Append CONMA separator"]
    STEP24 --> STEP25["Append data[12] - Construction completion date"]
    STEP25 --> STEP26["Append KARAMOJI (empty) - Construction case channel presence/absence"]
    STEP26 --> STEP27["Append CONMA separator"]
    STEP27 --> STEP28["Append data[14] - Application detail number"]
    STEP28 --> STEP29["Append CONMA separator"]
    STEP29 --> STEP30["Append data[15] - Anomaly separation"]
    STEP30 --> STEP31["Append CONMA separator"]
    STEP31 --> STEP32["Append data[16] - Construction case number"]
    STEP32 --> STEP33["Append CONMA separator"]
    STEP33 --> STEP34["Append data[17] - Price group code"]
    STEP34 --> STEP35["Append CONMA separator"]
    STEP35 --> STEP36["Append data[18] - Service contract status"]
    STEP36 --> STEP37["Append CONMA separator"]
    STEP37 --> STEP38["Append data[19] - Anomaly contract detail code"]
    STEP38 --> STEP39["Append CONMA (ANK-2765 extension)"]
    STEP39 --> STEP40["Append data[20] - Old plan code (ANK-2765)"]
    STEP40 --> STEP41["Append CONMA (ANK-3949 extension)"]
    STEP41 --> STEP42["Append data[21] - New cost course code (ANK-3949)"]
    STEP42 --> STEP43["Append CONMA (ANK-3949 extension)"]
    STEP43 --> STEP44["Append data[22] - Old cost course code (ANK-3949)"]
    STEP44 --> ENDN(["Return kjFinstrBuilder"])
```

**Constant Resolution:**
- `CONMA = ","` — Comma delimiter used to separate all 23+ output fields in the construction completion file. Defined as `private static final String CONMA = ","` in the class.
- `KARAMOJI = ""` — Empty string placeholder for "construction case channel presence/absence" (工事案件チャンネル有無). Currently unused but reserved for future expansion.

**Processing summary:** The method sequentially appends 23 data elements (`data[0]` through `data[22]`, skipping `data[13]`), with a comma delimiter (`CONMA`) appended after every element. The output is a flat CSV-like record that maps directly to the columns expected by the construction completion output file. No conditional branches exist within this method — it is a straight-line assembly pipeline.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `kjFinstrBuilder` | `StringBuilder` | Accumulator buffer for building the construction completion output record. Pre-instantiated by the caller (`execute()`) with `new StringBuilder()` before passing in. Fields are appended sequentially; the builder is returned after all data is assembled. |
| 2 | `data` | `String[]` | Raw input data array extracted from a parsed line of the batch course change input file. Contains up to 23 elements covering service contract information, anomaly contract details, registration dates, construction results, pricing data, and Netflix-related cost codes. Index `13` is skipped (gap in the source data layout). |

**Instance fields read by this method:** None. All state is provided via parameters.

## 4. CRUD Operations / Called Services

This method performs **no external service calls, database queries, or CRUD operations**. It is a pure data transformation method operating exclusively on the provided `StringBuilder` and `String[]` parameters. All data sourcing and persistence are handled by the caller (`execute()`) and surrounding batch framework methods.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | (none) | — | — | No CRUD operations. Pure string assembly with no external I/O or data access. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKCourseChgFileBnkt | `execute()` -> `setKjFinStr(kjFinstrBuilder, data)` | — (no terminal CRUD; writes to `kj_fin_file_path` output file via `kjFinWr.write()`) |

**Caller context:** This method is exclusively called from `JBSbatKKCourseChgFileBnkt.execute()`. The batch class processes course change (service contract modification) files. When the work result (`koji_rslt`) is `"1"` (Work Completed), `"2"` (Work Scheduled), `"6"` (Mobile), or `"0"` (No Work), a new `StringBuilder` is created and passed to `setKjFinStr()` along with the parsed `data` array. The resulting string is then written to the construction completion file (`kjFinWr.write(kjFinstrBuilder.toString())`).

## 6. Per-Branch Detail Blocks

Since this method contains no conditional branches, loops, or exception handling, there is a single linear block:

**Block 1** — [LINEAR SEQUENCE] (L339–L412)

> Straight-line construction completion string assembly. Appends 23 data elements from the input array to the `StringBuilder`, interleaved by comma delimiters. The array skips index 13 (gap in source data layout). Two version-extended regions (ANK-2765 and ANK-3949) add additional fields at the end.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `kjFinstrBuilder.append(data[0])` // Service contract number (サービス契約番号) [L339] |
| 2 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," (カンマ) [L340] |
| 3 | EXEC | `kjFinstrBuilder.append(data[1])` // Update datetime (更新年月日時分秒) [L342] |
| 4 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L343] |
| 5 | EXEC | `kjFinstrBuilder.append(data[2])` // Anomaly contract No. 1 (異動予約番号1) [L345] |
| 6 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L346] |
| 7 | EXEC | `kjFinstrBuilder.append(data[3])` // Update datetime 1 (更新年月日時分秒1) [L348] |
| 8 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L349] |
| 9 | EXEC | `kjFinstrBuilder.append(data[4])` // Service code (サービスコード) [L351] |
| 10 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L352] |
| 11 | EXEC | `kjFinstrBuilder.append(data[5])` // Service contract detail No. 1 (サービス契約内容番号1) [L354] |
| 12 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L355] |
| 13 | EXEC | `kjFinstrBuilder.append(data[6])` // Registration date 1 (世帯登録年月日1) [L357] |
| 14 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L358] |
| 15 | EXEC | `kjFinstrBuilder.append(data[7])` // Service contract detail No. 2 (サービス契約内容番号2) [L360] |
| 16 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L361] |
| 17 | EXEC | `kjFinstrBuilder.append(data[8])` // Registration date 2 (世帯登録年月日2) [L363] |
| 18 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L364] |
| 19 | EXEC | `kjFinstrBuilder.append(data[9])` // Anomaly contract No. 2 - cancellation detail (異動予約番号2（解約内容分）) [L366] |
| 20 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L367] |
| 21 | EXEC | `kjFinstrBuilder.append(data[10])` // Update datetime 2 - cancellation detail (更新年月日時分秒2（解約内容分）) [L369] |
| 22 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L370] |
| 23 | EXEC | `kjFinstrBuilder.append(data[11])` // Construction result (工事結果) [L372] |
| 24 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L373] |
| 25 | EXEC | `kjFinstrBuilder.append(data[12])` // Construction completion date (工事完了日) [L375] |
| 26 | EXEC | `kjFinstrBuilder.append(KARAMOJI)` // Empty string — construction case channel presence/absence (工事案件チャンネル有無) [L377] |
| 27 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L378] |
| 28 | EXEC | `kjFinstrBuilder.append(data[14])` // Application detail number (申込明細番号) — note: index 13 is skipped [L380] |
| 29 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L381] |
| 30 | EXEC | `kjFinstrBuilder.append(data[15])` // Anomaly separation (異動区分) [L383] |
| 31 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L384] |
| 32 | EXEC | `kjFinstrBuilder.append(data[16])` // Construction case number (工事案件番号) [L386] |
| 33 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L387] |
| 34 | EXEC | `kjFinstrBuilder.append(data[17])` // Price group code (料金グループコード) [L389] |
| 35 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L390] |
| 36 | EXEC | `kjFinstrBuilder.append(data[18])` // Service contract status (サービス契約ステータス) [L392] |
| 37 | EXEC | `kjFinstrBuilder.append(CONMA)` // Comma delimiter "," [L393] |
| 38 | EXEC | `kjFinstrBuilder.append(data[19])` // Anomaly contract detail code (異動予約詳細コード) [L395] |
| 39 | EXEC | `kjFinstrBuilder.append(CONMA)` // ANK-2765 extension — comma delimiter (ANK-2765-00-00 ADD START) [L397] |
| 40 | EXEC | `kjFinstrBuilder.append(data[20])` // Old plan code (旧プランコード) — added in v26.00.00 (ANK-2765-00-00) [L398] |
| 41 | EXEC | `kjFinstrBuilder.append(CONMA)` // ANK-3949 extension — comma delimiter (ANK-3949-00-00 ADD START) [L400] |
| 42 | EXEC | `kjFinstrBuilder.append(data[21])` // New cost course code (新料金コースコード) — added in v51.00.00 (ANK-3949-00-00) for Netflix introduction [L402] |
| 43 | EXEC | `kjFinstrBuilder.append(CONMA)` // ANK-3949 extension — comma delimiter [L404] |
| 44 | EXEC | `kjFinstrBuilder.append(data[22])` // Old cost course code (旧料金コースコード) — added in v51.00.00 (ANK-3949-00-00) [L405] |
| 45 | RETURN | `return kjFinstrBuilder;` // Return the fully assembled construction completion record [L407] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kjFin` | Field | Construction completion — short for "construction finished" (工事完了), used in file name and output record identifiers |
| `kjFinstrBuilder` | Parameter | Construction completion string builder — the accumulator for the output CSV record |
| `kjFinClstrBuilder` | Field | Construction completion cancellation string builder — parallel accumulator for cancellation records (handled by `setKjFinClStr`) |
| `kj_cl` | Field | Construction cancellation (工事取消) — when a scheduled construction job is cancelled |
| `KOJI_RSLT` | Field | Work result code (工事結果) — classification of construction job status: "1"=Completed, "2"=Scheduled, "3"=Completion cancelled, "4"=Work cancelled, "6"=Mobile, "0"=No work |
| `KKIFM151` | Constant prefix | Internal file mapping constant group for construction result classification (v20.00.00 refactoring) |
| `CONMA` | Constant | Comma character "," — CSV field delimiter (from Japanese "カンマ") |
| `KARAMOJI` | Constant | Empty string placeholder "" — for construction case channel presence/absence (工事案件チャンネル有無), currently unused |
| `data[0]` | Field | Service contract number (サービス契約番号) — unique identifier for the service contract |
| `data[1]` | Field | Update datetime (更新年月日時分秒) — timestamp of the last update (year/month/day/hour/minute/second) |
| `data[2]` / `data[9]` | Field | Anomaly contract number (異動予約番号) — contract number for service modification/change reservations; index 1 is primary, index 2 is for cancellation detail |
| `data[4]` | Field | Service code (サービスコード) — identifier for the type of telecommunication service |
| `data[5]` / `data[7]` | Field | Service contract detail number (サービス契約内容番号) — sub-line-item identifier within a service contract |
| `data[6]` / `data[8]` | Field | Household registration date (世帯登録年月日) — date when the household was registered in the system |
| `data[11]` | Field | Construction result (工事結果) — outcome code of the construction work |
| `data[12]` | Field | Construction completion date (工事完了日) — date when the construction work was completed |
| `data[13]` | Field | (skipped) — gap in the source data layout; not mapped to any output field |
| `data[14]` | Field | Application detail number (申込明細番号) — reference number for the original application/order |
| `data[15]` | Field | Anomaly separation (異動区分) — classification of the type of service change/movement |
| `data[16]` | Field | Construction case number (工事案件番号) — unique identifier for the construction job case |
| `data[17]` | Field | Price group code (料金グループコード) — pricing tier/group classification |
| `data[18]` | Field | Service contract status (サービス契約ステータス) — current active/inactive/suspended state of the contract |
| `data[19]` | Field | Anomaly contract detail code (異動予約詳細コード) — detailed classification of the service modification |
| `data[20]` | Field | Old plan code (旧プランコード) — previous service plan identifier before plan change (added v26.00.00, ANK-2765) |
| `data[21]` | Field | New cost course code (新料金コースコード) — new pricing course identifier after change (added v51.00.00, ANK-3949) |
| `data[22]` | Field | Old cost course code (旧料金コースコード) — previous pricing course before change (added v51.00.00, ANK-3949) |
| ANK-2765 | Change request | Authentication ID unification initiative (v26.00.00) — added old plan code support for contract content plan changes |
| ANK-3949 | Change request | Netflix introduction support Step 1 (v51.00.00) — added new/old cost course code fields for Netflix pricing |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service |
| Batch (バッチ) | Architecture | Batch processing — non-interactive background job that processes files in bulk |
| Course change (コース変更) | Business term | Service plan/course change — modification of a customer's telecom service package or pricing plan |
| JBSbatKKCourseChgFileBnkt | Class | Course change file batch — the batch job that splits and processes course change input files, routing output to construction completion, completion cancellation, and construction cancellation output files |
