# Business Logic — JBSbatKKDelSavePrdKikData.getShijishoInfSvcKei() [144 LOC]

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

## 1. Role

### JBSbatKKDelSavePrdKikData.getShijishoInfSvcKei()

This method is a core data-gathering routine within the contract deletion batch (`JBSbatKKDelSavePrdKikData`). Its business purpose is to retrieve service-contract-level information — specifically the linkage between service contract numbers (`SVC_KEI_NO`) and system IDs (`SYSID`) for lines under deletion, and to collect detailed data about every service contract attached to those lines. The method acts as a SQL-driven query-and-transform step that populates a shared `shijishoInfList` (instruction-sheet registration info list) used downstream by `addShijishoInf()` to generate batch instruction-sheet records (`insertShijisho`).

The method handles three service categories based on the `SVC_CD` field: Network services (`"01"`), Telephone services (`"02"`), and Television services (`"03"`). For Network and TV services, it resolves legacy ICS codes (`OLD_ICS_KEI_SVC_CD`, `OLD_ICS_PPLAN_CD`) from the `KK_M_OLD_ICS_CD_CHG` mapping table. For Telephone services, it additionally invokes `getTelNoJun()` to determine secondary coax counts, potentially generating an extra instruction-sheet record per telephone line when a second coax exists.

The method implements a routing/dispatch design pattern: it executes a single SQL query against `KK_T_SVC_KEI`, then dispatches each result row into one or more parameter maps (`wkMap2` for base line info, `wkMap3` for service-specific info, optionally `wkMap4` for secondary coax info). It also implements a deduplication pattern — maintaining two check-key lists (`chkKeyList`, `chkKeyList_2`) to prevent duplicate instruction-sheet records from being emitted, addressing IT2-2016-0000001 (instruction-sheet duplicate-key output suppression).

This is a shared data-access utility called by the batch's instruction-sheet registration flow (`addShijishoInf`). It operates within a larger physical-deletion batch pipeline that handles time-limit validation, key acquisition, major-item deletion evidence registration, and CSV output.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getShijishoInfSvcKei"])
    CHECK_EMPTY{key_svc_kei_no.size == 0}
    EARLY_RETURN(["Early return"])
    GET_SQL["Get SQL: KK_T_SVC_KEI_KK_SELECT_323"]
    FIX_IN["Fix IN clause: setInParam"]
    EXEC_SQL["Execute SQL with opeDate x6"]
    RESTORE_SQL["Restore original SQL"]
    FETCH_ROW["Fetch row: dbMap = selectNext()"]
    LOOP_CHECK{dbMap != null}
    DEDUP_INIT["Init chkKeyList, chkKeyList_2"]
    WKMAP2_CREATE["Create wkMap2 with 13 params"]
    CHK_KEY2{Duplicate check: wkChkKey2}
    ADD_WKMAP2["Add to chkKeyList and shijishoInfList"]
    SVC_CD_CHECK{SVC_CD in 01/02/03?}
    WKMAP3_CREATE["Create wkMap3 with 13 params"]
    SVC_CD_01{SVC_CD == 01 Net?}
    SVC_CD_02{SVC_CD == 02 Phone?}
    SVC_CD_03{SVC_CD == 03 TV?}
    PARAM12_01["PARAMETER_12=01; PARAMETER_13=OLD_ICS_KEI_SVC_CD + OLD_ICS_PPLAN_CD"]
    GET_TELNO["Call getTelNoJun"]
    PARAM12_02["PARAMETER_12=02; PARAMETER_13=OLD_ICS_HUKA_SVC_SBT_CD + 00 + telnoJun"]
    TELNO_CHECK{telnoJun == 2?}
    WKMAP4_COPY["Copy wkMap3 to wkMap4"]
    PARAM13_01["PARAMETER_13 = OLD_ICS_HUKA_SVC_SBT_CD + 001"]
    CHK_KEY4{Duplicate check: wkChkKey4}
    ADD_WKMAP4["Add wkMap4 to shijishoInfList"]
    PARAM12_03["PARAMETER_12=03; PARAMETER_13=OLD_ICS_KEI_SVC_CD + OLD_ICS_PPLAN_CD"]
    CHK_KEY3{Duplicate check: wkChkKey3}
    ADD_WKMAP3["Add wkMap3 to shijishoInfList"]
    FETCH_NEXT["Fetch next row"]
    CLOSE_DB["Close DB; Reinitialize"]
    END_RETURN(["Return"])

    START --> CHECK_EMPTY
    CHECK_EMPTY -->|Yes| EARLY_RETURN
    CHECK_EMPTY -->|No| GET_SQL
    GET_SQL --> FIX_IN
    FIX_IN --> EXEC_SQL
    EXEC_SQL --> RESTORE_SQL
    RESTORE_SQL --> FETCH_ROW
    FETCH_ROW --> LOOP_CHECK
    LOOP_CHECK -->|true| DEDUP_INIT
    DEDUP_INIT --> WKMAP2_CREATE
    WKMAP2_CREATE --> CHK_KEY2
    CHK_KEY2 -->|No| ADD_WKMAP2
    CHK_KEY2 -->|Yes| SVC_CD_CHECK
    ADD_WKMAP2 --> SVC_CD_CHECK
    SVC_CD_CHECK -->|Yes| SVC_CD_01
    SVC_CD_01 --> PARAM12_01
    PARAM12_01 --> CHK_KEY3
    SVC_CD_02 --> GET_TELNO
    GET_TELNO --> PARAM12_02
    PARAM12_02 --> TELNO_CHECK
    TELNO_CHECK -->|Yes| WKMAP4_COPY
    TELNO_CHECK -->|No| CHK_KEY3
    WKMAP4_COPY --> PARAM13_01
    PARAM13_01 --> CHK_KEY4
    CHK_KEY4 -->|No| ADD_WKMAP4
    CHK_KEY4 -->|Yes| CHK_KEY3
    ADD_WKMAP4 --> FETCH_NEXT
    SVC_CD_03 --> PARAM12_03
    PARAM12_03 --> CHK_KEY3
    CHK_KEY3 -->|No| ADD_WKMAP3
    CHK_KEY3 -->|Yes| FETCH_NEXT
    ADD_WKMAP3 --> FETCH_NEXT
    FETCH_NEXT --> LOOP_CHECK
    LOOP_CHECK -->|false| CLOSE_DB
    CLOSE_DB --> END_RETURN
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key_svc_kei_no` | `ArrayList<String>` | Deletion key list of service contract numbers — identifies which service contracts (lines) are targets of the physical deletion batch. Each element is a `SVC_KEI_NO` value used in the SQL WHERE clause IN list to filter the `KK_T_SVC_KEI` table. |
| 2 | `shijishoInfList` | `ArrayList<HashMap<String, String>>` | Instruction-sheet registration info list — an output parameter that receives all accumulated instruction-sheet records. Each HashMap represents one instruction-sheet record with 13 parameters (`PARAMETER_1` through `PARAMETER_13`) plus metadata fields (`TRN_CD`, `TRGT_TABLE_ID`, `TRAN_TRGT_SYSID`). |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `db_KK_T_SVC_KEI` | `JBSbatSQLAccess` | Database access object for the `KK_T_SVC_KEI` (Service Contract) table. Used to retrieve SQL, execute queries, and fetch result rows. |
| `opeDate` | `String` | Operations date — used as a bind parameter in the SQL execution (passed 6 times as `param` array). |
| `commonItem` | `CommonItem` | Shared common-item context providing `getBatchUserId()` and `getSysDateTimeStamp()`. |
| `D_TBL_NAME_KK_T_SVC_KEI` | `String` (constant) | Table name `"KK_T_SVC_KEI"` — used to reinitialize the DB access object after closing. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `db_KK_T_SVC_KEI.getSql` | - | - | Retrieves the SQL statement text for `KK_T_SVC_KEI_KK_SELECT_323` from the SQL map (internal SQL retrieval). |
| - | `db_KK_T_SVC_KEI.setSqlMap` | - | - | Modifies the SQL map with the IN-clause-expanded SQL, then later restores the original SQL. |
| R | `setInParam` | JBSbatKKDelSavePrdKikData | - | Internal method that expands the SQL IN clause by appending placeholders for each element in `key_svc_kei_no`. |
| - | `executeKK_T_SVC_KEI_KK_SELECT_323` | JBSbatKKDelSavePrdKikData | `KK_T_SVC_KEI` | Executes the SQL SELECT against the `KK_T_SVC_KEI` table with `opeDate` bind parameters to fetch service contract records. |
| R | `db_KK_T_SVC_KEI.selectNext` | JBSbatKKDelSavePrdKikData | `KK_T_SVC_KEI` | Fetches the next row from the result set of the executed SELECT as a `JBSbatCommonDBInterface` map. |
| R | `dbMap.getString` (multiple) | - | `KK_T_SVC_KEI` | Reads columns: `SYSID`, `SVC_KEI_NO`, `SHOSA_YMD`, `SVC_ENDYMD`, `MK_FLG`, `SVC_CD`, `PCRS_CD`. Also reads from `JBSbatKK_M_OLD_ICS_CD_CHG` view: `OLD_ICS_KEI_SVC_CD`, `OLD_ICS_PPLAN_CD`, `OLD_ICS_HUKA_SVC_SBT_CD`. |
| R | `JKKBatCommon.getSysDateTimeStamp` | JKKBatCommon | - | Retrieves the system date-time stamp used for audit fields `PARAMETER_6` and `PARAMETER_9`. |
| R | `commonItem.getBatchUserId` | CommonItem | - | Retrieves the batch user ID used for audit fields `PARAMETER_7` and `PARAMETER_10`. |
| R | `getTelNoJun` | JBSbatKKDelSavePrdKikData | `KK_T_SVC_KEI` (via `KK_T_SVC_KEI_KK_SELECT_324`) | Internal method that queries historical phone coax counts for telephone services. |
| R | `db_KK_T_SVC_KEI_2.selectNext` | - | `KK_T_SVC_KEI` | Used by `getTelNoJun` to fetch the next historical phone record. |
| R | `JBSbatKK_T_SVC_KEI.SVC_CD` (static ref) | - | `KK_T_SVC_KEI` | Column reference for service code — values `"01"` (Network), `"02"` (Phone), `"03"` (TV). |
| R | `JBSbatKK_T_SVC_KEI.SYSID` (static ref) | - | `KK_T_SVC_KEI` | Column reference for system ID. |
| R | `JBSbatKK_T_SVC_KEI.SVC_KEI_NO` (static ref) | - | `KK_T_SVC_KEI` | Column reference for service contract number. |
| R | `JBSbatKK_T_SVC_KEI.SHOSA_YMD` (static ref) | - | `KK_T_SVC_KEI` | Column reference for operational start date. |
| R | `JBSbatKK_T_SVC_KEI.SVC_ENDYMD` (static ref) | - | `KK_T_SVC_KEI` | Column reference for service end date. |
| R | `JBSbatKK_T_SVC_KEI.MK_FLG` (static ref) | - | `KK_T_SVC_KEI` | Column reference for mark flag. |
| R | `JBSbatKK_T_SVC_KEI.PCRS_CD` (static ref) | - | `KK_T_SVC_KEI` | Column reference for pricing code. |
| R | `JBSbatKK_M_OLD_ICS_CD_CHG.OLD_ICS_KEI_SVC_CD` (static ref) | - | `KK_M_OLD_ICS_CD_CHG` | Column reference for old ICS contract service code. |
| R | `JBSbatKK_M_OLD_ICS_CD_CHG.OLD_ICS_PPLAN_CD` (static ref) | - | `KK_M_OLD_ICS_CD_CHG` | Column reference for old ICS pricing plan code. |
| R | `JBSbatKK_M_OLD_ICS_CD_CHG.OLD_ICS_HUKA_SVC_SBT_CD` (static ref) | - | `KK_M_OLD_ICS_CD_CHG` | Column reference for old ICS additional service type code. |
| - | `db_KK_T_SVC_KEI.close` | JBSbatKKDelSavePrdKikData | `KK_T_SVC_KEI` | Closes the DB cursor to prevent exceeding max open cursor limit. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `addShijishoInf` | `addShijishoInf` -> `getShijishoInfSvcKei` | `KK_T_SVC_KEI_KK_SELECT_323 [R] KK_T_SVC_KEI` |

**Additional caller details:**

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 2 | Batch: `addShijishoInf` (same) | `addShijishoInf` -> `getShijishoInfSvcKei` -> `getTelNoJun` -> `KK_T_SVC_KEI_KK_SELECT_324 [R] KK_T_SVC_KEI` | `KK_T_SVC_KEI_KK_SELECT_324 [R] KK_T_SVC_KEI` |

`addShijishoInf()` is a private batch method within the same class that orchestrates the full instruction-sheet data gathering flow: it calls `getShijishoInfSvcKei()` alongside `getShijishoInfSysid()`, `getShijishoInfOp()`, `getShijishoInfNinshoId()`, and `getShijishoInfKakins()`, then consolidates all results via `insertShijisho()`. No screen entry points were found within 8 hops of this method.

## 6. Per-Branch Detail Blocks

### Block 1 — IF (early-exit guard) (L8197)

> If the input deletion key list is empty, terminate immediately. This prevents unnecessary SQL execution when there are no service contracts to process.

| # | Type | Code |
|---|------|------|
| 1 | SET | `key_svc_kei_no.size() == 0` // Empty input guard |
| 2 | RETURN | `return;` // Early exit, no processing [-> "抽出対象無しの場合、処理終了"] |

### Block 2 — Processing: SQL retrieval and execution (L8205–8214)

> Retrieve the SQL statement for the service contract SELECT, fix the IN clause to include all deletion keys, execute the query with date bind parameters, then restore the original SQL for reuse.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tgSql = db_KK_T_SVC_KEI.getSql(KK_T_SVC_KEI_KK_SELECT_323)` // Get execution SQL [-> SQL retrieval from SQL map] |
| 2 | EXEC | `db_KK_T_SVC_KEI.setSqlMap(KK_T_SVC_KEI_KK_SELECT_323, setInParam(tgSql, key_svc_kei_no))` // Fix IN clause [-> expands SQL with IN placeholders] |
| 3 | SET | `param = {this.opeDate, this.opeDate, this.opeDate, this.opeDate, this.opeDate, this.opeDate}` // 6 bind params [-> opeDate passed 6 times for SQL execution] |
| 4 | CALL | `executeKK_T_SVC_KEI_KK_SELECT_323(param)` // Execute SQL [-> R KK_T_SVC_KEI via SELECT_323] |
| 5 | EXEC | `db_KK_T_SVC_KEI.setSqlMap(KK_T_SVC_KEI_KK_SELECT_323, tgSql)` // Restore original SQL [-> "次処理のためSQLを元に戻す"] |

### Block 3 — FOR-WHILE: Row iteration loop (L8217–8335)

> Fetch rows one by one from the SQL result set. For each row, build a base info map (`wkMap2`) with 13 parameters, perform deduplication, then conditionally build a service-specific map (`wkMap3`) based on `SVC_CD`, and potentially a secondary-coax map (`wkMap4`) for telephone services with 2 coax.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbMap = db_KK_T_SVC_KEI.selectNext()` // Fetch next row [-> "削除対象データのキーを格納"] |
| 2 | SET | `chkKeyList = new ArrayList<String>()` // Dedup key list for base map [-> "同一キー複数出力防止用"] |
| 3 | SET | `chkKeyList_2 = new ArrayList<String>()` // Dedup key list for service-specific maps [-> IT2-2016-0000001: second dedup list] |
| 4 | WHILE | `while(dbMap != null)` // Loop until no more rows |

#### Block 3.1 — Inner: Base info map creation (wkMap2) (L8231–8269)

> Build a HashMap with 13 parameters representing base service contract line info. This map is always created for every row regardless of service type, as it captures the fundamental linkage between SYSID and SVC_KEI_NO.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkMap2 = new HashMap<String, String>()` // Create base info map |
| 2 | SET | `wkMap2.put("TRN_CD", "N01")` // Transaction code [-> N01: registration transaction] |
| 3 | SET | `wkMap2.put("TRGT_TABLE_ID", "TNM00040_D")` // Target table ID [-> TNM00040_D: instruction-sheet detail table] |
| 4 | EXEC | `wkMap2.put("TRAN_TRGT_SYSID", dbMap.getString(JBSbatKK_T_SVC_KEI.SYSID))` // System ID from row |
| 5 | SET | `wkMap2.put("PARAMETER_YK_CNT", "13")` // Parameter count [-> fixed at 13 params] |
| 6 | EXEC | `wkMap2.put("PARAMETER_1", dbMap.getString(JBSbatKK_T_SVC_KEI.SYSID))` // SYSID |
| 7 | EXEC | `wkMap2.put("PARAMETER_2", dbMap.getString(JBSbatKK_T_SVC_KEI.SVC_KEI_NO))` // Service contract number |
| 8 | EXEC | `wkMap2.put("PARAMETER_3", dbMap.getString(JBSbatKK_T_SVC_KEI.SHOSA_YMD))` // Operational start date |
| 9 | EXEC | `wkMap2.put("PARAMETER_4", dbMap.getString(JBSbatKK_T_SVC_KEI.SVC_ENDYMD))` // Service end date |
| 10 | EXEC | `wkMap2.put("PARAMETER_5", dbMap.getString(JBSbatKK_T_SVC_KEI.MK_FLG))` // Mark flag |
| 11 | EXEC | `wkMap2.put("PARAMETER_6", JKKBatCommon.getSysDateTimeStamp())` // System date-time stamp |
| 12 | EXEC | `wkMap2.put("PARAMETER_7", commonItem.getBatchUserId())` // Batch user ID |
| 13 | SET | `wkMap2.put("PARAMETER_8", "")` // Blank [-> empty placeholder] |
| 14 | EXEC | `wkMap2.put("PARAMETER_9", JKKBatCommon.getSysDateTimeStamp())` // System date-time stamp |
| 15 | EXEC | `wkMap2.put("PARAMETER_10", commonItem.getBatchUserId())` // Batch user ID |
| 16 | SET | `wkMap2.put("PARAMETER_11", "")` // Blank [-> empty placeholder] |
| 17 | SET | `wkMap2.put("PARAMETER_12", "00")` // Zero code [-> default code for base map] |
| 18 | SET | `wkMap2.put("PARAMETER_13", "00000")` // Zero code [-> default code for base map] |

#### Block 3.2 — Nested IF: Deduplication check for wkMap2 (L8270–8280)

> IT2-2016-0000001: Use a composite key (PARAMETER_1 + PARAMETER_2 + PARAMETER_12 + PARAMETER_13) to check for duplicates. This is more granular than the old approach which only checked SYSID + SVC_KEI_NO.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkChkKey2 = wkMap2.get("PARAMETER_1") + wkMap2.get("PARAMETER_2") + wkMap2.get("PARAMETER_12") + wkMap2.get("PARAMETER_13")` // Composite dedup key [-> SYSID+SVC_KEI_NO+"00"+"00000"] |
| 2 | IF | `!chkKeyList.contains(wkChkKey2)` // [-> "同一キー確認"] |
| 2.1 | SET | `chkKeyList.add(wkChkKey2)` // Register dedup key |
| 2.2 | EXEC | `shijishoInfList.add(wkMap2)` // Add to output list |

#### Block 3.3 — Nested IF: Service-type conditional branch (L8281–8329)

> Condition: `SVC_CD == "01" OR "02" OR "03"`. Only Network, Telephone, and TV service contracts produce service-specific instruction-sheet records. Other service types are skipped.

| # | Type | Code |
|---|------|------|
| 1 | IF | `SVC_CD in {"01", "02", "03"}` [-> "回線契約に紐く各種サービス契約の情報（各契約）"] |

##### Block 3.3.0 — Base wkMap3 creation (always for matched SVC_CD) (L8284–8310)

> Build a service-specific info map. Parameters 1–11 are the same as wkMap2. Parameters 12–13 are set differently depending on the service type.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkMap3 = new HashMap<String, String>()` // Create service-specific map |
| 2 | SET | `wkMap3.put("TRN_CD", "N01")` // Transaction code |
| 3 | SET | `wkMap3.put("TRGT_TABLE_ID", "TNM00040_D")` // Target table ID |
| 4 | EXEC | `wkMap3.put("TRAN_TRGT_SYSID", dbMap.getString(JBSbatKK_T_SVC_KEI.SYSID))` |
| 5 | SET | `wkMap3.put("PARAMETER_YK_CNT", "13")` |
| 6 | EXEC | `wkMap3.put("PARAMETER_1", dbMap.getString(JBSbatKK_T_SVC_KEI.SYSID))` |
| 7 | EXEC | `wkMap3.put("PARAMETER_2", dbMap.getString(JBSbatKK_T_SVC_KEI.SVC_KEI_NO))` |
| 8 | EXEC | `wkMap3.put("PARAMETER_3", dbMap.getString(JBSbatKK_T_SVC_KEI.SHOSA_YMD))` |
| 9 | EXEC | `wkMap3.put("PARAMETER_4", dbMap.getString(JBSbatKK_T_SVC_KEI.SVC_ENDYMD))` |
| 10 | EXEC | `wkMap3.put("PARAMETER_5", dbMap.getString(JBSbatKK_T_SVC_KEI.MK_FLG))` |
| 11 | EXEC | `wkMap3.put("PARAMETER_6", JKKBatCommon.getSysDateTimeStamp())` |
| 12 | EXEC | `wkMap3.put("PARAMETER_7", commonItem.getBatchUserId())` |
| 13 | SET | `wkMap3.put("PARAMETER_8", "")` |
| 14 | EXEC | `wkMap3.put("PARAMETER_9", JKKBatCommon.getSysDateTimeStamp())` |
| 15 | EXEC | `wkMap3.put("PARAMETER_10", commonItem.getBatchUserId())` |
| 16 | SET | `wkMap3.put("PARAMETER_11", "")` |

##### Block 3.3.1 — Service Type 01: Network (L8311–8314)

> Condition: `SVC_CD == "01"` [-> "対象サービスがネットの場合"]

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkMap3.put("PARAMETER_12", "01")` // Service type code: Network |
| 2 | SET | `wkMap3.put("PARAMETER_13", dbMap.getString(JBSbatKK_M_OLD_ICS_CD_CHG.OLD_ICS_KEI_SVC_CD) + dbMap.getString(JBSbatKK_M_OLD_ICS_CD_CHG.OLD_ICS_PPLAN_CD))` // Legacy ICS contract code + pricing plan code |

##### Block 3.3.2 — ELSE IF: Service Type 02: Telephone (L8315–8328)

> Condition: `SVC_CD == "02"` [-> "対象サービスが電話の場合"]

| # | Type | Code |
|---|------|------|
| 1 | CALL | `telnoJun = getTelNoJun(dbMap.getString(JBSbatKK_T_SVC_KEI.SVC_KEI_NO), dbMap.getString(JBSbatKK_T_SVC_KEI.SYSID), dbMap.getString(JBSbatKK_T_SVC_KEI.PCRS_CD))` // Get phone coax count [-> Calls SELECT_324 on KK_T_SVC_KEI to count historical secondary coax] |
| 2 | SET | `wkMap3.put("PARAMETER_12", "02")` // Service type code: Telephone |
| 3 | SET | `wkMap3.put("PARAMETER_13", dbMap.getString(JBSbatKK_M_OLD_ICS_CD_CHG.OLD_ICS_HUKA_SVC_SBT_CD) + "00" + telnoJun)` // Additional service type + "00" + coax count |

###### Block 3.3.2.1 — Nested IF: Secondary coax exists (telnoJun == "2") (L8321–8330)

> Condition: `telnoJun == "2"` [-> "2番号コースの場合：1電話番号目の情報も指示書登録"] — When the line has 2 secondary coax ports, a second instruction-sheet record is created for the first phone number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkMap4 = new HashMap<String, String>(wkMap3)` // Shallow copy of wkMap3 [-> "2番号コースの場合"] |
| 2 | SET | `wkMap4.put("PARAMETER_13", dbMap.getString(JBSbatKK_M_OLD_ICS_CD_CHG.OLD_ICS_HUKA_SVC_SBT_CD) + "001")` // Replace coax count from `telnoJun` to `"001"` [-> First phone number record] |
| 3 | SET | `wkChkKey4 = wkMap4.get("PARAMETER_1") + wkMap4.get("PARAMETER_2") + wkMap4.get("PARAMETER_12") + wkMap4.get("PARAMETER_13")` // Dedup key for wkMap4 |
| 4 | IF | `!chkKeyList_2.contains(wkChkKey4)` // [-> "同一キー確認"] |
| 4.1 | SET | `chkKeyList_2.add(wkChkKey4)` |
| 4.2 | EXEC | `shijishoInfList.add(wkMap4)` // Add secondary-coax record |

##### Block 3.3.3 — ELSE IF: Service Type 03: Television (L8331–8334)

> Condition: `SVC_CD == "03"` [-> "対象サービスがテレビの場合"]

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkMap3.put("PARAMETER_12", "03")` // Service type code: TV |
| 2 | SET | `wkMap3.put("PARAMETER_13", dbMap.getString(JBSbatKK_M_OLD_ICS_CD_CHG.OLD_ICS_KEI_SVC_CD) + dbMap.getString(JBSbatKK_M_OLD_ICS_CD_CHG.OLD_ICS_PPLAN_CD))` // Same as Network: legacy ICS contract code + pricing plan code |

##### Block 3.3.4 — Post-service-type: Deduplication check for wkMap3 (IT2-2016-0000001 MOD) (L8335–8342)

> IT2-2016-0000001 MOD: The old code directly added `wkMap3` to `shijishoInfList` without deduplication. After the IT2-2016-0000001 modification, a dedup check is now applied using `chkKeyList_2` and a composite key. This prevents duplicate instruction-sheet records when multiple services (e.g., base map + service-specific) produce the same key.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkChkKey3 = wkMap3.get("PARAMETER_1") + wkMap3.get("PARAMETER_2") + wkMap3.get("PARAMETER_12") + wkMap3.get("PARAMETER_13")` // Composite dedup key [-> SYSID+SVC_KEI_NO+svcTypeCode+svcDetail] |
| 2 | IF | `!chkKeyList_2.contains(wkChkKey3)` // [-> "同一キー確認"] |
| 2.1 | SET | `chkKeyList_2.add(wkChkKey3)` |
| 2.2 | EXEC | `shijishoInfList.add(wkMap3)` // Add service-specific record |

#### Block 3.4 — End of loop: fetch next row (L8336)

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbMap = db_KK_T_SVC_KEI.selectNext()` // Advance to next row |

### Block 4 — Post-loop: DB cleanup (L8338–8339)

> Prevents exceeding the maximum open cursor limit by closing the DB cursor and reinitializing the `db_KK_T_SVC_KEI` object.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `db_KK_T_SVC_KEI.close()` // Close DB cursor [-> "最大オープンカーソル数超対策"] |
| 2 | SET | `db_KK_T_SVC_KEI = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_SVC_KEI)` // Reinitialize [-> D_TBL_NAME_KK_T_SVC_KEI = "KK_T_SVC_KEI"] |

### Block 5 — RETURN (implicit)

> The method returns `void` implicitly after completing the loop and DB cleanup.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return;` // Implicit void return |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service contract number — the primary identifier for a service contract (line item) in the `KK_T_SVC_KEI` table. Used as a deletion key. |
| `sysid` | Field | System ID — a unique identifier for the customer/system in the deletion batch. Links service contracts to customer groups. |
| `svc_cd` | Field | Service code — classifies the type of service attached to a line. Values: `"01"` (Network/FTTH), `"02"` (Telephone), `"03"` (Television). |
| `shosa_ymd` | Field | Operational start date (施行年月日) — the date when the service contract became effective. |
| `svc_endedymd` | Field | Service end date — the date when the service contract ended or was terminated. |
| `mk_flg` | Field | Mark flag — a validity/deletion flag indicating whether the record is active or marked for deletion. |
| `pcrs_cd` | Field | Pricing code (料金コースコード) — the pricing course code for the contract, used by `getTelNoJun` to determine historical coax configuration. |
| `key_svc_kei_no` | Parameter | Deletion key list of service contract numbers — input list of `SVC_KEI_NO` values that are targets of the physical deletion batch. |
| `shijishoInfList` | Parameter | Instruction-sheet registration info list — output list that accumulates instruction-sheet records (`shijisho` = 指示書, batch work instruction documents) for physical deletion processing. |
| `wkMap2` | Variable | Base work map — intermediate HashMap holding 13 parameters for the base service contract line info (always produced per row). |
| `wkMap3` | Variable | Service-specific work map — intermediate HashMap holding 13 parameters for service-type-specific info (produced for SVC_CD 01/02/03). |
| `wkMap4` | Variable | Secondary-coax work map — intermediate HashMap copied from `wkMap3` with modified `PARAMETER_13`, representing an additional instruction-sheet record for the first phone number when 2 secondary coax exist. |
| `chkKeyList` | Variable | Deduplication check list for base maps — prevents duplicate `wkMap2` records from being added. |
| `chkKeyList_2` | Variable | Deduplication check list for service-specific maps — prevents duplicate `wkMap3` and `wkMap4` records from being added. Introduced in IT2-2016-0000001. |
| `wkChkKey2` | Variable | Composite dedup key for `wkMap2`: `SYSID + SVC_KEI_NO + PARAMETER_12 + PARAMETER_13`. |
| `wkChkKey3` | Variable | Composite dedup key for `wkMap3`: `SYSID + SVC_KEI_NO + PARAMETER_12 + PARAMETER_13`. |
| `wkChkKey4` | Variable | Composite dedup key for `wkMap4`: `SYSID + SVC_KEI_NO + PARAMETER_12 + PARAMETER_13` (where PARAMETER_13 is `"001"`). |
| `TRN_CD` | Field | Transaction code — `"N01"` indicates a registration-type transaction in the instruction-sheet system. |
| `TRGT_TABLE_ID` | Field | Target table identifier — `"TNM00040_D"` is the detail table for instruction-sheet data. |
| `PARAMETER_1`–`PARAMETER_13` | Field | Generic parameter slots — used to pass typed data to the instruction-sheet downstream processing. |
| `KK_T_SVC_KEI` | DB Table | Service Contract table — the core table storing service contract (line) records including SYSID, SVC_KEI_NO, SVC_CD, SHOSA_YMD, SVC_ENDYMD, MK_FLG, PCRS_CD. |
| `KK_M_OLD_ICS_CD_CHG` | DB Table | Old ICS Code Change mapping table — stores mappings from legacy ICS codes to new codes, used to resolve `OLD_ICS_KEI_SVC_CD`, `OLD_ICS_PPLAN_CD`, and `OLD_ICS_HUKA_SVC_SBT_CD` during service contract processing. |
| `KK_T_SVC_KEI_KK_SELECT_323` | SQL ID | SQL SELECT statement for querying service contract data by service contract number IN list. |
| `KK_T_SVC_KEI_KK_SELECT_324` | SQL ID | SQL SELECT statement used by `getTelNoJun` to query historical phone coax count. |
| `getTelNoJun` | Method | Get phone coax number — queries historical data to determine how many secondary coax ports are assigned to a telephone line. Returns `"1"` (single coax) or `"2"` (dual coax). |
| `telnoJun` | Variable | Phone coax count — the number returned by `getTelNoJun()`, indicating how many secondary coax ports exist. `"2"` triggers creation of an additional record for the first phone number. |
| `SVC_KEI_UCWK_NO` | Field | Service detail work number — internal tracking ID for service contract line items (used in related methods). |
| `opeDate` | Field | Operations date — the batch processing date used as a bind parameter in SQL queries. |
| `addShijishoInf` | Method | Add instruction-sheet info — orchestrator method that calls `getShijishoInfSvcKei` alongside other info-gathering methods, then consolidates all data via `insertShijisho`. |
| `insertShijisho` | Method | Insert instruction-sheet — final step that writes the accumulated `shijishoInfList` records into the instruction-sheet registration table. |
| IT2-2016-0000001 | Change ID | Change request for instruction-sheet duplicate-key output suppression — introduced two-stage deduplication (`chkKeyList` for base maps, `chkKeyList_2` for service-specific maps). |
| N01 | Code | Transaction type code for registration-type instruction-sheet operations. |
| TNM00040_D | Code | Target table ID for instruction-sheet detail records. |
| JKKBatCommon | Class | Common batch utility class providing `getSysDateTimeStamp()` for system date-time retrieval. |
| JBSbatSQLAccess | Class | Database access wrapper class used for SQL execution, cursor management, and result set fetching in the batch framework. |
| JBSbatCommonDBInterface | Interface | Common interface for database result sets, providing `getString()` column access. |
| D_TBL_NAME_KK_T_SVC_KEI | Constant | Table name constant `"KK_T_SVC_KEI"` used for DB access object reinitialization. |
| OLD_ICS_KEI_SVC_CD | Field | Old ICS contract service code — legacy service code from the old ICS system, resolved via `KK_M_OLD_ICS_CD_CHG`. |
| OLD_ICS_PPLAN_CD | Field | Old ICS pricing plan code — legacy pricing plan code from the old ICS system. |
| OLD_ICS_HUKA_SVC_SBT_CD | Field | Old ICS additional service type code — legacy additional/auxiliary service type from the old ICS system. |
| 指示書 (shijisho) | Term | Instruction sheet — a batch work document that provides detailed operational instructions for physical deletion of customer contract data. |
| 回線契約 (kaisen keiyaku) | Term | Line contract — the overarching service contract that links multiple service contract lines (SVC_KEI_NO records) to a single SYSID. |
| 物理削除 (butsuri sodaku) | Term | Physical deletion — the permanent removal of data from the database, as opposed to logical deletion via flagging. |
| NET | Service Type | Network service (FTTH / fiber-optic internet) — SVC_CD `"01"`. |
| TEL | Service Type | Telephone service — SVC_CD `"02"`. |
| TV | Service Type | Television service — SVC_CD `"03"`. |
