# Business Logic — JBSbatKKSyuKeiJudgeTran.executeKK_T_PRG_PKINSERT() [41 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKSyuKeiJudgeTran` |
| Layer | Batch Service (Package: `eo.business.service`, source dir: `koptBatch`) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKSyuKeiJudgeTran.executeKK_T_PRG_PKINSERT()

This method performs a **primary-key-based insert** into the `KK_T_PRG` progress tracking table, which stores advancement/progress records for billing contract judgment workflows. It acts as a **data mapper + delegate**: it receives 33 raw field values packed into a single `Object[]` array parameter, transforms them into a structured map via `JBSbatCommonDBInterface`, and delegates the actual database insertion to `db_KK_T_PRG.insertByPrimaryKeys()`. The method implements the **command pattern** for a single table insert — the caller supplies all fields (including audit fields like timestamps, operator accounts, and delete flags) in a predefined index order, and the method serially maps each index to its corresponding column name before issuing the insert. Its role in the larger system is a **low-level persistence helper** called from `addPrg()` within the same class, which is invoked when a new progress record must be created in the batch judgment processing flow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeKK_T_PRG_PKINSERT(params)"])
    MAP_CREATE["Create JBSbatCommonDBInterface setMap"]
    STEP1["setValue P-R-G-NO param-0"]
    STEP2["setValue MSKM-DTL-NO param-1"]
    STEP3["setValue SEIKY-KEI-NO param-2"]
    STEP4["setValue SEIKY-WAY-KOZA param-3"]
    STEP5["setValue SEIKY-WAY-CRECARD param-4"]
    STEP6["setValue SVC-KEI-NO param-5"]
    STEP7["setValue SVC-KEI-UCWK-NO param-6"]
    STEP8["setValue SVC-KEI-KAISEN-UCWK-NO param-7"]
    STEP9["setValue KKTK-SVC-KEI-NO param-8"]
    STEP10["setValue OP-SVC-KEI-NO param-9"]
    STEP11["setValue SEIOPSVC-KEI-NO param-10"]
    STEP12["setValue SBOP-SVC-KEI-NO param-11"]
    STEP13["setValue WRIB-SVC-KEI-NO param-12"]
    STEP14["setValue IDO-DIV param-13"]
    STEP15["setValue IDO-DTM param-14"]
    STEP16["setValue PRG-STAT param-15"]
    STEP17["setValue PRG-DTM param-16"]
    STEP18["setValue PRG-MEMO param-17"]
    STEP19["setValue PRG-TKJK-1 param-18"]
    STEP20["setValue PRG-TKJK-2 param-19"]
    STEP21["setValue ADD-DTM param-20"]
    STEP22["setValue ADD-OPEACNT param-21"]
    STEP23["setValue UPD-DTM param-22"]
    STEP24["setValue UPD-OPEACNT param-23"]
    STEP25["setValue DEL-DTM param-24"]
    STEP26["setValue DEL-OPEACNT param-25"]
    STEP27["setValue MK-FLG param-26"]
    STEP28["setValue ADD-UNYO-YMD param-27"]
    STEP29["setValue ADD-TRN-ID param-28"]
    STEP30["setValue UPD-UNYO-YMD param-29"]
    STEP31["setValue UPD-TRN-ID param-30"]
    STEP32["setValue DEL-UNYO-YMD param-31"]
    STEP33["setValue DEL-TRN-ID param-32"]
    DB_INSERT["db_KK-T-PRG insertByPrimaryKeys"]
    END_NODE(["Return / Next"])
    START --> MAP_CREATE
    MAP_CREATE --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> STEP6
    STEP6 --> STEP7
    STEP7 --> STEP8
    STEP8 --> STEP9
    STEP9 --> STEP10
    STEP10 --> STEP11
    STEP11 --> STEP12
    STEP12 --> STEP13
    STEP13 --> STEP14
    STEP14 --> STEP15
    STEP15 --> STEP16
    STEP16 --> STEP17
    STEP17 --> STEP18
    STEP18 --> STEP19
    STEP19 --> STEP20
    STEP20 --> STEP21
    STEP21 --> STEP22
    STEP22 --> STEP23
    STEP23 --> STEP24
    STEP24 --> STEP25
    STEP25 --> STEP26
    STEP26 --> STEP27
    STEP27 --> STEP28
    STEP28 --> STEP29
    STEP29 --> STEP30
    STEP30 --> STEP31
    STEP31 --> STEP32
    STEP32 --> STEP33
    STEP33 --> DB_INSERT
    DB_INSERT --> END_NODE
```

The method follows a **straight-line sequential flow** with no conditional branches:
1. **Map Creation**: Instantiates `JBSbatCommonDBInterface` as a key-value map structure.
2. **Parameter Mapping (33 steps)**: Iteratively calls `setValue(columnName, value)` for each of the 33 indexed parameters (indices 0 through 32), binding each array element to its corresponding database column key.
3. **DB Insert**: Delegates to `db_KK_T_PRG.insertByPrimaryKeys(setMap)` to perform the actual primary-key-based INSERT into the `KK_T_PRG` table.
4. **Return**: The method is `void`, so it simply returns to the caller.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `setParam` | `Object[]` | An ordered array of 33 field values representing all columns of a `KK_T_PRG` progress record. Index 0 maps to `PRG_NO` (progress number), index 1 to `MSKM_DTL_NO` (application detail number), index 2 to `SEIKY_KEI_NO` (billing contract number), and so on through index 32 (`DEL_TRN_ID`). The caller is responsible for ensuring the array has at least 33 elements in the correct order. Values may be `String`, `Integer`, `Date`, or other types depending on the column. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_KK_T_PRG` | `JBSbatSQLAccess` | Database access instance wired to the `KK_T_PRG` table (initialized via `D_TBL_NAME_KK_T_PRG` constant). Used to perform the primary-key-based insert. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `JBSbatSQLAccess.insertByPrimaryKeys` | - | `KK_T_PRG` | Performs a primary-key-based INSERT of the progress record into the `KK_T_PRG` table. This is the terminal database operation of this method. |
| U | `JBSbatCommonDBInterface.setValue` | - | - | Sets a key-value pair in the intermediate map structure (33 calls, one per column). |

**CRUD Summary:**
- **Create (C):** 1 — `insertByPrimaryKeys` on `KK_T_PRG`
- **Read (R):** 0
- **Update (U):** 1 — 33x `setValue` calls on the intermediate map object
- **Delete (D):** 0

## 5. Dependency Trace

### Caller Relationship

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JBSbatKKSyuKeiJudgeTran.addPrg()` | `addPrg()` → `executeKK_T_PRG_PKINSERT(setParam)` | `insertByPrimaryKeys [C] KK_T_PRG` |

**Details:**
- The sole direct caller is `JBSbatKKSyuKeiJudgeTran.addPrg()`, which is a method in the **same class**. This indicates the method is a **private helper** used during batch progress record creation in the billing contract judgment workflow.
- No screen entry points (e.g., `KKSV*`) or batch entry points were found within 8 hops. The call originates from within the same batch service class.
- Terminal operation: `insertByPrimaryKeys` on the `KK_T_PRG` table with a **[C]** (Create) operation type.

## 6. Per-Branch Detail Blocks

This method has **no conditional branches** (no if/else, no switch, no loops). The entire method is a single sequential block:

**Block 1** — [SEQUENTIAL] `(straight-line execution)` (L1052)

> **Business Description:** Creates a key-value map from the 33-element parameter array and maps each index to its corresponding column name. This block transforms the caller's indexed parameter array into a structured map that `JBSbatCommonDBInterface` uses as the row data for the subsequent insert.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface setMap = new JBSbatCommonDBInterface();` // Create map (L1053) |
| 2 | EXEC | `setMap.setValue("PRG_NO", setParam[0]);` // Set progress number (L1054) |
| 3 | EXEC | `setMap.setValue("MSKM_DTL_NO", setParam[1]);` // Set application detail number (L1055) |
| 4 | EXEC | `setMap.setValue("SEIKY_KEI_NO", setParam[2]);` // Set billing contract number (L1056) |
| 5 | EXEC | `setMap.setValue("SEIKY_WAY_NO_KOZA", setParam[3]);` // Set billing method number (bank account) (L1057) |
| 6 | EXEC | `setMap.setValue("SEIKY_WAY_NO_CRECARD", setParam[4]);` // Set billing method number (credit card) (L1058) |
| 7 | EXEC | `setMap.setValue("SVC_KEI_NO", setParam[5]);` // Set service contract number (L1059) |
| 8 | EXEC | `setMap.setValue("SVC_KEI_UCWK_NO", setParam[6]);` // Set service contract breakdown number (L1060) |
| 9 | EXEC | `setMap.setValue("SVC_KEI_KAISEN_UCWK_NO", setParam[7]);` // Set service contract line breakdown number (L1061) |
| 10 | EXEC | `setMap.setValue("KKTK_SVC_KEI_NO", setParam[8]);` // Set equipment provision service contract number (L1062) |
| 11 | EXEC | `setMap.setValue("OP_SVC_KEI_NO", setParam[9]);` // Set option service contract number (L1063) |
| 12 | EXEC | `setMap.setValue("SEIOPSVC_KEI_NO", setParam[10]);` // Set billing option service contract number (L1064) |
| 13 | EXEC | `setMap.setValue("SBOP_SVC_KEI_NO", setParam[11]);` // Set sub-option service contract number (L1065) |
| 14 | EXEC | `setMap.setValue("WRIB_SVC_KEI_NO", setParam[12]);` // Set discount service contract number (L1066) |
| 15 | EXEC | `setMap.setValue("IDO_DIV", setParam[13]);` // Set movement classification (L1067) |
| 16 | EXEC | `setMap.setValue("IDO_DTM", setParam[14]);` // Set movement timestamp (L1068) |
| 17 | EXEC | `setMap.setValue("PRG_STAT", setParam[15]);` // Set progress status (L1069) |
| 18 | EXEC | `setMap.setValue("PRG_DTM", setParam[16]);` // Set progress timestamp (L1070) |
| 19 | EXEC | `setMap.setValue("PRG_MEMO", setParam[17]);` // Set progress memo (L1071) |
| 20 | EXEC | `setMap.setValue("PRG_TKJK_1", setParam[18]);` // Set progress special item 1 (L1072) |
| 21 | EXEC | `setMap.setValue("PRG_TKJK_2", setParam[19]);` // Set progress special item 2 (L1073) |
| 22 | EXEC | `setMap.setValue("ADD_DTM", setParam[20]);` // Set registration timestamp (L1074) |
| 23 | EXEC | `setMap.setValue("ADD_OPEACNT", setParam[21]);` // Set registering operator account (L1075) |
| 24 | EXEC | `setMap.setValue("UPD_DTM", setParam[22]);` // Set update timestamp (L1076) |
| 25 | EXEC | `setMap.setValue("UPD_OPEACNT", setParam[23]);` // Set updating operator account (L1077) |
| 26 | EXEC | `setMap.setValue("DEL_DTM", setParam[24]);` // Set deletion timestamp (L1078) |
| 27 | EXEC | `setMap.setValue("DEL_OPEACNT", setParam[25]);` // Set deleting operator account (L1079) |
| 28 | EXEC | `setMap.setValue("MK_FLG", setParam[26]);` // Set invalid flag (L1080) |
| 29 | EXEC | `setMap.setValue("ADD_UNYO_YMD", setParam[27]);` // Set registered operation date (L1081) |
| 30 | EXEC | `setMap.setValue("ADD_TRN_ID", setParam[28]);` // Set registered process ID (L1082) |
| 31 | EXEC | `setMap.setValue("UPD_UNYO_YMD", setParam[29]);` // Set updated operation date (L1083) |
| 32 | EXEC | `setMap.setValue("UPD_TRN_ID", setParam[30]);` // Set updated process ID (L1084) |
| 33 | EXEC | `setMap.setValue("DEL_UNYO_YMD", setParam[31]);` // Set deleted operation date (L1085) |
| 34 | EXEC | `setMap.setValue("DEL_TRN_ID", setParam[32]);` // Set deleted process ID (L1086) |

**Block 2** — [SEQUENTIAL] `(database insert)` (L1089)

> **Business Description:** Executes the primary-key-based insert into the `KK_T_PRG` table. This is the terminal database operation. The method uses `insertByPrimaryKeys()` which means all primary key columns must be present and the record must not already exist. This corresponds to the "full item registration" (全項目登録) PK insert described in the Javadoc.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_KK_T_PRG.insertByPrimaryKeys(setMap);` // Execute DB access for primary-key insert [-> D_TBL_NAME_KK_T_PRG] (L1089) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_PRG` | Table | Progress table — stores advancement/progress records for billing contract judgment batch processing |
| `PRG_NO` | Field | Progress number — unique identifier for a progress record in the batch judgment workflow |
| `MSKM_DTL_NO` | Field | Application detail number — identifies the specific line item within a billing application |
| `SEIKY_KEI_NO` | Field | Billing contract number — the contract identifier associated with the billing request |
| `SEIKY_WAY_NO_KOZA` | Field | Billing method number (bank account) — payment method code when billed via bank transfer (口座 = account/bank) |
| `SEIKY_WAY_NO_CRECARD` | Field | Billing method number (credit card) — payment method code when billed via credit card (クレジットカード) |
| `SVC_KEI_NO` | Field | Service contract number — identifies the overall service contract |
| `SVC_KEI_UCWK_NO` | Field | Service contract breakdown number — internal tracking ID for service contract line items (内訳 = breakdown/details) |
| `SVC_KEI_KAISEN_UCWK_NO` | Field | Service contract line breakdown number — identifies the specific line within a service contract breakdown (回線 = line) |
| `KKTK_SVC_KEI_NO` | Field | Equipment provision service contract number — contract for services where equipment is provided (機器提供 = equipment provision) |
| `OP_SVC_KEI_NO` | Field | Option service contract number — contract for optional/add-on services (オプション) |
| `SEIOPSVC_KEI_NO` | Field | Billing option service contract number — option service contract that is billed (請求 = billing) |
| `SBOP_SVC_KEI_NO` | Field | Sub-option service contract number — sub-tier optional service contract (サブオプション) |
| `WRIB_SVC_KEI_NO` | Field | Discount service contract number — contract for discount/price reduction services (割引 = discount) |
| `IDO_DIV` | Field | Movement classification — indicates the type of record movement (e.g., add, update, delete) (異動 = movement/change) |
| `IDO_DTM` | Field | Movement timestamp — date and time of the record movement |
| `PRG_STAT` | Field | Progress status — current state of the progress record in the workflow |
| `PRG_DTM` | Field | Progress timestamp — date and time when the progress record was last updated |
| `PRG_MEMO` | Field | Progress memo — free-text memo attached to the progress record |
| `PRG_TKJK_1` | Field | Progress special item 1 — additional special note field 1 (特記事項 = special matters/notes) |
| `PRG_TKJK_2` | Field | Progress special item 2 — additional special note field 2 |
| `ADD_DTM` | Field | Registration timestamp — date and time when the record was created (登録 = registration) |
| `ADD_OPEACNT` | Field | Registering operator account — the operator account that created this record (運用 = operations) |
| `UPD_DTM` | Field | Update timestamp — date and time when the record was last modified (更新 = update) |
| `UPD_OPEACNT` | Field | Updating operator account — the operator account that last modified this record |
| `DEL_DTM` | Field | Deletion timestamp — date and time when the record was soft-deleted (削除 = deletion) |
| `DEL_OPEACNT` | Field | Deleting operator account — the operator account that performed the deletion |
| `MK_FLG` | Field | Invalid flag — indicates whether the record is marked as invalid/deleted (無効 = invalid) |
| `ADD_UNYO_YMD` | Field | Registered operation date — the date (year/month/day) the record was registered (運用年月日 = operations date) |
| `ADD_TRN_ID` | Field | Registered process ID — the process ID that performed the registration (処理ID = process ID) |
| `UPD_UNYO_YMD` | Field | Updated operation date — the date the record was last updated |
| `UPD_TRN_ID` | Field | Updated process ID — the process ID that performed the update |
| `DEL_UNYO_YMD` | Field | Deleted operation date — the date the record was deleted |
| `DEL_TRN_ID` | Field | Deleted process ID — the process ID that performed the deletion |
| `JBSbatCommonDBInterface` | Class | Common database interface — a map-like structure used to pass key-value pairs to batch DB access methods |
| `JBSbatSQLAccess` | Class | SQL access base class — provides `insertByPrimaryKeys()` and other DB operations for batch processing |
| `insertByPrimaryKeys` | Method | Insert using primary key — performs an INSERT into the target table using the primary key columns from the provided map |
| `setParam` | Parameter | Parameter array — the caller-supplied array of 33 values, one for each column of `KK_T_PRG` |
| `addPrg()` | Method | Add progress — the calling method in the same class that creates a new progress record |
