# Business Logic — JBSbatKKSodUpdInfCst.execute() [388 LOC]

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

## 1. Role

### JBSbatKKSodUpdInfCst.execute()

This method is the **Service Order (SOD) Update Information Extraction Component**, a batch service responsible for identifying which service contracts need to be updated (either newly installed or dismantled) as a result of a **Residential Change** (Address Change: KK_T_ADCHG) operation. It runs as part of the `JBSbatKKAdChgCstScreenKidou` batch orchestration, which processes all residential change registrations in a delayed batch job.

The method performs **routing/dispatch logic** based on two key dimensions: (1) whether the batch is running in **delayed mode** (scheduled, automatic) or **non-delayed mode** (manual or immediate), and (2) whether a **discount auto-application flag** (`WRIB_EXE_FLG`) is set, which indicates a line cut-over has been detected. It determines both **new service contracts** (the service assigned after the address change — the transfer destination) and **dismantled service contracts** (the service assigned before the address change — the transfer origin), and writes the results to an intermediate output map.

The design pattern is **delegation**: this method does not directly modify data. Instead, it queries multiple database tables to determine which contracts changed, then returns structured output (`JBSbatOutputItem`) that the caller (`JBSbatKKAdChgSodUpd`, the "Residential Change SOD Execution" component) uses to actually update the service order records. This separation of concerns between detection and execution is a core architectural pattern in this batch system.

Conditional branches handle: (a) discount auto-application detection via intermediate file `KK_T_SVKEI_KAISEN_UW`, (b) delayed-mode scheduling verification with move-in reservation date checks to prevent duplicate execution, (c) manual execution bypass, (d) new service determination through work completion worklists and installation status, and (e) dismantled service determination through work completion worklists and contract provision mode checks. The method also filters out surrender services (contracts that were cancelled) to prevent duplicate SOD issuance.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["Start: execute inMap"])
    CHECK_WRIB["Check: wribExeFlg equals 1?"]
    WRIB_FILE["Write: Execute KK_T_SVKEI_KAISEN_UW_KK_SELECT_039"]
    WRIB_CHECK["Check: Select result not null?"]
    WRIB_SET_NEW["SET: Set new service fields"]
    WRIB_RETURN["Return: outputItem (empty)"]
    CHECK_DELAYED["Check: isDelayed equals 1?"]
    CHECK_NEW_SVC["Check: new service contract number present?"]
    DELAYED_SET_NEW["SET: Set new service fields"]
    CHECK_SYUDO["Check: isSyudo(inAdchgNo)?"]
    CHECK_DELAYED_ZUMI["Check: isDelayedZumi(inAdchgNo)?"]
    CHECK_NYUKYO["Check: new service contract number not blank?"]
    NYUKYO_QUERY["CALL: executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_026"]
    NYUKYO_RESULT["Check: nyukyoRsvTriKisnInfo != null"]
    NYUKYO_SET_CHECK["Check: new service contract number present?"]
    NEW_KOJI_QUERY["CALL: getNewKojiFinYmd"]
    NEW_KOJI_CHECK["Check: newKojiFinYmd isBlank or equals opeDate?"]
    NYUKYO_SET["SET: Set new service fields"]
    NEW_KOJI_FULL["Check: new service contract number present?"]
    CHECK_DELAYED_ZUMI2["Check: isDelayedZumi?"]
    NYUKYO_RSV_QUERY["CALL: executeKK_T_SVKEI_KAISEN_UW_PKSELECT"]
    NYUKYO_RSV_CHECK["Check: opeDate less than nyukyoRsvYmd?"]
    WORKLIST_QUERY["CALL: executeKK_T_KJ_FIN_WK_KK_SELECT_020"]
    WORKLIST_LOOP["Loop: db_KK_T_KJ_FIN_WK.selectNext"]
    KOJIAK_QUERY["CALL: executeKU_T_SVKEI_KOJIAK_KK_SELECT_007"]
    KOJIAK_RESULT["Check: db_KU_T_SVKEI_KOJIAK.selectNext != null"]
    WORKLIST_SET["SET: Set new service fields"]
    CHECK_NOT_DELAYED["Check: isDelayed NOT equals 1?"]
    CHECK_DSL_SVC["Check: old service contract number present?"]
    DSL_WORKLIST_QUERY["CALL: executeKK_T_KJ_FIN_WK_KK_SELECT_019"]
    DSL_WORKLIST_LOOP["Loop: db_KK_T_KJ_FIN_WK.selectNext"]
    DSL_KOJIAK_QUERY["CALL: executeKU_T_SVKEI_KOJIAK_KK_SELECT_007"]
    DSL_KOJIAK_RESULT["Check: db_KU_T_SVKEI_KOJIAK.selectNext != null"]
    DSL_WORKSET["SET: Set dismantled service fields"]
    CHECK_KOJI_NASHI["Check: kojiNashiTel == false?"]
    HOSHIKI_QUERY["CALL: executeKK_T_TK_HOSHIKI_KEI_KK_SELECT_023"]
    ADCHG_DTL_QUERY["CALL: executeKK_T_ADCHG_DTL_KK_SELECT_021"]
    HOSHIKI_RESULT["Check: db_KK_T_TK_HOSHIKI_KEI or db_KK_T_ADCHG_DTL not null"]
    DSL_SET2["SET: Set dismantled service fields"]
    CHECK_ADCHG["Check: adchgNo present?"]
    OUT_MAP_SET["SET: Build outMap with all fields"]
    SURRENDER_CHECK["Check: isSurrenderService(inChbfSkbtNo)?"]
    ADD_OUT["outputItem.addOutMapList(outMap)"]
    RETURN_OUT["Return: outputItem"]
    RETURN_NULL["Return: null"]
    END(["End: Next"])

    START --> CHECK_WRIB
    CHECK_WRIB -->|"wribExeFlg equals 1"| WRIB_FILE
    CHECK_WRIB -->|"not 1"| CHECK_DELAYED
    WRIB_FILE --> WRIB_CHECK
    WRIB_CHECK -->|"not null"| WRIB_SET_NEW
    WRIB_CHECK -->|"null"| WRIB_RETURN
    WRIB_SET_NEW --> END
    WRIB_RETURN --> END
    CHECK_DELAYED -->|"isDelayed equals 1"| CHECK_NEW_SVC
    CHECK_DELAYED -->|"not 1"| CHECK_SYUDO
    CHECK_NEW_SVC -->|"present"| DELAYED_SET_NEW
    CHECK_NEW_SVC -->|"blank"| CHECK_SYUDO
    DELAYED_SET_NEW --> CHECK_SYUDO
    CHECK_SYUDO -->|"manual true"| CHECK_NOT_DELAYED
    CHECK_SYUDO -->|"not manual"| CHECK_DELAYED_ZUMI
    CHECK_DELAYED_ZUMI --> CHECK_NYUKYO
    CHECK_NYUKYO -->|"has contract"| NYUKYO_QUERY
    CHECK_NYUKYO -->|"blank"| NYUKYO_SET_CHECK
    NYUKYO_QUERY --> NYUKYO_RESULT
    NYUKYO_RESULT -->|"has reservation"| NYUKYO_SET_CHECK
    NYUKYO_RESULT -->|"no reservation"| NEW_KOJI_FULL
    NYUKYO_SET_CHECK -->|"present"| NEW_KOJI_QUERY
    NYUKYO_SET_CHECK -->|"blank"| NEW_KOJI_FULL
    NEW_KOJI_QUERY --> NEW_KOJI_CHECK
    NEW_KOJI_CHECK -->|"incomplete or today"| NYUKYO_SET
    NEW_KOJI_CHECK -->|"other"| NEW_KOJI_FULL
    NYUKYO_SET --> NEW_KOJI_FULL
    NEW_KOJI_FULL -->|"present"| CHECK_DELAYED_ZUMI2
    NEW_KOJI_FULL -->|"blank"| CHECK_NOT_DELAYED
    CHECK_DELAYED_ZUMI2 -->|"not confirmed"| NYUKYO_RSV_QUERY
    CHECK_DELAYED_ZUMI2 -->|"confirmed"| CHECK_NOT_DELAYED
    NYUKYO_RSV_QUERY --> NYUKYO_RSV_CHECK
    NYUKYO_RSV_CHECK -->|"date not arrived"| WORKLIST_QUERY
    NYUKYO_RSV_CHECK -->|"date arrived"| CHECK_NOT_DELAYED
    WORKLIST_QUERY --> WORKLIST_LOOP
    WORKLIST_LOOP -->|"next row"| KOJIAK_QUERY
    WORKLIST_LOOP -->|"no row"| CHECK_NOT_DELAYED
    KOJIAK_QUERY --> KOJIAK_RESULT
    KOJIAK_RESULT -->|"exists"| WORKLIST_SET
    KOJIAK_RESULT -->|"null"| WORKLIST_LOOP
    WORKLIST_SET --> WORKLIST_LOOP
    CHECK_NOT_DELAYED -->|"not delayed"| CHECK_DSL_SVC
    CHECK_NOT_DELAYED -->|"delayed"| CHECK_ADCHG
    CHECK_DSL_SVC -->|"present"| DSL_WORKLIST_QUERY
    CHECK_DSL_SVC -->|"blank"| CHECK_ADCHG
    DSL_WORKLIST_QUERY --> DSL_WORKLIST_LOOP
    DSL_WORKLIST_LOOP -->|"next row"| DSL_KOJIAK_QUERY
    DSL_WORKLIST_LOOP -->|"no row"| CHECK_KOJI_NASHI
    DSL_KOJIAK_QUERY --> DSL_KOJIAK_RESULT
    DSL_KOJIAK_RESULT -->|"exists"| DSL_WORKSET
    DSL_KOJIAK_RESULT -->|"null"| DSL_WORKLIST_LOOP
    DSL_WORKSET --> DSL_WORKLIST_LOOP
    DSL_WORKSET --> CHECK_KOJI_NASHI
    CHECK_KOJI_NASHI -->|"no work"| HOSHIKI_QUERY
    CHECK_KOJI_NASHI -->|"has work"| CHECK_ADCHG
    HOSHIKI_QUERY --> ADCHG_DTL_QUERY
    ADCHG_DTL_QUERY --> HOSHIKI_RESULT
    HOSHIKI_RESULT -->|"exists"| DSL_SET2
    HOSHIKI_RESULT -->|"null"| CHECK_ADCHG
    DSL_SET2 --> CHECK_ADCHG
    CHECK_ADCHG -->|"present"| OUT_MAP_SET
    CHECK_ADCHG -->|"blank"| RETURN_NULL
    OUT_MAP_SET --> SURRENDER_CHECK
    SURRENDER_CHECK -->|"not surrender"| ADD_OUT
    SURRENDER_CHECK -->|"surrender"| RETURN_OUT
    ADD_OUT --> RETURN_OUT
    RETURN_OUT --> END
    RETURN_NULL --> END
```

### Processing Flow Summary

1. **Discount auto-application branch** (L233): If `WRIB_EXE_FLG = "1"`, query the intermediate file table `KK_T_SVKEI_KAISEN_UW`. If a record exists, set the new service fields and return immediately. This handles the case where a line cut-over was detected by the discount auto-application Component.

2. **Delayed-mode new service detection** (L261): If `IS_DELAYED = "1"` (DELAYED_START constant), and a new service contract number exists, set the new service fields. This is the standard scheduled path.

3. **Non-delayed mode: move-in date check** (L287): If not manual (`isSyudo` returns false), check whether delayed confirmation is complete (`isDelayedZumi`). Query the service contract line reservation table (`KK_T_SVKEI_KAISEN_UW`) to verify the move-in reservation date has arrived. If the date has arrived and the new construction work is not yet completed (or completed today), set the new service fields.

4. **New construction completion worklist check** (L350): For non-delayed-confirmed cases, query the installation reservation details and work completion worklist (`KK_T_KJ_FIN_WK`). For each worklist entry, check the service contract/engineering case table (`KU_T_SVKEI_KOJIAK`). If a match exists and the move-in date has not yet arrived (prevents duplicate), set the new service fields.

5. **Dismantled service detection** (L421): If NOT delayed (`isDelayed` is not `"1"`), query the dismantled work completion worklist (`KK_T_KJ_FIN_WK_KK_SELECT_019`). For each entry, check the service contract/engineering case. If found, set dismantled service fields.

6. **Provider mode fallback** (L467): If no worklist entry was found (`kojiNashiTel == false`), query the provider contract table (`KK_T_TK_HOSHIKI_KEI`) and address change detail table (`KK_T_ADCHG_DTL`) as a fallback to find dismantled service information.

7. **Output assembly** (L510): If `adchgNo` was set (meaning at least one service change was detected), build the output map with all relevant fields. If the old service was NOT surrendered (per `isSurrenderService`), add the output map to the result. Return the output item; otherwise return `null`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input message envelope containing all residential change (address change) data: address change number, application number, transfer-origin and transfer-destination service contract line item numbers, service contract numbers before and after change, service contract disruption type code, delay start flag, and discount auto-application flag. |

**Instance fields / external state read:**

| Field | Business Description |
|-------|---------------------|
| `opeDate` | Operation date — the current processing date, used for date comparisons and SQL queries |
| `db_KK_T_SVKEI_KAISEN_UW` | DB access cursor for the service contract line item intermediate table (reservation data) |
| `db_KK_T_KJ_FIN_WK` | DB access cursor for the work completion worklist table |
| `db_KK_T_ADCHG_DTL` | DB access cursor for the address change detail table |
| `db_KU_T_SVKEI_KOJIAK` | DB access cursor for the service contract/engineering case table |
| `db_KK_T_TK_HOSHIKI_KEI` | DB access cursor for the provider contract table |
| `db_KK_T_ADCHG` | DB access cursor for the address change header table (used by helper methods) |
| `db_KK_T_SVC_KEI` | DB access cursor for the service contract table (used by `isSurrenderService`) |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatFUCaseFileRnkData.getString` | JBSbatFUCaseFileRnkData | - | Calls `getString` in `JBSbatFUCaseFileRnkData` to read a value from the input envelope |
| R | `JBSbatFUMoveNaviData.getString` | JBSbatFUMoveNaviData | - | Calls `getString` in `JBSbatFUMoveNaviData` to read a value from the input envelope |
| R | `JBSbatZMAdDataSet.getString` | JBSbatZMAdDataSet | - | Calls `getString` in `JBSbatZMAdDataSet` to read a value from the input envelope |
| C | `JBSbatKKGetCTITelno.addOutMapList` | JBSbatKKGetCTITelno | - | Calls `addOutMapList` in `JBSbatKKGetCTITelno` to add output data |
| R | `JBSbatKKSodUpdInfCst.executeKK_T_ADCHG_DTL_KK_SELECT_021` | JBSbatKKSodUpdInfCst | KK_T_ADCHG_DTL | Queries address change detail table for fallback dismantled service detection (ST2-2013-0001403: network/phone one-sided retention consideration) |
| R | `JBSbatKKSodUpdInfCst.executeKK_T_KJ_FIN_WK_KK_SELECT_019` | JBSbatKKSodUpdInfCst | KK_T_KJ_FIN_WK | Queries work completion worklist table to find dismantled service engineering cases |
| R | `JBSbatKKSodUpdInfCst.executeKK_T_KJ_FIN_WK_KK_SELECT_020` | JBSbatKKSodUpdInfCst | KK_T_KJ_FIN_WK | Queries work completion worklist table to find new service engineering cases |
| R | `JBSbatKKSodUpdInfCst.executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_026` | JBSbatKKSodUpdInfCst | KK_T_SVKEI_KAISEN_UW | Queries service contract line item intermediate table for move-in reservation check (before move-in date arrival) |
| R | `JBSbatKKSodUpdInfCst.executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_039` | JBSbatKKSodUpdInfCst | KK_T_SVKEI_KAISEN_UW | Queries intermediate file table to detect line cut-over for discount auto-application |
| R | `JBSbatKKSodUpdInfCst.executeKK_T_SVKEI_KAISEN_UW_PKSELECT` | JBSbatKKSodUpdInfCst | KK_T_SVKEI_KAISEN_UW | Primary-key selects service contract line item to get move-in reservation date |
| R | `JBSbatKKSodUpdInfCst.executeKK_T_TK_HOSHIKI_KEI_KK_SELECT_023` | JBSbatKKSodUpdInfCst | KK_T_TK_HOSHIKI_KEI | Queries provider contract table as fallback when worklist has no entry for dismantled service |
| R | `JBSbatKKSodUpdInfCst.executeKU_T_SVKEI_KOJIAK_KK_SELECT_007` | JBSbatKKSodUpdInfCst | KU_T_SVKEI_KOJIAK | Queries service contract/engineering case to verify new/dismantled service existence |
| R | `JBSbatKKSodUpdInfCst.executeKK_T_ADCHG_PKSELECT` | JBSbatKKSodUpdInfCst | KK_T_ADCHG | Primary-key select of address change header (used by isSyudo/isDelayedZumi) |
| R | `JBSbatKKSodUpdInfCst.executeKK_T_ADCHG_DTL_KK_SELECT_022` | JBSbatKKSodUpdInfCst | KK_T_ADCHG_DTL | Queries address change detail for new construction completion date (used by getNewKojiFinYmd) |
| R | `JBSbatKKSodUpdInfCst.getNewKojiFinYmd` | JBSbatKKSodUpdInfCst | KK_T_ADCHG_DTL | Gets the new construction completion date for duplicate execution prevention |
| R | `JBSbatKKSodUpdInfCst.isDelayedZumi` | JBSbatKKSodUpdInfCst | KK_T_ADCHG | Checks if manual confirmation is complete (duplicate execution prevention) |
| R | `JBSbatKKSodUpdInfCst.isSyudo` | JBSbatKKSodUpdInfCst | KK_T_ADCHG | Checks if the residential change was manually executed |
| R | `JBSbatKKSodUpdInfCst.isSurrenderService` | JBSbatKKSodUpdInfCst | KK_T_SVC_KEI | Checks if the old service contract was surrendered/cancelled (prevents duplicate SOD issuance) |
| - | `JBSbatInterface.adjustDate` | JBSbatInterface | - | Date arithmetic utility to adjust opeDate by a specified number of days |
| - | `JBSbatInterface.trim` | JBSbatInterface | - | Trims whitespace from string values |
| - | `JKKBatClarisAuthCrdt.isNullBlank` | JKKBatClarisAuthCrdt | - | Null/blank string check utility |
| - | `JKKBatClearPassBase.isNullBlank` | JKKBatClearPassBase | - | Null/blank string check utility |
| - | `JKKBatClearPassCrdt.isNullBlank` | JKKBatClearPassCrdt | - | Null/blank string check utility |
| - | `JZMBatCommon.trim` | JZMBatCommon | - | Trims whitespace utility |
| - | `JBSbatACEoElectPrcInfoTrkm.isNullBlank` | JBSbatACEoElectPrcInfoTrkm | - | Null/blank string check utility |
| - | `JBSbatACIcjknTrkmRsltHenshu.setOutFlg` | JBSbatACIcjknTrkmRsltHenshu | - | Sets output flag in result envelope |
| - | `JBSbatACTelnoGuideUseChrgInfoTrkmDataMake.setOutFlg` | JBSbatACTelnoGuideUseChrgInfoTrkmDataMake | - | Sets output flag in result envelope |
| - | `JBSbatACTrgtSvcKeiMake.isNullBlank` | JBSbatACTrgtSvcKeiMake | - | Null/blank string check utility |
| - | `JBSbatKKBmpKaihkPrdChokNoDel.trim` | JBSbatKKBmpKaihkPrdChokNoDel | - | Trims whitespace utility |
| - | `JBSbatKKSodSendReqBase.trim` | JBSbatKKSodSendReqBase | - | Trims whitespace utility |
| - | `JBSbatKKTchishoDelete.trim` | JBSbatKKTchishoDelete | - | Trims whitespace utility |
| - | `JBSbatKKAdChgDtlInfoTrkmDataMake.setOutFlg` | JBSbatKKAdChgDtlInfoTrkmDataMake | - | Sets output flag in result envelope |
| - | `JBSbatKKSodUpdInfCst.isBlank` | JBSbatKKSodUpdInfCst | - | Local utility: checks if a string is null or blank |
| R | `JBSbatFUCaseFileRnkData.getString` | JBSbatFUCaseFileRnkData | - | Reads a value from the service interface map |
| R | `JBSbatFUMoveNaviData.getString` | JBSbatFUMoveNaviData | - | Reads a value from the service interface map |
| R | `JBSbatZMAdDataSet.getString` | JBSbatZMAdDataSet | - | Reads a value from the service interface map |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: KKAdChgCstScreenKidou | `JBSbatKKAdChgCstScreenKidou.execute()` -> `this.execObjSod.execute(inMap)` | `executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_039 [R] KK_T_SVKEI_KAISEN_UW`, `executeKK_T_KJ_FIN_WK_KK_SELECT_019 [R] KK_T_KJ_FIN_WK`, `executeKK_T_KJ_FIN_WK_KK_SELECT_020 [R] KK_T_KJ_FIN_WK`, `executeKU_T_SVKEI_KOJIAK_KK_SELECT_007 [R] KU_T_SVKEI_KOJIAK`, `executeKK_T_TK_HOSHIKI_KEI_KK_SELECT_023 [R] KK_T_TK_HOSHIKI_KEI`, `executeKK_T_ADCHG_DTL_KK_SELECT_021 [R] KK_T_ADCHG_DTL`, `executeKK_T_SVKEI_KAISEN_UW_PKSELECT [R] KK_T_SVKEI_KAISEN_UW`, `executeKK_T_ADCHG_PKSELECT [R] KK_T_ADCHG`, `executeKK_T_ADCHG_DTL_KK_SELECT_022 [R] KK_T_ADCHG_DTL`, `isSurrenderService [R] KK_T_SVC_KEI` |

**Notes:**
- The sole caller is the batch component `JBSbatKKAdChgCstScreenKidou`, which orchestrates all address change processing tasks.
- `JBSbatKKAdChgCstScreenKidou` instantiates `JBSbatKKSodUpdInfCst` as `execObjSod` and calls its `execute(inMap)` method after the main address change registration component (`execObj.execute`) completes.
- The input map is constructed from `KK_T_ADCHG` and `KK_T_ADCHG_DTL` query results within the caller's processing loop.
- `IS_DELAYED` is always set to `"1"` (DELAYED_START) by the caller, so this method primarily runs in delayed (scheduled) mode.

## 6. Per-Branch Detail Blocks

**Block 1** — [INITIALIZATION] `(L211)`

> Initialize the output item and extract all input fields from the envelope.

| # | Type | Code |
|---|------|------|
| 1 | NEW | `outputItem = new JBSbatOutputItem()` |
| 2 | NEW | `outMap = new JBSbatServiceInterfaceMap()` |
| 3 | EXEC | `outMap.setOutFlg(true)` // Set output flag |
| 4 | SET | `inAdchgNo = inMap.getString(JBSbatKK_T_ADCHG.ADCHG_NO)` // Address change number |
| 5 | SET | `inMskmNo = inMap.getString(JBSbatKK_T_ADCHG.MSKM_NO)` // Application number |
| 6 | SET | `inItnmSvkeiKisuwNo = inMap.getString(JBSbatKK_T_ADCHG.ITNM_SVKEI_KISUW_NO)` // Transfer-origin service contract line item number |
| 7 | SET | `inItensSvkeiKisuwNo = inMap.getString(JBSbatKK_T_ADCHG.ITENS_SVKEI_KISUW_NO)` // Transfer-destination service contract line item number |
| 8 | SET | `inItnmSvkeiKisuwGeneAddDtm = inMap.getString("ITNM_SVKEI_KISUW_GENE_ADD_DTM")` // Transfer-origin generation add date/time |
| 9 | SET | `inItensSvkeiKisuwGeneAddDtm = inMap.getString("ITENS_SVKEI_KISUW_GENE_ADD_DTM")` // Transfer-destination generation add date/time |
| 10 | SET | `inChbfSkbtNo = inMap.getString(JBSbatKK_T_ADCHG_DTL.CHBF_SKBT_NO)` // Pre-change identification number (service contract number) |
| 11 | SET | `inChafSkbtNo = inMap.getString(JBSbatKK_T_ADCHG_DTL.CHAF_SKBT_NO)` // Post-change identification number (service contract number) |
| 12 | SET | `inSvcKeiIdoSbtCd = inMap.getString(JBSbatKK_T_ADCHG_DTL.SVC_KEI_IDO_SBT_CD)` // Service contract disruption type code |
| 13 | SET | `wribExeFlg = inMap.getString("WRIB_EXE_FLG")` // Discount auto-application execution flag [WRIB_EXE_FLG="1"] |
| 14 | SET | `isDelayed = inMap.getString("IS_DELAYED")` // Delay start flag |
| 15 | SET | `isDelayed = DELAYED_NOT_START` // Default: not delayed, if null or blank [DELAYED_NOT_START="0"] |

**Block 2** — [IF] `(wribExeFlg equals "1")` (L233)

> **Discount auto-application branch**: When the discount auto-application execution flag is set, the line cut-over has been detected by the discount CC component. Query the intermediate file table to determine if the new service is valid, and if so, set the new service fields and return early.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_039(new String[]{inItensSvkeiKisuwNo, opeDate, opeDate, opeDate})` // Query intermediate file table for line cut-over |
| 2 | CHECK | `db_KK_T_SVKEI_KAISEN_UW.selectNext() != null` // Check if intermediate record exists |
| 3 | SET | `adchgNo = inAdchgNo` // Address change number |
| 4 | SET | `mskmNo = inMskmNo` // Application number |
| 5 | SET | `newSvkeiKisuwNo = inItensSvkeiKisuwNo` // Transfer-destination service contract line item number |
| 6 | SET | `newSvcKeiNo = inChafSkbtNo` // Post-change service contract number |
| 7 | SET | `svcKeiIdoSbtCd = inSvcKeiIdoSbtCd` // Service contract disruption type code |
| 8 | SET | `newSvkeiKisuwGene = inItensSvkeiKisuwGeneAddDtm` // Transfer-destination generation |
| 9 | SET | `newFinFlg = FIN_FLG_FIN` // New service completed [FIN_FLG_FIN="1"] |
| 10 | RETURN | `return outputItem` // Return (with empty outMapList since adchgNo was never set to output) |

**ELSE Block 2.1** — [ELSE] `(wribExeFlg not "1")` (L261)

> **Standard processing branch**: Execute the main logic for delayed and non-delayed modes.

**Block 2.1.1** — [IF] `(DELAYED_START equals isDelayed)` (L264)

> **Delayed-mode new service detection**: When the batch is running in delayed (scheduled) mode, and a new service contract number exists, set the new service fields directly. This is the standard scheduled processing path.

| # | Type | Code |
|---|------|------|
| 1 | CHECK | `!(inChafSkbtNo == null || "".equals(inChafSkbtNo.trim()))` // New service contract number present? |
| 2 | SET | `adchgNo = inAdchgNo` // Address change number |
| 3 | SET | `mskmNo = inMskmNo` // Application number |
| 4 | SET | `newSvkeiKisuwNo = inItensSvkeiKisuwNo` // Transfer-destination service contract line item number |
| 5 | SET | `newSvcKeiNo = inChafSkbtNo` // Post-change service contract number |
| 6 | SET | `svcKeiIdoSbtCd = inSvcKeiIdoSbtCd` // Service contract disruption type code |
| 7 | SET | `newSvkeiKisuwGene = inItensSvkeiKisuwGeneAddDtm` // Transfer-destination generation |
| 8 | SET | `newFinFlg = FIN_FLG_FIN` // New service completed [FIN_FLG_FIN="1"] |

**Block 2.1.2** — [IF] `(!isSyudo(inAdchgNo))` (L287)

> **Non-manual execution check**: If the residential change was NOT manually executed (i.e., it is an automatic/scheduled change), perform detailed move-in date and completion checks. Manual execution bypasses these checks because the operator has already confirmed readiness.

**Block 2.1.2.1** — [IF] `(!isDelayedZumi(inAdchgNo))` (L291)

> **Duplicate execution prevention (delayed confirmation)**: Check that the delayed confirmation has not already been completed. This prevents the same service update from being recorded twice.

**Block 2.1.2.1.1** — [IF] `(!JKKStringUtil.isNullBlank(inItensSvkeiKisuwNo))` (L296)

> **Move-in reservation date arrival check**: Query the service contract line item intermediate table to verify the move-in reservation date has arrived.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_026(new String[]{inItensSvkeiKisuwNo, JBSbatDateUtil.adjustDate(opeDate, 1)})` // Query with service line number and previous day of operation date |
| 2 | SET | `nyukyoRsvTriKisnInfo = db_KK_T_SVKEI_KAISEN_UW.selectNext()` // Get move-in reservation info |

**Block 2.1.2.1.1.1** — [IF] `(nyukyoRsvTriKisnInfo != null)` (L302)

> **Move-in reservation exists**: The move-in reservation date has arrived for this service contract.

**Block 2.1.2.1.1.1.1** — [IF] `(inChafSkbtNo present)` (L310)

> **New service contract number exists**: Check if a new service contract has been assigned after the address change.

**Block 2.1.2.1.1.1.1.1** — [IF] `(!isDelayedZumi)` (L325, nested within)

> **Re-check delayed confirmation**: Inside the move-in reservation check, verify again that delayed confirmation has not completed.

**Block 2.1.2.1.1.1.1.1.1** — [IF] `(isBlank(newKojiFinYmd) || opeDate.equals(newKojiFinYmd))` (L332)

> **New construction not completed or completed today**: If the new construction completion date is blank (not completed) or equals today's operation date, set the new service fields. This prevents processing incomplete work or re-processing work that was already handled.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `newKojiFinYmd = getNewKojiFinYmd(inAdchgNo, inChafSkbtNo)` // Get new construction completion date |
| 2 | CHECK | `isBlank(newKojiFinYmd) || opeDate.equals(newKojiFinYmd)` // Not completed, or completed today |
| 3 | SET | `adchgNo = inAdchgNo` // Address change number |
| 4 | SET | `mskmNo = inMskmNo` // Application number |
| 5 | SET | `newSvkeiKisuwNo = inItensSvkeiKisuwNo` // Transfer-destination service contract line item number |
| 6 | SET | `newSvcKeiNo = inChafSkbtNo` // Post-change service contract number |
| 7 | SET | `svcKeiIdoSbtCd = inSvcKeiIdoSbtCd` // Service contract disruption type code |
| 8 | SET | `newSvkeiKisuwGene = inItensSvkeiKisuwGeneAddDtm` // Transfer-destination generation |
| 9 | SET | `newFinFlg = FIN_FLG_FIN` // New service completed [FIN_FLG_FIN="1"] |

**Block 2.1.2.1.2** — [IF] `(inChafSkbtNo present)` (L350)

> **New construction completion worklist check**: Separate from the move-in date check, query the work completion worklist table to find new service engineering cases. This handles the case where the move-in date has not yet arrived but the worklist entry exists.

**Block 2.1.2.1.2.1** — [IF] `(!isDelayedZumi)` (L357)

> **Re-check delayed confirmation** within the worklist check branch.

**Block 2.1.2.1.2.1.1** — [IF] `(opeDate.compareTo(nyukyoRsvYmd) < 0)` (L373)

> **Move-in date not yet arrived**: The operation date is before the move-in reservation date, indicating the work is pending. This prevents premature processing.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_KJ_FIN_WK_KK_SELECT_020(new String[]{inAdchgNo, opeDate})` // Query new service work completion worklist |
| 2 | SET | `newKjFinRnkiInfo = db_KK_T_KJ_FIN_WK.selectNext()` // Get first row from worklist cursor |

**Block 2.1.2.1.2.1.1.1** — [FOR LOOP] `(newKjFinRnkiInfo != null)` (L376)

> **Iterate over work completion worklist entries**: For each worklist entry, check the service contract/engineering case table.

| # | Type | Code |
|---|------|------|
| 1 | SET | `newKojiakNo = newKjFinRnkiInfo.getString(JBSbatKK_T_KJ_FIN_WK.KOJIAK_NO)` // Get engineering case number |
| 2 | CALL | `executeKU_T_SVKEI_KOJIAK_KK_SELECT_007(new String[]{inChafSkbtNo, newKojiakNo})` // Query service contract/engineering case |
| 3 | CHECK | `db_KU_T_SVKEI_KOJIAK.selectNext() != null` // Service contract/engineering case exists |
| 4 | SET | `adchgNo = inAdchgNo` // Address change number |
| 5 | SET | `mskmNo = inMskmNo` // Application number |
| 6 | SET | `newSvkeiKisuwNo = inItensSvkeiKisuwNo` // Transfer-destination service contract line item number |
| 7 | SET | `newSvcKeiNo = inChafSkbtNo` // Post-change service contract number |
| 8 | SET | `svcKeiIdoSbtCd = inSvcKeiIdoSbtCd` // Service contract disruption type code |
| 9 | SET | `newSvkeiKisuwGene = inItensSvkeiKisuwGeneAddDtm` // Transfer-destination generation |
| 10 | SET | `newFinFlg = FIN_FLG_FIN` // New service completed [FIN_FLG_FIN="1"] |

**Block 2.1.2.1.2.2** — [IF] `(!isDelayedZumi)` (L394, parallel to move-in check)

> **New construction completion re-check**: Another delayed confirmation check nested within the worklist logic.

**Block 2.1.3** — [ELSE from isSyudo check] (L421)

> **Dismantled service detection**: If the batch is NOT in delayed mode (`!DELAYED_START.equals(isDelayed)`), query the dismantled work completion worklist. This path handles non-delayed (e.g., immediate/manual-triggered) batch runs.

**Block 2.1.3.1** — [IF] `(inChbfSkbtNo present)` (L425)

> **Old service contract number exists**: A dismantled service contract was assigned before the address change.

**Block 2.1.3.1.1** — [FOR LOOP] `(dslKjFinRnkiInfo != null)` (L432)

> **Iterate dismantled work completion worklist**: For each entry, query the service contract/engineering case table to verify the dismantled service.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_KJ_FIN_WK_KK_SELECT_019(new String[]{inAdchgNo, opeDate})` // Query dismantled work completion worklist |
| 2 | SET | `dslKjFinRnkiInfo = db_KK_T_KJ_FIN_WK.selectNext()` // Get first row |
| 3 | SET | `dslKojiakNo = dslKjFinRnkiInfo.getString(JBSbatKK_T_KJ_FIN_WK.KOJIAK_NO)` // Engineering case number |
| 4 | CALL | `executeKU_T_SVKEI_KOJIAK_KK_SELECT_007(new String[]{inChbfSkbtNo, dslKojiakNo})` // Query service contract/engineering case |
| 5 | CHECK | `db_KU_T_SVKEI_KOJIAK.selectNext() != null` // Dismantled service exists |
| 6 | SET | `adchgNo = inAdchgNo` // Address change number |
| 7 | SET | `mskmNo = inMskmNo` // Application number |
| 8 | SET | `dslSvkeiKisuwNo = inItnmSvkeiKisuwNo` // Transfer-origin service contract line item number |
| 9 | SET | `dslSvcKeiNo = inChbfSkbtNo` // Pre-change service contract number |
| 10 | SET | `svcKeiIdoSbtCd = inSvcKeiIdoSbtCd` // Service contract disruption type code |
| 11 | SET | `dslSvkeiKisuwGene = inItnmSvkeiKisuwGeneAddDtm` // Transfer-origin generation |
| 12 | SET | `dslFinFlg = FIN_FLG_FIN` // Dismantled service completed [FIN_FLG_FIN="1"] |
| 13 | SET | `kojiNashiTel = true` // Flag: dismantled service found without provider mode |

**Block 2.1.3.1.2** — [IF] `(!kojiNashiTel)` (L467)

> **Provider mode fallback**: If no worklist entry was found, query the provider contract table and address change detail table as a fallback. This handles cases where the dismantled service exists but has no worklist entry (e.g., network/phone one-sided retention scenarios per ST2-2013-0001403).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_TK_HOSHIKI_KEI_KK_SELECT_023(new String[]{inAdchgNo, opeDate, inChbfSkbtNo, opeDate})` // Query provider contract table |
| 2 | CALL | `executeKK_T_ADCHG_DTL_KK_SELECT_021(new String[]{opeDate, inAdchgNo, inChbfSkbtNo})` // Query address change detail (ST2-0001403: network/phone one-sided retention) |
| 3 | CHECK | `db_KK_T_TK_HOSHIKI_KEI.selectNext() != null || db_KK_T_ADCHG_DTL.selectNext() != null` // Either table has result |
| 4 | SET | `adchgNo = inAdchgNo` // Address change number |
| 5 | SET | `mskmNo = inMskmNo` // Application number |
| 6 | SET | `dslSvkeiKisuwNo = inItnmSvkeiKisuwNo` // Transfer-origin service contract line item number |
| 7 | SET | `dslSvcKeiNo = inChbfSkbtNo` // Pre-change service contract number |
| 8 | SET | `svcKeiIdoSbtCd = inSvcKeiIdoSbtCd` // Service contract disruption type code |
| 9 | SET | `dslSvkeiKisuwGene = inItnmSvkeiKisuwGeneAddDtm` // Transfer-origin generation |
| 10 | SET | `dslFinFlg = FIN_FLG_FIN` // Dismantled service completed [FIN_FLG_FIN="1"] |

**Block 3** — [IF] `(adchgNo present)` (L510)

> **Output assembly**: If `adchgNo` was set (non-blank) by any of the above branches, meaning at least one service change (new or dismantled) was detected, assemble the output envelope with all relevant fields.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outMap.setString(JBSbatKKIFM102.ADCHG_NO, adchgNo)` // Address change number |
| 2 | SET | `outMap.setString(JBSbatKKIFM102.MSKM_NO, mskmNo)` // Application number |
| 3 | SET | `outMap.setString(JBSbatKKIFM102.NEW_SVKEI_KISUW_NO, newSvkeiKisuwNo)` // New service contract line item number |
| 4 | SET | `outMap.setString(JBSbatKKIFM102.DSL_SVKEI_KISUW_NO, dslSvkeiKisuwNo)` // Dismantled service contract line item number |
| 5 | SET | `outMap.setString(JBSbatKKIFM102.NEW_SVC_KEI_NO, newSvcKeiNo)` // New service contract number |
| 6 | SET | `outMap.setString(JBSbatKKIFM102.DSL_SVC_KEI_NO, dslSvcKeiNo)` // Dismantled service contract number |
| 7 | SET | `outMap.setString(JBSbatKKIFM102.SVC_KEI_IDO_SBT_CD, svcKeiIdoSbtCd)` // Service contract disruption type code |
| 8 | SET | `outMap.setString(JBSbatKKIFM102.NEW_SVKEI_KISUW_GENE, newSvkeiKisuwGene)` // New service generation |
| 9 | SET | `outMap.setString(JBSbatKKIFM102.DSL_SVKEI_KISUW_GENE, dslSvkeiKisuwGene)` // Dismantled service generation |
| 10 | SET | `outMap.setString(JBSbatKKIFM102.NEW_FIN_FLG, newFinFlg)` // New service completed flag [FIN_FLG_NOT_FIN="0", FIN_FLG_FIN="1"] |
| 11 | SET | `outMap.setString(JBSbatKKIFM102.DSL_FIN_FLG, dslFinFlg)` // Dismantled service completed flag [FIN_FLG_NOT_FIN="0", FIN_FLG_FIN="1"] |
| 12 | SET | `outMap.setString(JBSbatKKIFM102.WRIB_EXE_FLG, wribExeFlg)` // Discount auto-application execution flag |

**Block 3.1** — [IF] `(!isSurrenderService(inChbfSkbtNo))` (L535)

> **Surrender service filter**: Only add the output map if the old (pre-change) service contract was NOT surrendered/cancelled. This prevents duplicate SOD issuance for contracts that were cancelled. Per ANK-1429-00-00: "Only extract when transfer-origin service contract exists and is not cancelled."

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isSurrenderService(inChbfSkbtNo)` // Check if old service was surrendered |
| 2 | EXEC | `outputItem.addOutMapList(outMap)` // Add output to result list |

**Block 4** — [RETURN] `(L543)`

> Return the output item containing the assembled service change information.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return outputItem` |

**Block 5** — [ELSE: adchgNo blank] `(L549)`

> No service change was detected by any branch. Return `null` to indicate no work needed.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `adchgNo` | Field | Address change number (Residential Change number) — unique identifier for a residential change registration |
| `mskmNo` | Field | Application number — the customer's application/requisition number for the address change |
| `itnmSvkeiKisuwNo` | Field | Transfer-origin service contract line item number — the service contract line item that existed BEFORE the address change |
| `itensSvkeiKisuwNo` | Field | Transfer-destination service contract line item number — the service contract line item that will exist AFTER the address change |
| `itnmSvkeiKisuwGeneAddDtm` | Field | Transfer-origin generation add date/time — the generation/version timestamp of the pre-change service line item |
| `itensSvkeiKisuwGeneAddDtm` | Field | Transfer-destination generation add date/time — the generation/version timestamp of the post-change service line item |
| `chbfSkbtNo` | Field | Pre-change identification number (service contract number) — the service contract number before the address change |
| `chafSkbtNo` | Field | Post-change identification number (service contract number) — the service contract number after the address change |
| `svcKeiIdoSbtCd` | Field | Service contract disruption type code — classifies the type of service change (transfer, new installation, cancellation, etc.) |
| `wribExeFlg` | Field | Discount auto-application execution flag — when set to "1", indicates a line cut-over was detected by the discount auto-application Component |
| `isDelayed` | Field | Delay start flag — indicates whether the batch is running in delayed (scheduled) mode |
| `DELAYED_START` | Constant | Delayed start flag value "1" — batch is running in scheduled/delayed mode |
| `DELAYED_NOT_START` | Constant | Delayed not-start flag value "0" — batch is NOT running in delayed mode |
| `FIN_FLG_FIN` | Constant | Service completed flag value "1" — the service installation/dismantling has been completed |
| `FIN_FLG_NOT_FIN` | Constant | Service not-completed flag value "0" — the service installation/dismantling has NOT yet been completed |
| `kojiNashiTel` | Field | No-engineering-case telephone flag — true when a dismantled service was found without a worklist entry |
| `nyukyoRsvYmd` | Field | Move-in reservation date — the date when the customer is scheduled to move in at the new address |
| `newKojiFinYmd` | Field | New construction completion date — the date when the new service installation work was completed |
| `SOD` | Acronym | Service Order Data — the telecom order fulfillment process for registering/changing/cancelling services |
| `ADCHG` | Acronym | Address Change (住所変更) — the residential change registration operation in the system |
| `KK_T_ADCHG` | Table | Address Change header table — stores residential change registration records |
| `KK_T_ADCHG_DTL` | Table | Address Change detail table — stores residential change line item records |
| `KK_T_SVKEI_KAISEN_UW` | Table | Service Contract Line Item intermediate table — stores reservation/intermediate data for service contract line items (used for move-in date checks and line cut-over detection) |
| `KK_T_KJ_FIN_WK` | Table | Work Completion Worklist table — stores work completion worklist records that track engineering/installation work status |
| `KU_T_SVKEI_KOJIAK` | Table | Service Contract/Engineering Case table — links service contracts to engineering case records |
| `KK_T_TK_HOSHIKI_KEI` | Table | Provider Contract table — stores contract provision mode records (used as fallback for dismantled service detection) |
| `KK_T_SVC_KEI` | Table | Service Contract table — stores service contract master records (used by isSurrenderService) |
| `isSyudo` | Method | Manual execution check — returns true if the residential change was manually executed (as opposed to automatically scheduled) |
| `isDelayedZumi` | Method | Delayed confirmation completion check — returns true if the delayed batch confirmation has been completed (used for duplicate execution prevention) |
| `isSurrenderService` | Method | Surrender service check — returns true if the old service contract was surrendered/cancelled |
| `getNewKojiFinYmd` | Method | New construction completion date getter — retrieves the completion date of new installation work for duplicate prevention |
| FTTH | Business term | Fiber To The Home — fiber-optic internet broadband service |
| 住所変更 (Juusho Henkou) | Japanese term | Residential Change (Address Change) — the business operation of changing a customer's registered address, which may trigger service contract updates |
| 工事案件 (Kouji Anketa) | Japanese term | Engineering Case — a record tracking the installation/dismantling work associated with a service contract |
| 撤去 (Tetsu) | Japanese term | Dismantle/Removal — the cancellation of an existing service at the old address |
| 新設 (Shinsetsu) | Japanese term | New Installation — the creation of a new service at the new address |
| 提供方式 (Teikyou Houshiki) | Japanese term | Provision Mode — the method of service provision (e.g., VDSL, Isenet) |
| ネット・電話の片側保留 | Japanese term | Network/Phone one-sided retention — retaining only the network or phone service while cancelling the other |
