## 5. Dependency Trace

Trace who calls this method and what this method ultimately calls.
This method is a batch entry point in the JBSbat (Batch Service) framework. It is invoked by the batch scheduling layer and does not appear to be called directly by screen classes (KKSV*).

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKNrkeFinKikiHktgi | `JBSbatInvoker.execute` -> `JBSbatKKNrkeFinKikiHktgi.execute` | `executeKK_T_KKTK_SVC_KEI_PKINSERT [C] KK_T_KKTK_SVC_KEI` |
| 2 | (same batch entry) | `JBSbatInvoker.execute` -> `JBSbatKKNrkeFinKikiHktgi.execute` | `executeKK_T_KKOP_SVC_KEI_PKINSERT [C] KK_T_KKOP_SVC_KEI` |
| 3 | (same batch entry) | `JBSbatInvoker.execute` -> `JBSbatKKNrkeFinKikiHktgi.execute` | `executeDK_T_HAISO_TG_PKUPDATE [U] DK_T_HAISO_TG_BPIN` |
| 4 | (same batch entry) | `JBSbatInvoker.execute` -> `JBSbatKKNrkeFinKikiHktgi.execute` | `executeDK_T_HMPIN_KIKI_PKUPDATE [U] DK_T_HMPIN_KIKI` |
| 5 | (same batch entry) | `JBSbatInvoker.execute` -> `JBSbatKKNrkeFinKikiHktgi.execute` | `executeKK_T_SVKEI_KAISEN_UW_PKINSERT [C] KK_T_SVKEI_KAISEN_UW` |
| 6 | (same batch entry) | `JBSbatInvoker.execute` -> `JBSbatKKNrkeFinKikiHktgi.execute` | `executeKK_T_PRG_PKINSERT [C] KK_T_PRG` |
| 7 | (same batch entry) | `JBSbatInvoker.execute` -> `JBSbatKKNrkeFinKikiHktgi.execute` | `executeKK_T_ODR_HAKKO_JOKEN_PKINSERT [C] KK_T_ODR_HAKKO_JOKEN` |
| 8 | (same batch entry) | `JBSbatInvoker.execute` -> `JBSbatKKNrkeFinKikiHktgi.execute` | `executeKK_T_ODR_INF_SKSI_WK_PKINSERT [C] KK_T_ODR_INF_SKSI_WK` |
| 9 | (same batch entry) | `JBSbatInvoker.execute` -> `JBSbatKKNrkeFinKikiHktgi.execute` | `executeKU_T_KJAK_TG_TKKIKI_PKUPDATE [U] KU_T_KJAK_TG_TKKIKI` |

## 6. Per-Branch Detail Blocks

**Block 1** — INITIALIZATION `(variable setup)` (L613)

Initialize the output object and clear iteration state before the try block.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outputItem = new JBSbatOutputItem()` // Create output container |
| 2 | EXEC | `kktkSvcKeiNoList.clear()` // Clear equipment provider service contract number list |
| 3 | SET | `taknkikiModelList = ""` // Clear equipment model list |
| 4 | SET | `mskmDtlNo = null` // Application detail number |
| 5 | SET | `idoDiv = null` // Movement classification |
| 6 | SET | `addDtm = null` // Registration date/time |
| 7 | SET | `svcKeiGeneAddSaki = null` // Destination service contract generation registration date |
| 8 | SET | `svcStaYmdSaki = null` // Destination service start date |

**Block 2** — TRY BLOCK START `(exception handling boundary)` (L623)

Start of the main try-catch exception handling block. All business logic is wrapped here.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sakiSvcKeiNo = inMap.getString("SVC_KEI_NO")` // Destination service contract number |
| 2 | SET | `motoSvcKeiNo = inMap.getString("NRKEMT_SVKEI_NO")` // Source (transfer-from) service contract number |
| 3 | EXEC | `super.logPrint.printDebugLog(...)` // Debug log: destination/source service contract numbers |

**Block 3** — SELECT DESTINATION EQUIPMENT PROVIDER CONTRACT `(SELECT_280 with dummy filter)` (L637)

Query the equipment provider service contract table for the destination (saki) using dummy model code filters. The `humeiModelCdMap` provides hidden model code values for ONU, TKNRT, HGW, MESH, and MLAN types.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `executeKK_T_KKTK_SVC_KEI_KK_SELECT_280(sakiSvcKeiNo, humeiModelCdMap.get(KK_SBRY_DUMMY_ONU), humeiModelCdMap.get(KK_SBRY_DUMMY_TKNRT), humeiModelCdMap.get(KK_SBRY_DUMMY_HGW), humeiModelCdMap.get(KK_SBRY_DUMMY_MESH), humeiModelCdMap.get(KK_SBRY_DUMMY_MLAN))` |

**Block 4** — SELECT DESTINATION MINIMUM SERVICE CONTRACT `(SELECT_386)` (L640)

Query the minimum service contract record for the destination service contract number. This provides the application detail number (mskmDtlNo), movement classification (idoDiv), and registration timestamp.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `executeKK_T_SVC_KEI_KK_SELECT_386(sakiSvcKeiNo)` |
| 2 | SET | `mapSvcKeiSakiMin = db_KK_T_SVC_KEI.selectNext()` |
| 3 | IF | `null != mapSvcKeiSakiMin` — (Block 4.A) |
| 4 | ELSE | — (Block 4.B: return null) |

**Block 4.A** — GET DESTINATION MIN CONTRACT ATTRIBUTES (L643)

Extract the minimum service contract details needed for downstream processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mskmDtlNo = mapSvcKeiSakiMin.getString(MSKM_DTL_NO)` // Application detail number |
| 2 | SET | `idoDiv = mapSvcKeiSakiMin.getString(IDO_DIV)` // Movement classification |
| 3 | SET | `addDtm = mapSvcKeiSakiMin.getString(ADD_DTM)` // Registration date/time |

**Block 4.B** — EARLY EXIT: NO MIN CONTRACT (L652)

If the destination minimum service contract does not exist, the method returns null immediately.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null` // No destination minimum contract found |

**Block 5** — SELECT DESTINATION CURRENT SERVICE CONTRACT `(SELECT_384)` (L657)

Query the current service contract for the destination. This provides the gene registration date and service start date.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `executeKK_T_SVC_KEI_KK_SELECT_384(sakiSvcKeiNo)` |
| 2 | SET | `mapSvcKeiSakiCrnt = db_KK_T_SVC_KEI.selectNext()` |
| 3 | IF | `null != mapSvcKeiSakiCrnt` — (Block 5.A) |
| 4 | ELSE | — (Block 5.B: return null) |

**Block 5.A** — GET DESTINATION CURRENT CONTRACT ATTRIBUTES (L661)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiGeneAddSaki = mapSvcKeiSakiCrnt.getString(GENE_ADD_DTM)` // Service contract generation registration date |
| 2 | SET | `svcStaYmdSaki = mapSvcKeiSakiCrnt.getString(SVC_STA_YMD)` // Service start date |

**Block 5.B** — EARLY EXIT: NO CURRENT CONTRACT (L666)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null` // No destination current contract found |

**Block 6** — EQUIPMENT PROVIDER CONTRACT LOOP `(while null != mapKktkSvcKeiSaki)` (L671)

Main loop: iterate over all equipment provider service contract records from `db_KK_T_KKTK_SVC_KEI_SAKI` for the destination. For each iteration, locate the corresponding source (moto) contract and process the equipment transfer.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kktkSvcKeiMap = new HashMap<String, String>()` |
| 2 | SET | `kkopSvcKeiMap = new HashMap<String, String>()` |
| 3 | SET | `svkeiKaisenUwMap = new HashMap<String, String>()` |
| 4 | SET | Multiple local vars set to null (L678–L707) |
| 5 | SET | `dbExistsFlg = true` // Database existence flag |
| 6 | SET | `kktkSvcKeiNoSaki = mapKktkSvcKeiSaki.getString(KKTK_SVC_KEI_NO)` // Destination kktk service contract number |
| 7 | SET | `kktkSvcKeiGeneAddSaki = mapKktkSvcKeiSaki.getString(GENE_ADD_DTM)` // Destination gene registration date |
| 8 | SET | `pcrsCdSaki = mapKktkSvcKeiSaki.getString(PCRS_CD)` // Destination cost code |
| 9 | SET | `taknkikiSbtCdSaki = mapKktkSvcKeiSaki.getString(TAKNKIKI_SBT_CD)` // Destination equipment subtype code |
| 10 | SET | `kikiChgNoSaki = mapKktkSvcKeiSaki.getString(KIKI_CHG_NO)` // Destination equipment change number |
| 11 | SET | `oyaKeiSkbtCd = mapKktkSvcKeiSaki.getString(OYA_KEI_SKBT_CD)` // Parent contract type code |
| 12 | SET | `svcKeiKaisenUcwkNoSaki = mapKktkSvcKeiSaki.getString(SVC_KEI_KAISEN_UCWK_NO)` // Destination line inner number |
| 13 | EXEC | `super.logPrint.printDebugLog("Destination kktkSvcKeiNo: " + kktkSvcKeiNoSaki)` |

**Block 6.A** — ROUTE SOURCE SELECT BASED ON PARENT CONTRACT TYPE `(if oyaKeiSkbtCd == "02")` (L752)

Branch on the parent contract identification code. If `"02"` (service contract line inner / サービス契約回線内訳), use SELECT_281 which searches the source equipment provider contract by moto service contract number and equipment subtype plus registration date. Otherwise, use SELECT_282 which additionally includes the cost code (pcrsCd) as a filter criterion.

| # | Type | Code |
|---|------|------|
| 1 | IF | `oyaKeiSkbtCd == "02"` (CD_DIV_OYAKEISKBTCD_SVKEIKSNUW — service contract line inner) |
| 2 | SET | — |
| 3 | CALL | `executeKK_T_KKTK_SVC_KEI_KK_SELECT_281(motoSvcKeiNo, taknkikiSbtCdSaki, addDtm)` // SELECT_281 |
| 4 | ELSE | |
| 5 | CALL | `executeKK_T_KKTK_SVC_KEI_KK_SELECT_282(motoSvcKeiNo, taknkikiSbtCdSaki, pcrsCdSaki, addDtm)` // SELECT_282 |

**Block 6.B** — FIND CORRESPONDING SOURCE EQUIPMENT CONTRACT (L764)

Search through the result set to find a moto equipment provider contract number that is not already in the processed list. If the record was already processed, skip it; if it is new, continue with transfer processing.

| # | Type | Code |
|---|------|------|
| 1 | WHILE | `null != (mapKktkSvcKeiMoto = db_KK_T_KKTK_SVC_KEI.selectNext())` |
| 2 | IF | `kktkSvcKeiNoList.contains(mapKktkSvcKeiMoto.getString(KKTK_SVC_KEI_NO))` |
| 3 | SET | `continue` // Skip already-processed record |
| 4 | ELSE | `break` // Found new record |
| 5 | IF | `null == mapKktkSvcKeiMoto` (Block 6.B-1: skip iteration) |
| 6 | ELSE | (Block 6.B-2: continue processing) |

**Block 6.B-1** — SKIP: NO NEW SOURCE RECORD (L774)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` // Skip this destination iteration — no corresponding source found |

**Block 6.B-2** — EXTRACT SOURCE CONTRACT ATTRIBUTES (L778)

| # | Type | Code |
|---|------|------|
| 1 | SET | `kktkSvcKeiNoMoto = mapKktkSvcKeiMoto.getString(KKTK_SVC_KEI_NO)` // Source equipment provider contract number |
| 2 | SET | `taknkikiModelCdMoto = mapKktkSvcKeiMoto.getString(TAKNKIKI_MODEL_CD)` // Source equipment model code |
| 3 | SET | `kikiSeizoNoMoto = mapKktkSvcKeiMoto.getString(KIKI_SEIZO_NO)` // Source equipment serial number |
| 4 | SET | `kikiChgNoMoto = mapKktkSvcKeiMoto.getString(KIKI_CHG_NO)` // Source equipment change number |
| 5 | SET | `kikiStcSakiPlaceNoMoto = mapKktkSvcKeiMoto.getString(KIKI_STC_SAKI_PLACE_NO)` // Source installation location number |
| 6 | SET | `svcKeiKaisenUcwkNoMoto = mapKktkSvcKeiMoto.getString(SVC_KEI_KAISEN_UCWK_NO)` // Source line inner number |
| 7 | SET | `kktkSvcKeiEndymdMoto = mapKktkSvcKeiMoto.getString(SVC_CHRG_ENDYMD)` // Source charge end date |
| 8 | EXEC | `super.logPrint.printDebugLog("Source kktkSvcKeiNo: " + kktkSvcKeiNoMoto)` |
| 9 | EXEC | `kktkSvcKeiNoList.add(kktkSvcKeiNoMoto)` // Track this moto contract as processed |

**Block 6.C** — CALCULATE NEXT MONTH FROM ENDYMd (L798)

If the source charge end date exists and is at least 8 characters (valid date format), calculate the first day of the following month using `JBSbatDateUtil.adjustMonth`.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!JKKStringUtil.isNullBlank(kktkSvcKeiEndymdMoto) && 8 <= kktkSvcKeiEndymdMoto.length()` |
| 2 | SET | `date = JBSbatDateUtil.adjustMonth(kktkSvcKeiEndymdMoto, 1)` // Add 1 month |
| 3 | SET | `kktkSvcKeiNextMonth = date.substring(0, 6) + "01"` // First day of next month |

**Block 6.D** — DESTINATION KKTQ PK-SELECT AND BUILD INSERT MAP (L806)

Perform a PK-based SELECT on the destination equipment provider service contract, then build the INSERT map by copying fields from the PK result and setting all transfer-specific values.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kkTKktkSvcKeiPkSelectMap = executeKK_T_KKTK_SVC_KEI_PKSELECT(kktkSvcKeiNoSaki, kktkSvcKeiGeneAddSaki)` |
| 2 | IF | `null != kkTKktkSvcKeiPkSelectMap` |
| 3 | FOR | `for (String key : KK_T_KKTK_SVC_KEI_COL_LIST)` |
| 4 | SET | `kktkSvcKeiMap.put(key, kkTKktkSvcKeiPkSelectMap.getString(key))` |
| 5 | SET | `kkTKktkSvcKeiGeneAdd = JKKBatCommon.getSysDateTimeStamp()` // New registration timestamp |
| 6 | SET | `kktkSvcKeiMap.put(GENE_ADD_DTM, kkTKktkSvcKeiGeneAdd)` |
| 7 | SET | `kktkSvcKeiMap.put(KKTK_SVC_KEI_STAT, "1" (CD00056_STAT_TEIKYO_CHU))` // Delivery pending |
| 8 | SET | `kktkSvcKeiMap.put(TAKNKIKI_MODEL_CD, taknkikiModelCdMoto)` // Use source model |
| 9 | SET | `kktkSvcKeiMap.put(KIKI_SEIZO_NO, kikiSeizoNoMoto)` // Use source serial |
| 10 | SET | `kktkSvcKeiMap.put(KIKI_STC_SAKI_PLACE_NO, kikiStcSakiPlaceNoMoto)` // Use source install location |
| 11 | SET | `kktkSvcKeiMap.put(KEI_CNC_YMD, this.opeDate)` // Agreement cancellation date = operation date |
| 12 | SET | `kktkSvcKeiMap.put(RSV_APLY_YMD, this.opeDate)` // Reservation application date |
| 13 | SET | `kktkSvcKeiMap.put(RSV_APLY_CD, "2" (CD00343_2))` // Reservation confirmed |
| 14 | SET | `kktkSvcKeiMap.put(PLAN_STAYMD, svcStaYmdSaki)` // Plan start date from destination |
| 15 | SET | `kktkSvcKeiMap.put(PLAN_CHRG_STAYMD, kktkSvcKeiNextMonth)` // Plan charge start = next month |
| 16 | SET | `kktkSvcKeiMap.put(PLAN_ENDYMD, "20991231" (END_YMD_DEFAULT))` |
| 17 | SET | `kktkSvcKeiMap.put(PLAN_CHRG_ENDYMD, "20991231")` |
| 18 | SET | `kktkSvcKeiMap.put(SVC_STA_YMD, svcStaYmdSaki)` |
| 19 | SET | `kktkSvcKeiMap.put(SVC_CHRG_STAYMD, kktkSvcKeiNextMonth)` |
| 20 | SET | `kktkSvcKeiMap.put(SVC_ENDYMD, "20991231")` |
| 21 | SET | `kktkSvcKeiMap.put(SVC_CHRG_ENDYMD, "20991231")` |
| 22 | SET | `kktkSvcKeiMap.put(SHKA_FIN_JI_SYRZM_FLG, "1" (CD00581_1))` |

**Block 6.E** — INSERT DESTINATION EQUIPMENT PROVIDER CONTRACT (L830)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_KKTK_SVC_KEI_PKINSERT(kktkSvcKeiMap)` // Insert new destination kktk record |

**Block 6.F** — OPTION SERVICE CONTRACT BRANCH `(if taknkikiSbtCdSaki == "R0" or "S0")` (L839)

Only process equipment option service contracts (KKOP) for standalone routers (R0) and Home Gateways (S0). Other equipment types (ONU, TKNRT, MESH, MLAN) do not have option contracts.

| # | Type | Code |
|---|------|------|
| 1 | IF | `taknkikiSbtCdSaki == "R0" (TAKNKIKI_SBT_CD_TAKINORT) || taknkikiSbtCdSaki == "S0" (TAKNKIKI_SBT_CD_HGW)` |

**Block 6.F-a** — SELECT DESTINATION KKOP (L842)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_KKOP_SVC_KEI_KK_SELECT_035(kktkSvcKeiNoSaki)` |
| 2 | SET | `mapKkopSvcKeiSaki = db_KK_T_KKOP_SVC_KEI.selectNext()` |
| 3 | IF | `null != mapKkopSvcKeiSaki` (Block 6.F-b) |
| 4 | ELSE | — (Block 6.F-c: dbExistsFlg = false) |

**Block 6.F-b** — EXTRACT DESTINATION KKOP AND SELECT SOURCE KKOP (L849)

| # | Type | Code |
|---|------|------|
| 1 | SET | `kkopSvcKeiNoSaki = mapKkopSvcKeiSaki.getString(KKOP_SVC_KEI_NO)` |
| 2 | SET | `kkopSvcKeiGeneAddSaki = mapKkopSvcKeiSaki.getString(GENE_ADD_DTM)` |
| 3 | CALL | `executeKK_T_KKOP_SVC_KEI_KK_SELECT_036(kktkSvcKeiNoMoto, addDtm)` // SELECT source KKOP |
| 4 | SET | `mapKkopSvcKeiMoto = db_KK_T_KKOP_SVC_KEI.selectNext()` |
| 5 | IF | `null != mapKkopSvcKeiMoto` (Block 6.F-d) |
| 6 | ELSE | — (Block 6.F-e: dbExistsFlg = false) |

**Block 6.F-d** — BUILD KKOP INSERT MAP (L861)

Extract source KKOP attributes, compute next month, and build the full insert map mirroring the destination kktk block.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kkopSvcKeiEndymdMoto = mapKkopSvcKeiMoto.getString(SVC_CHRG_ENDYMD)` // Source KKOP charge end date |
| 2 | IF | `!JKKStringUtil.isNullBlank(kkopSvcKeiEndymdMoto) && 8 <= kkopSvcKeiEndymdMoto.length()` |
| 3 | SET | `kkopSvcKeiNextMonth = JBSbatDateUtil.adjustMonth(kkopSvcKeiEndymdMoto, 1).substring(0,6) + "01"` |
| 4 | SET | `kkTKkopSvcKeiPkSelectMap = executeKK_T_KKOP_SVC_KEI_PKSELECT(kkopSvcKeiNoSaki, kkopSvcKeiGeneAddSaki)` |
| 5 | FOR | `for (String key : KK_T_KKOP_SVC_KEI_COL_LIST)` — copy fields to kkopSvcKeiMap |
| 6 | SET | `kkTKkopSvcKeiGeneAdd = JKKBatCommon.getSysDateTimeStamp()` |
| 7 | SET | `kkopSvcKeiMap.put(GENE_ADD_DTM, kkTKkopSvcKeiGeneAdd)` |
| 8 | SET | `kkopSvcKeiMap.put(KKOP_SVC_KEI_STAT, "1" (CD00056_STAT_TEIKYO_CHU))` |
| 9 | SET | `kkopSvcKeiMap.put(KEI_CNC_YMD, this.opeDate)` |
| 10 | SET | `kkopSvcKeiMap.put(RSV_APLY_YMD, this.opeDate)` |
| 11 | SET | `kkopSvcKeiMap.put(RSV_APLY_CD, "2" (CD00343_2))` |
| 12 | SET | `kkopSvcKeiMap.put(PLAN_STAYMD, svcStaYmdSaki)` |
| 13 | SET | `kkopSvcKeiMap.put(PLAN_CHRG_STAYMD, kkopSvcKeiNextMonth)` |
| 14 | SET | `kkopSvcKeiMap.put(PLAN_ENDYMD, "20991231")` |
| 15 | SET | `kkopSvcKeiMap.put(SVC_STAYMD, svcStaYmdSaki)` |
| 16 | SET | `kkopSvcKeiMap.put(SVC_CHRG_STAYMD, kkopSvcKeiNextMonth)` |
| 17 | SET | `kkopSvcKeiMap.put(SVC_ENDYMD, "20991231")` |
| 18 | SET | `kkopSvcKeiMap.put(SVC_CHRG_ENDYMD, "20991231")` |

**Block 6.F-d-2** — INSERT DESTINATION KKOP (L896)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_KKOP_SVC_KEI_PKINSERT(kkopSvcKeiMap)` |

**Block 6.F-c** — DESTINATION KKOP NOT FOUND (L857)

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbExistsFlg = false` // Mark DB consistency failure |

**Block 6.F-e** — SOURCE KKOP NOT FOUND (L872)

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbExistsFlg = false` // Mark DB consistency failure |

**Block 6.G** — SELECT DELIVERY TARGET PRODUCT FOR SOURCE (L903)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeDK_T_HAISO_TG_BPIN_KK_SELECT_008(kktkSvcKeiNoMoto, kikiChgNoMoto)` |
| 2 | SET | `mapHaisoTgBpin = db_DK_T_HAISO_TG_BPIN.selectNext()` |
| 3 | IF | `null != mapHaisoTgBpin` (Block 6.G-1: update delivery) |
| 4 | ELSE | — (Block 6.G-2: skip to HMPIN) |

**Block 6.G-1** — UPDATE DELIVERY TARGET TO DESTINATION (L908)

| # | Type | Code |
|---|------|------|
| 1 | SET | `haisoTaibpinNo = mapHaisoTgBpin.getString(HAISO_TAIBPIN_NO)` // Delivery target product number |
| 2 | CALL | `executeDK_T_HAISO_TG_BPIN_PKUPDATE(new Object[] {kktkSvcKeiNoSaki, kikiChgNoSaki}, new Object[] {haisoTaibpinNo})` |

**Block 6.H** — SELECT AND UPDATE RETURN EQUIPMENT (L919)

Select return equipment records (HMPIN_KIKI_MOTO) for the source and update each record's status to "cancelled" (004) with cancellation reason "99" (other).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeDK_T_HMPIN_KIKI_KK_SELECT_016(kktkSvcKeiNoMoto, kikiChgNoMoto)` |
| 2 | WHILE | `null != (mapHmpinKiki = db_DK_T_HMPIN_KIKI_MOTO.selectNext())` |
| 3 | SET | `hmpinKikiNo = mapHmpinKiki.getString(HMPIN_KIKI_NO)` // Return equipment number |
| 4 | CALL | `executeDK_T_HMPIN_KIKI_PKUPDATE(new Object[] {"004" (CD00296_HMPIN_KIKI_STAT_004), this.opeDate, "99" (CD00633_HMPIN_KIKI_CLRE_CD_99)}, new Object[] {hmpinKikiNo})` |

**Block 6.I** — SERVICE LINE INNER (SVKEI_KAISEN_UW) BRANCH `(if oyaKeiSkbtCd == "02")` (L944)

Process the service contract line inner records (回線内訳) when the parent contract type is "02" (service contract line). This handles the PON (Passive Optical Network) type mapping between source and destination.

| # | Type | Code |
|---|------|------|
| 1 | IF | `oyaKeiSkbtCd == "02" (CD_DIV_OYAKEISKBTCD_SVKEIKSNUW)` |

**Block 6.I-a** — SELECT SOURCE SERVICE LINE INNER (L948)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_007(svcKeiKaisenUcwkNoMoto)` |
| 2 | SET | `mapSvkeiKaisenUwMoto = db_KK_T_SVKEI_KAISEN_UW.selectNext()` |
| 3 | IF | `null != mapSvkeiKaisenUwMoto` (Block 6.I-b) |
| 4 | ELSE | — (Block 6.I-c: dbExistsFlg = false) |

**Block 6.I-b** — EXTRACT SOURCE LINE INNER AND SELECT DESTINATION (L953)

Get the PON subtype code from the source record and query the destination record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ponSbtCdMoto = mapSvkeiKaisenUwMoto.getString(PON_SBT_CD)` // PON subtype from source |
| 2 | CALL | `executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_007(svcKeiKaisenUcwkNoSaki)` // Query destination |
| 3 | SET | `mapSvkeiKaisenUwSaki = db_KK_T_SVKEI_KAISEN_UW.selectNext()` |
| 4 | IF | `null != mapSvkeiKaisenUwSaki` (Block 6.I-d) |
| 5 | ELSE | — (Block 6.I-e: dbExistsFlg = false) |

**Block 6.I-d** — CONDITIONAL INSERT BASED ON EQUIPMENT TYPE (L968)

If the destination equipment is ONU (D0) or Home Gateway (S0), copy the service contract line inner data and insert it with the PON subtype from the source.

| # | Type | Code |
|---|------|------|
| 1 | IF | `taknkikiSbtCdSaki == "D0" (TAKNKIKI_SBT_CD_ONU) || taknkikiSbtCdSaki == "S0" (TAKNKIKI_SBT_CD_HGW)` |
| 2 | FOR | `for (String key : KK_T_SVKEI_KAISEN_UW_COL_LIST)` — copy from mapSvkeiKaisenUwSaki |
| 3 | SET | `kkTSvkeiKaisenUwGeneAdd = JKKBatCommon.getSysDateTimeStamp()` |
| 4 | SET | `svkeiKaisenUwMap.put(GENE_ADD_DTM, kkTSvkeiKaisenUwGeneAdd)` |
| 5 | SET | `svkeiKaisenUwMap.put(PON_SBT_CD, ponSbtCdMoto)` // Use source's PON subtype |
| 6 | CALL | `executeKK_T_SVKEI_KAISEN_UW_PKINSERT(svkeiKaisenUwMap)` |

**Block 6.I-e** — DESTINATION LINE INNER NOT FOUND (L985)

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbExistsFlg = false` |

**Block 6.I-c** — SOURCE LINE INNER NOT FOUND (L992)

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbExistsFlg = false` |

**Block 6.J** — ORDER EXECUTION CONDITION BRANCH `(if R0 or S0 AND dbExistsFlg)` (L998)

For standalone routers (R0) and Home Gateways (S0) where all prerequisite DB records exist, generate and insert order execution condition records (ODR_HAKKO_JOKEN and ODR_INF_SKSI_WK) for the new service setup. Note: the original "cancel + delete" dual-order logic (for DSL) has been removed (ANK-4577-00-00 DEL).

| # | Type | Code |
|---|------|------|
| 1 | IF | `taknkikiSbtCdSaki == "R0" || taknkikiSbtCdSaki == "S0" && dbExistsFlg` |
| 2 | CALL | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_143(sakiSvcKeiNo)` // SELECT service contract line for saki |
| 3 | SET | `mapSvcKeiUcwkSaki = db_KK_T_SVC_KEI_UCWK.selectNext()` |
| 4 | IF | `null != mapSvcKeiUcwkSaki` (Block 6.J-1) |
| 5 | ELSE | — skip to ANK-4656 block |

**Block 6.J-1** — BUILD AND INSERT ORDER CONDITIONS (L1028)

Generate a new order execution condition number via sequence and build both the ODR_HAKKO_JOKEN and ODR_INF_SKSI_WK parameter arrays with the transfer details.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiUcwkNoSaki = mapSvcKeiUcwkSaki.getString(SVC_KEI_UCWK_NO)` |
| 2 | SET | `svcKeiUcwkGeneAddSaki = mapSvcKeiUcwkSaki.getString(GENE_ADD_DTM)` |
| 3 | SET | `odrHakkoJokenNoNew = JCCBatCommon.getFormatedNextSeq(commonItem, SEQ_ODR_HAKKO_JOKEN_NO, "", 12)` // New order number |
| 4 | SET | `setParamInsHakkoJoken[0] = odrHakkoJokenNoNew` |
| 5 | SET | `setParamInsHakkoJoken[1] = sakiSvcKeiNo` |
| 6 | SET | `setParamInsHakkoJoken[2] = svcKeiUcwkNoSaki` |
| 7 | SET | `setParamInsHakkoJoken[3] = kktkSvcKeiNoSaki` |
| 8 | SET | `setParamInsHakkoJoken[7] = JKKBatConst.ORDER_SBT_CD_TEL` |
| 9 | SET | `setParamInsHakkoJoken[8] = JKKBatConst.SVC_ORDER_CD_MULTI_RUTA` |
| 10 | SET | `setParamInsHakkoJoken[9] = JKKBatConst.YOKYU_SBT_CD_NEW` // New (新規) |
| 11 | SET | `setParamInsHakkoJoken[10] = JKKBatConst.ODR_HAKKO_JOKEN_CD_SKGHAKKO` |
| 12 | SET | `setParamInsHakkoJoken[13] = taknkikiModelCdMoto` // Source model |
| 13 | SET | `setParamInsHakkoJoken[14] = kikiSeizoNoMoto` // Source serial |
| 14 | SET | `setParamInsHakkoJoken[17] = svcKeiKaisenUcwkNoSaki` |
| 15 | SET | `setParamInsInfSksiWk[0] = JCCBatCommon.getFormatedNextSeq(..., SEQ_ODR_INF_SKSI_WK_NO)` |
| 16 | SET | `setParamInsInfSksiWk[1] = odrHakkoJokenNoNew` |
| 17 | SET | `setParamInsInfSksiWk[2] = JBSbatKKConst.ORDER_NAIYO_CD_TAKINORT_ADD` // Equipment new |
| 18 | SET | `setParamInsInfSksiWk[3..38]` // Full parameter setup |
| 19 | CALL | `executeKK_T_ODR_HAKKO_JOKEN_PKINSERT(setParamInsHakkoJoken)` |
| 20 | CALL | `executeKK_T_ODR_INF_SKSI_WK_PKINSERT(setParamInfSksiWk)` |

**Block 6.K** — ANK-4656: WORK-ORDER TARGET HOME EQUIPMENT (L1065)

New functionality added by ANK-4656: query the work-order target home equipment table and update it with the new equipment change number if the target equipment record exists and is not null.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKU_T_KJAK_TG_TKKIKI_KK_SELECT_016(kktkSvcKeiNoMoto, taknkikiModelCdMoto, kikiSeizoNoMoto)` |
| 2 | SET | `mapKjakTgTkkiki = db_KU_T_KJAK_TG_TKKIKI.selectNext()` |
| 3 | IF | `null != mapKjakTgTkkiki` (Block 6.K-1) |
| 4 | ELSE | — skip to output map |

**Block 6.K-1** — UPDATE WORK-ORDER TARGET EQUIPMENT (L1073)

If the target equipment number is not null, get the system date, check if the change equipment change number is blank (flagging `chgKikiChgNoFlg`), and execute a PK update.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kojiakTrgtTaknkikiNo = mapKjakTgTkkiki.getString(KOJIAK_TRGT_TAKNKIKI_NO)` // Work-order target equipment number |
| 2 | IF | `!JKKCommonUtil.isNull(kojiakTrgtTaknkikiNo)` |
| 3 | SET | `sysdate = JBSbatDateUtil.getSystemDateTimeStamp()` |
| 4 | SET | `chgKikiChgNoFlg = false` |
| 5 | IF | `JKKStringUtil.isNullBlank(mapKjakTgTkkiki.getString(CHGE_KIKI_CHG_NO))` |
| 6 | SET | `chgKikiChgNoFlg = true` // Change number needs updating |
| 7 | CALL | `executeKU_T_KJAK_TG_TKKIKI_PKUPDATE(new Object[] {kikiChgNoSaki, kktkSvcKeiNoSaki, sysdate}, new Object[] {kojiakTrgtTaknkikiNo}, chgKikiChgNoFlg)` |

**Block 6.L** — BUILD OUTPUT MESSAGE (L1197)

Build the `JBSbatKKIFM964` output message for each processed equipment provider contract. This contains the destination service contract number, the destination equipment provider contract number, source model and serial, and the equipment subtype.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outMap = new JBSbatServiceInterfaceMap()` |
| 2 | SET | `outMap.setString(JBSbatKKIFM964.SVC_KEI_NO, sakiSvcKeiNo)` |
| 3 | SET | `outMap.setString(JBSbatKKIFM964.KKTK_SVC_KEI_NO, kktkSvcKeiNoSaki)` |
| 4 | SET | `outMap.setString(JBSbatKKIFM964.TAKNKIKI_MODEL_CD, taknkikiModelCdMoto)` |
| 5 | SET | `outMap.setString(JBSbatKKIFM964.KIKI_SEIZO_NO, kikiSeizoNoMoto)` |
| 6 | SET | `outMap.setString(JBSbatKKIFM964.TAKNKIKI_STAT, "1" (CD01704_STC))` // Installed |
| 7 | SET | `outMap.setString(JBSbatKKIFM964.TAKNKIKI_SBT_CD, taknkikiSbtCdSaki)` |
| 8 | SET | `outMap.setString(JBSbatKKIFM964.NRKEMT_SVC_KEI_KAISEN_UCWK_NO, svcKeiKaisenUcwkNoMoto)` |
| 9 | EXEC | `outMap.setOutFlg(true)` |
| 10 | EXEC | `outputItem.addOutMapList(outMap)` |

**Block 6.M** — ACCUMULATE EQUIPMENT MODEL LIST (L1207)

Maintain a running list of all equipment model codes transferred in this batch run, separated by Japanese ideograph comma.

| # | Type | Code |
|---|------|------|
| 1 | IF | `JKKStringUtil.isNullBlank(taknkikiModelList)` |
| 2 | SET | `taknkikiModelList = taknkikiModelCdMoto` // First entry |
| 3 | ELSE | `taknkikiModelList = taknkikiModelList + "、" + taknkikiModelCdMoto` // Append with separator |
| 4 | EXEC | `super.logPrint.printDebugLog("Equipment model list: " + taknkikiModelList)` |

**Block 7** — PROGRESS RECORD INSERT (L1224)

After the loop completes, if any equipment models were transferred, generate a progress record (KK_T_PRG) documenting the transfer completion.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!JKKStringUtil.isNullBlank(taknkikiModelList)` |
| 2 | SET | `prgTkjk1 = "接続機器引継[遷移元お客様ID：" + motoSvcKeiNo + "  引継型番号：" + taknkikiModelList + "]"` // Progress special item 1 |
| 3 | SET | `insertMap.put(PRG_NO, JCCBatCommon.getFormatedNextSeq(commonItem, SEQ_PRG_NO, "", 12))` |
| 4 | SET | `insertMap.put(MSKM_DTL_NO, mskmDtlNo)` |
| 5 | SET | `insertMap.put(SVC_KEI_NO, sakiSvcKeiNo)` |
| 6 | SET | `insertMap.put(IDO_DIV, idoDiv)` |
| 7 | SET | `insertMap.put(IDO_DTM, JKKBatPrgUtil.getIdoDtmMax(commonItem, sakiSvcKeiNo, idoDiv, db_KK_T_PRG))` |
| 8 | SET | `insertMap.put(PRG_STAT, "B811" (CD00647_CONNECT_KK_HKTGI_FIN))` // Equipment transfer complete |
| 9 | SET | `insertMap.put(PRG_DTM, this.opeDate + JKKBatCommon.getSysDateTimeStamp().substring(8))` |
| 10 | SET | `insertMap.put(PRG_TKJK_1, prgTkjk1)` |
| 11 | CALL | `this.executeKK_T_PRG_PKINSERT(insertMap)` |

**Block 8** — COMMIT (L1245)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getConnection().commit()` // Commit on normal completion |

**Block 9** — CATCH EXCEPTION HANDLER (L1248)

| # | Type | Code |
|---|------|------|
| 1 | CATCH | `catch (Exception e)` |
| 2 | EXEC | `commonItem.getConnection().rollback()` // Transaction rollback |
| 3 | EXEC | `commonItem.getLogPrint().printBusinessErrorLog(EKKB0010CW, new String[]{e.getMessage()})` // Error log |
| 4 | SET | `super.commonItem.setErrFlg(true)` // Set error flag |
| 5 | SET | `outputItem = new JBSbatOutputItem()` // Reset output |
| 6 | RETURN | `return outputItem` |

**Block 10** — FINAL RETURN (L1258)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return outputItem` // Normal completion with output |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `sakiSvcKeiNo` | Field | Destination service contract number — the new service contract at the new residence after address change |
| `motoSvcKeiNo` | Field | Source (transfer-from) service contract number — the original service contract from which equipment is being transferred |
| `kktkSvcKeiNo` | Field | Equipment provider service contract number — ID for a contract covering home network equipment (ONU, router, HGW) |
| `taknkikiSbtCd` | Field | Equipment subtype code — classifies the type of home network equipment: R0 (standalone router), S0 (Home Gateway), D0 (ONU), etc. |
| `oyaKeiSkbtCd` | Field | Parent contract identification code — classifies the parent contract type: "02" (service contract line inner), "03" (service contract), etc. |
| `mskmDtlNo` | Field | Application detail number — internal tracking ID for the service contract application |
| `idoDiv` | Field | Movement classification — indicates the type of movement/transfer (e.g., address change, new installation) |
| `addDtm` | Field | Registration date/time — timestamp when the minimum service contract record was registered |
| `svcStaYmdSaki` | Field | Destination service start date — the date the service begins at the new address |
| `geneAddDtm` | Field | Generation registration date — timestamp when the service contract record was created/generated |
| `kkopSvcKeiNo` | Field | Equipment option service contract number — ID for the equipment option (e.g., router rental) contract |
| `haisoTaibpinNo` | Field | Delivery target product number — product ID for the physical item being delivered to the customer |
| `hmpinKikiNo` | Field | Return equipment number — ID for equipment that the customer must return (e.g., old ONU) |
| `svkeiKaisenUcwkNo` | Field | Service contract line item number — internal tracking ID for service contract line items (回線内訳) |
| `ponSbtCd` | Field | PON subtype code — classifies the Passive Optical Network type (e.g., GPON, EPON) |
| `odrHakkoJokenNo` | Field | Order execution condition number — ID for an order execution condition record in the SOD (Service Order Data) |
| `kojiakTrgtTaknkikiNo` | Field | Work-order target home equipment number — ID for equipment referenced in work orders (工事案件対象) |
| `kikiChgNo` | Field | Equipment change number — tracks equipment replacement/change history |
| `kikiSeizoNo` | Field | Equipment serial number — unique manufacturing serial number of the home network device |
| `kikiStcSakiPlaceNo` | Field | Equipment installation location number — identifies where the equipment is installed |
| SVC_KEI_NO | Field | Service contract number — primary key for service contracts |
| NRKEMT_SVKEI_NO | Field | Transfer-from service contract number — the source contract in a transfer operation |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity that tracks order execution conditions |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service |
| KKTK | Abbreviation | Kiki Teikyou (機器提供) — Equipment Provider |
| KKOP | Abbreviation | Kiki Option (機器オプション) — Equipment Option |
| KK_T_KKTK_SVC_KEI | Table | Equipment provider service contract table — stores home network equipment service contracts |
| KK_T_SVC_KEI | Table | Service contract table — stores service contract records (minimum and current) |
| KK_T_KKOP_SVC_KEI | Table | Equipment option service contract table — stores equipment option contracts (router, HGW) |
| KK_T_SVKEI_KAISEN_UW | Table | Service contract line item table — stores line item details (回線内訳) including PON configuration |
| DK_T_HAISO_TG_BPIN | Table | Delivery target product table — stores physical product delivery information |
| DK_T_HMPIN_KIKI | Table | Return equipment table — stores equipment to be returned by customer |
| KK_T_ODR_HAKKO_JOKEN | Table | Order execution condition table — stores order execution conditions (SOD entity) |
| KK_T_ODR_INF_SKSI_WK | Table | Order information creation work table — stores work records for order information creation |
| KK_T_PRG | Table | Progress table — stores batch progress records for audit and tracking |
| KU_T_KJAK_TG_TKKIKI | Table | Work-order target home equipment table — stores equipment linked to work orders (ANK-4656) |
| ZM_M_WORK_PARAM_KNRI | Table | Business parameter management table — stores system parameter configurations |
| CD00056_STAT_TEIKYO_CHU | Constant | Status "1" (提供中) — delivery pending / being delivered |
| CD00343_2 | Constant | Reservation application code "2" — reservation confirmed |
| END_YMD_DEFAULT | Constant | End date "20991231" — far future date used as default meaning "active / no end" |
| CD01704_STC | Constant | Equipment status "1" (設置) — installed |
| CD00647_CONNECT_KK_HKTGI_FIN | Constant | Progress status "B811" — equipment transfer completed |
| CD00296_HMPIN_KIKI_STAT_004 | Constant | Return equipment status "004" — cancelled (取消済) |
| CD00633_HMPIN_KIKI_CLRE_CD_99 | Constant | Return equipment cancellation reason "99" — other (その他) |
| CD00581_1 | Constant | Shutdown finalization self-service flag "1" — enabled |
| 住所変更 | Business term | Address change (juusho henkou) — customer moves residence, triggering equipment transfer |
| 機器引継 | Business term | Equipment transfer (kiki hiki-tsuke) — handover of home network equipment between service contracts |
| 単独ルーター | Business term | Standalone router — standalone WiFi router equipment (subtype R0) |
| ホームゲートウェイ | Business term | Home Gateway — combined router/modem equipment (subtype S0) |
| ONU | Business term | Optical Network Unit — fiber optic endpoint device (subtype D0) |
| 回線内訳 | Business term | Line item (kaisen uwa) — service contract line item detailing network configuration |
| オペレーション日 | Business term | Operation date (opeDate) — the batch processing date used for planning fields |
| ANK-4577-00-00 | Change ID | Feature removal: DSL cancel+delete dual order logic removed |
| ANK-4656-00-00 | Change ID | Feature addition: work-order target home equipment handling |
| JBSbatKKIFM964 | Message ID | Output message format for equipment provider service contract details |
| SAKI (先) | Business term | Destination — the new target in a transfer operation |
| MOTO (元) | Business term | Source — the original item in a transfer operation |
