# Business Logic — JBSbatKKAdChgTekkyoKjFinUpd.executeKK_T_IDO_RSV_KK_PKUPDATE() [24 LOC]

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

## 1. Role

### JBSbatKKAdChgTekkyoKjFinUpd.executeKK_T_IDO_RSV_KK_PKUPDATE()

This method performs a **primary-key-based update** (PK Update) on the `KK_T_IDO_RSV` (Temporary Advance Reservation) table within the K-Opticom customer core system, which manages telecommunications service contracts and billing operations. Specifically, it records the completion of a work order related to address change cancellation tasks — it updates the application date, update timestamp, operator account, operation date, transaction ID, and optionally the service charge end date for a given reservation record. The method acts as a **data persistence delegate** following the batch service pattern: it receives raw parameter arrays from the calling `execute()` method, assembles them into structured database interface maps, conditionally computes derived values (the service charge end year/month/day by subtracting one day from the application date), and delegates the actual SQL UPDATE to the `db_KK_T_IDO_RSV` SQL access layer using the primary key `IDO_RSV_NO` as the where condition. This method implements the **delegation pattern** — it does not contain business rules or validation logic itself; instead, it transforms flat parameter arrays into typed database operation payloads and routes them to the persistence layer. Its role in the larger system is to finalize a cancellation work order record by committing audit fields and derived charge-end dates back to the reservation table, completing the address change cancellation workflow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START["executeKK_T_IDO_RSV_KK_PKUPDATE"]
    START --> STEP1["Create setMap"]
    STEP1 --> S0["setMap.setValue RSV_APLY_YMD setParam[0]"]
    S0 --> S1["setMap.setValue UPD_DTM setParam[1]"]
    S1 --> S2["setMap.setValue UPD_OPEACNT setParam[2]"]
    S2 --> S3["setMap.setValue UPD_UNYO_YMD setParam[3]"]
    S3 --> S4["setMap.setValue UPD_TRN_ID setParam[4]"]
    S4 --> COND1{"setParam[5] is null or empty?"}
    COND1 -->|no| S5["setMap.setValue SVC_CHRG_ENDYMD"]
    COND1 -->|yes| SKIP1["skip"]
    S5 --> STEP2["Create whereMap"]
    SKIP1 --> STEP2
    STEP2 --> W0["whereMap.setValue IDO_RSV_NO whereParam[0]"]
    W0 --> STEP3["DB update"]
    STEP3 --> UPDATE["db_KK_T_IDO_RSV.updateByPrimaryKeys"]
    UPDATE --> END["Return"]
```

**Processing Description:**
1. A new `JBSbatCommonDBInterface` (setMap) is instantiated to hold the values to be updated.
2. Five fields are populated sequentially from `setParam[0]` through `setParam[4]`: application date, update datetime, operator account, operation date, and transaction ID.
3. A conditional check on `setParam[5]` — if it is **not null** and **not empty** — the service charge end date is computed by calling `JBSbatDateUtil.adjustDate(setParam[0], -1)` (application date minus 1 day) and stored as `SVC_CHRG_ENDYMD`. This optional field was added under change request OM-2016-0002358 to address service charge end date update gaps.
4. A second `JBSbatCommonDBInterface` (whereMap) is instantiated to hold the primary key condition.
5. `IDO_RSV_NO` is populated from `whereParam[0]` as the primary key lookup criterion.
6. The `updateByPrimaryKeys` method is called on the `db_KK_T_IDO_RSV` SQL access object, passing the where condition map and the set values map, which triggers the actual SQL UPDATE against the `KK_T_IDO_RSV` table.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `setParam` | `Object[]` | An array of 6 elements containing field values for the update: `[0]` = Reservation Application Date (RSV_APLY_YMD), `[1]` = Update Datetime (UPD_DTM), `[2]` = Update Operator Account (UPD_OPEACNT), `[3]` = Update Operation Date (UPD_UNYO_YMD), `[4]` = Update Transaction ID (UPD_TRN_ID), `[5]` = Service Charge End Year/Month/Day (SVC_CHRG_ENDYMD, optional) |
| 2 | `whereParam` | `Object[]` | An array containing the primary key condition: `[0]` = Advance Reservation Number (IDO_RSV_NO), used to identify which record to update in KK_T_IDO_RSV |

**Instance Fields Used:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_KK_T_IDO_RSV` | `JBSbatSQLAccess` | Database access object for the KK_T_IDO_RSV table, initialized during the service's `initProcess()` method |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `db_KK_T_IDO_RSV.updateByPrimaryKeys` | - | `KK_T_IDO_RSV` | Updates a reservation record identified by primary key `IDO_RSV_NO` with application date, update timestamp, operator account, operation date, transaction ID, and optionally service charge end date |
| - | `JBSbatCommonDBInterface.setValue` | JDKStructuredMap | - | Sets key-value pairs in the setMap/whereMap parameter objects (called 6 times) |
| - | `JBSbatDateUtil.adjustDate` | JBSbatDateUtil | - | Adjusts a date string by a given offset (-1 day) to compute the service charge end date |

**Classification Rationale:**
- `updateByPrimaryKeys` is classified as **U** (Update) — the method name and the Javadoc explicitly state "PK update for DB access."
- `setValue` calls are internal data structure operations (no direct CRUD on database).
- `adjustDate` is a utility date manipulation (no database interaction).

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `setValue` [-], `setValue` [-], `setValue` [-], `setValue` [-], `setValue` [-], `setValue` [-], `adjustDate` [-], `updateByPrimaryKeys` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKAdChgTekkyoKjFinUpd.execute | `JBSbatKKAdChgTekkyoKjFinUpd.execute()` -> `executeKK_T_IDO_RSV_KK_PKUPDATE` | `updateByPrimaryKeys [U] KK_T_IDO_RSV` |

**Notes:**
- This method is `private`, meaning it can only be called from within its own class.
- The sole direct caller is the `execute()` method of the same class (`JBSbatKKAdChgTekkyoKjFinUpd`), which serves as the batch entry point for address change cancellation work order completion.
- The terminal operation is a database UPDATE on `KK_T_IDO_RSV` via the `updateByPrimaryKeys` method.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET / Object Creation] (L513)

> Creates the parameter map that holds the values to be written to the database.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface setMap = new JBSbatCommonDBInterface()` // Creates a new key-value map for update fields |

**Block 1.1** — [SET / setValue chain] (L514–L518)

> Populates the five mandatory update fields from setParam array indices 0–4.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setMap.setValue("RSV_APLY_YMD", setParam[0])` // Reservation Application Date — the date the reservation was applied [setParam[0]] |
| 2 | SET | `setMap.setValue("UPD_DTM", setParam[1])` // Update Datetime — timestamp of when this update record was created [setParam[1]] |
| 3 | SET | `setMap.setValue("UPD_OPEACNT", setParam[2])` // Update Operator Account — the operator ID who performed the update [setParam[2]] |
| 4 | SET | `setMap.setValue("UPD_UNYO_YMD", setParam[3])` // Update Operation Date — the operational date associated with the update [setParam[3]] |
| 5 | SET | `setMap.setValue("UPD_TRN_ID", setParam[4])` // Update Transaction ID — the transaction identifier for audit tracking [setParam[4]] |

**Block 2** — [IF] `(setParam[5] != null && setParam[5] != "")` (L520–L524)

> Conditionally sets the service charge end date. This block was added under change request OM-2016-0002358 to resolve gaps in service charge end date updates for address change cancellation work orders. The service charge end date is computed as the application date minus one day.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setMap.setValue("SVC_CHRG_ENDYMD", JBSbatDateUtil.adjustDate((String) setParam[0], -1))` // Service Charge End Year/Month/Day — application date minus 1 day [setParam[0], adjusted by -1 day] |

**Block 2.1** — [ELSE-IF / implicit] (L520)

> When setParam[5] is null or empty, the service charge end date field is not populated, and the map is written to the database without it. No action is taken.

**Block 3** — [SET / Object Creation] (L527)

> Creates the WHERE condition map for the primary key lookup.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface whereMap = new JBSbatCommonDBInterface()` // Creates a new key-value map for the WHERE clause |

**Block 3.1** — [SET / setValue] (L528)

> Sets the primary key value used to identify the record to update.

| # | Type | Code |
|---|------|------|
| 1 | SET | `whereMap.setValue("IDO_RSV_NO", whereParam[0])` // Advance Reservation Number — the primary key identifying the reservation record in KK_T_IDO_RSV [whereParam[0]] |

**Block 4** — [CALL / DB Update] (L531)

> Executes the database UPDATE against the KK_T_IDO_RSV table using the primary key condition and the set of values to update.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_KK_T_IDO_RSV.updateByPrimaryKeys(whereMap, setMap)` // Executes SQL UPDATE on KK_T_IDO_RSV [U] Entity: KK_T_IDO_RSV |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_IDO_RSV` | Table | Temporary Advance Reservation table — stores records of services that are reserved to be transferred/delivered at a future date, typically for telecom service provisioning workflows |
| `KK_T_MSKM_DTL` | Table | Application Details table — stores detailed information about service application records |
| `RSV_APLY_YMD` | Field | Reservation Application Year/Month/Day — the date when a reservation was originally applied |
| `IDO_RSV_NO` | Field | Advance Reservation Number — unique identifier for a reservation record in KK_T_IDO_RSV, used as the primary key for updates |
| `UPD_DTM` | Field | Update Datetime — system timestamp recording when the record was last modified |
| `UPD_OPEACNT` | Field | Update Operator Account — the operator/login ID of the user or batch process that performed the update |
| `UPD_UNYO_YMD` | Field | Update Operation Year/Month/Day — the business date on which the update operation was performed |
| `UPD_TRN_ID` | Field | Update Transaction ID — the unique transaction identifier used for audit trail and rollback tracking |
| `SVC_CHRG_ENDYMD` | Field | Service Charge End Year/Month/Day — the date when service charges terminate; computed as the reservation application date minus 1 day in this method |
| `setParam` | Parameter | Array of field values to be set in the database — contains application date, update datetime, operator account, operation date, transaction ID, and optionally service charge end date |
| `whereParam` | Parameter | Array of primary key values used to identify the record to update — contains the advance reservation number |
| `JBSbatCommonDBInterface` | Class | Framework interface for building key-value maps used in database CRUD operations |
| `JBSbatSQLAccess` | Class | Framework class providing SQL access methods (selectBySqlDefine, updateByPrimaryKeys, etc.) for database operations |
| `JBSbatDateUtil.adjustDate` | Method | Utility method that adjusts a date string by adding or subtracting a specified number of days |
| KK_T_ | Table Prefix | "K-Opticom Temporary" table prefix — denotes temporary/work tables used in batch processing for intermediate data |
| 住所変更撤去工事完了登録 | Japanese Term | Address Change Cancellation Work Order Completion Registration — the business process this class implements |
| 異動予約 | Japanese Term | Advance Reservation / Transfer Reservation — a reservation held for services to be activated or transferred at a future date |
| OM-2016-0002358 | Change Request | A change request (added 2017/02/13) that introduced the service charge end date update logic to address gaps in charge end date propagation |