# Business Logic — JBSbatTUBmpKojiFinTrn.executeKK_T_ICJKN_SETTE_PKUPDATE() [13 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatTUBmpKojiFinTrn` |
| Layer | Batch (Service — batch processing logic within the `eo.business.service` package) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatTUBmpKojiFinTrn.executeKK_T_ICJKN_SETTE_PKUPDATE()

This method performs a **primary-key-based update** on the `KK_T_ICJKN_SETTE` database table, which stores records for **temporary fund setup** (一時金設定 — *ichi-kin settei*). Specifically, it updates the **completion status code** (`FIN_STAT_CD`) of a single row identified by its primary key `ICJKN_SETTE_NO`. The method is a **private batch utility** that encapsulates the pattern of constructing a set-parameter map, a where-parameter map (containing the PK), and delegating the actual SQL UPDATE to the `db_KK_T_ICJKN_SETTE` SQL access layer.

Its role in the larger system is to serve as the atomic update primitive called during batch processing for **batch job finalization** (BMP works — 番ポ工事). When the batch process determines that a temporary fund setup record has been fully processed, it invokes this method to mark the record as completed (`FIN_STAT_CD = "1"`). Conversely, if a record should be excluded from processing, it is marked as "not targeted" (`FIN_STAT_CD = "2"`). The method follows a **delegation pattern** — it does not contain any business logic beyond parameter mapping and forwarding to the SQL access layer, acting as a thin, reusable wrapper for PK-based row updates across multiple batch callers.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeKK_T_ICJKN_SETTE_PKUPDATE(params)"])
    STEP1["Create JBSbatCommonDBInterface for setMap"]
    STEP2["setMap setValue with FIN_STAT_CD from setParam[0]"]
    STEP3["Create JBSbatCommonDBInterface for whereMap"]
    STEP4["whereMap setValue with ICJKN_SETTE_NO from whereParam[0]"]
    STEP5["db_KK_T_ICJKN_SETTE updateByPrimaryKeys"]
    END_NODE(["Return"])

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

**Step-by-step processing:**

1. **Set parameter map creation (L472):** A new `JBSbatCommonDBInterface` object is instantiated to serve as the `setMap`. This map will carry the field-value pairs to be updated in the database.

2. **Set completion status (L473):** The `setValue` method stores the completion status code (`FIN_STAT_CD`) extracted from the first element of the `setParam` array. The value is typically `"1"` (completed) or `"0"` (not yet completed), with `"2"` indicating the record is not a target.

3. **Where parameter map creation (L476):** A second `JBSbatCommonDBInterface` object is instantiated as the `whereMap`. This map carries the primary key condition for the UPDATE statement.

4. **Set primary key condition (L477):** The `setValue` method stores the `ICJKN_SETTE_NO` (temporary fund setup number) extracted from the first element of the `whereParam` array. This serves as the WHERE clause filter to identify the exact row to update.

5. **Execute PK-based update (L480):** The `db_KK_T_ICJKN_SETTE.updateByPrimaryKeys` method performs the actual SQL `UPDATE` operation against the `KK_T_ICJKN_SETTE` table. The `whereMap` identifies the target row by its primary key, and the `setMap` provides the column values to be updated.

6. **Return (L480):** The method is `void` and returns immediately after the database operation completes. Any exceptions are propagated to the caller.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `setParam` | `Object[]` | Array of field-value pairs to be updated. The first element (`setParam[0]`) is the **completion status code** (`FIN_STAT_CD`) for the temporary fund setup record. Valid values are `"1"` (completed / 確定), `"0"` (not completed / 未確定), or `"2"` (not targeted / 対象外). This code determines the lifecycle state of the temporary fund setup in the batch processing workflow. |
| 2 | `whereParam` | `Object[]` | Array containing the **primary key** used to identify the target row. The first element (`whereParam[0]`) is the `ICJKN_SETTE_NO` (temporary fund setup number) — a unique identifier for a specific temporary fund setup record in the `KK_T_ICJKN_SETTE` table. This serves as the WHERE clause condition for the UPDATE operation. |

**Instance fields / external state read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_KK_T_ICJKN_SETTE` | `JBSbatSQLAccess` | SQL access layer instance connected to the `KK_T_ICJKN_SETTE` database table. Provides the `updateByPrimaryKeys` method used to perform the actual row update. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JDKStructuredMap.setValue` | - | - | Sets the `FIN_STAT_CD` field-value pair in the set parameter map |
| U | `JDKStructuredMap.setValue` | - | - | Sets the `ICJKN_SETTE_NO` primary key in the where parameter map |
| U | `db_KK_T_ICJKN_SETTE.updateByPrimaryKeys` | - | `KK_T_ICJKN_SETTE` | Executes the primary-key-based UPDATE on the temporary fund setup table |

**Analysis of called services and their CRUD classification:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `updateByPrimaryKeys` | (framework) | `KK_T_ICJKN_SETTE` | Updates the `FIN_STAT_CD` field of the row identified by `ICJKN_SETTE_NO` primary key in the temporary fund setup table. This is the core business-critical update that marks the lifecycle state of a temporary fund setup record. |

**Classification rationale:**
- The method uses `updateByPrimaryKeys`, which maps to an `UPDATE` SQL statement targeting `KK_T_ICJKN_SETTE`.
- Only one column (`FIN_STAT_CD`) is updated per call, filtered by the primary key (`ICJKN_SETTE_NO`).
- No reads, creates, or deletes occur within this method.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatTUBmpKojiFinTrn.insertBmpKoji` | `insertBmpKoji` → `executeKK_T_ICJKN_SETTE_PKUPDATE` | `updateByPrimaryKeys [U] KK_T_ICJKN_SETTE` |
| 2 | Batch: `JBSbatKKAddKicjknInfo` | Batch processing logic → `executeKK_T_ICJKN_SETTE_PKUPDATE` | `updateByPrimaryKeys [U] KK_T_ICJKN_SETTE` |
| 3 | Batch: `JBSbatKKCrsChgOldKeiIfAdd` | Batch processing logic → `executeKK_T_ICJKN_SETTE_PKUPDATE` | `updateByPrimaryKeys [U] KK_T_ICJKN_SETTE` |
| 4 | Batch: `JBSbatKKKicjknAdd` | Batch processing logic → `executeKK_T_ICJKN_SETTE_PKUPDATE` | `updateByPrimaryKeys [U] KK_T_ICJKN_SETTE` |

**Notes on caller context:**
- **Caller #1** (`insertBmpKoji` in the same class) iterates over records from `KK_T_ICJKN_SETTE` fetched via `selectNext()`. For each record with a temporary fund setup code of `"02"` (存在 — *sonzai*, meaning "present/active"), it sets `FIN_STAT_CD = "1"` (completed) and calls this method to mark the record as finalized by the batch process.
- **Callers #2-#4** are duplicate method definitions in other batch classes (`JBSbatKKAddKicjknInfo`, `JBSbatKKCrsChgOldKeiIfAdd`, `JBSbatKKKicjknAdd`), each using the same method signature to update `FIN_STAT_CD` in the same table. This indicates code duplication rather than shared inheritance — each batch class has its own private copy of this method.

## 6. Per-Branch Detail Blocks

This method contains **no conditional branches** (no if/else, switch, loops, or try-catch). It is a linear sequence of 5 processing steps. Below is the block-by-block analysis of the linear flow.

---

**Block 1** — [SET] `(L472)`

> Create the set parameter map to hold field-value pairs for the UPDATE operation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface setMap = new JBSbatCommonDBInterface()` // Instantiate new map for SET parameters |

---

**Block 2** — [SET] `(L473)`

> Store the completion status code (`FIN_STAT_CD`) from the first element of `setParam` into the set map.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `setMap.setValue("FIN_STAT_CD", setParam[0])` // Set the completion status field-value pair. `setParam[0]` is resolved from the caller: typically `FIN_STAT_CD_FIN = "1"` (completed / 確定) or `FIN_STAT_NOT_TRGT = "2"` (not targeted / 対象外) |

---

**Block 3** — [SET] `(L476)`

> Create the where parameter map to hold the primary key condition for the UPDATE statement.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface whereMap = new JBSbatCommonDBInterface()` // Instantiate new map for WHERE parameters (PK condition) |

---

**Block 4** — [SET] `(L477)`

> Store the primary key (`ICJKN_SETTE_NO`) from the first element of `whereParam` into the where map.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `whereMap.setValue("ICJKN_SETTE_NO", whereParam[0])` // Set the primary key field-value pair. `whereParam[0]` is the temporary fund setup number, e.g., fetched from `mapIchjknSette.getString(JBSbatKK_T_ICJKN_SETTE.ICJKN_SETTE_NO)` |

---

**Block 5** — [CALL] `(L480)`

> Execute the primary-key-based UPDATE on the `KK_T_ICJKN_SETTE` table. The `whereMap` identifies the row by `ICJKN_SETTE_NO`, and `setMap` provides the `FIN_STAT_CD` value to update.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_KK_T_ICJKN_SETTE.updateByPrimaryKeys(whereMap, setMap)` // Perform the actual database UPDATE. Target table: `KK_T_ICJKN_SETTE`. Updated column: `FIN_STAT_CD`. Filter condition: `ICJKN_SETTE_NO` (primary key) |

---

**Block 6** — [RETURN] `(L480)`

> The method is `void` and returns immediately after the database operation. Any `Exception` thrown by `updateByPrimaryKeys` propagates to the caller (declared as `throws Exception` in the signature).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | (void) // Returns to caller. No further processing within this method. |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ICJKN_SETTE_NO` | Field | Temporary Fund Setup Number — unique identifier for a temporary fund setup record in the `KK_T_ICJKN_SETTE` table. Used as the primary key for row identification. |
| `FIN_STAT_CD` | Field | Completion Status Code — indicates the processing state of a temporary fund setup record in batch workflows. Values: `"0"` (not completed / 未確定), `"1"` (completed / 確定), `"2"` (not targeted / 対象外). |
| KK_T_ICJKN_SETTE | Table | Temporary Fund Setup Table — the database table storing temporary fund setup (一時金設定) records. Temporary funds are financial adjustments or one-time payments associated with service contracts. |
| 一時金 (Ichi-kin) | Business term | Temporary Fund / Lump-sum payment — a one-time financial adjustment or payment made in addition to regular billing, used in telecom service contracts for credits, rebates, or promotional adjustments. |
| 一時金設定 (Ichi-kin Settei) | Business term | Temporary Fund Setup — the configuration or record of a temporary fund arrangement for a service contract, including the setup number, status, and associated parameters. |
| 番ポ (Bampo) | Business term | Banpo — abbreviation for "ban-gou kouji" (番号工事), referring to contract/line-based installation or work orders in the telecom operations system. |
| BMP | Acronym | Batch Main Processing — the batch processing framework in which this method operates. `JBSbatTUBmpKojiFinTrn` handles batch job finalization for banpo (contract) work. |
| 確定 (Kakutei) | Business term | Completed / Confirmed — the final state of a temporary fund setup record after batch processing has finalized it. Corresponds to `FIN_STAT_CD = "1"`. |
| 未確定 (Mikakutei) | Business term | Not yet completed — the initial state of a temporary fund setup record before batch processing. Corresponds to `FIN_STAT_CD = "0"`. |
| 対象外 (Taishougai) | Business term | Not targeted / excluded — indicates the record should not be processed. Corresponds to `FIN_STAT_CD = "2"`. |
| JBSbatCommonDBInterface | Class | Common database interface for constructing key-value parameter maps used in batch SQL operations. Extends `JDKStructuredMap` for map-like operations. |
| JBSbatSQLAccess | Class | Database access layer class providing `updateByPrimaryKeys`, `selectNext`, `selectBySqlDefine`, and other SQL operation methods for batch processing. |
| `updateByPrimaryKeys` | Method | Framework method that generates and executes an UPDATE SQL statement using the primary key fields from the where-map and the column values from the set-map. |
| whereParam | Parameter | Where-parameter array carrying the primary key for identifying the target row in the UPDATE operation. |
| setParam | Parameter | Set-parameter array carrying the field-value pairs to be updated in the target row. |
| `JBSbatKK_T_ICJKN_SETTE` | Constant class | Contains field name constants (e.g., `ICJKN_SETTE_NO`, `TMP_PAY_PRC_NO`) for the `KK_T_ICJKN_SETTE` table columns. |
