# Business Logic — JBSbatKKFmtcelSodUpdInfCst.initial() [20 LOC]

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

## 1. Role

### JBSbatKKFmtcelSodUpdInfCst.initial()

This method is the **initialization entry point** for the `JBSbatKKFmtcelSodUpdInfCst` batch service, which is a short-term service update information extraction component (ショートタームSOD更新情報抽出部品) within the K-Opticom customer backbone system (eo顧客基幹システム). Its primary responsibility is to prepare the batch processing environment by instantiating database access objects (`JBSbatSQLAccess`) for five target tables that will be queried during the main execution flow (`execute()`). The method delegates common batch parameter configuration to `super.setCommonInfo(commonItem)`, following the standard batch service lifecycle pattern where `initial()` — `execute()` — `terminal()` are invoked in sequence. As a shared batch service (extending `JBSbatBusinessService`), this class is designed to be instantiated and invoked by the batch scheduler framework, specifically handling address change (住所変更) scenarios where service contracts need to be re-extracted and routed based on work completion status or move-in readiness. The `initial()` method itself performs no branching logic or business decisions — it solely sets up the infrastructure (DB access objects, common info) required by downstream processing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(commonItem)"])
    START --> SET_INFO["SET setCommonInfo(commonItem)"]
    SET_INFO --> DB1["SET db_KK_T_SVKEI_KAISEN_UW = new JBSbatSQLAccess(KK_T_SVKEI_KAISEN_UW)"]
    DB1 --> DB2["SET db_KK_T_ADCHG_DTL = new JBSbatSQLAccess(KK_T_ADCHG_DTL)"]
    DB2 --> DB3["SET db_KK_T_KJ_FIN_WK = new JBSbatSQLAccess(KK_T_KJ_FIN_WK)"]
    DB3 --> DB4["SET db_KU_T_SVKEI_KOJIAK = new JBSbatSQLAccess(KU_T_SVKEI_KOJIAK)"]
    DB4 --> DB5["SET db_KK_T_SVC_KEI = new JBSbatSQLAccess(KK_T_SVC_KEI)"]
    DB5 --> END_NODE(["Return / Next"])
```

**Branching Summary:** This method has **no conditional branches** — it executes a strictly linear sequence of initialization steps. All processing is sequential setup of database access objects for the tables required by the main `execute()` method.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | Batch common parameter message — carries shared batch execution context including operation date (`opeDate`), database connection credentials, logging configuration, and other system-wide settings required by all batch services in the K-Opticom backbone. Passed to `setCommonInfo()` for base class initialization and used during all five `JBSbatSQLAccess` constructor calls to establish DB connections. |

**Instance fields read/written by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_KK_T_SVKEI_KAISEN_UW` | `JBSbatSQLAccess` | Database access handle for `KK_T_SVKEI_KAISEN_UW` (Service Contract Line Details) — initialized for read queries (KK_SELECT_026) |
| `db_KK_T_ADCHG_DTL` | `JBSbatSQLAccess` | Database access handle for `KK_T_ADCHG_DTL` (Address Change Details) — initialized for read queries (KK_SELECT_003, KK_SELECT_020) |
| `db_KK_T_KJ_FIN_WK` | `JBSbatSQLAccess` | Database access handle for `KK_T_KJ_FIN_WK` (Work Completion Work) — initialized for read queries (KK_SELECT_019, KK_SELECT_020) |
| `db_KU_T_SVKEI_KOJIAK` | `JBSbatSQLAccess` | Database access handle for `KU_T_SVKEI_KOJIAK` (Service Contract_Work Item) — initialized for read queries (KK_SELECT_007) |
| `db_KK_T_SVC_KEI` | `JBSbatSQLAccess` | Database access handle for `KK_T_SVC_KEI` (Service Contract) — initialized for read queries (KK_SELECT_023, KK_SELECT_251) |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JBSbatBusinessService.setCommonInfo` | JBSbatBusinessService | In-memory | Calls `setCommonInfo` on base class to configure batch common parameters |
| C | `new JBSbatSQLAccess` (x5) | Framework | KK_T_SVKEI_KAISEN_UW | Creates database access handle for service contract line details table |
| C | `new JBSbatSQLAccess` (x5) | Framework | KK_T_ADCHG_DTL | Creates database access handle for address change details table |
| C | `new JBSbatSQLAccess` (x5) | Framework | KK_T_KJ_FIN_WK | Creates database access handle for work completion work table |
| C | `new JBSbatSQLAccess` (x5) | Framework | KU_T_SVKEI_KOJIAK | Creates database access handle for service contract work item table |
| C | `new JBSbatSQLAccess` (x5) | Framework | KK_T_SVC_KEI | Creates database access handle for service contract table |

**How to classify:**
- **U** (Update): `setCommonInfo()` — updates internal state of the base class with batch parameters
- **C** (Create): All `new JBSbatSQLAccess()` calls — create new database access handles (connection objects), one per target table

All five `JBSbatSQLAccess` objects are initialized here and used exclusively for **read (R)** operations (SQL SELECT queries) in the main `execute()` method. The `terminal()` method closes them.

## 5. Dependency Trace

This method implements the standard batch service initialization contract defined by `JBSbatBusinessService`. It is invoked automatically by the batch framework's execution pipeline, not by a specific screen or CBS.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKTVMainSubSwitch | `main()` -> batch processing dispatch -> `JBSbatKKFmtcelSodUpdInfCst.initial(commonItem)` | `db_KK_T_SVKEI_KAISEN_UW [R] KK_T_SVKEI_KAISEN_UW` |
| 2 | Batch: JBSbatKKEMoneyMailUtil | `initial(commonItem)` -> framework dispatch (subclass initialization) | `db_KK_T_SVKEI_KAISEN_UW [R] KK_T_SVKEI_KAISEN_UW` |
| 3 | Batch: JDKSendFileToWMSBaseService | `initial(commonItem)` -> base service framework | `db_KK_T_SVKEI_KAISEN_UW [R] KK_T_SVKEI_KAISEN_UW` |
| 4 | Batch: JDKSendFileBaseService | `initial(commonItem)` -> base service framework | `db_KK_T_SVKEI_KAISEN_UW [R] KK_T_SVKEI_KAISEN_UW` |
| 5 | Batch: JDKEFileKanriBaseService | `initial(commonItem)` -> base service framework | `db_KK_T_SVKEI_KAISEN_UW [R] KK_T_SVKEI_KAISEN_UW` |
| 6 | Batch: JBSbatBusinessService (abstract) | Abstract `initial()` -> implemented by subclasses | `db_KK_T_SVKEI_KAISEN_UW [R] KK_T_SVKEI_KAISEN_UW` |
| 7 | Batch: JBSbatDKHmpinTrnReqErrUpd | `initial(commonItem)` -> batch initialization | `db_KK_T_SVKEI_KAISEN_UW [R] KK_T_SVKEI_KAISEN_UW` |
| 8 | Batch: JBSbatCHPkozaNyukinAdd | `initial(commonItem)` -> batch initialization | `db_KK_T_SVKEI_KAISEN_UW [R] KK_T_SVKEI_KAISEN_UW` |

**From this method, the terminal calls reached during `execute()` processing:**

| # | Terminal Method | SC Code | Operation | Entity / DB | Business Description |
|---|----------------|---------|-----------|-------------|---------------------|
| 1 | `executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_026` | KK_SELECT_026 | R | KK_T_SVKEI_KAISEN_UW | Query service contract line details to check move-in reservation status |
| 2 | `executeKK_T_KJ_FIN_WK_KK_SELECT_020` | KK_SELECT_020 | R | KK_T_KJ_FIN_WK | Query new construction work completion work records |
| 3 | `executeKU_T_SVKEI_KOJIAK_KK_SELECT_007` | KK_SELECT_007 | R | KU_T_SVKEI_KOJIAK | Query service contract work item details |
| 4 | `executeKK_T_KJ_FIN_WK_KK_SELECT_019` | KK_SELECT_019 | R | KK_T_KJ_FIN_WK | Query disconnection work completion work records |

## 6. Per-Branch Detail Blocks

### Block 1 — SET (Common Info Setup) (L135)

> Sets batch common parameters by delegating to the base class initialization method. This establishes the operational context (operation date, logging, DB connection context) shared across all processing steps.

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | CALL | `super.setCommonInfo(commonItem)` | Sets common batch parameters / 共通パラメータを設定します |

### Block 2 — IF/ELSE: Delayed Start Check (L185) — Referenced from execute() context

> Checks whether the delayed start flag is set. If yes, outputs intermediate file data without further processing.

**Block 2.1 — IF: Delayed Start Equals "1"** `(DELAYED_START.equals(isDelayed))`

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | SET | `outMap.setString(SVC_KEI_NO, inSvcKeiNo)` | Service contract number / サービス契約番号 |
| 2 | SET | `outMap.setString(SVC_KEI_GENE_ADD_DTM, inGeneAddDtm)` | Service contract generation date-time / サービス契約＿世代登録年月日時分秒 |
| 3 | SET | `outMap.setString(KOJIAK_NO, "")` | Work item number (empty for delayed path) / 工事案件番号 |
| 4 | IF | `!isSurrenderService(inSvcKeiNo)` | Only extract if transfer source service contract is not surrendered |
| 5 | CALL | `outputItem.addOutMapList(outMap)` | Output to intermediate file / 中間ファイルに出力 |

**Block 2.2 — ELSE: Normal Processing Path**

> Continues to check move-in reservation status, new work completion, and disconnection work completion in sequence.

### Block 3 — IF: Move-in Reservation Status (L226) — Referenced from execute() context

> Checks if the move-in scheduled date has arrived for the service contract line details. If yes, outputs intermediate file data.

**Block 3.1 — Processing Step** `(nyukyoRsvTriKisnInfo != null)`

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | CALL | `executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_026(inItensSvkeiKisuwNo, adjustDate(opeDate, 1))` | Query service contract line details / サービス契約回線内訳を取得 |
| 2 | SET | `nyukyoRsvTriKisnInfo = db_KK_T_SVKEI_KAISEN_UW.selectNext()` | Get query result / 取得結果 |
| 3 | IF | `nyukyoRsvTriKisnInfo != null` | Move-in date has arrived / 入居予定日が到着した場合 |
| 4 | SET | `outMap.setString(SVC_KEI_NO, inSvcKeiNo)` | Service contract number |
| 5 | SET | `outMap.setString(SVC_KEI_GENE_ADD_DTM, inGeneAddDtm)` | Service contract generation date-time |
| 6 | SET | `outMap.setString(KOJIAK_NO, "")` | Work item number (empty) |
| 7 | IF | `!isSurrenderService(inSvcKeiNo)` | Only extract if not surrendered |
| 8 | CALL | `outputItem.addOutMapList(outMap)` | Output to intermediate file |

### Block 4 — FOR: New Work Completion Check (L261) — Referenced from execute() context

> Iterates through work completion work records for new construction, checking if each has a corresponding service contract work item.

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | CALL | `executeKK_T_KJ_FIN_WK_KK_SELECT_020(inAdchgNo, opeDate)` | Query new construction work completion work / 新規の工事完了ワークを取得 |
| 2 | FOR | `newKjFinRnkiInfo = db_KK_T_KJ_FIN_WK.selectNext()` | Iterate through work completion records |
| 3 | SET | `newKojiakNo = newKjFinRnkiInfo.getString(KOJIAK_NO)` | Get work item number / 工事案件番号を取得 |
| 4 | CALL | `executeKU_T_SVKEI_KOJIAK_KK_SELECT_007(inChafSkbtNo, newKojiakNo)` | Query service contract work item details |
| 5 | IF | `db_KU_T_SVKEI_KOJIAK.selectNext() != null` | Work item found / 工事案件が存在する場合 |
| 6 | SET | `outMap.setString(SVC_KEI_NO, inSvcKeiNo)` | Service contract number |
| 7 | SET | `outMap.setString(SVC_KEI_GENE_ADD_DTM, inGeneAddDtm)` | Service contract generation date-time |
| 8 | SET | `outMap.setString(KOJIAK_NO, "")` | Work item number (empty) |
| 9 | IF | `!isSurrenderService(inSvcKeiNo)` | Only extract if not surrendered |
| 10 | CALL | `outputItem.addOutMapList(outMap)` | Output to intermediate file |

### Block 5 — FOR: Disconnection Work Completion Check (L300) — Referenced from execute() context

> Iterates through work completion work records for disconnection, checking if each has a corresponding service contract work item.

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | CALL | `executeKK_T_KJ_FIN_WK_KK_SELECT_019(inAdchgNo, opeDate)` | Query disconnection work completion work / 撤去の工事完了ワークを取得 |
| 2 | FOR | `dslKjFinRnkiInfo = db_KK_T_KJ_FIN_WK.selectNext()` | Iterate through disconnection work records |
| 3 | SET | `dslKojiakNo = dslKjFinRnkiInfo.getString(KOJIAK_NO)` | Get disconnection work item number / 撤去工事案件番号を取得 |
| 4 | CALL | `executeKU_T_SVKEI_KOJIAK_KK_SELECT_007(inMap.getString(CHBF_SKBT_NO), dslKojiakNo)` | Query service contract work item details for disconnection |
| 5 | IF | `db_KU_T_SVKEI_KOJIAK.selectNext() != null` | Work item found |
| 6 | SET | `outMap.setString(SVC_KEI_NO, inSvcKeiNo)` | Service contract number |
| 7 | SET | `outMap.setString(SVC_KEI_GENE_ADD_DTM, inGeneAddDtm)` | Service contract generation date-time |
| 8 | SET | `outMap.setString(KOJIAK_NO, dslKojiakNo)` | Work item number (contains disconnection work item number) |
| 9 | IF | `!isSurrenderService(inSvcKeiNo)` | Only extract if not surrendered |
| 10 | CALL | `outputItem.addOutMapList(outMap)` | Output to intermediate file |

### Block 6 — ELSE: No Match (L340) — Referenced from execute() context

> If none of the four branches (delayed start, move-in reservation, new work completion, disconnection work completion) match, returns null — meaning nothing to output.

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | RETURN | `return null;` | No matching condition — do nothing / どれにも該当しない場合は何もしない |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service contract number — unique identifier for a customer's service contract line |
| `svc_kei_ucwk_no` | Field | Service detail work number — internal tracking ID for service contract line items |
| `odr_naiyo_cd` | Field | Order content code — classifies order type (FTTH registration, Mail change, etc.) |
| `adchg_no` | Field | Address change number — unique identifier for an address change request (住所変更番号) |
| `kojia_no` | Field | Work item number — unique identifier for a construction/work item (工事案件番号) |
| `chaf_skbt_no` | Field | Post-change service contract number — the service contract number after transfer/change (変更後識別番号) |
| `chbf_skbt_no` | Field | Pre-change service contract number — the service contract number before transfer/change (変更前サービス契約番号) |
| `itens_svkei_kisuw_no` | Field | Transfer destination service contract line details number — the line details number at the transfer destination (移転先サービス契約回線内訳番号) |
| `gene_add_dtm` | Field | Registration date-time — timestamp of when the service contract was registered/created (世代登録年月日時分秒) |
| `is_delayed` | Field | Delayed start flag — indicates whether the batch should execute in delayed mode |
| SOD | Acronym | Service Order Data — telecom service order fulfillment entity used in the K-Opticom system |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service |
| KK_ | Prefix | K-Opticom internal table prefix — denotes tables in the K-Opticom proprietary schema |
| KU_ | Prefix | KU (K-Opticom Utility) table prefix — denotes utility/work tables in the K-Opticom schema |
| SHOTTERMU | Domain term | Short-term — refers to short-term service updates in the telecom context (ショートターム) |
| SOD KOSIN JOUHOU | Domain term | Service Order Update Information — information extracted for updating service order data (SOD更新情報) |
| CHUSOU BUNSEKI | Domain term | Address change — customer relocation/address change processing workflow (住所変更) |
| KOuji BANGOU | Domain term | Work item number — identifier for a construction work item (工事案件番号) |
| KOUJI KANRYOU WORK | Domain term | Work completion work — work records tracking construction completion status (工事完了ワーク) |
| TETSUZO KOUJI | Domain term | Disconnection work — construction work for removing/disconnecting service lines (撤去工事) |
| NYUSYO YOTEIHI | Domain term | Move-in scheduled date — the date when service is scheduled to begin at the new address (入居予定日) |
| KAISETSU | Domain term | Surrender/cancellation — status indicating a service contract has been cancelled or surrendered (解約) |
| CHUTAN GEN NO SVC KEI | Domain term | Transfer source service contract — the original service contract before relocation/transfer (移転元のサービス契約) |
| CHUUKAN FAIRU | Domain term | Intermediate file — output file used for batch data transfer between processing stages (中間ファイル) |
| DELAYED_START | Constant | "1" — delayed start mode flag value (ディレイド（起動）) |
| DELAYED_NOT_START | Constant | "0" — not delayed start mode flag value (ディレイド（ない）) |
| ADCHG_DTL_SBT_CD_KOJIAK_NO | Constant | "06" — address change detail subtype code for work item number (住所変更明細種別コード（工事案件番号）) |
| KU_T_KOJIAK_KOJIAK_STAT | Constant | "900" — work item status code for cancellation (工事案件ステータス（中止）) |
| ADCHG_DTL_SBT_CD_SVC_KEI_NO | Constant | "01" — address change detail subtype code for service contract number (住所変更明細種別コード（サービス契約番号）) |
| `KK_T_SVKEI_KAISEN_UW` | Table | Service Contract Line Details — table storing breakdown details of service contracts (サービス契約回線内訳) |
| `KK_T_ADCHG_DTL` | Table | Address Change Details — table storing details of address change requests (住所変更明細) |
| `KK_T_KJ_FIN_WK` | Table | Work Completion Work — table storing work completion tracking records (工事完了ワーク) |
| `KU_T_SVKEI_KOJIAK` | Table | Service Contract_Work Item — table linking service contracts to work items (サービス契約＿工事案件) |
| `KK_T_SVC_KEI` | Table | Service Contract — table storing service contract master data (サービス契約) |
| JBSbatCommonItem | Class | Batch common parameter message — carries shared batch execution context (バッチ共通パラメータ電文) |
| JBSbatBusinessService | Class | Base batch service class — provides common initialization, execution, and terminal lifecycle methods |
| JBSbatSQLAccess | Class | Database access handle — wrapper around SQL execution for K-Opticom batch processing |
| JBSbatOutputItem | Class | Batch output item — carries output data including map lists for intermediate file output |
| JBSbatServiceInterfaceMap | Class | Service interface map — key-value container for passing data between batch processing steps |
| KK_SELECT_026 | SQL Key | SQL definition key for querying service contract line details by line details number and operation date (minus 1 day) |
| KK_SELECT_020 | SQL Key | SQL definition key for querying work completion work by address change number and operation date |
| KK_SELECT_019 | SQL Key | SQL definition key for querying disconnection work completion work |
| KK_SELECT_007 | SQL Key | SQL definition key for querying service contract work item details |
| KK_SELECT_023 | SQL Key | SQL definition key for service contract table queries |
| KK_SELECT_251 | SQL Key | SQL definition key for service contract table queries (added per ANK-1429-00-00) |
