# Business Logic — JBSBatKKKkOpDlRvChsht.searchSvkeiExcCtrl() [12 LOC]

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

## 1. Role

### JBSBatKKKkOpDlRvChsht.searchSvkeiExcCtrl()

This method performs a **primary key-based lookup** on the **Service Contract Exclusion Control Table** (`KK_T_SVKEI_EXC_CTRL`). In the telecom service fulfillment system, this table is used to manage exclusion/hold records for service contracts — essentially tracking which service contract lines are currently locked or under exclusion processing to prevent concurrent modification or to coordinate batch operations.

The method implements a simple **delegation pattern**: it receives a service contract number (`svc_kei_no`), constructs a primary key lookup map using the framework's `JBSbatCommonDBInterface`, delegates the actual SQL execution to the `db_KK_T_SVKEI_EXC_CTRL` SQL access object via `selectByPrimaryKeys`, and returns the `LAST_UPD_DTM` (last update timestamp) of the matching record as a string. If no record is found, it returns an empty string rather than null.

This is a **private utility method** (not publicly accessible) called by the class's own `execute()` batch method. Its role in the larger system is to support **concurrency control and data consistency** for service contract processing — the calling batch routine uses this timestamp to determine whether the service contract record is currently active, locked, or eligible for further processing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["searchSvkeiExcCtrl(svc_kei_no)"])
    STEP1["Create pkMap: new JBSbatCommonDBInterface()"]
    STEP2["Set PK value: pkMap.setValue(SVC_KEI_NO, svc_kei_no)"]
    STEP3["Query DB: db_KK_T_SVKEI_EXC_CTRL.selectByPrimaryKeys(pkMap)"]
    COND{outMap null?}
    RETNULL["Return empty string \"\""]
    RETDTM["Return: outMap.getString(LAST_UPD_DTM)"]
    END(["Return / Next"])

    START --> STEP1 --> STEP2 --> STEP3 --> COND
    COND -->|Yes| RETNULL --> END
    COND -->|No| RETDTM --> END
```

**Processing description:**

1. **Initialize parameter map** — A new `JBSbatCommonDBInterface` object (`pkMap`) is created to serve as the SQL query parameter container. This is the framework's standard pattern for building database query maps.

2. **Set primary key condition** — The service contract number (`svc_kei_no`) is set as the value for the `SVC_KEI_NO` column in the parameter map. This acts as the sole search condition for the primary key lookup.

3. **Execute primary key query** — The `db_KK_T_SVKEI_EXC_CTRL` SQL access object performs a primary key selection against the `KK_T_SVKEI_EXC_CTRL` table using the prepared parameter map. The result is stored in `outMap` as another `JBSbatCommonDBInterface` instance.

4. **Null-safe return** — If the query returns no matching record (`outMap` is null), an empty string `""` is returned. Otherwise, the `LAST_UPD_DTM` field value is extracted from the result map and returned as the last update timestamp string.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `svc_kei_no` | `String` | Service contract number — the unique identifier for a service contract line item in the telecom billing system. This number is used as the primary key to look up the corresponding exclusion control record. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_KK_T_SVKEI_EXC_CTRL` | `JBSbatSQLAccess` | Database access object initialized in `initial()` for reading/writing the `KK_T_SVKEI_EXC_CTRL` table. Connected during batch startup with the common batch parameters. |

## 4. CRUD Operations / Called Services

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

The method performs a single primary key read operation on the `KK_T_SVKEI_EXC_CTRL` table.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `db_KK_T_SVKEI_EXC_CTRL.selectByPrimaryKeys` | (Framework SQL access) | `KK_T_SVKEI_EXC_CTRL` | Primary key-based read of the Service Contract Exclusion Control table using the service contract number as the lookup key. Returns the full record if found. |
| - | `JBSbatCommonDBInterface.setValue` | (Framework map) | - | Sets the primary key condition in the parameter map before query execution. |
| - | `JBSbatCommonDBInterface.getString` | (Framework map) | - | Extracts the `LAST_UPD_DTM` (last update timestamp) field value from the query result map. |
| - | `JBSbatCommonDBInterface.<init>` | (Framework map) | - | Creates a new empty parameter map (`pkMap`) for constructing the query condition. |

**CRUD summary:** This method performs a single **Read (R)** operation against the `KK_T_SVKEI_EXC_CTRL` table. No Create, Update, or Delete operations are performed.

## 5. Dependency Trace

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSBatKKKkOpDlRvChsht | `JBSBatKKKkOpDlRvChsht.execute()` -> `searchSvkeiExcCtrl(svc_kei_no)` | `selectByPrimaryKeys [R] KK_T_SVKEI_EXC_CTRL` |

**Call chain details:**

The `searchSvkeiExcCtrl()` method is called directly from the `execute()` method of the same class `JBSBatKKKkOpDlRvChsht`. This is a batch processing service that handles **equipment/pas-service cancellation and withdrawal extraction**. The `execute()` method is the main batch processing entry point, which invokes `searchSvkeiExcCtrl()` to check the exclusion control status of specific service contract lines before proceeding with batch processing decisions.

The terminal operation reached from this method is a single database read: `selectByPrimaryKeys` on the `KK_T_SVKEI_EXC_CTRL` table.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF-ELSE] `(null-safe return check)` (L363)

> Determines whether the database query returned a matching record. If no record exists for the given service contract number, returns an empty string to signal "not found."

| # | Type | Code |
|---|------|------|
| 1 | COND | `null == outMap` [Condition: primary key query returned no record] |
| 2 | RETURN | `return ""` [No matching exclusion control record found; returns empty string to indicate absence] |
| 3 | ELSE | `(outMap is not null)` |
| 4 | EXEC | `outMap.getString(JBSbatKK_T_SVKEI_EXC_CTRL.LAST_UPD_DTM)` [-> FIELD: "LAST_UPD_DTM" = Last update date and time] |
| 5 | RETURN | `return outMap.getString(...)` [Returns the last update timestamp of the exclusion control record as a string] |

**Block 2** — [EXEC] `(primary key query preparation)` (L355-L362)

> Sets up the query parameter and executes the primary key read against the exclusion control table.

| # | Type | Code |
|---|------|------|
| 1 | SET | `pkMap = new JBSbatCommonDBInterface()` [Creates a new parameter map container for query conditions] |
| 2 | EXEC | `pkMap.setValue(JBSbatKK_T_SVKEI_EXC_CTRL.SVC_KEI_NO, svc_kei_no)` [-> COLUMN: "SVC_KEI_NO" = Service contract number; Sets the primary key search condition] |
| 3 | CALL | `outMap = db_KK_T_SVKEI_EXC_CTRL.selectByPrimaryKeys(pkMap)` [Executes primary key lookup on KK_T_SVKEI_EXC_CTRL table using the prepared condition map] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service contract number — the unique identifier for a service contract line item in the telecom billing/order fulfillment system |
| `LAST_UPD_DTM` | Field | Last update date and time — the timestamp of the most recent modification to the exclusion control record |
| `SVC_KEI_NO` | Field (Column) | Service contract number — the primary key column used to identify records in the `KK_T_SVKEI_EXC_CTRL` table |
| `KK_T_SVKEI_EXC_CTRL` | Table | Service Contract Exclusion Control table — a system table that tracks exclusion/hold status for service contract lines to coordinate batch processing and prevent concurrent modifications |
| `JBSbatCommonDBInterface` | Framework | Batch framework data interface — a generic key-value map used to pass query parameters and receive database query results |
| `JBSbatSQLAccess` | Framework | Batch framework SQL access class — the data access wrapper that executes SQL queries against configured database tables |
| `selectByPrimaryKeys` | Framework method | Primary key lookup — executes a SELECT query using the exact primary key columns and values provided in the parameter map |
| `JBSBatKKKkOpDlRvChsht` | Class | Equipment/Pas-Service Cancellation/Withdrawal Extraction batch service — the batch processing class that this method belongs to; handles extraction of service contracts subject to equipment and pas-service cancellation processing |
| `FLG_ON` | Constant | Flag-on value = "1" — used elsewhere in the class to indicate a flag is set/enabled |
| `BLANK` | Constant | Empty string = "" — used as a placeholder/empty value constant |
| `execute()` | Method | Main batch processing method — the entry point for the batch job that calls `searchSvkeiExcCtrl()` to check service contract exclusion status |
