# Business Logic — JBSbatKKSvkeiuwDelTgCst.setDelTrgtDataIn() [74 LOC]

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

## 1. Role

### JBSbatKKSvkeiuwDelTgCst.setDelTrgtDataIn()

This method configures deletion target data for **internet services** (the Javadoc states: "削除対象データ設定処理（インターネットサービス）" — Deletion target data setup processing for internet services). It is one of several overloaded variants of the deletion target data configuration logic in `JBSbatKKSvkeiuwDelTgCst`, each handling a different service type (telephone, internet, etc.). The batch system `eo` customer base system uses this method during the service contract cancellation / deletion workflow to determine which ISP authentication IDs qualify for deletion processing.

The method implements a **filter-and-route pattern**: it queries the `KK_T_SVKEIUW_EOH_NET` table for existing ISP authentication records associated with a given service contract detail number, then checks whether the corresponding deletion Service Order Data (SOD) has already been issued via `isAddSodHakCfmTrn()`. Only records with an already-issued deletion SOD proceed to the output stage, preventing duplicate deletion processing.

It also enforces an **aging gate** by consulting the `ZM_M_WORK_PARAM_KNRI` system parameter table to retrieve the permissible usage period count for old authentication IDs during address changes (`KK_OLDNISID_YYDAYCNT`). If the service end date has passed beyond this aging threshold, the method exits early without producing output — ensuring customers are not prematurely deleted while still within a permissible post-end-date grace period.

The method constructs an output record (`JBSbatServiceInterfaceMap`) with the deletion processing type set to `DEL_TRAN_SBT_SOD_AGING_UPD` ("3" — delete SOD issuance + aging update, introduced in change request IT1-2013-0000285 on 2013/02/13), and the deletion target type set to `DEL_TRGT_SBT_OLD_ISP_NINSHO_ID` ("02" — old ISP authentication ID). This output is appended to the `outputBean`'s list for downstream processing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setDelTrgtDataIn(params)"])

    START --> INIT["Initialize: outmap, nextRec, svcEndYmd, cschJiOldNinshoIdUseYuyoNisu"]

    INIT --> SETPARAM["Set SQL params: KK_OLDNISID_YYDAYCNT, opeDate x2"]

    SETPARAM --> CALLWORK["Call executeZM_M_WORK_PARAM_KNRI_KK_SELECT_017"]

    CALLWORK --> SELECTWORK["Select: db_ZM_M_WORK_PARAM_KNRI.selectNext()"]

    SELECTWORK --> CHKWORK{"nextRec != null?"}

    CHKWORK -->|No| EXIT(["Return / end"])

    CHKWORK -->|Yes| GETENDYMD["Get svcEndYmd from inMap[SVC_ENDYMD]"]

    GETENDYMD --> GETNISU["Get cschJiOldNinshoIdUseYuyoNisu from nextRec[WORK_PARAM_SETTE_VALUE]"]

    GETNISU --> CHECKAGE{"isOverDate(svcEndYmd, cschJiOldNinshoIdUseYuyoNisu)?"}

    CHECKAGE -->|true| EXIT

    CHECKAGE -->|false| SETISP["Set SQL params: SVC_KEI_UCWK_NO, UCWK_GENE"]

    SETISP --> CALLISP["Call executeKK_T_SVKEIUW_EOH_NET_SELECT_006"]

    CALLISP --> SELECTISP["Select: db_KK_T_SVKEIUW_EOH_NET.selectNext()"]

    SELECTISP --> CHKISP{"nextRec != null?"}

    CHKISP -->|No| EXIT

    CHKISP -->|Yes| CHECKSOD{"isAddSodHakCfmTrn(inMap)?"}

    CHECKSOD -->|false| EXIT

    CHECKSOD -->|true| SETMAP["Set outmap: DEL_TRAN_SBT=3, DEL_TRGT_SBT=02, SVKEI_NO, SVKEI_GADTM, SVKEIUW_NO, SVKEIUW_GADTM, ISP_NINSHO_ID"]

    SETMAP --> SETFLG["Set outmap.setOutFlg(true)"]

    SETFLG --> ADDOUT["outputBean.addOutMapList(outmap)"]

    ADDOUT --> EXIT
```

**Branch Summary:**

1. **System parameter lookup** (L235-245): Retrieves the aging threshold for old authentication IDs from the work parameter table. If no parameter record exists, processing terminates silently.
2. **Service end date aging check** (L250-257): Compares the service end date (`svcEndYmd`) against the configured permissible usage period (`cschJiOldNinshoIdUseYuyoNisu`). If the end date has expired beyond the grace period, no deletion output is produced.
3. **ISP authentication record lookup** (L261-270): Queries the `KK_T_SVKEIUW_EOH_NET` table using the service contract detail number and generation timestamp to find an existing ISP authentication ID.
4. **Deletion SOD issuance gate** (L272-293): Only if a deletion SOD has already been issued (`isAddSodHakCfmTrn` returns true), the method populates the output map with deletion processing type `3` and target type `02`, then adds it to the output bean.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | The input message map carrying source data for internet service deletion processing. Contains the service contract number (`SVC_KEI_NO`), service contract detail number (`SVC_KEI_UCWK_NO`), service end date (`SVC_ENDYMD`), generation timestamp (`UCWK_GENE`), and other fields that identify the specific service contract line item targeted for deletion. |
| 2 | `outputBean` | `JBSbatOutputItem` | The output accumulator. Deletion target records are appended here via `addOutMapList()`. Downstream processing will iterate over this bean's output list to perform actual ISP authentication ID deletion operations. |
| 3 | `tempHakkoParam` | `HashMap<Integer, String>` | Temporary parameters for issuance-related state. This parameter is **not used** within this method body (it is a leftover/unused parameter from method signature alignment with other overloaded variants). |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_ZM_M_WORK_PARAM_KNRI` | `JBSbatSQLAccess` | SQL access handle for the `ZM_M_WORK_PARAM_KNRI` work parameter table. Used to retrieve the aging threshold value. |
| `db_KK_T_SVKEIUW_EOH_NET` | `JBSbatSQLAccess` | SQL access handle for the `KK_T_SVKEIUW_EOH_NET` table. Used to query existing ISP authentication IDs. |
| `opeDate` | `String` | The operational date (inherited from parent class), used as a query parameter when looking up system parameters. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKSvkeiuwDelTgCst.executeZM_M_WORK_PARAM_KNRI_KK_SELECT_017` | ZM_M_WORK_PARAM_KNRI | `ZM_M_WORK_PARAM_KNRI` | Queries the work parameter table to retrieve the aging threshold (`KK_OLDNISID_YYDAYCNT`) for old authentication ID permissible usage period. |
| R | `JBSbatZM_M_WORK_PARAM_KNRI.getString` | - | - | Reads `WORK_PARAM_SETTE_VALUE` from the parameter result set to extract the numeric grace period days. |
| R | `JBSbatKKSvkeiuwDelTgCst.executeKK_T_SVKEIUW_EOH_NET_KK_SELECT_006` | KK_T_SVKEIUW_EOH_NET | `KK_T_SVKEIUW_EOH_NET` | Queries the ISP authentication net information table to find an existing ISP authentication ID for the given service contract detail. |
| R | `JBSbatKK_T_SVKEIUW_EOH_NET.getString` | - | - | Reads `ISP_NINSHO_ID` (ISP authentication ID) from the result set. |
| R | `JBSbatKK_T_SVC_KEI.getString` | - | - | Reads `SVC_ENDYMD` (service end date), `SVC_KEI_NO` (service contract number), and `GENE_ADD_DTM` (service contract generation timestamp). |
| R | `JBSbatKK_T_SVC_KEI_UCWK.getString` | - | - | Reads `SVC_KEI_UCWK_NO` (service contract detail number) from the input map. |
| R | `JBSbatKKSvkeiuwDelTgCst.isAddSodHakCfmTrn` | - | - | Checks whether a deletion SOD (Service Order Data) has already been issued for this service contract. Returns true only when deletion SOD is pending/issued. |
| U | `JBSbatServiceInterfaceMap.setString` | - | - | Populates the output map fields: deletion processing type, deletion target type, service numbers, timestamps, and ISP authentication ID. |
| U | `JBSbatServiceInterfaceMap.setOutFlg` | - | - | Sets the output flag to `true`, indicating this is a valid deletion target record. |
| C | `JBSbatOutputItem.addOutMapList` | - | - | Appends the constructed output record to the batch output list for downstream processing. |

## 5. Dependency Trace

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

Direct callers found: 1 methods.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKSvkeiuwDelTgCst` | `JBSbatKKSvkeiuwDelTgCst.execute()` -> `JBSbatKKSvkeiuwDelTgCst.setDelTrgtDataIn()` | `addOutMapList [C]`, `setOutFlg [U]`, `setString [U]`, `getString [R]`, `executeKK_T_SVKEIUW_EOH_NET_SELECT_006 [R]`, `executeZM_M_WORK_PARAM_KNRI_SELECT_017 [R]`, `isAddSodHakCfmTrn [R]` |

**Downstream impact:** The output records produced by this method flow into the deletion processing pipeline (`JBSbatKKDelRun` and related CBS components), where records with `DEL_TRAN_SBT=3` and `DEL_TRGT_SBT=02` trigger ISP authentication ID deletion operations against the `KK_T_SVKEIUW_EOH_NET` table.

## 6. Per-Branch Detail Blocks

### Block 1 — INITIALIZATION (L230)

> Initializes local variables and the output map.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outmap = new JBSbatServiceInterfaceMap()` // Create output record — 出力レコード [-> output message creation] |
| 2 | SET | `nextRec = null` // Result set cursor |
| 3 | SET | `cschJiOldNinshoIdUseYuyoNisu = ""` // Old auth ID usage period [-> 旧認証ID利用許容日数] |
| 4 | SET | `svcEndYmd = ""` // Service end date [-> サービス終了年月日] |

### Block 2 — IF: `nextRec != null` (Aging parameter check) (L247)

> Branch: Only proceeds if the work parameter lookup succeeded. Retrieves the aging threshold and service end date.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workSelectWhereParam = new Object[3]` // 3-element SQL parameter array |
| 2 | SET | `workSelectWhereParam[0] = "KK_OLDNISID_YYDAYCNT"` // Business parameter ID — 業務パラメータID [-> KK_OLDNISID_YYDAYCNT = business parameter ID for old auth ID grace days] |
| 3 | SET | `workSelectWhereParam[1] = super.opeDate` // Operational date [-> 運用日] |
| 4 | SET | `workSelectWhereParam[2] = super.opeDate` // Operational date (duplicated) |
| 5 | CALL | `executeZM_M_WORK_PARAM_KNRI_KK_SELECT_017(workSelectWhereParam)` // Query work parameter table |
| 6 | EXEC | `nextRec = db_ZM_M_WORK_PARAM_KNRI.selectNext()` // Fetch the parameter result row |
| 7 | SET | `svcEndYmd = inMap.getString(JBSbatKK_T_SVC_KEI.SVC_ENDYMD)` // Service end date — サービス終了年月日 |
| 8 | SET | `cschJiOldNinshoIdUseYuyoNisu = nextRec.getString(JBSbatZM_M_WORK_PARAM_KNRI.WORK_PARAM_SETTE_VALUE)` // Aging threshold — コース変更時旧認証ID利用許容日数 |

### Block 2.1 — IF: `isOverDate(svcEndYmd, cschJiOldNinshoIdUseYuyoNisu)` (L252)

> If the service end date has passed the permissible aging period (configured in the work parameter table), exit without producing deletion output. This is a safety gate to prevent premature deletion of services that are still within their grace period.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isOverDate(svcEndYmd, cschJiOldNinshoIdUseYuyoNisu)` // Check if end date exceeds aging threshold |
| 2 | RETURN | `return` // Early exit — no deletion output produced |

### Block 3 — IF: `nextRec != null` (ISP authentication record lookup) (L261)

> Branch: Only proceeds if an ISP authentication record exists for this service contract detail number. Queries the `KK_T_SVKEIUW_EOH_NET` table.

| # | Type | Code |
|---|------|------|
| 1 | SET | `selectWhereParam = new Object[3]` // 3-element SQL parameter array |
| 2 | SET | `selectWhereParam[0] = inMap.getString(JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_UCWK_NO)` // Service contract detail number — サービス契約内訳番号 |
| 3 | SET | `selectWhereParam[1] = inMap.getString("UCWK_GENE")` // Generation timestamp (modified) — 世代登録年月日秒時 [-> MOD START: changed from JBSbatKK_T_SVC_KEI_UCWK.GENE_ADD_DTM to hardcoded string "UCWK_GENE"] |
| 4 | CALL | `executeKK_T_SVKEIUW_EOH_NET_SELECT_006(selectWhereParam)` // Query ISP auth net info table |
| 5 | EXEC | `nextRec = db_KK_T_SVKEIUW_EOH_NET.selectNext()` // Fetch ISP authentication record |

### Block 3.1 — IF: `nextRec != null` (ISP record found) (L271)

> Branch: An ISP authentication record was found. Now check if deletion SOD has been issued.

### Block 3.1.1 — IF: `isAddSodHakCfmTrn(inMap)` (Deletion SOD gate) (L272)

> Only process if the deletion SOD has already been issued. The Javadoc comment states: "対象のISP認証IDの登録SODが発行済みの場合のみ出力する。" (Only output if the deletion SOD for the target ISP authentication ID has already been issued).

| # | Type | Code |
|---|------|------|
| 1 | SET | `outmap.setString(JBSbatKKIFM160.DEL_TRAN_SBT, DEL_TRAN_SBT_SOD_AGING_UPD)` // Delete processing type — 消去処理種別 [-> `DEL_TRAN_SBT_SOD_AGING_UPD = "3"` (Delete SOD issuance + aging update) — introduced by IT1-2013-0000285 2013/02/13] |
| 2 | SET | `outmap.setString(JBSbatKKIFM160.DEL_TRGT_SBT, DEL_TRGT_SBT_OLD_ISP_NINSHO_ID)` // Delete target type — 消去対象種別 [-> `DEL_TRGT_SBT_OLD_ISP_NINSHO_ID = "02"` (Old ISP authentication ID)] |
| 3 | SET | `outmap.setString(JBSbatKKIFM160.SVKEI_NO, inMap.getString(JBSbatKK_T_SVC_KEI.SVC_KEI_NO))` // Service contract number — サービス契約番号 |
| 4 | SET | `outmap.setString(JBSbatKKIFM160.SVKEI_GADTM, inMap.getString(JBSbatKK_T_SVC_KEI.GENE_ADD_DTM))` // Service contract generation timestamp — サービス契約世代登録年月日秒時 |
| 5 | SET | `outmap.setString(JBSbatKKIFM160.SVKEIUW_NO, inMap.getString(JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_UCWK_NO))` // Service contract detail number — サービス契約内訳番号 |
| 6 | SET | `outmap.setString(JBSbatKKIFM160.SVKEIUW_GADTM, inMap.getString("UCWK_GENE"))` // Service contract detail generation timestamp — サービス契約内訳世代登録年月日秒時 [-> MOD START: changed from JBSbatKK_T_SVC_KEI_UCWK.GENE_ADD_DTM to hardcoded string "UCWK_GENE"] |
| 7 | SET | `outmap.setString(JBSbatKKIFM160.ISP_NINSHO_ID, nextRec.getString(JBSbatKK_T_SVKEIUW_EOH_NET.ISP_NINSHO_ID))` // ISP authentication ID — ISP認証ID |
| 8 | EXEC | `outmap.setOutFlg(true)` // Set output flag to true |
| 9 | CALL | `outputBean.addOutMapList(outmap)` // Append output record to batch output list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `setDelTrgtDataIn` | Method | Deletion target data setup processing — configures which records should be included in a batch deletion run |
| `SVC_ENDYMD` | Field | Service end date — the date when the service contract ends, used for aging calculations |
| `SVC_KEI_NO` | Field | Service contract number — the unique identifier for a service contract (e.g., fiber internet plan) |
| `SVC_KEI_UCWK_NO` | Field | Service contract detail number — identifies a specific line item within a service contract |
| `GENE_ADD_DTM` / `UCWK_GENE` | Field | Generation registration timestamp — the date/time when the service contract or detail was registered/generated |
| `ISP_NINSHO_ID` | Field | ISP authentication ID — the authentication credential for an Internet Service Provider connection |
| `KK_OLDNISID_YYDAYCNT` | Field | Business parameter ID — system parameter key for configuring the permissible usage period (in days) of old authentication IDs during address changes |
| `WORK_PARAM_SETTE_VALUE` | Field | Work parameter set value — the numeric value stored in the work parameter table (e.g., number of grace days) |
| `DEL_TRAN_SBT` | Field | Delete processing type — classifies the type of deletion operation to perform |
| `DEL_TRGT_SBT` | Field | Delete target type — classifies which type of data is the deletion target |
| `DEL_TRAN_SBT_SOD` | Constant | Delete processing type = "1" — Delete SOD issuance |
| `DEL_TRAN_SBT_AGING_UPD` | Constant | Delete processing type = "2" — Aging update (graduated update) |
| `DEL_TRAN_SBT_SOD_AGING_UPD` | Constant | Delete processing type = "3" — Delete SOD issuance + aging update (combined operation) |
| `DEL_TRGT_SBT_OLD_ISP_NINSHO_ID` | Constant | Delete target type = "02" — Old ISP authentication ID |
| SOD | Acronym | Service Order Data — a service order document generated for provisioning or deletion of telecom services |
| ISP | Acronym | Internet Service Provider — provides internet connectivity services |
| Aging (アップデート) | Business term | A processing mode where data is not immediately deleted but flagged for aging-based deletion, allowing a grace period after service end |
| 旧認証ID利用許容日数 | Japanese field (translation: old authentication ID permissible usage days) | The number of days an old ISP authentication ID remains valid after an address change or service update before it can be deleted |
| IT1-2013-0000285 | Change request | A 2013/02/13 modification that introduced the combined deletion type `DEL_TRAN_SBT_SOD_AGING_UPD` ("3"), changing from pure deletion SOD issuance to a combined approach |
| KK_T_SVKEIUW_EOH_NET | Table | Internet service contract deletion target table — stores ISP authentication information for internet service contracts |
| ZM_M_WORK_PARAM_KNRI | Table | Work parameter management table — stores configurable system parameters used across batch processing |
| JBSbatServiceInterfaceMap | Class | Service batch interface map — a map-based data carrier for passing structured data between batch processing components |
| JBSbatOutputItem | Class | Service batch output item — accumulates output records for downstream batch processing |
| `isAddSodHakCfmTrn` | Method | Checks whether a deletion SOD has already been issued for the given service contract |
| `isOverDate` | Method | Determines whether a date exceeds a specified period count from a reference point |
| `opeDate` | Field | Operational date — the batch processing date, inherited from the parent batch service class |
