# Business Logic — JKKWrisvcAutoAplyCC.addChgNoDtl() [455 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKWrisvcAutoAplyCC` |
| Layer | CC / Common Component — Shared utility component for address-change-driven service contract processing |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKWrisvcAutoAplyCC.addChgNoDtl()

The `addChgNoDtl` method manages the **assignment of standard engineering cost shared-amount installment service contracts (CP) when processing address changes** (住所変更). Specifically, it retrieves service status from address change detail registrations and performs the CP transfer (付替え) for engineering cost installment CPs related to the K-Opticom fiber internet and telephone services. The method implements a **multi-branch dispatch pattern** based on three orthogonal dimensions: (1) whether the before-address and after-address residences are type "Home Mezon" (home gateway), (2) the operation trigger type (address change confirmation, address change disconnection, or general disconnection), and (3) the service sub-division status (transfer, continuation, addition, or disconnection) of each service line (NET/TEL/TV). Its role in the larger system is as a **shared CP-routing utility** called during address-change confirmation execution (in `delKojihiKapCp`) and during standard address-change processing (in `executeKojihiKapCpDel`), where it decides which engineering cost installment CPs to delete, transfer between service types (NET-to-TEL, TEL-to-NET), or retain based on the complex combinatorial state of the customer's service portfolio. The method supports five distinct business scenarios: Home Mezon to Home Mezon transfers (HT-to-HT), Home Mezon to non-Home Mezon transfers (HT-to-MT), service type transitions during address changes, CP disconnection when services are cancelled, and CP transfer when services are added at the new address.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addChgNoDtl(ccMap, mskmNo, addChgeDiv, kojihiKapAdchgDiv, baseSvcKeiNo)"])
    START --> INIT["Initialize: motoHomeMezonType=false, sakiHomeMezonType=false"]
    INIT --> FETCH["adChgDtlMskmNo(ccMap, mskmNo)"]
    FETCH --> CHECK1{addChgNoList null or empty?}
    CHECK1 -->|Yes| FALLBACK["adChgDtlChbfSkbtNo(ccMap, baseSvcKeiNo)"]
    CHECK1 -->|No| PROCESS["Proceed to main processing"]
    FALLBACK --> CHECK2{addChgNoList null or empty?}
    CHECK2 -->|Yes| RET_FALSE["Return false"]
    CHECK2 -->|No| CHECK_STAT{"adchgStat equals 003 (fixed)?"}
    CHECK_STAT -->|Yes| RET_FALSE2["Return false"]
    CHECK_STAT -->|No| PROCESS
    PROCESS --> SETCONST["comAdchgDtlSbtCd = 01"]
    SETCONST --> ADCHDTL["Initialize adchDtlMap with empty service fields"]
    ADCHDTL --> INITCP["Initialize netWribSvcKojihiKapCp, telWribSvcKojihiKapCp, iktWribSvcKojihiKapCp"]
    INITCP --> LOOP1["Loop: for each addChgNoMap in addChgNoList"]
    LOOP1 --> EXTRACT["Extract: adchgNo, itnmSvkeiKisuwNo, itensSvkeiKisuwNo"]
    EXTRACT --> GETDETAILS["callEKK2101B001ToAll(EKK2101B001_FUNC_CD_1=1, adchgNo, 01)"]
    GETDETAILS --> LOOP2["Loop: for each ekk2101B001Map"]
    LOOP2 --> EXTRACT2["Extract: chBfSkbtNo, chAfSkbtNo, svcKeiIdoSbtCd"]
    EXTRACT2 --> CHECKBF{chBfSkbtNo not null/blank?}
    CHECKBF -->|Yes| BFLOOKUP["callSvcKeiIchiiShokai(chBfSkbtNo, 2)"]
    BFLOOKUP --> SVC1{svcCd == 01?}
    SVC1 -->|Yes| BFNET["chBfSkbtNoSbtGet + adChgKojihiKapCp for NET and IKT"]
    SVC1 -->|No| SVC2{svcCd == 02?}
    SVC2 -->|Yes| BFTTEL["chBfSkbtNoSbtGet + adChgKojihiKapCp for TEL and IKT"]
    SVC2 -->|No| BFDTV["chBfSkbtNoSbtGet for TV"]
    CHECKBF -->|No| CHECKAF{chAfSkbtNo not null/blank?}
    CHECKAF -->|Yes| ALOOKUP["callSvcKeiIchiiShokai(chAfSkbtNo, 2)"]
    ALOOKUP --> ASVC1{svcCd == 01?}
    ASVC1 -->|Yes| AFNET["chAfSkbtNoSbtGet with svcCd, pcrsCd"]
    ASVC1 -->|No| ASVC2{svcCd == 02?}
    ASVC2 -->|Yes| AFTTEL["chAfSkbtNoSbtGet with svcCd, pcrsCd"]
    ASVC2 -->|No| AFDTV["chAfSkbtNoSbtGet with svcCd, pcrsCd"]
    CHECKAF -->|No| HOMECHECK
    BFNET --> HOMECHECK
    BFTTEL --> HOMECHECK
    BFDTV --> HOMECHECK
    AFNET --> HOMECHECK
    AFTTEL --> HOMECHECK
    AFDTV --> HOMECHECK
    HOMECHECK["homeMezonJuge(itnmSvkeiKisuwNo)"]
    HOMECHECK --> HM2["homeMezonJuge(itensSvkeiKisuwNo)"]
    HM2 --> BREAK["break"]
    BREAK --> CHECKCP{All CPs have null wrib_svc_kei_no?}
    CHECKCP -->|Yes| RET_TRUE1["Return true"]
    CHECKCP -->|No| ADCHGDIV["Normalize kojihiKapAdchgDiv"]
    ADCHGDIV --> MOTOHT{Both moto and saki Home Mezon?}
    MOTOHT -->|Yes| BLOCKHTHT["Block HT-to-HT branching"]
    MOTOHT -->|No| MOTOHTMT{Moto Home Mezon only?}
    MOTOHTMT -->|Yes| BLOCKHTMT["Block HT-to-MT branching"]
    MOTOHTMT -->|No| RET_TRUE2["Return true"]
    BLOCKHTHT --> RET_TRUE["Return true"]
    BLOCKHTMT --> RET_TRUE
    RET_FALSE --> END(["END"])
    RET_FALSE2 --> END
    RET_TRUE1 --> END
    RET_TRUE2 --> END
    RET_TRUE --> END
```

### Pre-Processing Phase

The method first attempts to fetch address change details using the application number (`mskmNo`). If that yields no results, it falls back to fetching by the base service contract number (`baseSvcKeiNo`). If both attempts fail, or if the fallback returns address change details that are already in the "fixed" state (status `003`), the method returns `false` immediately — indicating this is a standard disconnection path that does not require CP assignment.

### Data Gathering Phase

Once valid address change detail records are obtained, the method iterates through each record (but only processes the first iteration before breaking). For each record, it fetches the address change detail list from the `EKK2101B001` mapper using function code `1` and common sub-division code `01`. For each line item, it identifies the before and after service identification numbers (`chBfSkbtNo`, `chAfSkbtNo`) and determines the service type (NET/TEL/TV) by looking up service classification information via the `callSvcKeiIchiiShokai` mapper. The before-service data is fetched regardless of whether the after-service data exists, and vice versa. For NET and TEL services, it also retrieves the engineering cost installment CP records (separately for NET, TEL, and IKT/universal CPs). Home Mezon status is determined for both before and after residence service contract numbers.

### CP Assignment Phase

After determining the service states, the method normalizes the operation trigger (`kojihiKapAdchgDiv`), mapping the generic disconnection trigger (`IDO_DIV_DSL = "00005"`) to the address change disconnection trigger (`IDO_DIV_ADCHG_ADD = "00019"`). It then enters a large conditional block that handles specific combinations of before/after service status across NET, TEL, and TV dimensions, split by whether both residences are Home Mezon type (HT-to-HT, 28 scenarios) or only the before residence is Home Mezon (HT-to-MT, 3 scenarios). The actions taken are: **delete** CPs (for disconnections), **transfer** CPs from NET to TEL or TEL to NET (for service type changes), or **no action** (early return if no CPs to process).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `ccMap` | `HashMap<String, Object>` | The central context map carrying all business data for the current processing session. Contains keys such as `mskm_no` (application number), `kojihi_kap_adchg_div` (engineering cost installment address-change division), `add_chge_div` (addition/change division), `hjnkJh_map` (first billing service contract number map), and the service contract group list. |
| 2 | `mskmNo` | `String` | Application number (申請番号) — the unique identifier for the customer's address change application. Used as the primary key to look up address change detail records via `adChgDtlMskmNo`. |
| 3 | `addChgeDiv` | `String` | Addition/change division (追加変更区分) — indicates whether the operation is an addition, change, or other modification type. Passed through to downstream processing. |
| 4 | `kojihiKapAdchgDiv` | `String` | Engineering cost installment address-change division (工事費割賦住所変更区分) — the core operational trigger that determines what kind of CP handling to perform. Can be: `"00019"` (address change addition / 住所変更異動追加), `"00020"` (address change confirmation / 住所変更確定), or `"00005"` (disconnection / 解約 — internally mapped to address change addition). |
| 5 | `baseSvcKeiNo` | `String` | Base service contract number (基準サービス契約番号) — fallback identifier used to look up address change details when the application number yields no results. Represents the root service contract line item for the address change. |

**Instance/External Fields Read:**
- `getMapper()` — Returns `JKKWrisvcAutoAplyCCMapper` for executing SQL mapper calls.
- `homeMezonJuge(itnmSvkeiKisuwNo)` — Determines whether a residence is "Home Mezon" (home gateway) type.
- `JKKStringUtil.isNullBlank(String)` — Utility for null/blank string checking.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKWrisvcAutoAplyCCMapper.callEKK2101B001ToAll` | EKK2101B001 | KK_T_ADCHG_DTL, KK_T_ADCHG_DTL_LINE | Fetches all address change detail line items for a given address change number (`adchgNo`) with common sub-division code `01` |
| R | `JKKWrisvcAutoAplyCCMapper.callSvcKeiIchiiShokai` | EKK0081A010 | KK_T_SVC_KEI_ICHII, KK_M_SVC_CD | Looks up service classification information for a service identification number, returns `svc_cd` (service type: 01=NET, 02=TEL, 03=TV) and `pcrs_cd` (PCRS code) |
| C | `JKKWrisvcAutoAplyCC.adChgKojihiKapCp(ccMap, chBfSkbtNo, svcCd, false)` | EKK2091B001 | KK_T_WRIB_SVC_KOJIHI_KAP_CP (NET/TEL) | Retrieves the before-service engineering cost installment CP record (write-service contract number) for non-IKT (NET or TEL) |
| C | `JKKWrisvcAutoAplyCC.adChgKojihiKapCp(ccMap, chBfSkbtNo, svcCd, true)` | EKK2091B001 | KK_T_WRIB_SVC_KOJIHI_KAP_CP (IKT) | Retrieves the before-service engineering cost installment CP record for IKT (universal/integrated CP) |
| D | `JKKWrisvcAutoAplyCC.delNetTelWribSvcKojihiKapCp(ccMap, cpMap)` | EKK2091B001 | KK_T_WRIB_SVC_KOJIHI_KAP_CP | Deletes an engineering cost installment CP record (works for NET, TEL, or IKT CPs) |
| U | `JKKWrisvcAutoAplyCC.netFromTelCp(ccMap, netCpMap, telSvcNo)` | EKK2091B001 | KK_T_WRIB_SVC_KOJIHI_KAP_CP | Transfers CP from telephone to internet service type |
| U | `JKKWrisvcAutoAplyCC.telFromNetCp(ccMap, telCpMap, netSvcNo)` | EKK2091B001 | KK_T_WRIB_SVC_KOJIHI_KAP_CP | Transfers CP from internet to telephone service type |
| R | `JKKWrisvcAutoAplyCC.adChgDtlMskmNo` | EKK2091B001 | KK_T_ADCHG_DTL | Looks up address change details by application number |
| R | `JKKWrisvcAutoAplyCC.adChgDtlChbfSkbtNo` | EKK2091B001 | KK_T_ADCHG_DTL | Looks up address change details by base service contract number (fallback) |
| R | `JKKWrisvcAutoAplyCC.chBfSkbtNoSbtGet` | EKK2091B001 | In-memory adchDtlMap | Sets the before-service identification sub-division code and number into adchDtlMap |
| R | `JKKWrisvcAutoAplyCC.chAfSkbtNoSbtGet` | EKK2091B001 | In-memory adchDtlMap | Sets the after-service identification sub-division code and number into adchDtlMap |
| R | `JKKWrisvcAutoAplyCC.homeMezonJuge` | EKK2091B001 | KK_T_SVC_KEI_ICHII | Determines whether a service contract is a "Home Mezon" (home gateway) type |
| R | `JKKWrisvcAutoAplyCC.kojihiKapSerchFirstSeikySvcKeiNo` | EKK2091B001 | KK_T_WRIB_SVC_KOJIHI_KAP_CP | Searches whether the engineering cost installment status equals `030` (line switch) with the first billing service contract number remaining on the source line |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS:JKKWrisvcAutoAplyCC.delKojihiKapCp | `delKojihiKapCp(ccMap, ...)` → `addChgNoDtl(ccMap, mskmNo, addChgeDiv, kojihiKapAdchgDiv, baseSvcKeiNo)` | `delNetTelWribSvcKojihiKapCp [D] KK_T_WRIB_SVC_KOJIHI_KAP_CP`, `netFromTelCp [U] KK_T_WRIB_SVC_KOJIHI_KAP_CP`, `telFromNetCp [U] KK_T_WRIB_SVC_KOJIHI_KAP_CP` |
| 2 | CBS:JKKWrisvcAutoAplyCC.executeKojihiKapCpDel | `executeKojihiKapCpDel(ccMap, ...)` → `addChgNoDtl(ccMap, mskmNo, addChgeDiv, kojihiKapAdchgDiv, baseSvcKeiNo)` | `delNetTelWribSvcKojihiKapCp [D] KK_T_WRIB_SVC_KOJIHI_KAP_CP`, `netFromTelCp [U] KK_T_WRIB_SVC_KOJIHI_KAP_CP`, `telFromNetCp [U] KK_T_WRIB_SVC_KOJIHI_KAP_CP` |

**Notes:** Both callers are internal business component methods (not direct screen entry points). They are invoked as part of the address change confirmation workflow. The `delKojihiKapCp` caller handles the address-change-confirmation path (line 15567), while `executeKojihiKapCpDel` handles the standard CP deletion during address change processing (line 16506).

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `addChgNoList == null || addChgNoList.size() == 0` (L17777)

> If address change details fetched by `mskmNo` are empty, attempt fallback lookup by `baseSvcKeiNo`.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `addChgNoList = adChgDtlChbfSkbtNo(ccMap, baseSvcKeiNo)` | Fallback: look up address change details by base service contract number |

**Block 1.1** — [IF] `addChgNoList == null || addChgNoList.size() == 0` (L17782)

> If fallback lookup also returns nothing, no address change exists — perform normal disconnection processing and exit.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return false` | No address change found; return false for normal disconnection path |

**Block 1.2** — [ELSE-IF] `addChgNoList != null && !empty` (L17783)

> Fallback succeeded. Check if the address change is already in "fixed" state.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `addChgNoMap = addChgNoList.get(0)` | Get the first address change detail record |
| 2 | SET | `adchgStat = addChgNoMap.get(ADCHG_STAT)` | Extract address change status field |
| 3 | [IF] | `adchgStat == "003"` | Address change is already fixed (確定) |

**Block 1.2.1** — [IF] `adchgStat.equals("003")` (L17788)

> The address change detail is already in "fixed" state. Treat as normal disconnection — no CP assignment needed.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return false` | Address change already fixed; skip CP assignment |

**Block 2** — [SET] Constant definition (L17804)

> Define the common sub-division code for address change details.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `comAdchgDtlSbtCd = "01"` | Common sub-division code: used to filter address change detail lines |

**Block 3** — [SET] Initialize adchDtlMap (L17807–L17823)

> Initialize the address change detail map with all service line item fields set to empty strings.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `adchDtlMap = new HashMap<>()` | Create new detail map |
| 2 | SET | `motoSvckeiNetIdoSbtCd = ""` | Before: NET service sub-division code (0=transfer, 2=continuation, 3=addition, 4=disconnection) |
| 3 | SET | `motoSvckeiTelIdoSbtCd = ""` | Before: TEL service sub-division code |
| 4 | SET | `motoSvckeiTvIdoSbtCd = ""` | Before: TV service sub-division code |
| 5–12 | SET | `motoSvckeiNoNet/Tel/Tv`, `sakiSvckeiNoNet/Tel/Tv` | Before/after service numbers for each line type |

**Block 4** — [SET] Initialize CP maps (L17826–L17829)

> Create separate maps to hold engineering cost installment CP data for each service type.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `netWribSvcKojihiKapCp = new HashMap<>()` | NET CP record holder |
| 2 | SET | `telWribSvcKojihiKapCp = new HashMap<>()` | TEL CP record holder |
| 3 | SET | `iktWribSvcKojihiKapCp = new HashMap<>()` | IKT (universal/integrated) CP record holder (v53.00.00) |

**Block 5** — [FOR LOOP] Iterate address change records (L17832)

> Iterate over all address change detail records (but only the first one is processed).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `adchgNo = addChgNoMap.get(ADCHG_NO)` | Extract address change number |
| 2 | SET | `itnmSvkeiKisuwNo = addChgNoMap.get(ITNM_SVKEI_KISUW_NO)` | Before: service contract line number |
| 3 | SET | `itensSvkeiKisuwNo = addChgNoMap.get(ITENS_SVKEI_KISUW_NO)` | After: service contract line number |
| 4 | CALL | `getMapper().callEKK2101B001ToAll(ccMap, 1, adchgNo, "01")` | Fetch address change detail lines (EKK2101B001_FUNC_CD_1="1", comAdchgDtlSbtCd="01") |

**Block 5.1** — [FOR LOOP] Iterate detail lines (L17838)

> Process each address change detail line item.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `chBfSkbtNo = ekk2101B001Map.get(CHBF_SKBT_NO)` | Before: identification number |
| 2 | SET | `chAfSkbtNo = ekk2101B001Map.get(CHAF_SKBT_NO)` | After: identification number |
| 3 | SET | `svcKeiIdoSbtCd = ekk2101B001Map.get(SVC_KEI_IDO_SBT_CD)` | Service line transfer sub-division code |

**Block 5.1.1** — [IF] `!JKKStringUtil.isNullBlank(chBfSkbtNo)` (L17847)

> Before identification number exists. Look up service classification and fetch before-service CP data.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `getMapper().callSvcKeiIchiiShokai(ccMap, chBfSkbtNo, "2", "")` | Look up service classification (SVC_KEI_ICHII_FUNC_CD="2") |
| 2 | SET | `svcCd = sakiSvcKeiMap.get(SVC_CD)` | Extract service code: `"01"`=NET, `"02"`=TEL, `"03"`=TV |

**Block 5.1.1.1** — [IF] `svcCd == "01"` (NET) (L17852)

> Before service is NET type. Fetch before-service NET parameters and CP record.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `chBfSkbtNoSbtGet(svcKeiIdoSbtCd, "motoSvckeiNetIdoSbtCd", "motoSvckeiNoNet", ...)` | Set before-service NET sub-division and number in adchDtlMap |
| 2 | CALL | `netWribSvcKojihiKapCp = adChgKojihiKapCp(ccMap, chBfSkbtNo, svcCd, false)` | Fetch before-service NET CP (v53.00.00: added `false` parameter) |
| 3 | CALL | `iktWribSvcKojihiKapCp = adChgKojihiKapCp(ccMap, chBfSkbtNo, svcCd, true)` | Fetch IKT CP for this service line |

**Block 5.1.1.2** — [ELSE-IF] `svcCd == "02"` (TEL) (L17863)

> Before service is TEL type. Fetch before-service TEL parameters and CP record.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `chBfSkbtNoSbtGet(svcKeiIdoSbtCd, "motoSvckeiTelIdoSbtCd", "motoSvckeiNoTel", ...)` | Set before-service TEL sub-division and number in adchDtlMap |
| 2 | CALL | `telWribSvcKojihiKapCp = adChgKojihiKapCp(ccMap, chBfSkbtNo, svcCd, false)` | Fetch before-service TEL CP |
| 3 | CALL | `iktWribSvcKojihiKapCp = adChgKojihiKapCp(ccMap, chBfSkbtNo, svcCd, true)` | Fetch IKT CP for this service line |

**Block 5.1.1.3** — [ELSE-IF] `svcCd == "03"` (TV) (L17874)

> Before service is TV type. Only fetch the service sub-division parameters (no CP retrieval for TV).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `chBfSkbtNoSbtGet(svcKeiIdoSbtCd, "motoSvckeiTvIdoSbtCd", "motoSvckeiNoTv", ...)` | Set before-service TV sub-division and number in adchDtlMap |

**Block 5.1.2** — [IF] `!JKKStringUtil.isNullBlank(chAfSkbtNo)` (L17880)

> After identification number exists. Look up service classification and fetch after-service parameters.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `getMapper().callSvcKeiIchiiShokai(ccMap, chAfSkbtNo, "2", "")` | Look up after-service classification |
| 2 | SET | `svcCd = sakiSvcKeiMap.get(SVC_CD)` | After-service type code |
| 3 | SET | `pcrsCd = sakiSvcKeiMap.get(PCRS_CD)` | PCRS code (IT2-2018-0000052) |

**Block 5.1.2.1** — [IF] `svcCd == "01"` (NET) (L17890)

> After service is NET type. Fetch after-service NET parameters (with svcCd and pcrsCd).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `chAfSkbtNoSbtGet(svcKeiIdoSbtCd, "sakiSvckeiNetIdoSbtCd", "sakiSvckeiNoNet", ..., svcCd, pcrsCd)` | Set after-service NET sub-division and number (updated with svcCd, pcrsCd params) |

**Block 5.1.2.2** — [ELSE-IF] `svcCd == "02"` (TEL) (L17905)

> After service is TEL type.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `chAfSkbtNoSbtGet(svcKeiIdoSbtCd, "sakiSvckeiTelIdoSbtCd", "sakiSvckeiNoTel", ..., svcCd, pcrsCd)` | Set after-service TEL sub-division and number |

**Block 5.1.2.3** — [ELSE-IF] `svcCd == "03"` (TV) (L17918)

> After service is TV type.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `chAfSkbtNoSbtGet(svcKeiIdoSbtCd, "sakiSvckeiTvIdoSbtCd", "sakiSvckeiNoTv", ..., svcCd, pcrsCd)` | Set after-service TV sub-division and number |

**Block 5.2** — [SET] Home Mezon judgment (L17928–L17933)

> Determine whether the before and after residences are Home Mezon (home gateway) type.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `motoHomeMezonType = homeMezonJuge(itnmSvkeiKisuwNo)` | Before: Home Mezon judgment |
| 2 | SET | `sakiHomeMezonType = homeMezonJuge(itensSvkeiKisuwNo)` | After: Home Mezon judgment |
| 3 | EXEC | `break` | Only process the first iteration |

**Block 6** — [IF] All CPs have no `wrib_svc_kei_no` (L17939–L17944)

> If no engineering cost installment CPs were retrieved for any service type (NET, TEL, or IKT), there is nothing to process.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return true` | No CP records to process; exit early (v53.00.01: includes IKT check) |

**Block 7** — [IF/ELSE-IF/ELSE] Normalize `kojihiKapAdchgDiv` (L17950–L17972)

> Normalize the engineering cost installment address-change division to a canonical value. The disconnection trigger (`IDO_DIV_DSL = "00005"`) is mapped to address change addition (`IDO_DIV_ADCHG_ADD = "00019"`).

| # | Type | Code | Constant Value |
|---|------|------|----------------|
| 1 | IF | `IDO_DIV_ADCHG_FIX.equals(kojihiKapAdchgDiv)` | `"00020"` = Address change confirmation (住所変更確定) — no change needed |
| 2 | ELSE-IF | `IDO_DIV_ADCHG_ADD.equals(kojihiKapAdchgDiv)` | `"00019"` = Address change addition (住所変更異動追加) — no change needed |
| 3 | ELSE-IF | `IDO_DIV_DSL.equals(kojihiKapAdchgDiv)` | `"00005"` = Disconnection (解約) — **maps to** `"00019"` (address change addition) |
| 4 | SET | `kojihiKapAdchgDiv = IDO_DIV_ADCHG_ADD` | Update disconnection trigger to address change addition |

**Block 8** — [IF] HT-to-HT branching (motoHomeMezonType && sakiHomeMezonType) (L17976–L18125)

> Both before and after residences are Home Mezon type. This block handles **28 distinct scenarios** (scenarios 2, 6, 7, 13, 16, 20, 22, 23, 25, 26, 28, 29, 30, 32, 33, 35, 40, 47, 49, 53, 58) based on the combination of before-service disconnection status and after-service addition status across NET/TEL/TV.

**Block 8.1** — [IF] Scenario 2: Address change addition, before NET disconnection, after TEL transfer, TV no change (L17981)

> Transfer CP from TEL to NET (since before was NET disconnection and after is TEL transfer).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `netFromTelCp(ccMap, netWribSvcKojihiKapCp, sakiSvckeiNoTel)` | NET CP from TEL CP transfer |

**Block 8.2** — [ELSE-IF] Scenario 6: Address change addition, before NET+TV disconnection, after TEL transfer (L17988)

> Delete NET CP and IKT CP.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, netWribSvcKojihiKapCp)` | Delete NET CP |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 8.3** — [ELSE-IF] Scenario 7: Address change addition, before NET+TEL disconnection, after TV transfer (L17990)

> Delete NET CP and IKT CP.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, netWribSvcKojihiKapCp)` | Delete NET CP |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 8.4** — [ELSE-IF] Scenario 13: Address change addition, before NET+TEL continuation, after TV transfer (L18002)

> Delete NET CP and IKT CP. (TEL was continuation, not disconnection — but NET was disconnection.)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, netWribSvcKojihiKapCp)` | Delete NET CP |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 8.5** — [ELSE-IF] Scenario 16: Address change addition, before NET disconnection, after TV continuation, TEL transfer (L18014)

> Delete NET CP and IKT CP.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, netWribSvcKojihiKapCp)` | Delete NET CP |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 8.6** — [ELSE-IF] Scenario 20: Address change confirmation, after NET addition, TEL transfer, TV transfer (L18027)

> Transfer CP from TEL to NET (since after is NET addition with TEL and TV transfers).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `telFromNetCp(ccMap, telWribSvcKojihiKapCp, sakiSvckeiNoNet)` | TEL CP from NET CP transfer |

**Block 8.7** — [ELSE-IF] Scenario 22: Address change addition or confirmation, before TEL disconnection, after NET addition, TV transfer (L18035)

> Transfer TEL to NET CP and delete IKT CP.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `telFromNetCp(ccMap, telWribSvcKojihiKapCp, sakiSvckeiNoNet)` | TEL CP from NET CP transfer |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 8.8** — [ELSE-IF] Scenario 23: Address change addition or confirmation, before TV disconnection, after NET addition, TEL transfer (L18048)

> Transfer TEL to NET CP and delete IKT CP.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `telFromNetCp(ccMap, telWribSvcKojihiKapCp, sakiSvckeiNoNet)` | TEL CP from NET CP transfer |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 8.9** — [ELSE-IF] Scenario 25: Address change addition, before no NET/TEL, after TEL transfer, TV disconnection (L18061)

> Delete TEL CP and IKT CP.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, telWribSvcKojihiKapCp)` | Delete TEL CP |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 8.10** — [ELSE-IF] Scenario 26: Address change addition, before TEL disconnection, no NET, after TV transfer (L18074)

> Delete TEL CP and IKT CP.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, telWribSvcKojihiKapCp)` | Delete TEL CP |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 8.11** — [ELSE-IF] Scenario 28: Address change confirmation, before TEL continuation, after NET addition, TV transfer (L18086)

> Check if engineering cost installment has line switch (status=030) with first billing service contract on source line. If yes, delete CP and return early (no CP transfer needed). Otherwise, transfer TEL to NET and delete IKT.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `kojihiKapSerchFirstSeikySvcKeiNo(ccMap, motoSvckeiNoTel)` | Search if first billing service contract remains on source line (line switch) |
| 2 | RETURN | `return true` | Skip CP transfer; only delete TEL and IKT CPs (OM-2018-0000711) |
| 3 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, telWribSvcKojihiKapCp)` | Delete TEL CP |
| 4 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |
| 5 | CALL | `telFromNetCp(ccMap, telWribSvcKojihiKapCp, sakiSvckeiNoNet)` | TEL CP from NET CP transfer |
| 6 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 8.12** — [ELSE-IF] Scenario 29: Address change confirmation, before TEL continuation, no NET, after TV transfer (L18104)

> Delete TEL CP and IKT CP.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, telWribSvcKojihiKapCp)` | Delete TEL CP |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 8.13** — [ELSE-IF] Scenario 30: Address change confirmation, before TEL continuation, after NET addition+TV disconnection (L18116)

> Same line-switch check as Scenario 28. If line switch detected, skip CP transfer. Otherwise, transfer and delete.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `kojihiKapSerchFirstSeikySvcKeiNo(ccMap, motoSvckeiNoTel)` | Check for line switch |
| 2 | RETURN | `return true` | Skip transfer if line switch |
| 3 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, telWribSvcKojihiKapCp)` | Delete TEL CP |
| 4 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.01) |
| 5 | CALL | `telFromNetCp(ccMap, telWribSvcKojihiKapCp, sakiSvckeiNoNet)` | TEL CP from NET CP transfer |

**Block 8.14** — [ELSE-IF] Scenario 32: Address change confirmation, after NET addition, TEL transfer, TV continuation (L18134)

> Transfer TEL CP to NET CP and delete IKT.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `telFromNetCp(ccMap, telWribSvcKojihiKapCp, sakiSvckeiNoNet)` | TEL CP from NET CP transfer |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.01) |

**Block 8.15** — [ELSE-IF] Scenario 33: Address change confirmation, before TV continuation, no NET/TEL, after TEL transfer (L18145)

> Delete TEL CP and IKT.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, telWribSvcKojihiKapCp)` | Delete TEL CP |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.01) |

**Block 8.16** — [ELSE-IF] Scenario 35: Address change confirmation, before NET disconnection, after TEL addition, TV transfer (L18156)

> Transfer NET CP to TEL CP.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `netFromTelCp(ccMap, netWribSvcKojihiKapCp, sakiSvckeiNoTel)` | NET CP from TEL CP transfer |

**Block 8.17** — [ELSE-IF] Scenario 40: Address change addition, before NET disconnection, no TEL/TV change (L18163)

> Delete NET CP only.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, netWribSvcKojihiKapCp)` | Delete NET CP |

**Block 8.18** — [ELSE-IF] Scenario 47: Address change addition, before NET disconnection, after TEL addition, TV continuation (L18172)

> Delete NET CP only.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, netWribSvcKojihiKapCp)` | Delete NET CP |

**Block 8.19** — [ELSE-IF] Scenario 49: Address change addition, before NET disconnection, after TEL+TV addition (L18181)

> Delete NET CP only.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, netWribSvcKojihiKapCp)` | Delete NET CP |

**Block 8.20** — [ELSE-IF] Scenario 53: Address change addition, before NET disconnection, after TEL transfer, no TV (L18190)

> Delete NET CP.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, netWribSvcKojihiKapCp)` | Delete NET CP |

**Block 8.21** — [ELSE-IF] Scenario 58: Address change addition, before NET disconnection, after TEL transfer, no TV (L18199)

> Delete NET CP. (Duplicate of scenario 53 — appears to be a code-level duplication.)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, netWribSvcKojihiKapCp)` | Delete NET CP |

**Block 9** — [ELSE-IF] HT-to-MT branching (motoHomeMezonType && !sakiHomeMezonType) (L18209)

> Before residence is Home Mezon type, after is not. This block handles **3 scenarios** for the HT-to-MT transition.

**Block 9.1** — [IF] Before NET disconnection or after NET no-addition (L18212)

> Network contract ended at before residence or not added at after.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `"4".equals(motoSvckeiNetIdoSbtCd)` or `"0".equals(sakiSvckeiNetIdoSbtCd)` | NET disconnection at before or no NET at after |

**Block 9.1.1** — [IF] Address change addition, after NET no-change, before TEL+TV continuation (L18216)

> Transfer NET CP to TEL CP (since before is NET disconnection but TEL/TV continued).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `netFromTelCp(ccMap, netWribSvcKojihiKapCp, motoSvckeiNoTel)` | NET CP from TEL CP transfer (using before-service TEL number) |

**Block 9.1.2** — [ELSE-IF] Address change addition, NOT the TEL+TV continuation case (L18224)

> Delete NET CP and IKT CP (all other cases).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, netWribSvcKojihiKapCp)` | Delete NET CP |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 9.2** — [ELSE-IF] Before has TEL+TV but no NET, operation is addition or confirmation (L18234)

> Customer had TEL and TV services at before address (without NET). Delete TEL CP and IKT.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, telWribSvcKojihiKapCp)` | Delete TEL CP |
| 2 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, iktWribSvcKojihiKapCp)` | Delete IKT CP (v53.00.00) |

**Block 10** — [RETURN] Default (L18243)

> For any case not covered by the HT-to-HT or HT-to-MT branching (e.g., neither residence is Home Mezon), return `true` to indicate successful processing.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return true` | Processing complete; all CP operations handled or not applicable |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mskmNo` / `mskm_no` | Field | Application number (申請番号) — unique identifier for the customer's address change application request |
| `kojihiKapAdchgDiv` | Field | Engineering cost installment address-change division (工事費割賦住所変更区分) — operational trigger code determining CP handling strategy |
| `IDO_DIV_ADCHG_ADD` | Constant | `"00019"` — Address change addition trigger (住所変更異動追加) — indicates an address change is being processed (not yet confirmed) |
| `IDO_DIV_ADCHG_FIX` | Constant | `"00020"` — Address change confirmation trigger (住所変更確定) — indicates the address change has been finalized |
| `IDO_DIV_DSL` | Constant | `"00005"` — Disconnection trigger (解約) — indicates service cancellation; internally mapped to address change addition |
| `baseSvcKeiNo` | Field | Base service contract number (基準サービス契約番号) — root service contract for fallback lookup |
| `adchgNo` | Field | Address change number (住所変更番号) — unique identifier for an address change record |
| `adchgStat` | Field | Address change status (住所変更状態) — `"003"` means the address change is confirmed/fixed (確定) |
| `comAdchgDtlSbtCd` | Constant | `"01"` — Common sub-division code for address change details (住所変更明細共通区分) |
| `chBfSkbtNo` | Field | Before identification number (変更前識別番号) — service identification number at the before (old) address |
| `chAfSkbtNo` | Field | After identification number (変更後識別番号) — service identification number at the after (new) address |
| `svcCd` | Field | Service code (サービスコード) — `"01"` = NET (fiber internet), `"02"` = TEL (telephone), `"03"` = TV (television) |
| `SVC_KEI_ICHII_FUNC_CD` | Constant | `"2"` — Function code for service classification lookup (サービス体系一覧機能コード) |
| `EKK2101B001_FUNC_CD_1` | Constant | `"1"` — Function code for address change detail line fetch (住所変更明細一覧機能コード) |
| `motoSvckeiNetIdoSbtCd` | Field | Before NET service sub-division code (元サービスNET異動区分) — `"0"`=transfer, `"2"`=continuation, `"3"`=addition, `"4"`=disconnection, `""`=not applicable |
| `motoSvckeiTelIdoSbtCd` | Field | Before TEL service sub-division code (元サービスTEL異動区分) — same code values |
| `motoSvckeiTvIdoSbtCd` | Field | Before TV service sub-division code (元サービスTV異動区分) — same code values |
| `sakiSvckeiNetIdoSbtCd` | Field | After NET service sub-division code (先サービスNET異動区分) — same code values |
| `sakiSvckeiTelIdoSbtCd` | Field | After TEL service sub-division code (先サービスTEL異動区分) — same code values |
| `sakiSvckeiTvIdoSbtCd` | Field | After TV service sub-division code (先サービスTV異動区分) — same code values |
| `motoSvckeiNoNet/Tel/Tv` | Field | Before service contract number for NET/TEL/TV (元サービス契約番号) |
| `sakiSvckeiNoNet/Tel/Tv` | Field | After service contract number for NET/TEL/TV (先サービス契約番号) |
| `homeMezonJuge` | Method | Home Mezon judgment (ホームメゾン判定) — determines if a residence is Home Mezon type (home gateway service) |
| `motoHomeMezonType` | Field | Flag indicating if the before residence is Home Mezon type |
| `sakiHomeMezonType` | Field | Flag indicating if the after residence is Home Mezon type |
| `netWribSvcKojihiKapCp` | Field | NET write-service engineering cost installment CP map (ネット工事費割賦CP) |
| `telWribSvcKojihiKapCp` | Field | TEL write-service engineering cost installment CP map (電話工事費割賦CP) |
| `iktWribSvcKojihiKapCp` | Field | IKT (integrated/universal) write-service CP map (一括CP) — added in v53.00.00 |
| `wrib_svc_kei_no` | Field | Write-service contract number (登録サービス契約番号) — the CP record's service contract identifier |
| CP | Acronym | Installment service contract (割賦契約) — standard engineering cost shared-amount installment plan |
| IKT | Acronym | Integrated/Universal (一括) — integrated engineering cost installment CP covering multiple services |
| HT (Home Mezon to Home Mezon) | Business term | HT-to-HT transition — both before and after residences have Home Mezon (home gateway) service |
| MT (Home Mezon to non-Home Mezon) | Business term | HT-to-MT transition — before residence has Home Mezon, after does not |
| NET | Business term | Fiber internet service (FTTH) |
| TEL | Business term | Telephone service |
| TV | Business term | Television/broadcast service |
| PCRS | Acronym | Customer subscription code (PCRSコード) — customer classification code |
| adchgDtlMap | Field | Address change detail map (住所変更明細マップ) — in-memory map holding before/after service status across all three line types |
| addChgNoList | Variable | Address change detail list (住所変更明細リスト) — list of address change records fetched by application or base service number |
| KK_T_ADCHG_DTL | Table | Address change master table (住所変更テーブル) — stores address change header records |
| KK_T_ADCHG_DTL_LINE | Table | Address change detail table (住所変更明細テーブル) — stores address change line items |
| KK_T_SVC_KEI_ICHII | Table | Service contract master table (サービス契約一覧テーブル) — service classification reference data |
| KK_T_WRIB_SVC_KOJIHI_KAP_CP | Table | Write-service engineering cost installment CP table (登録工事費割賦CPテーブル) — stores engineering cost installment contract records |
| KK_M_SVC_CD | Table | Service code master table (サービスコードマスタテーブル) — service type reference table |
| `adChgKojihiKapCp` | Method | Address change engineering cost installment CP fetch — retrieves CP record for before/after service |
| `delNetTelWribSvcKojihiKapCp` | Method | Delete NET/TEL write-service engineering cost installment CP — removes CP record |
| `netFromTelCp` | Method | NET from TEL CP transfer — transfers CP ownership from TEL to NET service type |
| `telFromNetCp` | Method | TEL from NET CP transfer — transfers CP ownership from NET to TEL service type |
| `kojihiKapSerchFirstSeikySvcKeiNo` | Method | Engineering cost installment first billing service contract search — checks if line switch (status 030) is in effect with first billing contract on source line |
| `callEKK2101B001ToAll` | Mapper Method | Fetch all address change detail lines for a given address change number |
| `callSvcKeiIchiiShokai` | Mapper Method | Service classification inquiry — looks up service type and related data by service identification number |
| OM-2018-0000711 | Change | Change request: engineering cost installment line switch check — skip CP transfer when line switch status is active |
| v53.00.00 | Version | Version that added IKT (integrated CP) handling and updated `adChgKojihiKapCp` signature with `isIkt` parameter |
| v53.00.01 | Version | Version that extended the early-return check to include IKT CP, and added IKT deletion in scenario 30 and 32 |
| IT2-2018-0000052 | Change | Change request: updated `chAfSkbtNoSbtGet` signature to include `svcCd` and `pcrsCd` parameters for after-service detail |
| IT2-2018-0000061 | Change | Change request: removed CP retrieval for after-service (commented out); after-service no longer triggers CP fetch |