---

# Business Logic — JBSbatKKSyuKeiStabunKikiStaAdd.initial() [19 LOC]

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

## 1. Role

### JBSbatKKSyuKeiStabunKikiStaAdd.initial()

This method performs the **initialization phase** for the "Main Contract Start Machine Start Registration" batch service (`JBSbatKKSyuKeiStabunKikiStaAdd`). The class handles registration of machines (equipment) that need to be started at contract commencement for the main contract division — specifically, it registers machines eligible for start-up when a primary service contract begins. This is a key step in the customer contract lifecycle where new subscriber equipment is activated and registered in the system.

The method implements a **delegation pattern**, extending `JBSbatBusinessService` and invoking `super.setCommonInfo(commonItem)` to inherit standard batch initialization logic (setting up common parameters, logging, and error handling context). It then constructs four `JBSbatSQLAccess` instances — one per database table required by this service — enabling the downstream `execute()` method to perform CRUD operations against the installment contract table, progress tracking table, service contract details table, and line target service contract table.

Its role in the larger system is as an **entry-point preparer** within the batch processing pipeline. It is instantiated and initialized by `JBSbatKKAdChgCstScreenKidou` (Customer Contract Change Screen Migration), which orchestrates multiple sub-services for customer contract change/migration operations. This method does not branch conditionally — it is a straight-line initialization routine that sets up all data access infrastructure before the batch's main processing logic runs.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(commonItem)"])
    STEP1["setCommonInfo(commonItem)
<BR>Inherited common setup"]
    STEP2["Create db_KK_T_KAP_KEI
<BR>SQL access: KK_T_KAP_KEI
<BR>(Installment Contract)"]
    STEP3["Create db_KK_T_PRG
<BR>SQL access: KK_T_PRG
<BR>(Progress)"]
    STEP4["Create db_KK_T_SVC_KEI_UCWK
<BR>SQL access: KK_T_SVC_KEI_UCWK
<BR>(Service Contract Details)"]
    STEP5["Create db_KK_T_KAISEN_TG_SVKEI
<BR>SQL access: KK_T_KAISEN_TG_SVKEI
<BR>(Line Target Service Contract)"]
    STEP6["Set stmt = KK_T_PRG
<BR>Shared SQL access for common parts"]
    END_NODE(["Return / Next"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> STEP6
    END_NODE
```

This method executes in a **linear, unbranched flow** — there are no conditional branches, loops, or error-handling blocks. Every line is a setup step that prepares the service for its main `execute()` processing phase.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | The batch common parameter message — carries shared context for the entire batch operation including batch execution ID, operator ID, start/end timestamps, logging configuration, transaction settings, and shared data maps. This object is the contract-wide context object passed through all service components during batch execution. |

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

| Field | Type | Access | Description |
|-------|------|--------|-------------|
| `db_KK_T_KAP_KEI` | `JBSbatSQLAccess` | Write | SQL access layer for the `KK_T_KAP_KEI` (Installment Contract) table |
| `db_KK_T_PRG` | `JBSbatSQLAccess` | Write | SQL access layer for the `KK_T_PRG` (Progress) table |
| `db_KK_T_SVC_KEI_UCWK` | `JBSbatSQLAccess` | Write | SQL access layer for the `KK_T_SVC_KEI_UCWK` (Service Contract Details) table |
| `db_KK_T_KAISEN_TG_SVKEI` | `JBSbatSQLAccess` | Write | SQL access layer for the `KK_T_KAISEN_TG_SVKEI` (Line Target Service Contract) table |
| `stmt` | `JBSbatSQLAccess` | Write | Shared SQL access instance for the `KK_T_PRG` (Progress) table, used for common parts processing |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JBSbatBusinessService.setCommonInfo` | JBSbatBusinessService | - | Inherits common batch initialization — sets up logging, transaction context, and shared data from `commonItem` |
| - | `JBSbatSQLAccess` constructor | - | `KK_T_KAP_KEI` | Creates SQL access layer for Installment Contract table — enables read/write operations for contract installment data |
| - | `JBSbatSQLAccess` constructor | - | `KK_T_PRG` | Creates SQL access layer for Progress table — enables read/write operations for batch progress tracking |
| - | `JBSbatSQLAccess` constructor | - | `KK_T_SVC_KEI_UCWK` | Creates SQL access layer for Service Contract Details table — enables read/write operations for contract item details |
| - | `JBSbatSQLAccess` constructor | - | `KK_T_KAISEN_TG_SVKEI` | Creates SQL access layer for Line Target Service Contract table — enables read/write operations for line-targeted service contracts |
| - | `JBSbatSQLAccess` constructor (stmt) | - | `KK_T_PRG` | Creates shared SQL access instance for Progress table used by common parts processing in the main execution method |

**Notes:**
- This method performs no actual CRUD operations. All operations are **C (Create)** on the SQL access infrastructure objects.
- The `JBSbatSQLAccess` instances created here are used by the `execute()` method to perform actual reads (R), creates (C), and updates (U) against the underlying database tables.
- SQL definition keys used by the `execute()` method include: `KK_SELECT_014` (targeted at `KK_T_SVC_KEI_UCWK`), `KK_SELECT_032` (targeted at `KK_T_KAISEN_TG_SVKEI`), and `KK_SELECT_040` (targeted at `KK_T_PRG`).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKAdChgCstScreenKidou | `JBSbatKKAdChgCstScreenKidou.initial(commonItem)` → `execKikiStaAdd = new JBSbatKKSyuKeiStabunKikiStaAdd()` → `execKikiStaAdd.initial(commonItem)` | `setCommonInfo` [SET] commonItem context |

**Notes:**
- `JBSbatKKAdChgCstScreenKidou` is the batch service that orchestrates customer contract change/migration processing. It instantiates multiple sub-service objects (for SOD updates, address changes, SIM card registration, place number changes, and machine start registration) and initializes each one via `initial(commonItem)`.
- The `execKikiStaAdd` field is a private member (`private JBSbatKKSyuKeiStabunKikiStaAdd execKikiStaAdd = null;`) instantiated during `initial()` and called as part of the full customer contract migration workflow.

## 6. Per-Branch Detail Blocks

> This method has no conditional branches or loops — it is a linear initialization sequence. Each processing step is documented below.

**Block 1** — [EXEC] `super.setCommonInfo(commonItem)` (L130)

> Call inherited common initialization from the parent service class. Sets up batch context from the common parameter message.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.setCommonInfo(commonItem)` // Inherited: set common batch initialization parameters |

**Block 2** — [EXEC] Tool-generated initialization block start — SQL access creation (L133)

> Begin of tool-generated initialization section: creating SQL access layers for all four database tables required by this service.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_KK_T_KAP_KEI = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_KAP_KEI)` // [-> D_TBL_NAME_KK_T_KAP_KEI = "KK_T_KAP_KEI"] — SQL access for Installment Contract table |
| 2 | SET | `db_KK_T_PRG = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_PRG)` // [-> D_TBL_NAME_KK_T_PRG = "KK_T_PRG"] — SQL access for Progress table |
| 3 | SET | `db_KK_T_SVC_KEI_UCWK = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_SVC_KEI_UCWK)` // [-> D_TBL_NAME_KK_T_SVC_KEI_UCWK = "KK_T_SVC_KEI_UCWK"] — SQL access for Service Contract Details table |
| 4 | SET | `db_KK_T_KAISEN_TG_SVKEI = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_TKAISEN_TG_SVKEI)` // [-> D_TBL_NAME_KK_TKAISEN_TG_SVKEI = "KK_T_KAISEN_TG_SVKEI"] — SQL access for Line Target Service Contract table |

**Block 3** — [EXEC] Tool-generated initialization block end (L140)

> End of tool-generated initialization section.

| # | Type | Code |
|---|------|------|
| 1 | — | (no code: closing comment only) |

**Block 4** — [EXEC] Common parts SQL access setup (L141)

> Initialize a shared SQL access instance (`stmt`) for the Progress table, designated for use in common parts processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `stmt = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_PRG)` // [-> D_TBL_NAME_KK_T_PRG = "KK_T_PRG"] — Shared SQL access for common parts |

**Block 5** — [RETURN] Service initialization complete (L143)

> End of the `initial()` method. Returns `void`. The service is now ready for the `execute()` method to perform actual processing.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | (void) // Return control to caller after initialization |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `Kiki` | Field | Machine start — refers to the activation/starting of customer equipment (modem, router, ONT, etc.) |
| `Sta` | Field | Start — indicates the registration of machine activation timing |
| `Add` | Field | Add — the action of registering or adding a new record (as opposed to update or cancel) |
| `SyuKei` | Field | Main contract — the primary service contract between the provider and the customer |
| `Stabun` | Field | Division/Section — indicates this service handles a specific division or section of the main contract |
| `KAP_KEI` | Field | Installment Contract (割賦契約) — contract for installment payment plans; stored in table `KK_T_KAP_KEI` |
| `SVC_KEI_UCWK` | Field | Service Contract Details (サービス契約内訳) — detailed breakdown of service contract line items; stored in table `KK_T_SVC_KEI_UCWK` |
| `KAISEN_TG_SVKEI` | Field | Line Target Service Contract (回線対象サービス契約) — service contracts associated with specific network lines; stored in table `KK_T_KAISEN_TG_SVKEI` |
| `PRG` | Field | Progress (進捗) — batch processing progress tracking table; stored in table `KK_T_PRG` |
| `JBSbatCommonItem` | Field | Batch Common Parameter — the shared context object passed to all batch service components, containing batch execution ID, operator info, timestamps, logging, and transaction state |
| `JBSbatSQLAccess` | Field | Database SQL Access Layer — the framework class that provides database connectivity for reading and writing to specific tables |
| `JBSbatBusinessService` | Field | Base Batch Service — the parent class providing shared batch service functionality including `setCommonInfo()` |
| `commonItem` | Field | Batch Common Parameter Message — carries shared configuration and state for the batch run across all service components |
| `KK_SELECT_014` | Field | SQL definition key for queries against `KK_T_SVC_KEI_UCWK` |
| `KK_SELECT_032` | Field | SQL definition key for queries against `KK_T_KAISEN_TG_SVKEI` |
| `KK_SELECT_040` | Field | SQL definition key for queries against `KK_T_PRG` |
| `SEQ_PRG_NO` | Field | Progress Sequence Number Key — key used in progress tracking to identify the current processing step |
| ScreenKidou | Field | Screen Migration — refers to the migration from screen-based processing to batch-based processing (`Kidou` = 異動, migration/transfer) |

---

---
