---

# Business Logic — JBSbatKKKktsvKkChgTtdkFin.execute() [14 LOC]

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

## 1. Role

### JBSbatKKKktsvKkChgTtdkFin.execute()

This method serves as the **entry point for the Equipment-Provided Service Contract Device Change Completion** batch processing item (機器提供サービス契約機器変更手続完了処理品目). It is responsible for orchestrating the finalization of a device change procedure for a service contract that was originally provided through equipment (e.g., router or ONT terminal supplied by the telecom provider).

The method follows a **delegation pattern**: it receives an input map containing the device change request data, delegates the core processing to the private `execKKSV0532()` method, and logs its start and completion via debug log calls. The `execKKSV0532()` method constructs a structured service invocation payload (including the service contract number, registration timestamp, reservation application date, and update timestamp), sends it to the external service component `KKSV053201SC` via the ESB (Enterprise Service Bus), and handles any error return codes by logging a business error.

This method is a **singleton batch processor** — it is not called by any screen or other service class (the caller search found no references). It is likely invoked by a batch scheduler or a top-level batch orchestrator as one of several parallel processing items within a larger batch job. The class name encodes its domain: `KK` (K-Opticom), `Kktsv` (Kikou Teigi Service — Equipment-Provided Service), `KkChg` (Kiki Henkou — Device Change), `Fin` (Finish — Completion Processing).

Although the method declares `throws Exception`, its own try-catch-free body relies on the called `execKKSV0532()` and `printDebugLog()` methods to handle or propagate exceptions. The method always returns `null`, suggesting the actual output is communicated through side effects on the service layer (the ESB invocation) rather than through the return value.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute(inMap)"])
    DEBUG_START["Print debug log: execute_START"]
    CALL_EXEC["execKKSV0532(inMap)"]
    OUT_MAP["outMap0532 = result"]
    DEBUG_END["Print debug log: execute_END"]
    RETURN_NULL["Return null"]

    START --> DEBUG_START
    DEBUG_START --> CALL_EXEC
    CALL_EXEC --> OUT_MAP
    OUT_MAP --> DEBUG_END
    DEBUG_END --> RETURN_NULL
```

The `execute()` method is a thin orchestration wrapper. It performs three sequential steps:

1. **Pre-processing log**: Prints a debug marker `"execute_START"` to signal the beginning of batch processing.
2. **Core delegation**: Calls `execKKSV0532(inMap)`, which performs the actual device change completion processing. The result is stored in `outMap0532` (note: the variable is assigned but never used in the `execute()` method).
3. **Post-processing log**: Prints `"execute_END"` to mark completion. Returns `null`.

The substantive business logic resides entirely in `execKKSV0532()`, which is documented below as the internal processing flow.

### Internal Flow — execKKSV0532 (called by execute)

```mermaid
flowchart TD
    START(["execKKSV0532(inMap)"])

    GET_KKTK["Get kktkSvcKeiNo from inMap"]
    GET_GENE["Get geneAddDtmStr from inMap"]
    GET_RSVYMD["Get rsvAplyYmdStr from inMap"]
    GET_LASTUPD["Get lastUpdDtmStr from inMap"]

    NEW_PARAM["Create paramMap0532"]
    SET_USECASE["Set TELEGRAM_INFO_USECASE_ID = KKSV0532"]
    NEW_INPUT["Create inputMap0532"]
    NEW_DATAMAP["Create dataMap0532"]

    PUT_KKTK["Put kktk_svc_kei_no to dataMap0532"]
    PUT_GENE["Put gene_add_dtm to dataMap0532"]
    PUT_RSVYMD["Put rsv_aply_ymd to dataMap0532"]
    PUT_RSVAPLY["Put rsv_aply_cd = 2 to dataMap0532"]
    PUT_LASTUPD["Put upd_dtm_bf to dataMap0532"]
    PUT_FUNC["Put func_code = 1 to dataMap0532"]

    SET_SCCODE["Set scTitleOpn = KKSV053201SC"]
    PUT_INPUT["Put dataMap0532 into inputMap0532 keyed by scTitleOpn"]

    NEW_OUTPUT["Create outputMapOpn532"]
    INVOKE_SVC["Invoke JCCBatchEsbInterface.invokeService"]

    GET_RETURN["Get RETURN_CODE from outputMapOpn532"]
    DEBUG_RETURN["Print debug log with RETURN_CODE"]

    CHECK_RETURN{RETURN_CODE equals 0000?}
    LOG_ERROR["Print business error log EKKB0010CW"]

    RETURN_OUT["Return outputMapOpn532"]

    START --> GET_KKTK
    GET_KKTK --> GET_GENE
    GET_GENE --> GET_RSVYMD
    GET_RSVYMD --> GET_LASTUPD
    GET_LASTUPD --> NEW_PARAM
    NEW_PARAM --> SET_USECASE
    SET_USECASE --> NEW_INPUT
    NEW_INPUT --> NEW_DATAMAP
    NEW_DATAMAP --> PUT_KKTK
    PUT_KKTK --> PUT_GENE
    PUT_GENE --> PUT_RSVYMD
    PUT_RSVYMD --> PUT_RSVAPLY
    PUT_RSVAPLY --> PUT_LASTUPD
    PUT_LASTUPD --> PUT_FUNC
    PUT_FUNC --> SET_SCCODE
    SET_SCCODE --> PUT_INPUT
    PUT_INPUT --> NEW_OUTPUT
    NEW_OUTPUT --> INVOKE_SVC
    INVOKE_SVC --> GET_RETURN
    GET_RETURN --> DEBUG_RETURN
    DEBUG_RETURN --> CHECK_RETURN
    CHECK_RETURN -->|No - Error| LOG_ERROR
    CHECK_RETURN -->|Yes - Success| RETURN_OUT
    LOG_ERROR --> RETURN_OUT
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input message carrying the device change completion data for an equipment-provided service contract. Contains keys such as the service contract number (`KKTK_SVC_KEI_NO`), the registration date/time stamp (`GENE_ADD_DTM`), the reservation application date (`RSV_APLY_YMD`), and the pre-update timestamp (`UPD_DTM_BF`). These fields collectively identify which service contract's device change is being finalized. |

### Instance Fields / External State Read

| Field | Type | Business Description |
|-------|------|---------------------|
| `super.logPrint` | Inherited from `JBSbatBusinessService` | Debug log utility for outputting processing markers and error messages |
| `super.commonItem` | `JBSbatCommonItem` | Shared common item passed to the ESB service invocation (contains framework-level metadata) |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `super.logPrint.printDebugLog` | JACBatCommon | - | Prints debug log markers (`execute_START`, `execute_END`, `*RETURN_CODE:`) via inherited debug logger |
| - | `JPCBatchMessageConstant.EKKB0010CW` | JPCBatchMessage | - | Error message constant key — `"EKKB0010CW"` used when a service interface error occurs |
| ESB | `JCCBatchEsbInterface.invokeService` | JCCBatchEsb | - | Invokes the external service `KKSV053201SC` via the Enterprise Service Bus with constructed input payload and receives output map |
| - | `execKKSV0532` | JBSbatKKKktsvKkChgTtdkFin | - | Internal method that builds and dispatches the service invocation payload for device change completion |

### Method Call Detail

The method delegates to `execKKSV0532()`, which in turn calls:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| ESB | `JCCBatchEsbInterface.invokeService` | KKSV053201SC | External Service (ESB) | Invokes service component `KKSV053201SC` through the ESB framework. This service component handles the actual device change completion logic, including any database updates to the service contract and device registration tables. The specific DB tables are not directly visible in this method — they are internal to the `KKSV053201SC` component resolved via the ESB routing. |

The SC Code pattern `KKSV053201SC` follows the convention: `KK` (K-Opticom), `SV` (Service), `0532` (screen/batch ID), `01` (sequence), `SC` (Service Component). This is an **external service invocation (ESB)**, meaning the actual data access logic is in a separate service component reachable via the Enterprise Service Bus.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch Orchestrator | BatchScheduler -> JBSbatKKKktsvKkChgTtdkFin.execute | `execKKSV0532 [ESB] KKSV053201SC` |

**Note:** No callers were found within the codebase for `JBSbatKKKktsvKkChgTtdkFin`. This method is expected to be invoked by an external batch scheduler or a higher-level batch orchestrator that dispatches processing items. The class name ending in `Fin` indicates it is a **finalization completion item**, typically one of many processing items in a larger batch workflow that handles equipment-provided service contract modifications.

## 6. Per-Branch Detail Blocks

### Block 1 — EXEC (Processing Wrapper) (L63)

> The `execute()` method is a thin wrapper. It logs start, delegates to the core method, logs end, and returns null.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `super.logPrint.printDebugLog("execute_START")` | Log the start of the device change completion processing [Print debug log: Processing start] |
| 2 | CALL | `HashMap<Object, Object> outMap0532 = this.execKKSV0532(inMap)` | Delegate to `execKKSV0532()` — builds and dispatches the service invocation for device change completion. Result stored in `outMap0532` (unused in execute) [Call internal processing method] |
| 3 | EXEC | `super.logPrint.printDebugLog("execute_END")` | Log the end of the device change completion processing [Print debug log: Processing end] |
| 4 | RETURN | `return null` | Return null — the actual output is communicated through the ESB invocation side effects, not via the return value |

### Block 2 — EXEC (Core Processing) Inside `execKKSV0532` (L100)

> This block constructs the service invocation payload for the device change completion, sends it to the ESB service component `KKSV053201SC`, and processes the return code.

#### Block 2.1 — EXEC (Extract Input Fields) (L106–L115)

> Extracts the four key input fields from `inMap` using constants defined in `JBSbatKKIFM163`.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `String kktkSvcKeiNoStr = inMap.getString(JBSbatKKIFM163.KKTK_SVC_KEI_NO)` | Extract the equipment-provided service contract number [-> KKTK_SVC_KEI_NO = "KKTK_SVC_KEI_NO"] |
| 2 | SET | `String geneAddDtmStr = inMap.getString(JBSbatKKIFM163.GENE_ADD_DTM)` | Extract the registration date/time stamp when the service contract was created [-> GENE_ADD_DTM = "GENE_ADD_DTM"] |
| 3 | SET | `String rsvAplyYmdStr = inMap.getString(JBSbatKKIFM163.RSV_APLY_YMD)` | Extract the reservation application date in YYYYMMDD format [-> RSV_APLY_YMD = "RSV_APLY_YMD"] |
| 4 | SET | `String lastUpdDtmStr = inMap.getString(JBSbatKKIFM163.UPD_DTM_BF)` | Extract the pre-update timestamp for optimistic concurrency control [-> UPD_DTM_BF = "UPD_DTM_BF"] |

#### Block 2.2 — SET (Prepare Payload Maps) (L117–L120)

> Creates the parameter map, input map, and data map structures required by the ESB invocation framework.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `HashMap<String, Object> paramMap0532 = new HashMap<String, Object>()` | Create the parameter map for the ESB invocation |
| 2 | SET | `paramMap0532.put(JCCBatchEsbInterface.TELEGRAM_INFO_USECASE_ID, "KKSV0532")` | Set the use case ID to `KKSV0532`, identifying this as the device change completion use case |
| 3 | SET | `HashMap<String, Object> inputMap0532 = new HashMap<String, Object>()` | Create the input map that will hold the business data payload |
| 4 | SET | `HashMap<String, Object> dataMap0532 = new HashMap<String, Object>()` | Create the data map containing the actual business fields |

#### Block 2.3 — SET (Populate Data Map) (L123–L138)

> Populates the data map with device change completion data. Note the fixed reservation application code and hardcoded function code.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `dataMap0532.put("kktk_svc_kei_no", kktkSvcKeiNoStr)` | Set the service contract number in the data payload |
| 2 | SET | `dataMap0532.put("gene_add_dtm", geneAddDtmStr)` | Set the registration date/time in the data payload |
| 3 | SET | `dataMap0532.put("rsv_aply_ymd", rsvAplyYmdStr)` | Set the reservation application date in the data payload |
| 4 | SET | `dataMap0532.put("rsv_aply_cd", JBSbatKKConst.RSV_APLY_CD_FIX)` | Set the reservation application code to the fixed value `[-> RSV_APLY_CD_FIX = "2"]`. Changed from hardcoded to constant in v20.00.00 for readability |
| 5 | SET | `dataMap0532.put("upd_dtm_bf", lastUpdDtmStr)` | Set the pre-update timestamp in the data payload |
| 6 | SET | `dataMap0532.put("func_code", "1")` | Set the function code to `"1"`, indicating a "change completion" operation type |

#### Block 2.4 — SET (Build Service Invocation Request) (L140–L141)

> Associates the data map with the service component code and prepares the output map container.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `String scTitleOpn = "KKSV053201SC"` | Set the SC Code for the target service component [KKSV053201SC = "KKSV053201SC"] |
| 2 | SET | `inputMap0532.put(scTitleOpn, dataMap0532)` | Register the data map under the SC Code key in the input map |
| 3 | SET | `HashMap<Object, Object> outputMapOpn532 = new HashMap<Object, Object>()` | Create the output map container for the service invocation result |

#### Block 2.5 — CALL (ESB Invocation) (L145)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `JCCBatchEsbInterface.invokeService(super.commonItem, paramMap0532, inputMap0532, outputMapOpn532)` | Invoke the ESB service component `KKSV053201SC` with the constructed payload |

#### Block 2.6 — EXEC (Extract and Check Return Code) (L147–L154)

> Retrieves the return code from the output map, logs it, and handles non-success codes as business errors.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `String returnCode = (String)outputMapOpn532.get("RETURN_CODE")` | Extract the return code from the service response |
| 2 | EXEC | `super.logPrint.printDebugLog("*RETURN_CODE: " + returnCode)` | Log the return code value for debugging |
| 3 | IF | `if(!"0000".equals(returnCode))` | Check if the return code is NOT success `[RETURNCODE_SUCCESS = "0000"]` |
| 3.1 | EXEC | `super.logPrint.printBusinessErrorLog(JPCBatchMessageConstant.EKKB0010CW, new String[]{"CCでエラーが発生しました(リターンコード):" + returnCode + " 機器提供サービス番号：" + kktkSvcKeiNoStr})` | **ELSE branch:** Log a business error with key `EKKB0010CW` ("Error occurred in CC") including return code and service contract number |
| 4 | RETURN | `return outputMapOpn532` | Return the output map regardless of success or error |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kktkSvcKeiNo` | Field | Equipment-Provided Service Contract Number — unique identifier for a service contract line involving equipment (router/ONT) supplied by K-Opticom |
| `geneAddDtm` | Field | Generation/Registration Date/Time — the timestamp when the service contract was originally registered |
| `rsvAplyYmd` | Field | Reservation Application Date — date (YYYYMMDD format) when the service reservation was applied |
| `rsvAplyCd` | Field | Reservation Application Code — classifies reservation type; `"2"` indicates a fixed/standard reservation |
| `updDtmBf` | Field | Update Date/Time (Before) — the timestamp of the last update before the current change, for optimistic concurrency control |
| `funcCode` | Field | Function Code — `"1"` indicates a device change completion operation type |
| `RETURN_CODE` | Field | Service response code — `"0000"` means success, any other value indicates error |
| `scTitleOpn` | Field | Service Component Title — key identifying the target service component in the input map |
| KKTK | Acronym | K-Opticom Kikou (Equipment) — prefix for equipment-provided services |
| KKSV | Acronym | K-Opticom Service — prefix for service-related batch/screen components |
| KKSV0532 | Domain ID | Screen/Batch number for equipment-provided service contract device change completion |
| KKSV053201SC | Domain ID | Service Component code for device change completion — ESB target component |
| ESB | Acronym | Enterprise Service Bus — middleware for service-to-service communication |
| `RSV_APLY_CD_FIX` | Constant | Fixed reservation application code — value `"2"`, defined in `JBSbatKKConst` |
| `KKTK_SVC_KEI_NO` | Constant | Input map key for the equipment-provided service contract number |
| `GENE_ADD_DTM` | Constant | Input map key for the registration date/time |
| `RSV_APLY_YMD` | Constant | Input map key for the reservation application date |
| `UPD_DTM_BF` | Constant | Input map key for the pre-update timestamp |
| `TELEGRAM_INFO_USECASE_ID` | Constant | ESB parameter key identifying the use case identifier |
| EKKB0010CW | Constant | Error message key for service interface errors — "Error occurred in CC" |
| JBSbatKKKktsvKkChgTtdkFin | Class | Equipment-Provided Service Contract Device Change Completion batch processing item |
| `JBSbatServiceInterfaceMap` | Class | Service Interface Map — input/output message container for batch components |
| `JBSbatOutputItem` | Class | Batch Output Item — return type for batch processing items |
| 機器提供サービス契約機器変更手続完了 | Japanese Term | Equipment-Provided Service Contract Device Change Completion — finalizing device change operations for equipment-provided services |
| フレームワーク (v20.00.00) | Version | Project normalization initiative — v20.00.00 introduced constant-based code for readability improvement |

---