# Business Logic — JKKWrisvcAutoAplyCC.addChgNoDtl2() [458 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKWrisvcAutoAplyCC` |
| Layer | Common Component / CC (Shared business logic coordinator) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKWrisvcAutoAplyCC.addChgNoDtl2()

This method is responsible for cancelling the Standard Installation Fee Discount CP (Campaign Plan, **工事費割引CP**) during address change processing for customer service contracts. Specifically, it retrieves the current state of service registration records associated with address change details and determines whether the discount campaign plan agreement should be cancelled as a result of the address change operation. The method handles multiple telecom service categories — **NET** (fibre broadband), **TEL** (fixed-line telephone), and **TV** (cable television) — and applies routing/dispatch logic to determine whether the CP agreement should remain with the pre-address-change (moto) contract or be transferred to the post-address-change (saki) contract. It implements a multi-stage evaluation: first locating address change records, then classifying service types, determining home-maison type transitions (HT to MT), and finally deciding on CP cancellation based on a complex set of conditions including service contract move classification codes, re-check flags, and address change operation types. This method serves as a shared utility called by several internal processing methods within `JKKWrisvcAutoAplyCC` that handle address change cancellation, DSL release, and re-verification workflows.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addChgNoDtl2 ccMap, mskmNo, addChgeDiv, kojihiKapAdchgDiv, baseSvcKeiNo"])
    START --> INIT["Initialize: motoHomeMezonType, sakiHomeMezonType, addChgNoList"]
    INIT --> EXTRACT_HJNK["Extract from hjnkjhMap"]
    EXTRACT_HJNK --> CHECK_NULL{"hjnkjhMap != null?"}
    CHECK_NULL -->|yes| EXTRACT_VALS["firstSeikySvcKeiNo, kapSysid, kapSeikyKeiNo, isRecheck"]
    CHECK_NULL -->|no| SKIP_EXTRACT["Skip extraction"]
    EXTRACT_VALS --> FETCH_DTL["adChgDtlMskmNo(ccMap, mskmNo)"]
    SKIP_EXTRACT --> FETCH_DTL
    FETCH_DTL --> LIST_CHECK{"addChgNoList empty?"}

    LIST_CHECK -->|yes| BASE_LOOKUP["Fallback: adChgDtlChbfSkbtNo by baseSvcKeiNo"]
    LIST_CHECK -->|no| SORT_LIST["Sort by adchgComparator"]
    SORT_LIST --> CHECK_STAT{"adchgStat == 003?"}
    CHECK_STAT -->|yes| RECHECK_CHECK{"isRecheck AND IDO_DIV_DSL?"}
    CHECK_STAT -->|no| PROCEED_TO_LOOP["Proceed to loop"]
    RECHECK_CHECK -->|yes| PROCEED_TO_LOOP
    RECHECK_CHECK -->|no| RETURN_FALSE_1["Return false"]
    BASE_LOOKUP --> BASE_EMPTY{"Base lookup empty?"}
    BASE_EMPTY -->|yes| VIEWID_CHECK{"idoDiv == CD00576_ADCHG_ADD AND viewId == KKW042090PJP?"}
    BASE_EMPTY -->|no| SORT_LIST
    VIEWID_CHECK -->|yes| RETURN_TRUE_1["Return true"]
    VIEWID_CHECK -->|no| RETURN_FALSE_2["Return false"]

    PROCEED_TO_LOOP --> LOOP_START["Loop: for each addChgNoMap"]
    LOOP_START --> FETCH_MAP["getMapper().callEKK2101B001ToAll"]
    FETCH_MAP --> LOOP_DTL["Loop: for each ekk2101B001Map"]
    LOOP_DTL --> GET_IDS["Get chBfSkbtNo, chAfSkbtNo, svcKeiIdoSbtCd"]
    GET_IDS --> BF_CHECK{"chBfSkbtNo not empty?"}
    BF_CHECK -->|yes| FETCH_BF["callSvcKeiIchiiShokai by chBfSkbtNo"]
    FETCH_BF --> SVC_CD_CHECK{"svcCd?"}
    SVC_CD_CHECK -->|01 Net| SET_NET["motoSvckeiNoNet, svckeiNetIdoSbtCd"]
    SVC_CD_CHECK -->|02 Tel| SET_TEL["motoSvckeiNoTel, svckeiTelIdoSbtCd"]
    SVC_CD_CHECK -->|03 Tv| SET_TV["motoSvckeiNoTv, svckeiTvIdoSbtCd, isMotoTvSaisosin"]
    GET_IDS --> AF_CHECK{"chAfSkbtNo not empty?"}
    AF_CHECK -->|yes| FETCH_AF["callSvcKeiIchiiShokai by chAfSkbtNo"]
    FETCH_AF --> AF_SVC_CHECK{"svcCd?"}
    AF_SVC_CHECK -->|01 Net| SET_NET_SAKI["sakiSvckeiNoNet, svckeiNetIdoSbtCd"]
    AF_SVC_CHECK -->|02 Tel| SET_TEL_SAKI["sakiSvckeiNoTel, svckeiTelIdoSbtCd"]
    AF_SVC_CHECK -->|03 Tv| SET_TV_SAKI["sakiSvckeiNoTv, svckeiTvIdoSbtCd, isSakiTvSaisosin"]
    SET_NET --> HOME_CHECK["homeMezonJuge on itnm/itens"]
    SET_TEL --> HOME_CHECK
    SET_TV --> HOME_CHECK
    SET_NET_SAKI --> HOME_CHECK
    SET_TEL_SAKI --> HOME_CHECK
    SET_TV_SAKI --> HOME_CHECK
    HOME_CHECK --> LOOP_BREAK["break"]

    RETURN_FALSE_1 --> END_RETURN(["Return false"])
    RETURN_FALSE_2 --> END_RETURN
    RETURN_TRUE_1 --> RETURN_TRUE_2["Return true"]
    LOOP_BREAK --> FETCH_CP["adChgKojihiKapCp2 if firstSeikySvcKeiNo exists"]
    RETURN_TRUE_2 --> END_RETURN
    FETCH_CP --> CP_VALID{"CP data valid?"}
    CP_VALID -->|no| RETURN_TRUE_3["Return true"]
    CP_VALID -->|yes| KAP_STAT_CHECK{"status not 010/100?"}
    KAP_STAT_CHECK -->|yes| CP_CLEAR["Clear wribSvcKojihiKapCp"]
    KAP_STAT_CHECK -->|no| CHECK_CP_DATA{"CP data not null?"}
    CP_CLEAR --> CHECK_CP_DATA
    CHECK_CP_DATA -->|no| RETURN_TRUE_3
    CHECK_CP_DATA -->|yes| ADCHG_DIV_CHECK{"kojihiKapAdchgDiv?"}

    ADCHG_DIV_CHECK -->|00020 FIX| DO_FIX["kojihiKapAdchgDiv = 00020 (address change fixed)"]
    ADCHG_DIV_CHECK -->|00019 ADD| DO_ADD["kojihiKapAdchgDiv = 00019 (address change addition)"]
    ADCHG_DIV_CHECK -->|00005 DSL| DO_DSL["kojihiKapAdchgDiv = 00019 (DSL reclassified)"]
    ADCHG_DIV_CHECK -->|other| RETURN_TRUE_4["Return true"]

    DO_FIX --> KAP_KETZANI["Determine isKapKeiZanti"]
    DO_ADD --> KAP_KETZANI
    DO_DSL --> KAP_KETZANI

    KAP_KETZANI --> KAP_CONDITION{"isKapKeiZanti?"}
    KAP_CONDITION -->|yes| MOTO_VERIFY["Verify moto services (motoIdoSbtOkList=2)"]
    KAP_CONDITION -->|no| SAKI_VERIFY["Verify saki services (sakiIdoSbtOkList=0,1,3)"]
    MOTO_VERIFY --> MOTO_BRANCH{"moto HT and saki MT?"}
    SAKI_VERIFY --> MOTO_BRANCH
    MOTO_BRANCH -->|yes HT2MT| HT2MT_CHECK["HT2MT branch: netDslIdoSbtCdList check"]
    MOTO_BRANCH -->|yes HT2HT| HT2HT_CHECK["HT2HT branch: DSL determination"]
    MOTO_BRANCH -->|no other| DONE_VERIFY["Done verify"]

    HT2HT_CHECK --> HT2HT_OK{"isOk?"}
    HT2HT_OK -->|no| DSL_FLAG["Check isDsl"]
    HT2HT_OK -->|yes| DONE_VERIFY
    DSL_FLAG --> DSL_DIV_CHECK{"kojihiKapAdchgDiv?"}
    DSL_DIV_CHECK -->|00019 ADD| DSL_ADD["Check service cancellation"]
    DSL_DIV_CHECK -->|00020 FIX| DSL_FIX["Check DSL completion and re-verify"]
    DSL_ADD --> DSL_CHECK{"isNetDsl or isTelDsl or isTvDsl?"}
    DSL_CHECK -->|yes| SET_DSL["Set isDsl = true"]
    DSL_CHECK -->|no| DSL_DONE["DSL done"]
    DSL_FIX --> NO_DSL{"isNetDsl and isTelDsl and isTvDsl false?"}
    NO_DSL -->|yes| DSL_DONE_FIX["isDsl = true"]
    NO_DSL -->|no| DSL_FIN_CHECK["Check if DSL finished (SVC_KEI_STAT == 00005)"]
    DSL_FIN_CHECK --> DSL_FIN{"isDslFin?"}
    DSL_FIN -->|yes| SET_DSL_FIX["isDsl = true"]
    DSL_FIN -->|no| DSL_NO_DSL["Do nothing"]

    HT2MT_CHECK --> HT2MT_OK{"isOk?"}
    HT2MT_OK -->|no| HT2MT_DSL["Check netDslIdoSbtCdList and conditions"]
    HT2MT_OK -->|yes| DONE_VERIFY
    HT2MT_DSL --> HT2MT_ADD{"kojihiKapAdchgDiv == 00019?"}
    HT2MT_ADD -->|yes| SET_DSL_MT["isDsl = true"]
    HT2MT_ADD -->|no| HT2MT_DONE["HT2MT done"]

    SET_DSL --> FINAL_DSL_CHECK["if isDsl, delNetTelWribSvcKojihiKapCp"]
    SET_DSL_FIX --> FINAL_DSL_CHECK
    SET_DSL_MT --> FINAL_DSL_CHECK
    DSL_DONE --> FINAL_RETURN["Return true"]
    DSL_DONE_FIX --> FINAL_RETURN
    DSL_NO_DSL --> FINAL_RETURN
    HT2MT_DONE --> FINAL_RETURN
    DONE_VERIFY --> FINAL_RETURN
    FINAL_DSL_CHECK --> FINAL_RETURN
    DSL_ADD --> DSL_CHECK
    RETURN_TRUE_3 --> FINAL_RETURN
    RETURN_TRUE_4 --> FINAL_RETURN
    END_RETURN --> DONE_FINAL["Done"]

    style START fill:#e1f5fe
    style END_RETURN fill:#ffebee
    style FINAL_RETURN fill:#c8e6c9
    style DSL_FLAG fill:#fff9c4
    style KAP_CONDITION fill:#f3e5f5
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `ccMap` | `HashMap<String, Object>` | Work map carrying all session-scoped data for address change processing. Contains `hjnkjhMap` (relocation work map with first billing contract number, KAP system ID, KAP billing contract number, and re-check flag), `IDO_DIV` (move classification code), and other operational data shared across screen processing. |
| 2 | `mskmNo` | `String` | Application number (**申込番号**) — the unique customer application identifier used to look up address change details. Serves as the primary key for searching address change registration records. |
| 3 | `addChgeDiv` | `String` | Address change addition division — classification indicating whether this is a new address change addition, a fix, or a DSL release. Used to determine which processing path the CP cancellation logic follows. |
| 4 | `kojihiKapAdchgDiv` | `String` | Non-applicable campaign address change division — identifies the type of address change operation: `00020` (address change confirmed/fixed), `00019` (address change addition), or `00005` (DSL). Determines whether CP cancellation should be triggered. |
| 5 | `baseSvcKeiNo` | `String` | Base service contract number — used as a fallback search key when address change details cannot be found by `mskmNo`. If the primary lookup fails, the system searches using this contract number instead. |

**Instance fields read by this method:**

| Field | Description |
|-------|-------------|
| `iRparaReadW` | Instance of input parameter reader — used to fetch the current view ID (`REQ_VIEWID`) from the control map |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `adChgDtlMskmNo(ccMap, mskmNo)` | (inferred: EKK2091B001SC) | KK_T_ADCHG_NO (Address Change Detail) | Find address change details by application number |
| R | `adChgDtlChbfSkbtNo(ccMap, baseSvcKeiNo)` | (inferred: EKK2091B001SC) | KK_T_ADCHG_NO (Address Change Detail) | Find address change details by base service contract number (fallback) |
| R | `getMapper().callEKK2101B001ToAll(ccMap, "1", adchgNo, "01")` | EKK2101B001SC | KK_T_ADCHG_NO_DTL (Address Change Detail List) | Get all address change detail rows for a given address change number |
| R | `getMapper().callSvcKeiIchiiShokai(ccMap, chBfSkbtNo, "2", "")` | EKK0081A010SC | KK_T_SVC_KEI_ISHII (Service Contract Master) | Lookup service contract information by pre-change identifier number |
| R | `getMapper().callSvcKeiIchiiShokai(ccMap, chAfSkbtNo, "2", "")` | EKK0081A010SC | KK_T_SVC_KEI_ISHII (Service Contract Master) | Lookup service contract information by post-change identifier number |
| R | `adChgKojihiKapCp2(ccMap, firstSeikySvcKeiNo)` | (inferred: EKK0451A010SC) | KK_T_WRIB_SVC_KEI (Writ Service Contract / CP Agreement) | Retrieve standard installation fee discount CP data for the first billing contract |
| R | `isOkSvcKei(ccMap, kapSysid, kapSeikyKeiNo, svcKeiNo)` | (inferred: EKK0081A010SC) | KK_T_SVC_KEI_ISHII (Service Contract Master) | Validate whether a service contract is valid/active for CP eligibility |
| C | `delNetTelWribSvcKojihiKapCp(ccMap, wribSvcKojihiKapCp)` | (inferred: EKK0451A010SC) | KK_T_WRIB_SVC_KEI (Writ Service Contract / CP Agreement) | Cancel/delete the network/telephone standard installation fee discount CP agreement |

### Analysis

This method primarily performs **Read** operations to gather service contract and address change detail data. The critical **Create** operation is the CP cancellation (which, in Fujitsu's system convention, is classified as a "Create" — `del*` methods that register cancellation records). No direct **Update** or **Delete** (data removal) operations are performed. The method acts as a coordinator that reads multiple entity tables to build a decision context, then triggers a cancellation via `delNetTelWribSvcKojihiKapCp`.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 86 methods.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKWrisvcAutoAplyCC.delKojihiWrbkCpAfSeikySta()` | `Screen entry` -> `delKojihiWrbkCpAfSeikySta` -> `addChgNoDtl2` | `delNetTelWribSvcKojihiKapCp [C] KK_T_WRIB_SVC_KEI` |
| 2 | `JKKWrisvcAutoAplyCC.executeKojihiKapCpDel()` | `Screen entry` -> `executeKojihiKapCpDel` -> `addChgNoDtl2` | `delNetTelWribSvcKojihiKapCp [C] KK_T_WRIB_SVC_KEI` |
| 3 | `JKKWrisvcAutoAplyCC.recheckDslAfJuhen()` | `Screen entry` -> `recheckDslAfJuhen` -> `addChgNoDtl2` | `delNetTelWribSvcKojihiKapCp [C] KK_T_WRIB_SVC_KEI` |

This method is exclusively called by internal methods within `JKKWrisvcAutoAplyCC` — it is not a direct screen entry point. Its terminal operation is always `delNetTelWribSvcKojihiKapCp` which writes a CP cancellation record to the **KK_T_WRIB_SVC_KEI** table. The method always returns `true` or `false` (boolean) and does not propagate exceptions beyond its `throws Throwable` declaration.

## 6. Per-Branch Detail Blocks

**Block 1** — VARIABLE ASSIGNMENT (L20648)

> Initialize local variables before processing begins.

| # | Type | Code |
|---|------|------|
| 1 | SET | `motoHomeMezonType = false` // Address change source home-maison flag |
| 2 | SET | `sakiHomeMezonType = false` // Address change destination home-maison flag |
| 3 | SET | `addChgNoList = new ArrayList<HashMap<String, Object>>()` // Address change detail list |

**Block 2** — WORK MAP EXTRACTION (L20664-L20670)

> Extract relocation work data (`hjnkjhMap`) from the main work map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `hjnkjhMap = (HashMap)ccMap.get(KKSV0313_KKSV0313OP_WORK.HJNKJH_MAP)` // Relocation work map |
| 2 | SET | `firstSeikySvcKeiNo = ""` // First billing service contract number |
| 3 | SET | `kapSysid = ""` // KAP system ID |
| 4 | SET | `kapSeikyKeiNo = ""` // KAP billing contract number |
| 5 | SET | `isRecheck = false` // Re-check flag |
| 6 | EXEC | `firstSeikySvcKeiNo = nullToBlank(hjnkjhMap.get(EKK3131B060CBSMsg1List.FIRST_SEIKY_SVC_KEI_NO))` |
| 7 | EXEC | `kapSysid = nullToBlank(hjnkjhMap.get(KAP_SYSID))` |
| 8 | EXEC | `kapSeikyKeiNo = nullToBlank(hjnkjhMap.get(KAP_SEIKY_KEI_NO))` |
| 9 | SET | `isRecheck = SEIRITSU_JOKEN_RECHECK_YES.equals(...)` `[-> SEIRITSU_JOKEN_RECHECK_YES="1"]` |

**Block 3** — ADDRESS CHANGE DETAIL LOOKUP (L20674)

> Fetch address change details by application number (`mskmNo`).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `addChgNoList = adChgDtlMskmNo(ccMap, mskmNo)` |

**Block 4** — IF: LIST EMPTY (L20676)

> When no address change details are found by application number, attempt fallback or early exit.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `addChgNoList = adChgDtlChbfSkbtNo(ccMap, baseSvcKeiNo)` // Fallback by base service contract number |
| 2 | IF | `addChgNoList == null || size == 0` — No records even by base number |

**Block 4.1** — IF: FALLEN THROUGH TO VIEWID CHECK (L20682)

> When no address change details found at all, check if we're on the address change registration screen — if so, return true (processing in progress, no details yet expected).

| # | Type | Code |
|---|------|------|
| 1 | SET | `idoDiv = nullToBlank(ccMap.get(KKSV0313_KKSV0313OP_WORK.IDO_DIV))` |
| 2 | SET | `viewId = nullToBlank(iRparaReadW.getControlMapData(SCControlMapKeys.REQ_VIEWID))` |
| 3 | IF | `idoDiv == CD00576_ADCHG_ADD` AND `viewId == "KKW042090PJP"` — Address change registration screen |
| 4 | RETURN | `true` // Address change details not yet retrieved but address change is in progress |

**Block 4.2** — ELSE IF: LIST FOUND BUT NO BASE LOOKUP (L20691)

> When fallback lookup DID find records, sort them and check the address change status.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `Collections.sort(addChgNoList, adchgComparator())` |
| 2 | SET | `addChgNoMap = addChgNoList.get(0)` // First record |
| 3 | SET | `adchgStat = addChgNoMap.get(EKK2101B001CBSMsg1List.ADCHG_STAT)` |

**Block 4.2.1** — IF: adchgStat == "003" (L20693)

> Address change has been confirmed. Normally skip CP cancellation, but allow if re-checking DSL address change.

| # | Type | Code |
|---|------|------|
| 1 | IF | `adchgStat == "003"` — Address change confirmed |
| 2 | IF | `!(isRecheck AND kojihiKapAdchgDiv == IDO_DIV_DSL)` `[-> IDO_DIV_DSL="00005"]` |
| 3 | RETURN | `false` // Address change confirmed, not re-checking DSL — skip CP cancellation processing |

**Block 4.3** — ELSE IF: LIST FOUND (L20698)

> When fallback lookup found records, sort and proceed to loop.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `Collections.sort(addChgNoList, adchgComparator())` |

**Block 5** — ELSE: LIST NOT EMPTY (L20701)

> When primary lookup found address change details, just sort them.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `Collections.sort(addChgNoList, adchgComparator())` |

**Block 6** — LOOP: PROCESS EACH ADDRESS CHANGE DETAIL (L20709)

> Iterate over address change detail records to extract service type information for net, tel, and tv services.

| # | Type | Code |
|---|------|------|
| 1 | SET | `comAdchgDtlSbtCd = "01"` // Common address change detail subtype code |
| 2 | SET | `motoSvckeiNoNet = ""` // Moto service contract number - Net |
| 3 | SET | `motoSvckeiNoTel = ""` // Moto service contract number - Tel |
| 4 | SET | `motoSvckeiNoTv = ""` // Moto service contract number - TV |
| 5 | SET | `sakiSvckeiNoNet = ""` // Saki service contract number - Net |
| 6 | SET | `sakiSvckeiNoTel = ""` // Saki service contract number - Tel |
| 7 | SET | `sakiSvckeiNoTv = ""` // Saki service contract number - TV |
| 8 | SET | `svckeiNetIdoSbtCd = ""` // Service contract net move subtype code |
| 9 | SET | `svckeiTelIdoSbtCd = ""` // Service contract tel move subtype code |
| 10 | SET | `svckeiTvIdoSbtCd = ""` // Service contract tv move subtype code |
| 11 | SET | `isMotoTvSaisosin = false` // Moto TV re-application flag |
| 12 | SET | `isSakiTvSaisosin = false` // Saki TV re-application flag |
| 13 | SET | `wribSvcKojihiKapCp = new HashMap<>()` |

**Block 6.1** — FOR: for each addChgNoMap (L20714)

> Main processing loop over address change records.

| # | Type | Code |
|---|------|------|
| 1 | SET | `adchgNo = addChgNoMap.get(EKK2091B001CBSMsg1List.ADCHG_NO)` |
| 2 | SET | `itnmSvkeiKisuwNo = addChgNoMap.get(EKK2091B001CBSMsg1List.ITNM_SVKEI_KISUW_NO)` // Transfer source service contract line item detail number |
| 3 | SET | `itensSvkeiKisuwNo = addChgNoMap.get(EKK2091B001CBSMsg1List.ITENS_SVKEI_KISUW_NO)` // Transfer destination service contract line item detail number |
| 4 | CALL | `ekk2101B001List = getMapper().callEKK2101B001ToAll(ccMap, "1", adchgNo, "01")` |

**Block 6.1.1** — FOR: for each ekk2101B001Map (L20724)

> Inner loop over address change detail rows within an address change record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `chBfSkbtNo = ekk2101B001Map.get(EKK2101B001CBSMsg1List.CHBF_SKBT_NO)` // Pre-change identifier number |
| 2 | SET | `chAfSkbtNo = ekk2101B001Map.get(EKK2101B001CBSMsg1List.CHAF_SKBT_NO)` // Post-change identifier number |
| 3 | SET | `svcKeiIdoSbtCd = ekk2101B001Map.get(EKK2101B001CBSMsg1List.SVC_KEI_IDO_SBT_CD)` // Service contract move subtype code |

**Block 6.1.1.1** — IF: chBfSkbtNo not empty (L20731)

> Look up the pre-change (moto) service contract to classify by service type (NET/Tel/TV).

| # | Type | Code |
|---|------|------|
| 1 | IF | `!JKKStringUtil.isNullBlank(chBfSkbtNo)` |
| 2 | CALL | `sakiSvcKeiMap = getMapper().callSvcKeiIchiiShokai(ccMap, chBfSkbtNo, "2", "")` |
| 3 | SET | `svcCd = sakiSvcKeiMap.get(EKK0081A010CBSMsg1List.SVC_CD)` |
| 4 | SET | `pcrsCd = sakiSvcKeiMap.get(EKK0081A010CBSMsg1List.PCRS_CD)` |

**Block 6.1.1.1.1** — IF: svcCd == "01" (Net) (L20735)

> Pre-change is a NET service (fibre broadband).

| # | Type | Code |
|---|------|------|
| 1 | SET | `motoSvckeiNoNet = chBfSkbtNo` |
| 2 | SET | `svckeiNetIdoSbtCd = svcKeiIdoSbtCd` |

**Block 6.1.1.1.2** — IF: svcCd == "02" (Tel) (L20740)

> Pre-change is a TEL service (fixed-line telephone).

| # | Type | Code |
|---|------|------|
| 1 | SET | `motoSvckeiNoTel = chBfSkbtNo` |
| 2 | SET | `svckeiTelIdoSbtCd = svcKeiIdoSbtCd` |

**Block 6.1.1.1.3** — IF: svcCd == "03" (TV) (L20745)

> Pre-change is a TV service (cable television). Track re-application flag for TV.

| # | Type | Code |
|---|------|------|
| 1 | SET | `motoSvckeiNoTv = chBfSkbtNo` |
| 2 | SET | `svckeiTvIdoSbtCd = svcKeiIdoSbtCd` |
| 3 | SET | `isMotoTvSaisosin = "A23".equals(pcrsCd)` // TV re-application indicator |

**Block 6.1.1.2** — IF: chAfSkbtNo not empty (L20753)

> Look up the post-change (saki) service contract to classify by service type.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!JKKStringUtil.isNullBlank(chAfSkbtNo)` |
| 2 | CALL | `sakiSvcKeiMap = getMapper().callSvcKeiIchiiShokai(ccMap, chAfSkbtNo, "2", "")` |
| 3 | SET | `svcCd = sakiSvcKeiMap.get(EKK0081A010CBSMsg1List.SVC_CD)` |
| 4 | SET | `pcrsCd = sakiSvcKeiMap.get(EKK0081A010CBSMsg1List.PCRS_CD)` |

**Block 6.1.1.2.1** — IF: svcCd == "01" (Net) (L20757)

> Post-change is a NET service.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sakiSvckeiNoNet = chAfSkbtNo` |
| 2 | IF | `svckeiNetIdoSbtCd is blank` — fill from svcKeiIdoSbtCd |

**Block 6.1.1.2.2** — IF: svcCd == "02" (Tel) (L20764)

> Post-change is a TEL service.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sakiSvckeiNoTel = chAfSkbtNo` |
| 2 | IF | `svckeiTelIdoSbtCd is blank` — fill from svcKeiIdoSbtCd |

**Block 6.1.1.2.3** — IF: svcCd == "03" (TV) (L20772)

> Post-change is a TV service. Track re-application flag.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sakiSvckeiNoTv = chAfSkbtNo` |
| 2 | IF | `svckeiTvIdoSbtCd is blank` — fill from svcKeiIdoSbtCd |
| 3 | SET | `isSakiTvSaisosin = "A23".equals(pcrsCd)` |

**Block 6.1.1.3** — HOME-Maison JUDGMENT (L20784-L20787)

> Determine whether the pre-change and post-change contracts are for home-maison (single dwelling) type.

| # | Type | Code |
|---|------|------|
| 1 | SET | `motoHomeMezonType = homeMezonJuge(itnmSvkeiKisuwNo)` |
| 2 | SET | `sakiHomeMezonType = homeMezonJuge(itensSvkeiKisuwNo)` |
| 3 | EXEC | `break` // Only process the first address change detail record |

**Block 7** — CP DATA RETRIEVAL (L20791-L20806)

> Retrieve the standard installation fee discount CP agreement data if the first billing service contract number exists.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!JKKStringUtil.isNullBlank(firstSeikySvcKeiNo)` |
| 2 | CALL | `wribSvcKojihiKapCp = adChgKojihiKapCp2(ccMap, firstSeikySvcKeiNo)` |
| 3 | IF | `wribSvcKojihiKapCp != null` |
| 4 | SET | `wribSvcKeiStat = wribSvcKojihiKapCp.get(EKK0451A010CBSMsg1List.WRIB_SVC_KEI_STAT)` |

**Block 7.1** — IF: CP STATUS CHECK (L20796)

> Only accepted statuses are `010` (unconfirmed/not registered) and `100` (service in progress). Clear data for other statuses.

| # | Type | Code |
|---|------|------|
| 1 | IF | `wribSvcKeiStat != WRIB_SVC_KEI_STAT_UK_ZM` `[-> "010"]` AND `!= WRIB_SVC_KEI_STAT_SVC_TK_CHU` `[-> "100"]` |
| 2 | EXEC | `wribSvcKojihiKapCp.clear()` |

**Block 8** — EARLY EXIT: NO CP DATA (L20810)

> If no CP data can be retrieved, the method returns true (no CP to cancel).

| # | Type | Code |
|---|------|------|
| 1 | IF | `wribSvcKojihiKapCp == null || wrib_svc_kei_no is blank` |
| 2 | RETURN | `true` |

**Block 9** — kojihiKapAdchgDiv NORMALIZATION (L20815-L20832)

> Normalize the address change division code into one of three recognized states.

| # | Type | Code |
|---|------|------|
| 1 | IF | `kojihiKapAdchgDiv == IDO_DIV_ADCHG_FIX` `[-> "00020"]` |
| 2 | SET | `kojihiKapAdchgDiv = "00020"` |
| 3 | ELSE IF | `kojihiKapAdchgDiv == IDO_DIV_ADCHG_ADD` `[-> "00019"]` |
| 4 | SET | `kojihiKapAdchgDiv = "00019"` |
| 5 | ELSE IF | `kojihiKapAdchgDiv == IDO_DIV_DSL` `[-> "00005"]` |
| 6 | SET | `kojihiKapAdchgDiv = "00019"` // DSL is reclassified to ADD |
| 7 | ELSE | **return true** — unrecognized division, exit early |

**Block 10** — isKapKeiZanti DETERMINATION (L20837-L20866)

> Determine whether the CP agreement should be retained (remain with) the pre-address-change contract. Called "Kap Kei Zanti" (**工事費割租残置** — retain installation fee discount).

| # | Type | Code |
|---|------|------|
| 1 | SET | `isKapKeiZanti = false` |
| 2 | IF | `motoHomeMezonType && !sakiHomeMezonType` // HT to MT transition |
| 3 | SET | `isKapKeiZanti = true` // CP stays with moto (MT has no CP) |
| 4 | ELSE IF | `firstSeikySvcKeiNo == motoSvckeiNoNet && svckeiNetIdoSbtCd == "2"` // First billing = net, status is retention |
| 5 | SET | `isKapKeiZanti = true` |
| 6 | ELSE IF | `firstSeikySvcKeiNo == motoSvckeiNoTel && svckeiTelIdoSbtCd == "2"` // First billing = tel, status is retention |
| 7 | SET | `isKapKeiZanti = true` |
| 8 | ELSE IF | `saki has no net AND saki has no tel` |
| 9 | SET | `isKapKeiZanti = true` // CP stays with moto since saki has neither |

**Block 11** — Service VALIDATION BRANCH (L20870-L20896)

> Based on `isKapKeiZanti`, verify either the moto (source) or saki (destination) service contracts are valid for CP continuation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `motoIdoSbtOkList = ["2"]` // Moto acceptable: only "2" (retention) |
| 2 | SET | `sakiIdoSbtOkList = ["0", "1", "3"]` // Saki acceptable: "0" (continuation), "1" (content change), "3" (addition) |
| 3 | IF | `isKapKeiZanti` — Verify moto |
| 4 | IF | `moto has net` AND `svckeiNetIdoSbtCd in motoIdoSbtOkList` AND `isOkSvcKei(...)` |
| 5 | SET | `isOk = true` |
| 6 | ELSE IF | `moto has tel AND tv` AND both pass `motoIdoSbtOkList` AND `!isMotoTvSaisosin` AND `isOkSvcKei` for both |
| 7 | SET | `isOk = true` |

**Block 11.1** — HT to MT Special Case (L20883)

> When moving from Home (HT) to Maison (MT), if the first billing contract number was a telephone, the CP should not continue since MT cannot bill for standard installation fees.

| # | Type | Code |
|---|------|------|
| 1 | IF | `motoHomeMezonType && !sakiHomeMezonType` |
| 2 | IF | `moto has tel AND saki has tel` |
| 3 | IF | `firstSeikySvcKeiNo == motoSvckeiNoTel` // First billing was telephone |
| 4 | SET | `isOk = false` // CP cannot apply to MT |

**Block 11.2** — ELSE: Verify saki (L20891)

> When CP should transfer to saki, validate saki services.

| # | Type | Code |
|---|------|------|
| 1 | IF | `saki has net` AND `svckeiNetIdoSbtCd in sakiIdoSbtOkList` AND `isOkSvcKei` |
| 2 | SET | `isOk = true` |
| 3 | ELSE IF | `saki has tel AND tv` AND both pass `sakiIdoSbtOkList` AND `!isSakiTvSaisosin` AND `isOkSvcKei` for both |
| 4 | SET | `isOk = true` |

**Block 12** — HT to HT DSL DETERMINATION (L20899-L20996)

> When both pre-change and post-change are Home (HT) type, determine whether DSL cancellation of CP is needed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `isDsl = false` |
| 2 | IF | `motoHomeMezonType && sakiHomeMezonType` // HT to HT |
| 3 | IF | `!isOk` // Conditions not maintained |

**Block 12.1** — HT to HT: isKapKeiZanti true branch (L20837 check)

> When CP stays with moto (isKapKeiZanti=true), verify the moto services.

| # | Type | Code |
|---|------|------|
| 1 | IF | `moto has net` AND `svckeiNetIdoSbtCd in ["2"]` AND `isOkSvcKei` |
| 2 | SET | `isOk = true` |
| 3 | ELSE IF | `moto has tel AND tv` AND both in `["2"]` AND `!isMotoTvSaisosin` AND `isOkSvcKei` for all |
| 4 | SET | `isOk = true` |
| 5 | IF | `motoHomeMezonType && !sakiHomeMezonType` AND `moto has tel AND saki has tel` AND `firstSeiky == motoTel` |
| 6 | SET | `isOk = false` // HT2MT case within HT2HT — CP cannot carry forward |

**Block 12.2** — HT to HT: isKapKeiZanti false branch (L20906)

> When CP transfers to saki, verify the saki services.

| # | Type | Code |
|---|------|------|
| 1 | IF | `saki has net` AND `svckeiNetIdoSbtCd in ["0","1","3"]` AND `isOkSvcKei` |
| 2 | SET | `isOk = true` |
| 3 | ELSE IF | `saki has tel AND tv` AND both in `["0","1","3"]` AND `!isSakiTvSaisosin` AND `isOkSvcKei` for all |
| 4 | SET | `isOk = true` |

**Block 12.3** — HT to HT: !isOk DSL determination (L20910)

> When HT to HT but conditions are NOT maintained, determine if DSL cancellation of CP is needed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `isNetDsl = motoNet has service AND svckeiNetIdoSbtCd == "4"` (4 = cancellation) |
| 2 | SET | `isTelDsl = motoTel has service AND svckeiTelIdoSbtCd == "4"` |
| 3 | SET | `isTvDsl = motoTv has service AND svckeiTvIdoSbtCd == "4"` |

**Block 12.3.1** — IF: address change addition (L20915)

> When the operation is an address change addition (`00019`), cancel CP if any service line item has been cancelled.

| # | Type | Code |
|---|------|------|
| 1 | IF | `kojihiKapAdchgDiv == IDO_DIV_ADCHG_ADD` `[-> "00019"]` |
| 2 | IF | `isNetDsl OR isTelDsl OR isTvDsl` |
| 3 | SET | `isDsl = true` |

**Block 12.3.2** — IF: address change fix (L20954)

> When the operation is an address change confirmation (`00020`), check if DSL has completed.

| # | Type | Code |
|---|------|------|
| 1 | IF | `kojihiKapAdchgDiv == IDO_DIV_ADCHG_FIX` `[-> "00020"]` |
| 2 | IF | `!isNetDsl AND !isTelDsl AND !isTvDsl` // No service cancellations |
| 3 | SET | `isDsl = true` // Conditions not maintained, no DSL in progress — cancel CP |
| 4 | ELSE | Determine which service is being cancelled, then look up its status |
| 5 | CALL | `svcKeiMap = getMapper().callSvcKeiIchiiShokai(ccMap, svcKeiNo, "2", "")` |
| 6 | IF | `svcKeiStat == CD00037_DSL_ZM` `[-> "00005"]` // Service fully cancelled |
| 7 | SET | `isDslFin = true` |
| 8 | IF | `isDslFin` |
| 9 | SET | `isDsl = true` |

**Block 13** — HT to MT DSL DETERMINATION (L20998-L20854)

> When pre-change is Home (HT) and post-change is Maison (MT), check if CP cancellation is needed.

| # | Type | Code |
|---|------|------|
| 1 | IF | `motoHomeMezonType && !sakiHomeMezonType` |
| 2 | IF | `!isOk` // Conditions not maintained |

**Block 13.1** — HT to MT: Net DSL check (L21003)

> Check if the net service move subtype code allows DSL-based cancellation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `netDslIdoSbtCdList = ["0", "1", "4"]` |
| 2 | IF | `svckeiNetIdoSbtCd in netDslIdoSbtCdList` |
| 3 | SET | `netAddChgIdoSbtCdList = ["0", "1"]` |
| 4 | IF | `svckeiNetIdoSbtCd in netAddChgIdoSbtCdList AND svckeiTelIdoSbtCd == "2" AND svckeiTvIdoSbtCd == "2" AND !isMotoTvSaisosin` |
| 5 | SET | (CP continues — no action) // Tel and TV remain at moto, net moves to saki |
| 6 | ELSE IF | `kojihiKapAdchgDiv == "00019"` |
| 7 | SET | `isDsl = true` |

**Block 13.2** — HT to MT: No net, has tel/tv (L21014)

> When moto has no net but has tel and tv (saki has no net or tel).

| # | Type | Code |
|---|------|------|
| 1 | IF | `moto has no net AND moto has tel AND moto has tv AND !isMotoTvSaisosin` |
| 2 | IF | `kojihiKapAdchgDiv == "00019" OR kojihiKapAdchgDiv == "00020"` |
| 3 | SET | `isDsl = true` // CP cancellation triggered by address change addition or fix |

**Block 14** — CP CANCELLATION EXECUTION (L21020-L21027)

> If DSL cancellation was determined, execute the CP cancellation.

| # | Type | Code |
|---|------|------|
| 1 | IF | `isDsl` |
| 2 | IF | `hjnkjhMap != null` |
| 3 | EXEC | `hjnkjhMap.put(WRIB_DSL_FLG, "1")` `[-> WRIB_DSL_FLG_ON="1"]` |
| 4 | CALL | `delNetTelWribSvcKojihiKapCp(ccMap, wribSvcKojihiKapCp)` // Cancel the CP agreement |

**Block 15** — RETURN (L21029)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `true` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mskmNo` | Field | Application number — unique customer application ID used to look up address change details |
| `addChgeDiv` | Field | Address change addition division — classifies the type of address change operation being performed |
| `kojihiKapAdchgDiv` | Field | Non-applicable campaign address change division — identifies whether this is address change addition (00019), address change fix (00020), or DSL (00005) |
| `baseSvcKeiNo` | Field | Base service contract number — primary contract identifier used for fallback address change detail lookup |
| `firstSeikySvcKeiNo` | Field | First billing service contract number — the initial service contract number from the first billing cycle, used to determine CP eligibility |
| `kapSysid` | Field | KAP system ID — system identifier associated with the campaign plan (CP) agreement |
| `kapSeikyKeiNo` | Field | KAP billing contract number — the billing contract number for the campaign plan |
| `isRecheck` | Field | Re-check flag — indicates whether this is a re-check operation for DSL address change cancellation |
| `motoHomeMezonType` | Field | Pre-address-change home-maison type flag — true if the source contract is for a single dwelling (home) |
| `sakiHomeMezonType` | Field | Post-address-change home-maison type flag — true if the destination contract is for a single dwelling (home) |
| `adchgNo` | Field | Address change number — unique identifier for an address change record |
| `itnmSvkeiKisuwNo` | Field | Transfer source service contract line item detail number — the contract detail number before the address change |
| `itensSvkeiKisuwNo` | Field | Transfer destination service contract line item detail number — the contract detail number after the address change |
| `chBfSkbtNo` | Field | Pre-change identifier number — the service contract identifier before the address change |
| `chAfSkbtNo` | Field | Post-change identifier number — the service contract identifier after the address change |
| `svcKeiIdoSbtCd` | Field | Service contract move subtype code — classifies how the service contract changed (0=continuation, 1=content change, 2=retention, 3=addition, 4=cancellation) |
| `svcCd` | Field | Service code — classifies the service type: 01=NET (fibre broadband), 02=TEL (fixed-line), 03=TV (cable television) |
| `pcrsCd` | Field | Package code — identifies specific service packages, e.g., "A23" for TV re-application |
| `wribSvcKojihiKapCp` | Field | Writ (Standard Installation Fee) discount CP data — campaign plan agreement data for the installation fee discount |
| `wribSvcKeiStat` | Field | Writ service contract status — CP agreement status code (010=unconfirmed, 100=in progress) |
| `isKapKeiZanti` | Field | CP retention flag (工事費割引租残置) — determines whether the CP agreement should remain with the pre-address-change contract |
| `isDsl` | Field | DSL cancellation flag — determines whether the CP agreement should be cancelled |
| `isMotoTvSaisosin` | Field | Moto TV re-application flag — true if the pre-change TV contract includes a re-application |
| `isSakiTvSaisosin` | Field | Saki TV re-application flag — true if the post-change TV contract includes a re-application |
| HT | Business term | Home — home-type dwelling (single-family house, traditional residence) |
| MT | Business term | Maison — maison-type dwelling (apartment building, multi-unit dwelling) |
| CP | Business term | Campaign Plan (キャンペーンプラン) — promotional service discount agreements, specifically the Standard Installation Fee Discount CP |
| NET | Business term | Net service — fibre broadband / internet connectivity service (FTTH: Fiber To The Home) |
| TEL | Business term | TEL service — fixed-line telephone service |
| TV | Business term | TV service — cable television service |
| IDO_DIV_DSL | Constant | Move classification code for DSL (`00005`) — indicates a DSL release operation |
| IDO_DIV_ADCHG_ADD | Constant | Move classification code for address change addition (`00019`) — indicates a new address change registration |
| IDO_DIV_ADCHG_FIX | Constant | Move classification code for address change confirmation (`00020`) — indicates an address change has been finalized |
| WRIB_SVC_KEI_STAT_UK_ZM | Constant | Writ service contract status: unconfirmed/registered (`010`) — CP has been recorded but not yet processed |
| WRIB_SVC_KEI_STAT_SVC_TK_CHU | Constant | Writ service contract status: service provision in progress (`100`) — CP is actively providing the discount |
| CD00037_DSL_ZM | Constant | Service contract status: not cancelled (`00005`) — the service contract has been fully cancelled |
| CD00576_ADCHG_ADD | Constant | Move classification for address change addition — identifies the screen is in address change registration mode |
| KKW042090PJP | Constant | View ID for address change screen (`KKW042090PJP`) — the page identifier for the address change registration screen |
| SVC_KEI_ICHII_FUNC_CD | Constant | Service contract master lookup function code (`"2"`) — used in `callSvcKeiIchiiShokai` queries |
| EKK2101B001_FUNC_CD_1 | Constant | EKK2101B001 function code (`"1"`) — used in `callEKK2101B001ToAll` queries |
| comAdchgDtlSbtCd | Constant | Common address change detail subtype code (`"01"`) — filters detail records by subtype |
| SEIRITSU_JOKEN_RECHECK_YES | Constant | Re-check yes flag (`"1"`) — indicates a re-check operation is in progress |
| KAP_SYSID | Constant | Work map key for KAP system ID |
| KAP_SEIKY_KEI_NO | Constant | Work map key for KAP billing contract number |
| WRIB_DSL_FLG | Constant | Work map key for writ DSL flag |
| WRIB_DSL_FLG_ON | Constant | Writ DSL flag value (`"1"`) — indicates DSL cancellation is active |
| ADCHG_STAT | Field | Address change status — `003` means the address change has been confirmed/finalized |
| KK_T_SVC_KEI_ISHII | Table | Service contract master table — stores all active service contract information including service codes and statuses |
| KK_T_ADCHG_NO | Table | Address change detail table — stores address change header records |
| KK_T_ADCHG_NO_DTL | Table | Address change detail list table — stores line items within each address change record |
| KK_T_WRIB_SVC_KEI | Table | Writ service contract table — stores standard installation fee discount CP agreement records |