# Business Logic — JBSbatKKBandWidthOverLmtDtTst.executeCK_T_RRKS_KK_SELECT_012() [25 LOC]

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

## 1. Role

### JBSbatKKBandWidthOverLmtDtTst.executeCK_T_RRKS_KK_SELECT_012()

This method performs a database read against the **RRKS (Contact/Registration) table** (`CK_T_RRKS`) using a SQL define key (`KK_SELECT_012`) to retrieve **option service contract information** associated with a customer. It is a dedicated SELECT-only helper method within a batch service class responsible for **bandwidth over-limit notification processing** — specifically, it queries whether any option service contracts (such as contact method registrations or service add-ons like "simple plan") exist for a given service contract. The method binds three values from its input parameter array (service contract number, reservation application date, and an additional field introduced in change ticket ANK-4468-00-01), executes the SQL query through the `db_CK_T_RRKS` SQL access layer, and collects all returned rows into a list. It follows the standard **Data Access Object (DAO) delegation pattern** used throughout the batch framework, wrapping low-level SQL access behind a typed return interface (`JBSbatCommonDBInterface`). Its role in the larger system is to answer the business question: "Does this service contract have any registered option service entries in the RRKS (contact/registration) table?"

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["executeCK_T_RRKS_KK_SELECT_012 param"])
    CREATE_LIST["Create List with capacity 2"]
    CREATE_PARAM["Create paramList JBSbatCommonDBInterface"]
    SET_SERVICE["Set param[0] serviceContractNumber"]
    SET_DATE["Set param[1] reservationApplicationDate"]
    SET_EXTRA["Set param[2] extra bound variable ANK-4468-00-01"]
    EXEC_SQL["Execute DB query selectBySqlDefine CK_T_RRKS KK_SELECT_012"]
    FETCH["resultMap = selectNext()"]
    CHECK_NULL{"resultMap != null?"}
    ADD_RESULT["Add resultMap to list"]
    FETCH_NEXT["resultMap = selectNext()"]
    RETURN["Return list"]

    START --> CREATE_LIST
    CREATE_LIST --> CREATE_PARAM
    CREATE_PARAM --> SET_SERVICE
    SET_SERVICE --> SET_DATE
    SET_DATE --> SET_EXTRA
    SET_EXTRA --> EXEC_SQL
    EXEC_SQL --> FETCH
    FETCH --> CHECK_NULL
    CHECK_NULL -- Yes --> ADD_RESULT
    ADD_RESULT --> FETCH_NEXT
    FETCH_NEXT --> CHECK_NULL
    CHECK_NULL -- No --> RETURN
```

**Processing Summary:**
1. **Initialize** — Creates a pre-sized `ArrayList` (capacity 2) to hold result rows.
2. **Prepare bind parameters** — Instantiates a `JBSbatCommonDBInterface` parameter object and populates it by converting the first three elements of the `param` array from `Object` to `String` via `setValue()`.
3. **Execute SQL query** — Delegates to the `db_CK_T_RRKS` SQL access layer with the prepared parameter list and the SQL define key `CK_T_RRKS_KK_SELECT_012` (value `"KK_SELECT_012"`).
4. **Iterate results** — Uses a `while` loop calling `selectNext()` repeatedly. Each non-null result row is appended to the result list. The loop terminates when `selectNext()` returns `null` (no more rows).
5. **Return** — Returns the populated result list (which may be empty if no rows matched).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `Object[]` | An array of bind variables for the SQL query. It contains exactly 3 elements: **param[0]** = Service Contract Number (the customer's contract identifier used to look up option services), **param[1]** = Reservation Application Date (the date the service reservation was applied, used for date-range filtering in the SQL), **param[2]** = Extra bound variable added via change ticket ANK-4468-00-01 (an additional filter parameter for the simple plan feature). |
| — | `db_CK_T_RRKS` | `JBSbatSQLAccess` | Instance field — the SQL access layer configured for the `CK_T_RRKS` (Contact/Registration) table. Used to execute the SQL query and iterate over results. Initialized in the `initial()` method. |
| — | `CK_T_RRKS_KK_SELECT_012` | `String` | Instance field — SQL define key with value `"KK_SELECT_012"` (see JZMEnumSwitchConstCC). Identifies the specific SQL query to execute against `CK_T_RRKS`. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JDKStructuredMap.setValue` | JDKStructuredMap | - | Calls `setValue` in `JDKStructuredMap` |
| - | `JKKEohTvGuideAddCC.setValue` | JKKEohTvGuideAddCC | - | Calls `setValue` in `JKKEohTvGuideAddCC` |
| - | `DKSV0101_DKSV0101OP_EDKA0010001BSMapper.setValue` | DKSV0101_DKSV0101OP_EDKA0010001BSMapper | - | Calls `setValue` in `DKSV0101_DKSV0101OP_EDKA0010001BSMapper` |
| - | `DKSV0102_DKSV0102OP_EDKA0010001BSMapper.setValue` | DKSV0102_DKSV0102OP_EDKA0010001BSMapper | - | Calls `setValue` in `DKSV0102_DKSV0102OP_EDKA0010001BSMapper` |
| - | `DKSV0103_DKSV0103OP_EDKA0010001BSMapper.setValue` | DKSV0103_DKSV0103OP_EDKA0010001BSMapper | - | Calls `setValue` in `DKSV0103_DKSV0103OP_EDKA0010001BSMapper` |

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| EXEC | `JBSbatCommonDBInterface.setValue(String)` | - | - | Sets bind variable values into the parameter list object for the SQL query. Called 3 times (service contract number, reservation application date, extra parameter). |
| R | `JBSbatSQLAccess.selectBySqlDefine(JBSbatCommonDBInterface, String)` | - | `CK_T_RRKS` | Executes a SELECT query against the `CK_T_RRKS` (Contact/Registration) table using the SQL define key `KK_SELECT_012`. Reads option service contract data. |
| R | `JBSbatSQLAccess.selectNext()` | - | `CK_T_RRKS` | Fetches the next result row from the executed query. Called repeatedly in a `while` loop until no more rows remain (returns `null`). |

**Classification reasoning:**
- **EXEC**: `setValue()` calls are data preparation — binding input values to the query parameter object. They are not CRUD on persistent storage but are execution of the parameter binding mechanism.
- **R (Read)**: `selectBySqlDefine()` and `selectNext()` are both read operations — they query the `CK_T_RRKS` table for option service contract records without modifying data.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKBandWidthOverLmtDtTst | `JBSbatKKBandWidthOverLmtDtTst.execute()` -> `JBSbatKKBandWidthOverLmtDtTst.executeCK_T_RRKS_KK_SELECT_012` | `selectBySqlDefine [R] CK_T_RRKS`, `selectNext [R] CK_T_RRKS` |

**Caller details:**

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKBandWidthOverLmtDtTst | `JBSbatKKBandWidthOverLmtDtTst.execute()` -> `executeCK_T_RRKS_KK_SELECT_012` | `selectBySqlDefine [R] CK_T_RRKS`, `selectNext [R] CK_T_RRKS` |

This method is called by the parent class's `execute()` method within the same class (`JBSbatKKBandWidthOverLmtDtTst`), which serves as the main entry point for the bandwidth over-limit notification batch processing job. The batch processes customers whose data transfer usage has exceeded their contracted bandwidth limit, and this method specifically checks the RRKS (contact/registration) table for any associated option service contracts.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(L656)` Initialize result list

> Creates a pre-sized ArrayList to hold result rows. The capacity of 2 reflects the expected maximum number of option service contract rows per service contract.

| # | Type | Code |
|---|------|------|
| 1 | SET | `List<JBSbatCommonDBInterface> list = new ArrayList<>(2)` // Pre-sized result container |

**Block 2** — [SET] `(L659-663)` Prepare bind parameter list

> Instantiates the parameter binding object and populates it with the three bind variables extracted from the input parameter array. Each `setValue()` call appends a bound variable to the list for SQL execution.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `JBSbatCommonDBInterface paramList = new JBSbatCommonDBInterface()` | Create new bind variable container |
| 2 | EXEC | `paramList.setValue(param[0].toString())` | Set **service contract number** as first bind variable |
| 3 | EXEC | `paramList.setValue(param[1].toString())` | Set **reservation application date** as second bind variable |
| 4 | EXEC | `paramList.setValue(param[2].toString())` // ANK-4468-00-01 | Set **extra parameter** as third bind variable (Simple Plan addition) |

**Block 3** — [EXEC] `(L666)` Execute SQL SELECT query

> Delegates to the `db_CK_T_RRKS` SQL access layer to execute the SQL define key `KK_SELECT_012` against the `CK_T_RRKS` (Contact/Registration) table. The parameter list `paramList` supplies the bind values.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `db_CK_T_RRKS.selectBySqlDefine(paramList, CK_T_RRKS_KK_SELECT_012)` | Execute SELECT query `[R] CK_T_RRKS` with SQL key `KK_SELECT_012` [-> `CK_T_RRKS_KK_SELECT_012 = "KK_SELECT_012"`] |

**Block 4** — [SET + WHILE LOOP] `(L668-675)` Iterate result rows

> Fetches result rows one at a time using `selectNext()` in a `while` loop. Each non-null row is added to the result list. The loop exits when `selectNext()` returns `null`, indicating no more rows.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `JBSbatCommonDBInterface resultMap = db_CK_T_RRKS.selectNext()` | Fetch first result row `[R] CK_T_RRKS` |
| 2 | IF | `while (null != resultMap)` | Check if a row was returned |

**Block 4.1** — [SET + WHILE BODY] `(L670-L671)` Process each result row

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `list.add(resultMap)` | Append current result row to the result list |
| 2 | SET | `resultMap = db_CK_T_RRKS.selectNext()` | Fetch next result row `[R] CK_T_RRKS` |

**Block 5** — [RETURN] `(L677)` Return result list

> Returns the populated list of option service contract records. The list may be empty (0 rows) if no option services were found matching the bind variables.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return list;` | Return the list of option service contracts found |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `CK_T_RRKS` | Table | Contact/Registration table — stores customer contact preferences and service registration data including option service contracts |
| `KK_SELECT_012` | SQL Key | SQL define key identifying the SELECT query against `CK_T_RRKS` that retrieves option service contract information |
| `serviceContractNumber` | Field | Service contract number — the primary identifier for a customer's service contract, used as the main lookup key |
| `reservationApplicationDate` | Field | Reservation application date — the date on which a service reservation was submitted, used for date-scoped queries |
| `param[2]` | Field | Extra bound variable — an additional query parameter added by change ticket ANK-4468-00-01 to support the "Simple Plan" feature |
| `JBSbatCommonDBInterface` | Interface | Base interface for database bind/parameter objects in the batch framework; provides `setValue()` for adding bind variables and is used as the return type for query result rows |
| `JBSbatSQLAccess` | Class | SQL access framework class — provides `selectBySqlDefine()` and `selectNext()` methods for executing parameterized SQL queries and iterating results |
| `selectBySqlDefine` | Method | Executes a pre-defined SQL statement (identified by a SQL define key string) with the given bind parameters |
| `selectNext` | Method | Fetches the next row from the result set of a previously executed SQL query; returns `null` when no more rows exist |
| `ANK-4468-00-01` | Change Ticket | Change ticket that added the third bind parameter to support the "eo Light Net Simple Plan" feature |
| `JBSbatCommonDBInterface` list | Return type | A `List` of option service contract records, each row representing a registered option service associated with the queried service contract |
| `db_CK_T_RRKS` | Instance field | SQL access layer instance configured for the `CK_T_RRKS` table, initialized in the `initial()` method |
| `CK_T_RRKS_KK_SELECT_012` | Instance field | SQL define key constant with value `"KK_SELECT_012"` — identifies the specific SELECT query definition for option service contract lookup |
