# Business Logic — JBSbatKKAdChgFmtcelSodUpd.terminal() [13 LOC]

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

## 1. Role

### JBSbatKKAdChgFmtcelSodUpd.terminal()

This method performs the **business service termination processing** for the address-change-format cell service update batch (`JBSbatKKAdChgFmtcelSodUpd`). The batch's business purpose is to update Fiber-to-the-Home (FTTH) cell service orders when a customer's address is changed (住所変更: *jusho henkou*) and confirmed (確定: *kakutei*). The `terminal()` method serves as the cleanup hook at the end of each batch execution cycle, ensuring that all database access objects opened during batch processing are properly released.

Specifically, it closes three `JBSbatSQLAccess` instances: `db_KK_T_PRG` (progress tracking table), `db_KK_T_OP_SVC_KEI` (option service contract table), and `db_KK_T_ADCHG_DTL` (address-change detail table — added via ANK-2286-00-00 on 2014/10/17). This follows a standard resource-cleanup pattern used across all batch service components in the system, preventing resource leaks and ensuring clean database connection state for subsequent processing cycles or error-handling paths.

The method implements a **delegation pattern** — it does not contain business logic itself but delegates all cleanup work to the `close()` methods of its injected `JBSbatSQLAccess` collaborators. Its role in the larger system is as the mandatory teardown step in the batch service lifecycle, consistently invoked after the `execute()` method completes (whether successfully or via exception handling).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["terminal()"])
    CLOSE_PRG["db_KK_T_PRG.close()"]
    CLOSE_OP_SVC["db_KK_T_OP_SVC_KEI.close()"]
    CLOSE_ADCHG["db_KK_T_ADCHG_DTL.close()"]
    END_NODE(["Return / Next"])

    START --> CLOSE_PRG
    CLOSE_PRG --> CLOSE_OP_SVC
    CLOSE_OP_SVC --> CLOSE_ADCHG
    CLOSE_ADCHG --> END_NODE
```

**Processing flow:**
1. Close the database access object for the progress table (`KK_T_PRG`).
2. Close the database access object for the option service contract table (`KK_T_OP_SVC_KEI`).
3. Close the database access object for the address-change detail table (`KK_T_ADCHG_DTL`).
4. Return (void method — execution continues to the caller's next step).

No conditional branches exist in this method. It is a linear cleanup sequence.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It operates purely on instance fields (the `JBSbatSQLAccess` objects) that were initialized during the batch's setup phase. |

**Instance fields read by this method:**

| Field Name | Type | Business Description |
|------------|------|---------------------|
| `db_KK_T_PRG` | `JBSbatSQLAccess` | Database access object for the progress management table (`KK_T_PRG`). Tracks batch job advancement status. |
| `db_KK_T_OP_SVC_KEI` | `JBSbatSQLAccess` | Database access object for the option service contract table (`KK_T_OP_SVC_KEI`). Manages option service contract data during address change processing. |
| `db_KK_T_ADCHG_DTL` | `JBSbatSQLAccess` | Database access object for the address-change detail table (`KK_T_ADCHG_DTL`). Stores detail records for address change operations (added in fix ANK-2286-00-00). |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `db_KK_T_PRG.close` | - | `KK_T_PRG` | Closes the database access object for the progress management table. Releases connection/resources. |
| - | `db_KK_T_OP_SVC_KEI.close` | - | `KK_T_OP_SVC_KEI` | Closes the database access object for the option service contract table. Releases connection/resources. |
| - | `db_KK_T_ADCHG_DTL.close` | - | `KK_T_ADCHG_DTL` | Closes the database access object for the address-change detail table. Releases connection/resources. |

**Operation classification:** All three operations are **cleanup/resource-release** actions. They do not perform Create, Read, Update, or Delete operations on data — instead, they close the underlying database connections and free allocated resources for the respective tables.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKAdChgFmtcelSodUpd | `execute()` -> `terminal()` | `db_KK_T_PRG.close` [-] `KK_T_PRG` |

**Notes:** The `terminal()` method is called by the parent class's batch framework from within the `execute()` lifecycle method of `JBSbatKKAdChgFmtcelSodUpd` (which extends `JBSbatBusinessService`). No external screens or CBS classes reference this method directly. The comment in `JBSbatKKAdChgCstScreenKidou.java` shows a commented-out reference to this class (`//private JBSbatKKAdChgFmtcelSodUpd execRunObjFmtcel = null;`), indicating it is NOT an active caller. The method is purely an internal batch teardown hook.

## 6. Per-Branch Detail Blocks

**Block 1** — [EXEC] `(db_KK_T_PRG.close())` (L346)

> Closes the database access object for the progress management table. This is part of the tool-generated termination processing block.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_PRG.close();` // Close DB access class (progress) |

**Block 2** — [EXEC] `(db_KK_T_OP_SVC_KEI.close())` (L347)

> Closes the database access object for the option service contract table.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_OP_SVC_KEI.close();` // Close DB access class (option service contract) |

**Block 3** — [EXEC] `(db_KK_T_ADCHG_DTL.close())` (L349)

> Closes the database access object for the address-change detail table. Added via ANK-2286-00-00 (2014/10/17).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_ADCHG_DTL.close();` // Close DB access class (address-change detail) | ANK-2286-00-00 |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_PRG` | DB Table | Progress management table — stores batch job advancement status and tracking information |
| `KK_T_OP_SVC_KEI` | DB Table | Option service contract table — stores option service contract line items processed during address change |
| `KK_T_ADCHG_DTL` | DB Table | Address-change detail table — stores detail records for address change operations (住所変更詳細) |
| `JBSbatSQLAccess` | Class | Batch SQL access utility class — provides database query/insert/update/delete operations with connection lifecycle management |
| `terminal()` | Method | Termination processing — cleanup hook invoked at the end of a batch service lifecycle |
| ANK-2286-00-00 | Fix ID | Internal fix/tracking ID for the 2014/10/17 addition of `db_KK_T_ADCHG_DTL` support |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity used in service registration |
| 住所変更 (jusho henkou) | Japanese term | Address change — the business operation of updating a customer's registered address |
| 確定 (kakutei) | Japanese term | Confirmation — the state of finalizing an address change operation |
| 住所変更完了 (jusho henkou kanryo) | Japanese term | Address change completion — progress state code `6100` indicating the address change process is complete |
| USECASE_ID | Field | `KKSV0709` — the use case identifier for this batch processing |
| OPERATION_ID | Field | `KKSV0709OP` — the operation identifier within the use case |
| FIXED_TEXT | Field | `KKSV070901CC` — the user-defined text string key for localized messages |
| IDO_DIV_ADCHG_FIX | Constant | `"00020"` — movement division code for address-change confirmation |
| PRG_STAT_ADCHG_FIN | Constant | `"6100"` — progress status code for address-change completion |
| OYA_KEI_SKBT_CD_SVC_KEI | Constant | `"01"` — parent contract identification code for service contract |
| FMTCEL_IDO_DTL_CD_INIT | Constant | `"00"` — format cell movement detail code initial value |
