# Business Logic — JBSbatKKSvkeiuwDelTgCst.isDelTrgtNoDataTel() [44 LOC]

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

## 1. Role

### JBSbatKKSvkeiuwDelTgCst.isDelTrgtNoDataTel()

This method performs a "deletion-target exclusion check for telephone-based services" (消去対象外確認処理). Its business purpose is to determine whether a given telephone number should be **excluded** from a batch deletion target list. In other words, if the method returns `true`, the record is flagged as *not* eligible for deletion (消去対象外); if `false`, the record is eligible for deletion (消去対象).

The method implements a **nested query traversal pattern** across three related database tables. It starts from the service contract line item table (`KK_T_SVC_KEI_UCWK`), resolves associated VA (Virtual Appliance) home device phone records (`KK_T_SVKEIUW_EOH_TEL`), links them to equipment-provided service contracts (`KK_T_KKTK_SVC_KEI`), and finally checks whether any corresponding returned equipment records exist in the returned equipment table (`DK_T_HMPIN_KIKI`). The existence of a returned equipment record means the device is in a return/recycling pipeline and must be protected from deletion — hence the method returns `true`.

The design follows a **delegation pattern**: each query step delegates to a dedicated select execution method (`executeKK_T_SVKEIUW_EOH_TEL_KK_SELECT_036`, `executeKK_T_KKTK_SVC_KEI_KK_SELECT_129`, `executeDK_T_HMPIN_KIKI_KK_SELECT_003`) and iterates over result sets using `selectNext()`. The method is private, indicating it is a shared internal utility called by the parent class's deletion target data setup logic (`setDelTrgtDataTel`).

It handles all branches uniformly: each SQL query is executed with computed parameters, and the result is simply checked for existence (null vs. non-null). There is no branching on service type codes — the traversal is purely structural, following foreign-key relationships between telecom service contracts, device assignments, and equipment return records.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["isDelTrgtNoDataTel inMap, inTelno"])
    INIT["nextRec = null<br/>workSelectWhereParam[2] setup"]
    SET1["workSelectWhereParam[0] = inMap.getString SVC_KEI_UCWK_NO<br/>workSelectWhereParam[1] = inTelno"]
    CALL1["executeKK_T_SVKEIUW_EOH_TEL_KK_SELECT_036 workSelectWhereParam"]
    FETCH1["nextRec = db_KK_T_SVKEIUW_EOH_TEL.selectNext"]
    WHILE1{nextRec != null}
    SET2["wkSelectWhereParam[3] setup<br/>param[0] = inMap.getString SVC_KEI_NO<br/>param[1] = nextRec.getString VA_TAKNKIKI_MODEL_CD<br/>param[2] = nextRec.getString VA_KIKI_CHG_NO"]
    CALL2["executeKK_T_KKTK_SVC_KEI_KK_SELECT_129 wkSelectWhereParam"]
    FETCH2["nextRec = db_KK_T_KKTK_SVC_KEI.selectNext"]
    WHILE2{nextRec != null}
    SET3["SelectWhereParam[2] setup<br/>param[0] = nextRec.getString KKTK_SVC_KEI_NO<br/>param[1] = nextRec.getString KIKI_CHG_NO"]
    CALL3["executeDK_T_HMPIN_KIKI_KK_SELECT_003 SelectWhereParam"]
    FETCH3["nextRec = db_DK_T_HMPIN_KIKI.selectNext"]
    IF_EMPTY{nextRec != null}
    RETURN_TRUE["return true"]
    RETURN_FALSE["return false"]
    END_NODE(["Return / Next"])

    START --> INIT --> SET1 --> CALL1 --> FETCH1 --> WHILE1
    WHILE1 -- true --> SET2 --> CALL2 --> FETCH2 --> WHILE2
    WHILE1 -- false --> RETURN_FALSE
    WHILE2 -- true --> SET3 --> CALL3 --> FETCH3 --> IF_EMPTY
    IF_EMPTY -- true --> RETURN_TRUE --> END_NODE
    IF_EMPTY -- false --> WHILE2
    RETURN_FALSE --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | A service interface map carrying the current batch processing context. It contains the service contract line item number (`SVC_KEI_UCWK_NO`) and service contract number (`SVC_KEI_NO`) needed to traverse the related records. These values serve as the entry point for the multi-table join traversal. |
| 2 | `inTelno` | `String` | The telephone number used to identify VA (Virtual Appliance) home device phone records. This is the key discriminator when querying the `KK_T_SVKEIUW_EOH_TEL` table — only phone records matching both the service contract line item and this phone number are considered. |

**External state read by the method:**
- `db_KK_T_SVKEIUW_EOH_TEL` — DB interface for the VA home device phone table (`KK_T_SVKEIUW_EOH_TEL`). Used via `selectNext()` to iterate query results.
- `db_KK_T_KKTK_SVC_KEI` — DB interface for the equipment-provided service contract table (`KK_T_KKTK_SVC_KEI`). Used via `selectNext()` to iterate the second level of results.
- `db_DK_T_HMPIN_KIKI` — DB interface for the returned equipment table (`DK_T_HMPIN_KIKI`). Used via `selectNext()` for the final existence check.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `executeKK_T_SVKEIUW_EOH_TEL_KK_SELECT_036` | `EKK0361A010SC` (inferred) | `KK_T_SVKEIUW_EOH_TEL` | Queries VA home device phone records matching a service contract line item number and telephone number. Used in the first traversal level. |
| R | `db_KK_T_SVKEIUW_EOH_TEL.selectNext` | — | `KK_T_SVKEIUW_EOH_TEL` | Reads the next row from the result set of the previous select query. Iterates over all matching VA device phone records. |
| R | `executeKK_T_KKTK_SVC_KEI_KK_SELECT_129` | `EKK1291A010SC` (inferred) | `KK_T_KKTK_SVC_KEI` | Queries equipment-provided service contract records matching a service contract number, VA home device model code, and device change number. Used in the second traversal level. |
| R | `db_KK_T_KKTK_SVC_KEI.selectNext` | — | `KK_T_KKTK_SVC_KEI` | Reads the next row from the result set of the previous select query. Iterates over all matching equipment-provided service contract records. |
| R | `executeDK_T_HMPIN_KIKI_KK_SELECT_003` | `EKK0031A010SC` (inferred) | `DK_T_HMPIN_KIKI` | Queries returned equipment records matching an equipment-provided service contract number and device change number. Used for the final existence check — if any returned equipment record exists, the phone is excluded from deletion. |
| R | `db_DK_T_HMPIN_KIKI.selectNext` | — | `DK_T_HMPIN_KIKI` | Reads the next row from the result set of the previous select query. Checks whether any returned equipment records exist. |
| R | `JBSbatServiceInterfaceMap.getString` | — | — | Reads values (e.g., `SVC_KEI_UCWK_NO`, `SVC_KEI_NO`) from the input map. |
| R | `JBSbatCommonDBInterface.getString` | — | — | Reads field values from DB result rows (e.g., `VA_TAKNKIKI_MODEL_CD`, `VA_KIKI_CHG_NO`, `KKTK_SVC_KEI_NO`, `KIKI_CHG_NO`). |

**CRUD Classification Rationale:**
- All three `execute*SELECT_*` methods are **Read (R)** operations — their names contain `SELECT` and they populate DB interfaces for iteration.
- All `selectNext()` calls are **Read (R)** operations — they retrieve the next row from an already-executed query.
- All `getString()` calls are **Read (R)** operations — they extract field values from maps or result rows.
- No Create, Update, or Delete operations are performed by this method.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class: `JBSbatKKSvkeiuwDelTgCst.setDelTrgtDataTel()` | `setDelTrgtDataTel()` → `isDelTrgtNoDataTel(inMap, inTelno)` | `executeDK_T_HMPIN_KIKI_KK_SELECT_003 [R] DK_T_HMPIN_KIKI`<br/>`executeKK_T_KKTK_SVC_KEI_KK_SELECT_129 [R] KK_T_KKTK_SVC_KEI`<br/>`executeKK_T_SVKEIUW_EOH_TEL_KK_SELECT_036 [R] KK_T_SVKEIUW_EOH_TEL`<br/>`getString [R] map/row fields` |

**Notes:**
- This method is **private**, so it is only called internally within `JBSbatKKSvkeiuwDelTgCst`.
- The direct caller `setDelTrgtDataTel()` is likely the method that assembles the full deletion target list for telephone-based services, calling `isDelTrgtNoDataTel()` to filter out records that should be protected from deletion.
- No screen entry points (`KKSV*`) or batch entry points were identified within 8 hops of the call graph.

## 6. Per-Branch Detail Blocks

### Block 1 — INIT (variable initialization) (L474)

> Initialize the iteration cursor and SQL WHERE parameters array.

| # | Type | Code |
|---|------|------|
| 1 | SET | `nextRec = null` // Initialize result set cursor to null |
| 2 | SET | `workSelectWhereParam = new Object[2]` // Allocate SQL WHERE parameter array of size 2 |

### Block 2 — SET (SQL WHERE parameter setup) (L477–480)

> Set up the SQL WHERE parameters for the first query. Uses the service contract line item number from the input map and the input telephone number.
> Japanese comment: `SQLパラメータの設定(VA宅内機器型式コード、VA機器変更番号の取得)` — "SQL parameter setup (retrieve VA home device model code and VA device change number)"

| # | Type | Code |
|---|------|------|
| 1 | SET | `workSelectWhereParam[0] = inMap.getString(JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_UCWK_NO)` // Service contract line item number — from `KK_T_SVC_KEI_UCWK` table constant |
| 2 | SET | `workSelectWhereParam[1] = inTelno` // Telephone number — input parameter |

### Block 3 — CALL (First select execution) (L482–483)

> Execute the query against the VA home device phone table and fetch the first result row.
> Japanese comment: `SQLパラメータの設定` — "SQL parameter setup"

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_SVKEIUW_EOH_TEL_KK_SELECT_036(workSelectWhereParam)` // Execute select query on KK_T_SVKEIUW_EOH_TEL with the prepared WHERE parameters |
| 2 | SET | `nextRec = db_KK_T_SVKEIUW_EOH_TEL.selectNext()` // Fetch first result row; null if no matching records |

### Block 4 — WHILE (Outer loop: iterate VA device phone records) (L485)

> Iterate over all VA home device phone records that match the service contract line item and telephone number.

| # | Type | Code |
|---|------|------|
| 1 | IF | `while (nextRec != null)` [L485] — Continue processing while there are matching phone records |

#### Block 4.1 — Nested body (when nextRec != null) (L487)

> For each VA device phone record, proceed to the second-level query on equipment-provided service contracts.
> Japanese comment: `SQLパラメータの設定(機器提供サービス契約番号、機器変更番号の取得)` — "SQL parameter setup (retrieve equipment-provided service contract number and device change number)"

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkSelectWhereParam = new Object[3]` // Allocate SQL WHERE parameter array of size 3 |
| 2 | SET | `wkSelectWhereParam[0] = inMap.getString(JBSbatKK_T_SVC_KEI.SVC_KEI_NO)` // Service contract number — from input map, `KK_T_SVC_KEI` table constant |
| 3 | SET | `wkSelectWhereParam[1] = nextRec.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.VA_TAKNKIKI_MODEL_CD)` // VA home device model code — from current phone record row |
| 4 | SET | `wkSelectWhereParam[2] = nextRec.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.VA_KIKI_CHG_NO)` // VA device change number — from current phone record row |

#### Block 4.2 — CALL (Second select execution) (L489–490)

> Execute query on equipment-provided service contracts and fetch first result.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_KKTK_SVC_KEI_KK_SELECT_129(wkSelectWhereParam)` // Execute select query on KK_T_KKTK_SVC_KEI |
| 2 | SET | `nextRec = db_KK_T_KKTK_SVC_KEI.selectNext()` // Fetch first result row; reuses nextRec variable |

#### Block 5 — WHILE (Inner loop: iterate equipment-provided service contracts) (L492)

> Iterate over all equipment-provided service contracts matching the service contract number, VA device model code, and device change number.

| # | Type | Code |
|---|------|------|
| 1 | IF | `while (nextRec != null)` [L492] — Continue processing while there are matching equipment contracts |

##### Block 5.1 — Nested body (when nextRec != null) (L494)

> For each equipment-provided service contract, check the returned equipment table for any records.
> Japanese comment: `SQLパラメータの設定` — "SQL parameter setup"

| # | Type | Code |
|---|------|------|
| 1 | SET | `SelectWhereParam = new Object[2]` // Allocate SQL WHERE parameter array of size 2 |
| 2 | SET | `SelectWhereParam[0] = nextRec.getString(JBSbatKK_T_KKTK_SVC_KEI.KKTK_SVC_KEI_NO)` // Equipment-provided service contract number — from current equipment contract row |
| 3 | SET | `SelectWhereParam[1] = nextRec.getString(JBSbatKK_T_KKTK_SVC_KEI.KIKI_CHG_NO)` // Device change number — from current equipment contract row |

##### Block 5.2 — CALL (Third select execution) (L496–497)

> Execute query on returned equipment table and fetch first result.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeDK_T_HMPIN_KIKI_KK_SELECT_003(SelectWhereParam)` // Execute select query on DK_T_HMPIN_KIKI |
| 2 | SET | `nextRec = db_DK_T_HMPIN_KIKI.selectNext()` // Fetch first result row; reuses nextRec variable |

##### Block 6 — IF (Return equipment existence check) (L499)

> If a returned equipment record exists, the device is in the return pipeline and must be excluded from deletion.
> This is the **termination condition** of the entire method — the moment any returned equipment record is found, the method immediately returns `true`.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (nextRec != null)` [L499] — A returned equipment record exists |

###### Block 6.1 — RETURN (Exclusion confirmed) (L500)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true` // Deletion excluded — returned equipment found |

###### Block 6.2 — ELSE (implicit fall-through) (L501)

> No matching returned equipment for this equipment contract. Continue the inner loop to check the next equipment contract.

### Block 7 — Implicit ELSE of inner WHILE (L502)

> No more equipment-provided service contracts to check. Continue the outer loop to check the next VA device phone record.

### Block 8 — Implicit ELSE of outer WHILE (L504)

> No more VA device phone records to check. All traversals completed without finding any returned equipment.

### Block 9 — RETURN (No deletion exclusion found) (L505)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return false` // No returned equipment found in any path — record is eligible for deletion |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `SVC_KEI_UCWK_NO` | Field | Service contract line item number — internal tracking ID for a specific line item within a service contract. Links to `KK_T_SVC_KEI_UCWK` table. |
| `SVC_KEI_NO` | Field | Service contract number — top-level service contract identifier. Links to `KK_T_SVC_KEI` table. |
| `TELNO` | Field | Telephone number — the customer's contact phone number associated with a VA home device. |
| `VA_TAKNKIKI_MODEL_CD` | Field | VA home device model code — identifies the type/model of a Virtual Appliance home-connected device. |
| `VA_KIKI_CHG_NO` | Field | VA device change number — a sequence/identifier for device changes or replacements associated with a VA home device. |
| `KKTK_SVC_KEI_NO` | Field | Equipment-provided service contract number — links equipment-provided service contracts (`KK_T_KKTK_SVC_KEI`) to specific devices. |
| `KIKI_CHG_NO` | Field | Device change number — tracks equipment changes for equipment-provided service contracts. |
| `KK_T_SVKEIUW_EOH_TEL` | Table | VA Home Device Phone table — stores phone number records associated with VA (Virtual Appliance) home-connected equipment. |
| `KK_T_KKTK_SVC_KEI` | Table | Equipment-Provided Service Contract table — stores contracts for devices provided by the operator (e.g., router, set-top box). |
| `DK_T_HMPIN_KIKI` | Table | Returned Equipment table — stores records of equipment that has been returned (hmpin = 返品) and is in the recycling/refurbishment pipeline. |
| `KK_T_SVC_KEI_UCWK` | Table | Service Contract Line Item table — stores detailed line items within a service contract, including pricing and plan information. |
| HMPIN | Japanese term | 返品 (Henten) — Return. Refers to equipment returned by the customer for recycling, refurbishment, or warranty. |
| 消去対象外 (shojiotaigai) | Japanese term | "Not a deletion target" — the record should NOT be deleted. When `isDelTrgtNoDataTel` returns `true`, the phone number is excluded from batch deletion. |
| 消去対象 (shojiotaigai) | Japanese term | "Deletion target" — the record IS eligible for deletion. When `isDelTrgtNoDataTel` returns `false`, the phone number can be safely deleted. |
| VA | Acronym | Virtual Appliance — a home-connected network device (e.g., router, modem) that provides internet connectivity. |
| `JBSbatServiceInterfaceMap` | Class | Service interface map — a key-value container used to pass batch processing context and input data between CBS (Component Business Service) methods. |
| `JBSbatCommonDBInterface` | Interface | Common DB interface — the abstraction for executing SQL queries and iterating result sets in the batch framework. |
| `selectNext()` | Method | Fetches the next row from a previously executed query's result set. Returns `null` when no more rows exist. |
