# Business Logic — JBSbatKKSvkeiDelTgCst.setDelTrgtDataTel() [57 LOC]

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

## 1. Role

### JBSbatKKSvkeiDelTgCst.setDelTrgtDataTel()

This method performs **delete-target data setup processing for telephone services** (Japanese: 消去対象データ設定処理(電話サービス)). It is responsible for iterating over the PPP authentication ID records associated with a given service contract and building output records that identify which PPP authentication IDs should be flagged for deletion as part of a service termination workflow. Specifically, it queries the `T_SVC_KEI_EOH_TEL` table (telephone service contract ending data) for PPP authentication IDs matching the input service contract, extracts relevant fields, and populates an output map with delete-target classification data. The method implements a **routing/dispatch pattern** — it reads each PPP record, enriches it with service-level metadata, computes the delete operation type by delegating to `getDelTranSbt()`, and then conditionally includes the record in the final output only when the delete operation type matches `DEL_TRAN_SBT_SOD_AGING_UPD` ("3", meaning "delete SOD issuance / aging update"). This ensures that only PPP authentication IDs backed by already-issued SOD (Service Order Data) records are propagated downstream for deletion processing. The method operates as a **shared utility** within the service deletion cascade, invoked by `JBSbatKKSvkeiDelTgCst.execute()` and serving telephone-service-specific deletion target identification.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setDelTrgtDataTel(inMap, outputBean, selectWhereParam, tempHakkoParam)"])

    START --> INIT["Initialize: outmap = null, nextRec = null"]

    INIT --> EXEC_SELECT["Call executeKK_T_SVC_KEI_EOH_TEL_KK_SELECT_002(selectWhereParam)"]

    EXEC_SELECT --> GET_NEXT["Call db_KK_T_SVC_KEI_EOH_TEL.selectNext()"]

    GET_NEXT --> CHECK_NEXT{"nextRec != null?"}

    CHECK_NEXT -->|Yes| NEW_OUTMAP["outmap = new JBSbatServiceInterfaceMap()"]

    NEW_OUTMAP --> EXTRACT["Extract: svkeiNo from inMap svkeiGadtm from inMap pppNinshoId from nextRec"]

    EXTRACT --> CHECK_TEMP{"tempHakkoParam != null?"}

    CHECK_TEMP -->|Yes| FILL_PARAMS["Fill tempHakkoParam: HAKKO_PARAM_IDX_SVKEI_NO=0 -> svkeiNo HAKKO_PARAM_IDX_SBT_CD=2 -> ORDER_SBT_CD_TEL=2 HAKKO_PARAM_IDX_SVC_ORDER_CD=3 -> SVC_ORDER_CD_FTTH_RADIUS=23"]

    CHECK_TEMP -->|No| SKIP_FILL["Skip tempHakkoParam fill"]

    FILL_PARAMS --> SET_OUT[["Set outmap: DEL_TRAN_SBT=getDelTranSbt(tempHakkoParam) DEL_TRGT_SBT=DEL_TRGT_SBT_PPP_NINSHO_ID=06 SVKEI_NO=svkeiNo SVKEI_GADTM=svkeiGadtm PPP_NINSHO_ID=pppNinshoId setOutFlg(true)"]]

    SKIP_FILL --> SET_OUT

    SET_OUT --> CHECK_DEL_TYPE{"DEL_TRAN_SBT equals DEL_TRAN_SBT_SOD_AGING_UPD=3?"}

    CHECK_DEL_TYPE -->|Yes| ADD_OUTPUT["outputBean.addOutMapList(outmap)"]

    CHECK_DEL_TYPE -->|No| FILTERED["Record filtered out - not added to output"]

    ADD_OUTPUT --> GET_NEXT_REC["Call db_KK_T_SVC_KEI_EOH_TEL.selectNext()"]

    GET_NEXT_REC --> CHECK_NEXT

    CHECK_NEXT -->|No| END_NODE(["Return"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input data map carrying service contract header information, including the service contract number (`svc_kei_no`) and service contract generation registration datetime (`gene_add_dtm`). These values are extracted per iteration and copied into the output record. |
| 2 | `outputBean` | `JBSbatOutputItem` | The output collection into which validated delete-target records are appended via `addOutMapList()`. Only PPP authentication IDs whose computed delete operation type matches the SOD aging update condition are added here. |
| 3 | `selectWhereParam` | `Object[]` | SQL WHERE clause parameters used by `executeKK_T_SVC_KEI_EOH_TEL_KK_SELECT_002()` to filter the `T_SVC_KEI_EOH_TEL` table. Typically contains the service contract number to restrict results to a single service. |
| 4 | `tempHakkoParam` | `HashMap<Integer, String>` | Temporary issuance-condition parameter map used to carry order-level metadata (service contract number, order subtype code, service order code) to downstream processing via `getDelTranSbt()`. If `null`, the enrichment step is skipped but deletion-target data is still produced. |

**Instance fields / external state read:**
- `db_KK_T_SVC_KEI_EOH_TEL` — Database interface for the telephone service contract ending data table, used to call `selectNext()` and iterate over PPP authentication ID records.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKSvkeiDelTgCst.executeKK_T_SVC_KEI_EOH_TEL_KK_SELECT_002` | (internal) | `KK_T_SVC_KEI_EOH_TEL` | Executes a database SELECT on the telephone service contract ending data table using the provided WHERE parameters. Initializes a cursor for iteration via `selectNext()`. |
| R | `JBSbatCommonDBInterface.selectNext` | (internal) | `KK_T_SVC_KEI_EOH_TEL` | Retrieves the next row from the result set opened by the SELECT call. Called in a while-loop to iterate over all matching PPP authentication ID records. |
| R | `JBSbatKK_T_SVC_KEI.getString` | (internal) | - | Extracts the service contract number (`SVC_KEI_NO`) from `inMap` using the field constant. |
| R | `JBSbatKK_T_SVC_KEI.getString` | (internal) | - | Extracts the service contract generation registration datetime (`GENE_ADD_DTM`) from `inMap`. |
| R | `JBSbatCommonDBInterface.getString` | (internal) | - | Extracts the PPP authentication ID (`PPP_NINSHO_ID`) from the current database row (`nextRec`). |
| C | `HashMap.put` | (internal) | - | Populates the `tempHakkoParam` map with service contract number, order subtype code, and service order code for downstream delete-type computation. |
| R | `JBSbatKKSvkeiDelTgCst.getDelTranSbt` | (internal) | - | Delegates to determine the delete operation type by examining `tempHakkoParam`. Returns a code indicating how the deletion should be processed. |
| U | `JBSbatServiceInterfaceMap.setString` | (internal) | - | Sets delete operation type, delete-target subtype, service contract number, service contract generation datetime, and PPP authentication ID into the output map. |
| U | `JBSbatServiceInterfaceMap.setOutFlg` | (internal) | - | Marks the output record as valid/ready for output by setting the flag to `true`. |
| C | `JBSbatOutputItem.addOutMapList` | (internal) | - | Appends the completed output record to the batch output collection if the delete operation type matches the SOD aging update condition. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKSvkeiDelTgCst.execute()` | `JBSbatKKSvkeiDelTgCst.execute()` -> `JBSbatKKSvkeiDelTgCst.setDelTrgtDataTel` | `addOutMapList [C]`, `setOutFlg [-]`, `setString [-]` |

**Note:** No screen/batch entry points were found within 8 hops. The only direct caller is the sibling method `execute()` within the same class `JBSbatKKSvkeiDelTgCst`, which serves as the batch entry point for service contract deletion processing.

**Terminal operations from this method:** `addOutMapList` [C], `setOutFlg` [-], `setOutFlg` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-]

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] (L406-407)

> Variable initialization — declares local output map and database cursor. A code review note (IT1-2013-0000285) indicates that the `outmap` initialization was moved inside the loop to prevent stale data issues when `outmap` was previously reused across iterations.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outmap = null` // Output record holder (moved inside loop per IT1-2013-0000285) |
| 2 | SET | `nextRec = null` // Database cursor for T_SVC_KEI_EOH_TEL rows |

**Block 2** — [EXEC] (L411)

> Executes the database SELECT to retrieve PPP authentication ID records for the telephone service. The SQL parameters come from `selectWhereParam`.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_SVC_KEI_EOH_TEL_KK_SELECT_002(selectWhereParam)` // PPP authentication ID acquisition (PPP認証IDの取得) |

**Block 3** — [EXEC] (L413)

> Retrieves the first row from the query result set to begin iteration.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `nextRec = db_KK_T_SVC_KEI_EOH_TEL.selectNext()` |

**Block 4** — [WHILE] `(nextRec != null)` (L415)

> Iterates over all PPP authentication ID records returned by the SELECT. For each record, a new output map is created and populated with delete-target classification data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outmap = new JBSbatServiceInterfaceMap()` // Initialize output record area (出力レコード領域の初期化) |
| 2 | CALL | (nested blocks below) |

**Block 4.1** — [SET] (L417-419)

> Extracts business-relevant fields from the input map and the current database row. These represent the service contract identity and its associated PPP authentication ID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svkeiNo = inMap.getString(JBSbatKK_T_SVC_KEI.SVC_KEI_NO)` // Service contract number (サービス契約番号) |
| 2 | SET | `svkeiGadtm = inMap.getString(JBSbatKK_T_SVC_KEI.GENE_ADD_DTM)` // Service contract generation registration datetime (サービス契約世代登録年月日时分秒) |
| 3 | SET | `pppNinshoId = nextRec.getString(JBSbatKK_T_SVC_KEI_EOH_TEL.PPP_NINSHO_ID)` // PPP authentication ID (PPP認証ID) |

**Block 4.2** — [IF] `(tempHakkoParam != null)` (L422)

> Conditionally enriches the temporary issuance parameter map with order-level metadata. This data is used by `getDelTranSbt()` to determine the delete operation type. If `tempHakkoParam` is `null`, this enrichment is skipped entirely.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `tempHakkoParam.put(HAKKO_PARAM_IDX_SVKEI_NO, svkeiNo)` // Service contract number [-> HAKKO_PARAM_IDX_SVKEI_NO=0] |
| 2 | EXEC | `tempHakkoParam.put(HAKKO_PARAM_IDX_SBT_CD, JBSbatKKConst.ORDER_SBT_CD_TEL)` // Order subtype code [-> HAKKO_PARAM_IDX_SBT_CD=2, ORDER_SBT_CD_TEL="2" (Telecom)] |
| 3 | EXEC | `tempHakkoParam.put(HAKKO_PARAM_IDX_SVC_ORDER_CD, JBSbatKKConst.SVC_ORDER_CD_FTTH_RADIUS)` // Service order code [-> HAKKO_PARAM_IDX_SVC_ORDER_CD=3, SVC_ORDER_CD_FTTH_RADIUS="23" (FTTH Authentication)] |

**Block 4.3** — [SET] (L427-432)

> Populates the output map with delete-target classification data. The delete operation type is computed by delegating to `getDelTranSbt()`, which examines `tempHakkoParam` to determine the appropriate deletion code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outmap.setString(JBSbatKKIFM160.DEL_TRAN_SBT, getDelTranSbt(tempHakkoParam))` // Delete operation type (消去処理種類) |
| 2 | SET | `outmap.setString(JBSbatKKIFM160.DEL_TRGT_SBT, DEL_TRGT_SBT_PPP_NINSHO_ID)` // Delete-target subtype [-> DEL_TRGT_SBT_PPP_NINSHO_ID="06" (PPP Authentication ID)] |
| 3 | SET | `outmap.setString(JBSbatKKIFM160.SVKEI_NO, svkeiNo)` // Service contract number (サービス契約番号) |
| 4 | SET | `outmap.setString(JBSbatKKIFM160.SVKEI_GADTM, svkeiGadtm)` // Service contract generation registration datetime (サービス契約世代登録年月日时分秒) |
| 5 | SET | `outmap.setString(JBSbatKKIFM160.PPP_NINSHO_ID, pppNinshoId)` // PPP authentication ID (PPP認証ID) |
| 6 | EXEC | `outmap.setOutFlg(true)` // Mark record as valid for output |

**Block 4.4** — [IF] `(outmap.get(JBSbatKKIFM160.DEL_TRAN_SBT).equals(DEL_TRAN_SBT_SOD_AGING_UPD))` `[DEL_TRAN_SBT_SOD_AGING_UPD="3"]` (L448)

> **Critical filtering condition:** Only includes the output record when the computed delete operation type equals `"3"` (Delete SOD issuance / aging update — 消去SOD発行・エイジング更新). A code review note (IT1-2013-0000285) indicates this was changed from the original `DEL_TRAN_SBT_SOD` ("1", Delete SOD issuance) to the more specific `DEL_TRAN_SBT_SOD_AGING_UPD` ("3"), ensuring that only PPP authentication IDs whose backing SOD record has already been issued and aged are propagated. The original Japanese comment states: "Only output if the SOD for the target PPP authentication ID has already been issued" (対象のPPP認証IDの登録SODが既発行の場合のみ出力する).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outputBean.addOutMapList(outmap)` // Append to output collection — only reached when delete operation type = "3" |

**Block 4.5** — [EXEC] (L454)

> Advances the database cursor to the next record, maintaining the while-loop iteration.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `nextRec = db_KK_T_SVC_KEI_EOH_TEL.selectNext()` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `setDelTrgtDataTel` | Method | Delete-target data setup processing for telephone services — builds output records for PPP authentication IDs flagged for deletion during service termination. Japanese: 消去対象データ設定処理(電話サービス) |
| `svc_kei_no` / `SVKEI_NO` | Field | Service contract number — unique identifier for a customer's service contract line item. Japanese: サービス契約番号 |
| `gene_add_dtm` / `SVKEI_GADTM` | Field | Service contract generation registration datetime — timestamp recording when the service contract version was registered. Japanese: サービス契約世代登録年月日时分秒 |
| `pppNinshoId` / `PPP_NINSHO_ID` | Field | PPP authentication ID — unique identifier for a PPP (Point-to-Point Protocol) authentication credential associated with a telephone service line. Japanese: PPP認証ID |
| `del_tran_sbt` / `DEL_TRAN_SBT` | Field | Delete operation type — classification code indicating how the deletion should be processed. Values: "1" (Delete SOD issuance), "3" (Delete SOD issuance / aging update) |
| `del_trgt_sbt` / `DEL_TRGT_SBT` | Field | Delete-target subtype — classification code indicating which data entity is the deletion target. "06" = PPP Authentication ID |
| `SOD` | Acronym | Service Order Data — telecom order fulfillment entity representing a service request/order record |
| `ORDER_SBT_CD_TEL` | Constant | Order subtype code: "2" (Telecom) — classifies the order as a telephone service order. Japanese: オーダ種別コード（電話） |
| `SVC_ORDER_CD_FTTH_RADIUS` | Constant | Service order code: "23" (FTTH Authentication) — specifies the service order type as FTTH (Fiber To The Home) authentication via RADIUS. Japanese: サービスオーダコード（FTTH認証） |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service |
| `HAKKO_PARAM_IDX_SVKEI_NO` | Constant | Issuance condition parameter index 0 — maps to service contract number in `tempHakkoParam`. Japanese: オーダ発行条件パラメータインデックス（サービス契約番号） |
| `HAKKO_PARAM_IDX_SBT_CD` | Constant | Issuance condition parameter index 2 — maps to order subtype code in `tempHakkoParam`. Japanese: オーダ発行条件パラメータインデックス（オーダ種別コード） |
| `HAKKO_PARAM_IDX_SVC_ORDER_CD` | Constant | Issuance condition parameter index 3 — maps to service order code in `tempHakkoParam`. Japanese: オーダ発行条件パラメータインデックス（サービスオーダコード） |
| `KK_T_SVC_KEI_EOH_TEL` | DB Table | Service contract telephone ending data table — stores telephone service contract termination/ending records, including PPP authentication IDs. Japanese: T_SVC_KEI_EOH_TEL (サービス契約終了電話) |
| `JBSbatServiceInterfaceMap` | Class | Batch service interface map — key-value container used to pass structured data between batch processing components. |
| `JBSbatOutputItem` | Class | Batch output item — collection class into which processed output records are appended via `addOutMapList()`. |
| `JBSbatCommonDBInterface` | Class | Common database interface — provides `selectNext()` for cursor-based iteration over SQL query results. |
