# Business Logic — JBSbatKKKktsvKkChgTtdkStp.execKKSV0533() [72 LOC]

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

## 1. Role

### JBSbatKKKktsvKkChgTtdkStp.execKKSV0533()

This method implements the **Equipment Provision Service Contract Equipment Change Procedure Cancellation** service call (機器提供サービス契約機器変更手続中止). It acts as a routing/dispatch handler that extracts equipment provisioning service contract data from an incoming parameter map, assembles it into a structured service invocation request, and delegates the actual business processing to a downstream service component via the ESB interface.

The method follows a **delegation + ESB invocation pattern**. It does not contain business logic itself; instead, it prepares the request payload (including the service ID `KKSV053301SC` and function code `1`) and invokes the service through `JCCBatchEsbInterface.invokeService()`. Upon receiving the response, it inspects the return code — a value of `"0000"` indicates success, while any other code triggers a business error log (`EKKB0010CW`) containing the return code and equipment service contract number.

This method is the **service contract handler** for screen batch `KKSV0533`. It is called by `JBSbatKKKktsvKkChgTtdkStp.execute()` as part of the screen batch processing pipeline for equipment change procedure cancellation. Its role in the larger system is to serve as the bridge between the screen batch orchestration layer and the actual service component (`KKSV053301SC`) that performs the cancellation operation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execKKSV0533 begins"])
    KKSVC["Extract kktkSvcKeiNo from inMap using KKTK_SVC_KEI_NO"]
    GENE["Extract geneAddDtm from inMap using GENE_ADD_DTM"]
    RSVCL["Extract rsvClYmd from inMap using RSV_CL_YMD"]
    RSVAPL["Extract rsvAplyCd from inMap using RSV_APLY_CD"]
    UPDTM["Extract lastUpdDtm from inMap using UPD_DTM_BF"]
    PARA["Create paramMap0533; set TELEGRAM_INFO_USECASE_ID to KKSV0533"]
    INPUT["Create inputMap0533 and dataMap0533"]
    DMAP["Populate dataMap0533 with kktk_svc_kei_no, gene_add_dtm, rsv_cl_ymd, rsv_aply_cd, upd_dtm_bf, func_code=1"]
    SCOP["Set scTitleOpn = KKSV053301SC; put dataMap0533 into inputMap0533 keyed by scTitleOpn"]
    OUTMAP["Create outputMapOpn0533"]
    INVOKE["Invoke JCCBatchEsbInterface.invokeService with paramMap0533, inputMap0533, outputMapOpn0533"]
    RETCODE["Extract RETURN_CODE from outputMapOpn0533; log RETURN_CODE value"]
    CHECK["RETURN_CODE equals 0000?"]
    ERROR["Log business error EKKB0010CW with returnCode and kktkSvcKeiNo"]
    RETURN(["Return outputMapOpn0533"])

    START --> KKSVC --> GENE --> RSVCL --> RSVAPL --> UPDTM --> PARA --> INPUT --> DMAP --> SCOP --> OUTMAP --> INVOKE --> RETCODE --> CHECK
    CHECK -- No --> ERROR --> RETURN
    CHECK -- Yes --> RETURN
```

**Processing Steps:**

1. **Data Extraction (L99–L113):** Six fields are extracted from the input map `inMap` using predefined constant keys from `JBSbatKKIFM164` — the equipment service contract number, generation registration datetime, reservation application date, reservation application code, and pre-update datetime.

2. **Parameter Map Construction (L115–L118):** A `paramMap0533` is created and populated with the use case ID `"KKSV0533"` keyed by `TELEGRAM_INFO_USECASE_ID`. This identifies the ESB service invocation context.

3. **Data Map Assembly (L120–L139):** An `inputMap0533` and inner `dataMap0533` are constructed. The extracted fields are placed into `dataMap0533` under the keys: `kktk_svc_kei_no`, `gene_add_dtm`, `rsv_cl_ymd`, `rsv_aply_cd`, `upd_dtm_bf`. Additionally, `func_code` is hardcoded to `"1"`.

4. **Service Invocation Setup (L141–L144):** The service component title (`KKSV053301SC`) is used as the key to place `dataMap0533` into `inputMap0533`.

5. **ESB Service Call (L147–L150):** `JCCBatchEsbInterface.invokeService()` is invoked with `paramMap0533`, `inputMap0533`, and an empty `outputMapOpn0533`. The service component processes the cancellation request.

6. **Return Code Verification (L152–L160):** The return code is extracted from `outputMapOpn0533` under the key `"RETURN_CODE"`. It is logged via `printDebugLog`. If the return code is NOT `"0000"`, a business error log is emitted with message key `EKKB0010CW` containing the return code and equipment service contract number.

7. **Return (L162):** The output map is returned to the caller, which includes any service-side response data.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input map containing equipment provisioning service contract cancellation data. It carries the equipment service contract number (`KKTK_SVC_KEI_NO`), generation registration datetime (`GENE_ADD_DTM`), reservation application date (`RSV_CL_YMD`), reservation application code (`RSV_APLY_CD`), and pre-update datetime (`UPD_DTM_BF`). These fields uniquely identify a service contract line item and the cancellation context. |
| 2 | `super.commonItem` | (instance field) | Common items shared across batch service invocations (e.g., authentication info, tenant ID, batch metadata). Passed to `invokeService` for ESB context. |
| 3 | `super.logPrint` | (instance field) | Logging utility used for debug and business error log output. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JCCBatchEsbInterface.invokeService` | KKSV053301SC | - | Invokes the Equipment Provision Service Contract Equipment Change Procedure Cancellation service component via ESB. This is the core service call that performs the actual cancellation business logic downstream. |
| R | `JBSbatKKIFM164.getString` (via inMap) | - | - | Reads field values from the input parameter map using constant keys (KKTK_SVC_KEI_NO, GENE_ADD_DTM, RSV_CL_YMD, RSV_APLY_CD, UPD_DTM_BF). |
| - | `super.logPrint.printDebugLog` | - | - | Logs the return code from the service invocation for debug tracing. |
| - | `super.logPrint.printBusinessErrorLog` | - | - | Logs business error when the service returns a non-zero error code. |

### Additional Detail

The primary downstream operation is the ESB invocation through `JCCBatchEsbInterface.invokeService()`, which routes to service component `KKSV053301SC`. This SC handles the Equipment Provision Service Contract Equipment Change Procedure Cancellation. The method itself does not perform direct database operations — it delegates all data access to the SC layer via the ESB interface.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| (C/U) | `JCCBatchEsbInterface.invokeService` | KKSV053301SC | Equipment Provision Service Contract (equipment_svc_kei) | Cancels an equipment change procedure for the specified equipment provisioning service contract. SC determines the underlying create/update/delete operations. |

## 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: `printBusinessErrorLog` [-], `printDebugLog` [-], `invokeService` [-]

Trace who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch:KKSV0533 handler | `JBSbatKKKktsvKkChgTtdkStp.execute()` -> `execKKSV0533(inMap)` | `JCCBatchEsbInterface.invokeService [Service Call] KKSV053301SC` |
| 2 | - | - | `super.logPrint.printDebugLog [LOG] RETURN_CODE` |
| 3 | - | - | `super.logPrint.printBusinessErrorLog [ERROR] EKKB0010CW (when RETURN_CODE != 0000)` |

## 6. Per-Branch Detail Blocks

**Block 1** — [Field Extraction] (L99–L113)

> Extracts five fields from the input map `inMap` using constant keys defined in `JBSbatKKIFM164`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kktkSvcKeiNoStr = inMap.getString(JBSbatKKIFM164.KKTK_SVC_KEI_NO)` // Equipment provision service contract number [KKTK_SVC_KEI_NO = "kktk_svc_kei_no"] |
| 2 | SET | `geneAddDtmStr = inMap.getString(JBSbatKKIFM164.GENE_ADD_DTM)` // Generation registration datetime [GENE_ADD_DTM = "gene_add_dtm"] |
| 3 | SET | `rsvClYmdStr = inMap.getString(JBSbatKKIFM164.RSV_CL_YMD)` // Reservation application date [RSV_CL_YMD = "rsv_cl_ymd"] |
| 4 | SET | `rsvAplyCdStr = inMap.getString(JBSbatKKIFM164.RSV_APLY_CD)` // Reservation application code [RSV_APLY_CD = "rsv_aply_cd"] |
| 5 | SET | `lastUpdDtmStr = inMap.getString(JBSbatKKIFM164.UPD_DTM_BF)` // Pre-update datetime [UPD_DTM_BF = "upd_dtm_bf"] |

**Block 2** — [Parameter Map Construction] (L115–L118)

> Creates the parameter map for ESB invocation and sets the use case identifier.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap0533 = new HashMap<String, Object>()` // Parameter map for service invocation |
| 2 | SET | `paramMap0533.put(JCCBatchEsbInterface.TELEGRAM_INFO_USECASE_ID, "KKSV0533")` // Sets use case ID [TELEGRAM_INFO_USECASE_ID = "telegram_info_uscase_id"] |

**Block 3** — [Data Map Assembly] (L120–L139)

> Constructs the input data maps and populates them with extracted fields and metadata.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inputMap0533 = new HashMap<String, Object>()` // Input map for service data |
| 2 | SET | `dataMap0533 = new HashMap<String, Object>()` // Data map holding business fields |
| 3 | SET | `dataMap0533.put("kktk_svc_kei_no", kktkSvcKeiNoStr)` // Equipment service contract number |
| 4 | SET | `dataMap0533.put("gene_add_dtm", geneAddDtmStr)` // Generation registration datetime |
| 5 | SET | `dataMap0533.put("rsv_cl_ymd", rsvClYmdStr)` // Reservation cancellation date |
| 6 | SET | `dataMap0533.put("rsv_aply_cd", rsvAplyCdStr)` // Reservation application code |
| 7 | SET | `dataMap0533.put("upd_dtm_bf", lastUpdDtmStr)` // Pre-update datetime |
| 8 | SET | `dataMap0533.put("func_code", "1")` // Function code [func_code = "1" (hardcoded)] |

**Block 4** — [Service Invocation Setup] (L141–L144)

> Sets the service component title and places the data map into the input map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `scTitleOpn = "KKSV053301SC"` // Service component code for equipment change procedure cancellation [KKSV053301SC = "KKSV053301SC"] |
| 2 | SET | `inputMap0533.put(scTitleOpn, dataMap0533)` // Puts dataMap0533 keyed by SC title |

**Block 5** — [ESB Service Call] (L147–L150)

> Invokes the downstream service component via the ESB interface.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outputMapOpn0533 = new HashMap<Object, Object>()` // Output map for service results |
| 2 | CALL | `JCCBatchEsbInterface.invokeService(super.commonItem, paramMap0533, inputMap0533, outputMapOpn0533)` // Invokes KKSV053301SC service component |

**Block 6** — [Return Code Extraction and Verification] (L152–L160)

> Extracts and checks the return code from the service response. Conditionally logs a business error.

| # | Type | Code |
|---|------|------|
| 1 | SET | `returnCode = (String)outputMapOpn0533.get("RETURN_CODE")` // Extracts return code [RETURN_CODE = "RETURN_CODE"] |
| 2 | EXEC | `super.logPrint.printDebugLog("★RETURN_CODE:" + returnCode)` // Logs return code for debug |
| 3 | IF | `if(!"0000".equals(returnCode))` [Condition: returnCode != "0000"] |

**Block 6.1** — [NESTED ELSE-IF] — Error Logging (L155–L157)

> When the return code is NOT "0000", logs a business error with details.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printBusinessErrorLog(JPCBatchMessageConstant.EKKB0010CW, new String[]{"機器提供サービス契約機器変更手続中止SCでエラーが発生しました(リターンコード):" + returnCode + " 機器提供サービス番号：" + kktkSvcKeiNoStr})` // Logs business error EKKB0010CW [EKKB0010CW = "EKKB0010CW"] |

**Block 7** — [Return] (L162)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return outputMapOpn0533` // Returns the service response map to caller |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kktk_svc_kei_no` | Field | Equipment provision service contract number — the unique identifier for an equipment provisioning service contract line item |
| `gene_add_dtm` | Field | Generation registration datetime — the timestamp when the service contract record was originally created/registered |
| `rsv_cl_ymd` | Field | Reservation cancellation date — the date when the reservation for the service contract is cancelled |
| `rsv_aply_cd` | Field | Reservation application code — a code indicating the type of reservation application (e.g., new, change, cancellation) |
| `upd_dtm_bf` | Field | Pre-update datetime — the timestamp of the last update before the current operation (optimistic concurrency control) |
| `kktkSvcKeiNo` | Field | Shortened name for the equipment service contract number |
| KKSV0533 | Use Case ID | Screen batch use case identifier for Equipment Provision Service Contract Equipment Change Procedure Cancellation |
| KKSV053301SC | SC Code | Service Component code — the downstream service component that handles the actual cancellation processing |
| func_code | Field | Function code — hardcoded to "1", indicates the operation type within the service |
| RETURN_CODE | Field | Return code — the service component's response code; "0000" indicates success, any other value indicates an error |
| EKKB0010CW | Constant | Business error message key — logged when the ESB service invocation returns a non-zero error code |
| ESB | Acronym | Enterprise Service Bus — the middleware integration layer used for service invocation |
| TELEGRAM_INFO_USECASE_ID | Constant | ESB parameter key used to identify the use case for service routing |
| 機器提供サービス契約 | Business term | Equipment Provision Service Contract — a contract for providing telecommunication equipment services to customers |
| 機器変更手続中止 | Business term | Equipment Change Procedure Cancellation — the business operation to cancel an equipment change procedure for a service contract |
