# Business Logic — JBSbatKKNrkeFinKikiHktgi.terminal() [24 LOC]

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

## 1. Role

### JBSbatKKNrkeFinKikiHktgi.terminal()

This method implements the business service termination (lifecycle teardown) processing for the "eo Light Net Single Plane" equipment succession batch job. Its sole responsibility is to release all database resource handles that were acquired during the batch processing lifecycle, ensuring proper cleanup regardless of whether the batch completed successfully or terminated abnormally. The method follows the resource cleanup design pattern commonly used in batch service frameworks, where a `terminal()` lifecycle hook is guaranteed to execute after the main processing completes (typically via a `finally` block in the parent framework's invocation chain). As a resource cleanup method with no conditional branches or data mutations, it serves as a defensive safeguard against database connection leaks and file descriptor exhaustion during long-running batch operations. It is part of the class whose purpose is handling equipment succession processing after the completion of net-to-single-plane migration, and also outputs succeeded equipment information to the "Equipment Succession Completion List" file.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["terminal()"])
    START --> CLOSE_WORK_PARAM["Close db_ZM_M_WORK_PARAM_KNRI
(Work Parameter Management)"]
    CLOSE_WORK_PARAM --> CLOSE_SVC_KEI["Close db_KK_T_KKTK_SVC_KEI
(Equipment Provision Service Contract)"]
    CLOSE_SVC_KEI --> CLOSE_SVC_KEI_SAKI["Close db_KK_T_KKTK_SVC_KEI_SAKI
(Equipment Provision Service Contract (After))"]
    CLOSE_SVC_KEI_SAKI --> CLOSE_SVC_KEI_ORIG["Close db_KK_T_SVC_KEI
(Service Contract)"]
    CLOSE_SVC_KEI_ORIG --> CLOSE_KKOP["Close db_KK_T_KKOP_SVC_KEI
(Equipment Option Service Contract)"]
    CLOSE_KKOP --> CLOSE_HAISO["Close db_DK_T_HAISO_TG_BPIN
(Delivery Target Product)"]
    CLOSE_HAISO --> CLOSE_HMPIN["Close db_DK_T_HMPIN_KIKI
(Returned Equipment)"]
    CLOSE_HMPIN --> CLOSE_HMPIN_MOTO["Close db_DK_T_HMPIN_KIKI_MOTO
(Returned Equipment (Original))"]
    CLOSE_HMPIN_MOTO --> CLOSE_KAISEN["Close db_KK_T_SVKEI_KAISEN_UW
(Service Contract Line Detail)"]
    CLOSE_KAISEN --> CLOSE_ODR_SET["Close db_KK_T_ODR_SET
(Order Settings)"]
    CLOSE_ODR_SET --> CLOSE_UCWK["Close db_KK_T_SVC_KEI_UCWK
(Service Contract Detail)"]
    CLOSE_UCWK --> CLOSE_HAKKO["Close db_KK_T_ODR_HAKKO_JOKEN
(Order Issuance Criteria)"]
    CLOSE_HAKKO --> CLOSE_SKSI["Close db_KK_T_ODR_INF_SKSI_WK
(Order Info Creation Work)"]
    CLOSE_SKSI --> CLOSE_PRG["Close db_KK_T_PRG
(Progress)"]
    CLOSE_PRG --> CLOSE_KJAK["Close db_KU_T_KJAK_TG_TKKIKI
(Work Case Target Indoor Equipment)
[ANK-4656-00-00]"]
    CLOSE_KJAK --> END(["Return / Next"])
```

**Processing Description:**
The `terminal()` method executes a flat, sequential chain of 17 `close()` calls. There are no conditional branches, no loops, and no error handling logic within the method itself. Each `close()` call releases a database SQL access handle (`JBSbatSQLAccess`) that was opened during the batch job's processing phase. The handles are closed in the reverse order of their typical lifecycle acquisition, following a structured resource cleanup pattern. The additional handle `db_KU_T_KJAK_TG_TKKIKI` (Work Case Target Indoor Equipment) was added in version v74.00.00 under ticket ANK-4656-00-00 for the "eo Light Single Plane Provision (STEP3)" feature.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It operates entirely on instance-level database resource handles that were initialized by the batch framework. |

**Instance fields / external state read by this method:**

| No | Field Name | Type | Business Description |
|----|-----------|------|---------------------|
| 1 | `db_ZM_M_WORK_PARAM_KNRI` | `JBSbatSQLAccess` | Work parameter management — holds the DB handle for the work parameter table used to manage batch job parameters |
| 2 | `db_KK_T_KKTK_SVC_KEI` | `JBSbatSQLAccess` | Equipment provision service contract — holds the DB handle for the equipment provision service contract table |
| 3 | `db_KK_T_KKTK_SVC_KEI_SAKI` | `JBSbatSQLAccess` | Equipment provision service contract (after) — holds the DB handle for the post-modification equipment provision service contract table |
| 4 | `db_KK_T_SVC_KEI` | `JBSbatSQLAccess` | Service contract — holds the DB handle for the service contract table |
| 5 | `db_KK_T_KKOP_SVC_KEI` | `JBSbatSQLAccess` | Equipment option service contract — holds the DB handle for the equipment option service contract table |
| 6 | `db_DK_T_HAISO_TG_BPIN` | `JBSbatSQLAccess` | Delivery target product — holds the DB handle for the delivery target product table |
| 7 | `db_DK_T_HMPIN_KIKI` | `JBSbatSQLAccess` | Returned equipment — holds the DB handle for the returned equipment table |
| 8 | `db_DK_T_HMPIN_KIKI_MOTO` | `JBSbatSQLAccess` | Returned equipment (original) — holds the DB handle for the original returned equipment table |
| 9 | `db_KK_T_SVKEI_KAISEN_UW` | `JBSbatSQLAccess` | Service contract line detail — holds the DB handle for the service contract line detail table |
| 10 | `db_KK_T_ODR_SET` | `JBSbatSQLAccess` | Order settings — holds the DB handle for the order settings table |
| 11 | `db_KK_T_SVC_KEI_UCWK` | `JBSbatSQLAccess` | Service contract detail — holds the DB handle for the service contract detail table |
| 12 | `db_KK_T_ODR_HAKKO_JOKEN` | `JBSbatSQLAccess` | Order issuance criteria — holds the DB handle for the order issuance criteria table |
| 13 | `db_KK_T_ODR_INF_SKSI_WK` | `JBSbatSQLAccess` | Order info creation work — holds the DB handle for the order information creation work table |
| 14 | `db_KK_T_PRG` | `JBSbatSQLAccess` | Progress — holds the DB handle for the job progress tracking table |
| 15 | `db_KU_T_KJAK_TG_TKKIKI` | `JBSbatSQLAccess` | Work case target indoor equipment — holds the DB handle for the work case target indoor equipment table (added in v74.00.00 / ANK-4656-00-00) |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `db_ZM_M_WORK_PARAM_KNRI.close` | JBSbatZM_M_WORK_PARAM_KNRI | ZM_M_WORK_PARAM_KNRI | Closes the SQL access handle for the work parameter management table |
| - | `db_KK_T_KKTK_SVC_KEI.close` | JBSbatKK_T_KKTK_SVC_KEI | KK_T_KKTK_SVC_KEI | Closes the SQL access handle for the equipment provision service contract table |
| - | `db_KK_T_KKTK_SVC_KEI_SAKI.close` | JBSbatKK_T_KKTK_SVC_KEI_SAKI | KK_T_KKTK_SVC_KEI_SAKI | Closes the SQL access handle for the post-modification equipment provision service contract table |
| - | `db_KK_T_SVC_KEI.close` | JBSbatKK_T_SVC_KEI | KK_T_SVC_KEI | Closes the SQL access handle for the service contract table |
| - | `db_KK_T_KKOP_SVC_KEI.close` | JBSbatKK_T_KKOP_SVC_KEI | KK_T_KKOP_SVC_KEI | Closes the SQL access handle for the equipment option service contract table |
| - | `db_DK_T_HAISO_TG_BPIN.close` | JBSbatDK_T_HAISO_TG_BPIN | DK_T_HAISO_TG_BPIN | Closes the SQL access handle for the delivery target product table |
| - | `db_DK_T_HMPIN_KIKI.close` | JBSbatDK_T_HMPIN_KIKI | DK_T_HMPIN_KIKI | Closes the SQL access handle for the returned equipment table |
| - | `db_DK_T_HMPIN_KIKI_MOTO.close` | JBSbatDK_T_HMPIN_KIKI_MOTO | DK_T_HMPIN_KIKI_MOTO | Closes the SQL access handle for the original returned equipment table |
| - | `db_KK_T_SVKEI_KAISEN_UW.close` | JBSbatKK_T_SVKEI_KAISEN_UW | KK_T_SVKEI_KAISEN_UW | Closes the SQL access handle for the service contract line detail table |
| - | `db_KK_T_ODR_SET.close` | JBSbatKK_T_ODR_SET | KK_T_ODR_SET | Closes the SQL access handle for the order settings table |
| - | `db_KK_T_SVC_KEI_UCWK.close` | JBSbatKK_T_SVC_KEI_UCWK | KK_T_SVC_KEI_UCWK | Closes the SQL access handle for the service contract detail table |
| - | `db_KK_T_ODR_HAKKO_JOKEN.close` | JBSbatKK_T_ODR_HAKKO_JOKEN | KK_T_ODR_HAKKO_JOKEN | Closes the SQL access handle for the order issuance criteria table |
| - | `db_KK_T_ODR_INF_SKSI_WK.close` | JBSbatKK_T_ODR_INF_SKSI_WK | KK_T_ODR_INF_SKSI_WK | Closes the SQL access handle for the order info creation work table |
| - | `db_KK_T_PRG.close` | JBSbatKK_T_PRG | KK_T_PRG | Closes the SQL access handle for the job progress tracking table |
| - | `db_KU_T_KJAK_TG_TKKIKI.close` | JBSbatKU_T_KJAK_TG_TKKIKI | KU_T_KJAK_TG_TKKIKI | Closes the SQL access handle for the work case target indoor equipment table [ANK-4656-00-00] |

**Notes:**
- All operations are resource release calls (`close()`) on `JBSbatSQLAccess` objects. These are not CRUD operations against the database — they are framework-level resource cleanup calls that release database connections, statements, and result sets back to the pool.
- No SC codes (Service Component codes) are present because this method does not invoke service components; it only performs resource teardown.

## 5. Dependency Trace

The `terminal()` method is defined as an abstract method in the parent class `JBSbatBusinessService` and is implemented as a lifecycle hook. It is invoked automatically by the batch processing framework (typically in a `finally` block) after the main business processing completes — either successfully or due to an exception. No explicit callers were found in the codebase beyond the framework inheritance chain.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch Framework | `JBSbatBusinessService.execute()` (framework) -> `JBSbatKKNrkeFinKikiHktgi.terminal()` | `close(ZM_M_WORK_PARAM_KNRI) [RES] ZM_M_WORK_PARAM_KNRI`<br>`close(KK_T_KKTK_SVC_KEI) [RES] KK_T_KKTK_SVC_KEI`<br>`close(KK_T_KKTK_SVC_KEI_SAKI) [RES] KK_T_KKTK_SVC_KEI_SAKI`<br>`close(KK_T_SVC_KEI) [RES] KK_T_SVC_KEI`<br>`close(KK_T_KKOP_SVC_KEI) [RES] KK_T_KKOP_SVC_KEI`<br>`close(DK_T_HAISO_TG_BPIN) [RES] DK_T_HAISO_TG_BPIN`<br>`close(DK_T_HMPIN_KIKI) [RES] DK_T_HMPIN_KIKI`<br>`close(DK_T_HMPIN_KIKI_MOTO) [RES] DK_T_HMPIN_KIKI_MOTO`<br>`close(KK_T_SVKEI_KAISEN_UW) [RES] KK_T_SVKEI_KAISEN_UW`<br>`close(KK_T_ODR_SET) [RES] KK_T_ODR_SET`<br>`close(KK_T_SVC_KEI_UCWK) [RES] KK_T_SVC_KEI_UCWK`<br>`close(KK_T_ODR_HAKKO_JOKEN) [RES] KK_T_ODR_HAKKO_JOKEN`<br>`close(KK_T_ODR_INF_SKSI_WK) [RES] KK_T_ODR_INF_SKSI_WK`<br>`close(KK_T_PRG) [RES] KK_T_PRG`<br>`close(KU_T_KJAK_TG_TKKIKI) [RES] KU_T_KJAK_TG_TKKIKI` |

**Legend:** `[RES]` = Resource release (close) — not a database CRUD operation.

## 6. Per-Branch Detail Blocks

The `terminal()` method has no conditional branches, loops, or nested blocks. It consists of a flat sequence of 17 resource cleanup calls. Below is the complete block analysis:

**Block 1** — [SEQUENCE] `(terminal method body, lines 1317–1334)`

> This is the complete method body. It contains no conditions, no loops, and no try/catch. The method simply executes sequential close() calls to release all DB resource handles.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | COMMENT | `/** begin of auto-generated terminal processing source */` | Marks the start of framework-generated terminal processing section |
| 2 | EXEC | `db_ZM_M_WORK_PARAM_KNRI.close();` | Releases the work parameter management DB handle |
| 3 | EXEC | `db_KK_T_KKTK_SVC_KEI.close();` | Releases the equipment provision service contract DB handle |
| 4 | EXEC | `db_KK_T_KKTK_SVC_KEI_SAKI.close();` | Releases the post-modification equipment provision service contract DB handle |
| 5 | EXEC | `db_KK_T_SVC_KEI.close();` | Releases the service contract DB handle |
| 6 | EXEC | `db_KK_T_KKOP_SVC_KEI.close();` | Releases the equipment option service contract DB handle |
| 7 | EXEC | `db_DK_T_HAISO_TG_BPIN.close();` | Releases the delivery target product DB handle |
| 8 | EXEC | `db_DK_T_HMPIN_KIKI.close();` | Releases the returned equipment DB handle |
| 9 | EXEC | `db_DK_T_HMPIN_KIKI_MOTO.close();` | Releases the original returned equipment DB handle |
| 10 | EXEC | `db_KK_T_SVKEI_KAISEN_UW.close();` | Releases the service contract line detail DB handle |
| 11 | EXEC | `db_KK_T_ODR_SET.close();` | Releases the order settings DB handle |
| 12 | EXEC | `db_KK_T_SVC_KEI_UCWK.close();` | Releases the service contract detail DB handle |
| 13 | EXEC | `db_KK_T_ODR_HAKKO_JOKEN.close();` | Releases the order issuance criteria DB handle |
| 14 | EXEC | `db_KK_T_ODR_INF_SKSI_WK.close();` | Releases the order info creation work DB handle |
| 15 | EXEC | `db_KK_T_PRG.close();` | Releases the job progress tracking DB handle |
| 16 | COMMENT | `// ANK-4656-00-00 ADD START` | Version tag for the ANK-4656-00-00 change addition |
| 17 | EXEC | `db_KU_T_KJAK_TG_TKKIKI.close();` | Releases the work case target indoor equipment DB handle [ANK-4656-00-00] |
| 18 | COMMENT | `// ANK-4656-00-00 ADD END` | End of version-tagged addition |
| 19 | COMMENT | `/** end of auto-generated terminal processing source */` | Marks the end of framework-generated terminal processing section |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `terminal()` | Method | Business service termination processing — the lifecycle cleanup hook called after batch processing completes |
| `JBSbatBusinessService` | Class | Abstract base class for batch business services — defines the `terminal()` lifecycle method |
| `JBSbatSQLAccess` | Class | Database SQL access control class — manages database connections, statements, and result sets for a specific table |
| `ZM_M_WORK_PARAM_KNRI` | Table | Work parameter management table — stores batch job configuration and runtime parameters |
| `KK_T_KKTK_SVC_KEI` | Table | Equipment provision service contract table — stores service contracts associated with equipment provisioning |
| `KK_T_KKTK_SVC_KEI_SAKI` | Table | Equipment provision service contract (after modification) table — stores the post-modification state of equipment provision service contracts |
| `KK_T_SVC_KEI` | Table | Service contract table — stores core service contract records |
| `KK_T_KKOP_SVC_KEI` | Table | Equipment option service contract table — stores service contracts for optional equipment add-ons |
| `DK_T_HAISO_TG_BPIN` | Table | Delivery target product table — stores products targeted for delivery to customers |
| `DK_T_HMPIN_KIKI` | Table | Returned equipment table — stores information about equipment returned by customers |
| `DK_T_HMPIN_KIKI_MOTO` | Table | Returned equipment (original) table — stores the original state of returned equipment before modification |
| `KK_T_SVKEI_KAISEN_UW` | Table | Service contract line detail table — stores detailed information for each line item within a service contract |
| `KK_T_ODR_SET` | Table | Order settings table — stores order configuration and settings |
| `KK_T_SVC_KEI_UCWK` | Table | Service contract detail table — stores detailed records of service contracts |
| `KK_T_ODR_HAKKO_JOKEN` | Table | Order issuance criteria table — stores the criteria/conditions under which orders are issued |
| `KK_T_ODR_INF_SKSI_WK` | Table | Order info creation work table — temporary/work table used during order information creation processing |
| `KK_T_PRG` | Table | Progress tracking table — stores batch job progress and execution status |
| `KU_T_KJAK_TG_TKKIKI` | Table | Work case target indoor equipment table — stores indoor equipment associated with work cases (added in v74.00.00 / ANK-4656-00-00) |
| ANK-4577-00-00 | Change ticket | Feature: "eo Light Net Single Plane Addition Support (Step2)" — initial implementation of the equipment succession batch |
| ANK-4656-00-00 | Change ticket | Feature: "eo Light Single Plane Provision (STEP3)" — added indoor equipment work case support |
| シンプルプラン (Simple Plan) | Business term | "Single Plane" / "Simple Plan" — a streamlined internet service plan offered by eo Light |
| 機器引継 (Kiki Hikitsugi) | Business term | Equipment succession — the process of transferring equipment records from old service contracts to new ones after a service plan change |
| ネット↔シンプル (Net to Simple) | Business term | Net-to-Simple-plane migration — the process of converting customers from standard net plans to the streamlined Simple Plan |
| 業務パラメータ (Gyoumu Parameter) | Business term | Work/Business parameter — batch job configuration parameters that control processing behavior |
| 作業案件 (Sagyou Anken) | Business term | Work case — a work order or job record in the system that tracks service delivery tasks |
| 宅内機器 (Takunai Kiki) | Business term | Indoor equipment — customer-premises equipment (CPE) installed inside the customer's premises |
