# Business Logic — JKKUsePlaceAdInfUpdCC.updateKikiUsedAd() [212 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKUsePlaceAdInfUpdCC` |
| Layer | CC / Common Component (Controller-Component) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKUsePlaceAdInfUpdCC.updateKikiUsedAd()

This method performs the core business operation of updating **device installation addresses** for all equipment linked to NTT West service contracts during a customer's address change (move) process. It is called from `JKKUsePlaceAdInfUpdCC.updateUsePlaceAd()` when a subscriber's registered address changes and all associated equipment (modems, routers, ONUs, HGW, etc.) must have their installation addresses synchronized to the new address.

The method handles **two distinct device categories**: (1) **Service-contract-linked devices** (devices associated with a service contract routing number, i.e., `svc_kei_kaisen_ucwk_no`), which are typically standalone devices that may not have a direct service contract number; and (2) **Contract-linked devices** (devices associated with a service contract number, `kiki_svc_kei_no`), which are equipment directly tied to an active service agreement.

For service-contract-linked devices, the method applies a **device-type-aware routing pattern**: it determines the correct service contract number to associate with the device based on the equipment type — for example, a V-ONU (`E0`) resolves to the TV service contract (`03`), while modems (`60`), splitters (`70`), inline filters (`90`), ONUs (`D0`), multi-function routers (`R0`), and HGWs (`S0`) resolve to the network service contract (`01`) or telephone service contract (`02`) if both exist, with network taking priority.

The method acts as a **shared utility** within the address change workflow (KKSV0004 screen), delegating the actual database update of device address information to `chgIdodiv_EKK0341C200` for each device. It implements a **data-driven batch processing pattern**, iterating through retrieved device lists, filtering by status, mapping address data, and triggering per-device updates — all within a single transactional context managed by the `SessionHandle`.

The Japanese Javadoc translates to: "Update device installation address" (機器利用場所住所更新).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["updateKikiUsedAd()"])
    START --> INIT["Initialize: get mapper, fetch service contract routing number"]
    INIT --> FETCH_B504["Query EKK0341B504 - Device service contract list (by routing number)"]
    FETCH_B504 --> LOOP1{"Iterate device list?"}
    LOOP1 -->|Yes| GET_KKTK["Get kktkSvcKeiNo (device service contract number)"]
    GET_KKTK --> FETCH_A010["Query EKK0341A010 - Device service contract agreement"]
    FETCH_A010 --> CHECK_STAT{"Service status in allowed list?"}
    CHECK_STAT -->|No| SKIP_STAT["Continue - skip this device"]
    SKIP_STAT --> LOOP1
    CHECK_STAT -->|Yes| MAP_ADDR["Map use place address fields to device installation address"]
    MAP_ADDR --> FETCH_SVC["Query EKK0081B007 - Service contract list"]
    FETCH_SVC --> LOOP2{"Iterate service contracts?"}
    LOOP2 -->|Yes| CHECK_DEVICE{"Device type?"}
    CHECK_DEVICE -->|E0 V-ONU| CHECK_TV{"Service code 03 (TV)?"}
    CHECK_TV -->|Yes| SET_SVC_NUM["Set kiki_svc_kei_no = TV service"]
    CHECK_TV -->|No| CONT_SVC["Continue searching"]
    SET_SVC_NUM --> LOOP2_END
    CHECK_DEVICE -->|60/70/90/D0/R0/S0| CHECK_NET{"Service code 01 (Net)?"}
    CHECK_NET -->|Yes| SET_NET["Set kiki_svc_kei_no = Net service"]
    CHECK_NET -->|No| CHECK_TEL2{"Service code 02 (Tel)?"}
    CHECK_TEL2 -->|Yes| SET_TEL["Set kiki_svc_kei_no = Tel service (no break)"]
    CHECK_TEL2 -->|No| CONT_SVC2["Continue searching"]
    CONT_SVC2 --> LOOP2
    CONT_SVC --> LOOP2
    SET_NET --> LOOP2_END
    SET_TEL --> LOOP2_END
    LOOP2_END --> UPDATE_A010["Update EKK0341C200 - Device address"]
    UPDATE_A010 --> LOOP1
    LOOP1 -->|No| CHECK_SVC_LIST{"Has svc_kei_list?"}
    CHECK_SVC_LIST -->|No| END_RETURN["Return"]
    CHECK_SVC_LIST -->|Yes| LOOP3{"Iterate contract service list?"}
    LOOP3 -->|Yes| CHECK_KKTK{"Has kktkSvcKeiNo?"}
    CHECK_KKTK -->|No| LOOP3
    CHECK_KKTK -->|Yes| FETCH_B002["Query EKK0341B002 - Device service contract list (by contract number)"]
    FETCH_B002 --> LOOP4{"Iterate device list?"}
    LOOP4 -->|No| LOOP3
    LOOP4 -->|Yes| FETCH_A010_2["Query EKK0341A010 - Device agreement"]
    FETCH_A010_2 --> CHECK_STAT2{"Status in allowed list?"}
    CHECK_STAT2 -->|No| SKIP_STAT2["Continue - skip"]
    SKIP_STAT2 --> LOOP4
    CHECK_STAT2 -->|Yes| MAP_ADDR2["Map address fields"]
    MAP_ADDR2 --> UPDATE_A010_2["Update EKK0341C200 - Device address"]
    UPDATE_A010_2 --> LOOP4
    LOOP3 -->|No| END_RETURN
```

**Service Status Filter Values** (`CD00056_KKTK_STATUS_LIST`):

| Status Code | Meaning |
|-------------|---------|
| `010` | 受付済 (Order received) |
| `020` | 照収済 (Confirmed) |
| `030` | 締結済 (Contracted) |
| `100` | サービス提供中 (Service active) |
| `110` | 契約変更中 (Contract change in progress) |
| `210` | 休止・中断中 (Suspended/interrupted) |
| `220` | 停止中 (Stopped) |

**Device Type Resolution** (Net/Tel priority for devices 60/70/90/D0/R0/S0):

| Device Code | Business Name |
|-------------|--------------|
| `E0` | V-ONU (VDSL Optical Network Unit) |
| `60` | モデム (Modem) |
| `70` | スプリッター (Splitter) |
| `90` | インラインフィルタ (Inline Filter) |
| `D0` | ONU (Optical Network Unit) |
| `R0` | 多機能ルーター (Multi-Function Router) |
| `S0` | HGW (Home Gateway) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle representing the current transaction context. Manages DB connections and transaction boundaries for all service component calls made during the address update process. |
| 2 | `param` | `IRequestParameterReadWrite` | Request/reply parameter container carrying data between the method and service components. Used for setting conditions, populating request maps, and extracting response data from SC queries. |
| 3 | `fixedText` | `String` | Fixed text / display constants used by service components for message formatting and label generation. Passed through to mapper methods for consistency across the transaction. |
| 4 | `scCall` | `ServiceComponentRequestInvoker` | Service component invocation engine. Executes SC queries (set + run + get pattern) against the database. Used for all data reads: EKK0341B504, EKK0341A010, EKK0081B007, EKK0341B002. |
| 5 | `paramMap` | `HashMap<String, Object>` | Input parameter map carrying business context from the caller (`updateUsePlaceAd`). Contains: the service contract routing number (`svc_kei_kaisen_ucwk_no`), the new address data (postal code, state, city, town, lot number, building name/number), operation date, and the optional contract-linked service list (`svc_kei_list`). |

**Key values in `paramMap`:**

| Key Constant | Business Data |
|-------------|---------------|
| `PARAM_SVC_KEI_KAISEN_UCWK_NO` | Service contract routing number — links devices to a parent service contract chain |
| `KAISEN_PLACE_AD_CD` | New installation address code |
| `PARAM_AD_PCD` | New postal code |
| `PARAM_AD_STATE_NM` | New prefecture/prefectural city name |
| `PARAM_AD_CITY_NM` | New municipality name |
| `PARAM_AD_OAZTSU_NM` | New district/block name |
| `PARAM_AD_AZCHO_NM` | New town/cho name |
| `PARAM_AD_BNCHIGO` | New lot number |
| `PARAM_AD_ADRTTM` | New address supplementary / building name |
| `PARAM_AD_ADRRM` | New address supplementary / room number |
| `MAN_INPUT_FLG` | Manual input flag for installation address (linking to home equipment management system) |
| `KISN_PLC_AD_MI_FIX_FLG` | Unconfirmed address flag |
| `JKKAdInfChgConstCC.PARAM_KEY_OPE_DATE` | Operation date for query conditions |
| `SVC_KEI_LIST` | List of contract-linked services (for second processing loop, may be null) |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKAdInfChgMapperCC.setEKK0341B504` | EKK0341B504SC | EKK0341B504 (Device service contract list) | Sets query conditions to fetch devices linked by routing number |
| R | `scCall.run` (EKK0341B504) | EKK0341B504SC | EKK0341B504 (Device service contract list) | Executes the SC to retrieve device service contracts by routing number |
| R | `JKKAdInfChgMapperCC.getEKK0341B504` | EKK0341B504SC | EKK0341B504 (Device service contract list) | Extracts list of device service contracts from the response |
| R | `JKKAdInfChgMapperCC.setEKK0341A010` | EKK0341A010SC | EKK0341A010 (Device service contract agreement) | Sets query conditions to fetch device agreement by KKTK service contract number |
| R | `scCall.run` (EKK0341A010) | EKK0341A010SC | EKK0341A010 (Device service contract agreement) | Executes the SC to retrieve device agreement details |
| R | `JKKAdInfChgMapperCC.getEKK0341A010` | EKK0341A010SC | EKK0341A010 (Device service contract agreement) | Extracts device agreement data (status, service code, equipment type) |
| U | `JKKAdInfChgMapperCC.setEKK0081B007` | EKK0081B007SC | EKK0081B007 (Service contract list) | Sets query conditions to fetch service contract numbers for device type resolution |
| R | `scCall.run` (EKK0081B007) | EKK0081B007SC | EKK0081B007 (Service contract list) | Executes the SC to retrieve service contract numbers |
| R | `JKKAdInfChgMapperCC.getEKK0081B007` | EKK0081B007SC | EKK0081B007 (Service contract list) | Extracts service contract data for device type resolution |
| R | `JKKAdInfChgMapperCC.setEKK0341B002` | EKK0341B002SC | EKK0341B002 (Device service contract list) | Sets query conditions to fetch devices linked by service contract number (contract-linked devices) |
| R | `scCall.run` (EKK0341B002) | EKK0341B002SC | EKK0341B002 (Device service contract list) | Executes the SC to retrieve device service contracts by contract number |
| R | `JKKAdInfChgMapperCC.getEKK0341B002` | EKK0341B002SC | EKK0341B002 (Device service contract list) | Extracts list of device service contracts from the response |
| U | `JKKUsePlaceAdInfUpdCC.chgIdodiv_EKK0341C200` | EKK0341C200SC | EKK0341C200 (Device address/update table) | Updates the device address table with new installation address data — terminal CRUD operation |

**CRUD Summary:**
- **R (Read)**: 6 SC queries (EKK0341B504, EKK0341A010 x2, EKK0081B007, EKK0341B002)
- **U (Update)**: 1 terminal SC (`chgIdodiv_EKK0341C200`), called once per qualifying device (two loops)
- **C/D**: None

**Address field mapping** (applied in both loops):

| Source (paramMap) | Target (EKK0341A010 map) | Business Meaning |
|-------------------|------------------------|------------------|
| `KAISEN_PLACE_AD_CD` | `KIKI_STC_SAKI_AD_CD` | Use place address code → Device installation address code |
| `PARAM_AD_PCD` | `KIKI_STC_SAKI_PCD` | Use place postal code → Device installation postal code |
| `PARAM_AD_STATE_NM` | `KIKI_STC_SAKI_STATE_NM` | Use place prefecture name → Device installation prefecture name |
| `PARAM_AD_CITY_NM` | `KIKI_STC_SAKI_CITY_NM` | Use place municipality name → Device installation municipality name |
| `PARAM_AD_OAZTSU_NM` | `KIKI_STC_SAKI_OAZTSU_NM` | Use place district name → Device installation district name |
| `PARAM_AD_AZCHO_NM` | `KIKI_STC_SAKI_AZCHO_NM` | Use place town name → Device installation town name |
| `PARAM_AD_BNCHIGO` | `KIKI_STC_SAKI_BNCHIGO` | Use place lot number → Device installation lot number |
| `PARAM_AD_ADRTTM` | `KIKI_STC_SAKI_ADRTTM` | Use place address supplement → Device installation address supplement (building name) |
| `PARAM_AD_ADRRM` | `KIKI_STC_SAKI_ADRRM` | Use place address supplement → Device installation address supplement (room number) |
| `MAN_INPUT_FLG` | `KEY_SETPLACE_AD_MAN_INPUT_FLG` | Manual input flag → Installation address manual input flag (for home equipment management system integration) |
| `"1"` | `KIKI_STC_AD_CHK_LV` | Device address check level = 1 (validation level) |
| `UPD_DTM` (existing) | `UPD_DT_KKTK_SVC_KEI_UPD_DTM_BEF` | Previous update datetime (preserved before overwrite) |
| `KISN_PLC_AD_MI_FIX_FLG` | `AD_MI_FIX_FLG` | Unconfirmed address flag |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKUsePlaceAdInfUpdCC.updateUsePlaceAd` | `updateUsePlaceAd` → `updateKikiUsedAd` | `chgIdodiv_EKK0341C200 [U] EKK0341C200` |

**Notes:** No screen (KKSV) or batch entry points were found within the call graph. The method is called exclusively from `JKKUsePlaceAdInfUpdCC.updateUsePlaceAd()`, which is itself a CBS (cross-system business service) method. The terminal database operation flows through `chgIdodiv_EKK0341C200` which updates the `EKK0341C200` table (device address table) with the new installation address.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialize local variables and mapper (L1575)

> Declares local working variables and obtains the singleton mapper instance for device address data mapping.

| # | Type | Code |
|---|------|------|
| 1 | SET | `condMap = new HashMap<String, String>()` |
| 2 | SET | `mapper = JKKAdInfChgMapperCC.getInstance()` |

---

**Block 2** — [SET] Fetch service contract routing number (L1584)

> Retrieves the service contract routing number from `paramMap` — this is the key for finding devices not directly linked to a service contract number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `work_kaisen_ucwk_cd = (String)paramMap.get(PARAM_SVC_KEI_KAISEN_UCWK_NO)` |

---

**Block 3** — [CALL] Query device service contract list by routing number (L1587-L1592)

> Fetches all devices linked via the service contract routing number (EKK0341B504: 機器提供サービス契約一覧照会(サービス契約回線内訳)). This is the first data retrieval for service-contract-linked devices.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `condMap.clear()` |
| 2 | SET | `condMap.put(JKKAdInfChgConstCC.COND_KEY_SVC_KEI_KAIS_UCWK_NO, work_kaisen_ucwk_cd)` |
| 3 | SET | `reqMap = mapper.setEKK0341B504(param, fixedText, condMap)` |
| 4 | CALL | `resMap = scCall.run(reqMap, handle)` |
| 5 | CALL | `kk341_b504_lst = mapper.getEKK0341B504(param, fixedText, resMap)` |
| 6 | CALL | `mapper.scResultCheck(param)` |

---

**Block 4** — [WHILE] Iterate service-contract-linked device list (L1595)

> Iterates through all devices returned from EKK0341B504. For each device, queries the agreement details, validates status, maps address data, resolves the correct service contract number based on device type, and updates the device address.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kikiTk_ite = kk341_b504_lst.iterator()` |
| 2 | SET | `cur_kikiTk_list = kikiTk_ite.next()` |
| 3 | CALL | `kktkSvcKeiNo = getMapString(cur_kikiTk_list, EKK0341B501CBSMsg1List.KKTK_SVC_KEI_NO)` |

---

**Block 5** — [CALL] Query device service contract agreement (L1603-L1610)

> Retrieves the device service contract agreement details (EKK0341A010: 機器提供サービス契約同意照会) using the KKTK service contract number and operation date. This provides the service status and equipment type for filtering and type-based routing.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `condMap.clear()` |
| 2 | SET | `condMap.put(JKKAdInfChgConstCC.COND_KEY_KKTK_SVC_KEI_NO, kktkSvcKeiNo)` |
| 3 | SET | `condMap.put(JKKAdInfChgConstCC.COND_KEY_OPEDATE, getMapString(paramMap, JKKAdInfChgConstCC.PARAM_KEY_OPE_DATE))` |
| 4 | SET | `reqMap = mapper.setEKK0341A010(param, fixedText, condMap)` |
| 5 | CALL | `resMap = scCall.run(reqMap, handle)` |
| 6 | CALL | `kk341_a010_map = mapper.getEKK0341A010(param, fixedText, resMap)` |
| 7 | CALL | `mapper.scResultCheck(param)` |
| 8 | SET | `tgtStatList = Arrays.asList(JKKAdInfChgConstCC.CD00056_KKTK_STATUS_LIST)` |

> `tgtStatList` contains all service statuses that are eligible for processing. Devices with any other status are excluded.

---

**Block 6** — [IF] Service status filter check (L1612)

> Checks if the device's service status code is in the allowed list. If the status is NOT in the allowed list (`010` 受付済, `020` 照収済, `030` 締結済, `100` サービス提供中, `110` 契約変更中, `210` 休止・中断中, `220` 停止中), the device is skipped. This ensures only active or recently processed devices are updated.

| # | Type | Code |
|---|------|------|
| 1 | IF | `kk341_a010_map.containsKey(EKK0341A010CBSMsg1List.KKTK_SVC_KEI_STAT)` |
| 2 | SET | `stat = (String)kk341_a010_map.get(EKK0341A010CBSMsg1List.KKTK_SVC_KEI_STAT)` |
| 3 | IF-NOT | `!tgtStatList.contains(stat)` → `continue` |

---

**Block 7** — [SET] Map address fields to device agreement map (L1617-L1642)

> Copies the new address data from `paramMap` into the device agreement map (`kk341_a010_map`). This is where the actual address change data is assembled for the device.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_AD_CD, paramMap.get(KAISEN_PLACE_AD_CD))` |
| 2 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_PCD, paramMap.get(PARAM_AD_PCD))` |
| 3 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_STATE_NM, paramMap.get(PARAM_AD_STATE_NM))` |
| 4 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_CITY_NM, paramMap.get(PARAM_AD_CITY_NM))` |
| 5 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_OAZTSU_NM, paramMap.get(PARAM_AD_OAZTSU_NM))` |
| 6 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_AZCHO_NM, paramMap.get(PARAM_AD_AZCHO_NM))` |
| 7 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_BNCHIGO, paramMap.get(PARAM_AD_BNCHIGO))` |
| 8 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_ADRTTM, paramMap.get(PARAM_AD_ADRTTM))` |
| 9 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_ADRRM, paramMap.get(PARAM_AD_ADRRM))` |
| 10 | SET | `kk341_a010_map.put(KEY_SETPLACE_AD_MAN_INPUT_FLG, paramMap.get(MAN_INPUT_FLG))` |
| 11 | SET | `kk341_a010_map.put(KIKI_STC_AD_CHK_LV, "1")` |
| 12 | SET | `kk341_a010_map.put(UPD_DT_KKTK_SVC_KEI_UPD_DTM_BEF, kk341_a010_map.get(UPD_DTM))` |
| 13 | SET | `kk341_a010_map.put(AD_MI_FIX_FLG, paramMap.get(KISN_PLC_AD_MI_FIX_FLG))` |

---

**Block 8** — [CALL] Query service contract list for type resolution (L1645-L1651)

> Retrieves service contract numbers (EKK0081B007: サービス契約一覧取得) linked to the routing number and operation date. These service contracts are matched against the device's equipment type to determine which service contract number to associate with the device.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `condMap.clear()` |
| 2 | SET | `condMap.put("key_svc_kei_kaisen_ucwk_no", work_kaisen_ucwk_cd)` |
| 3 | SET | `condMap.put("key_ope_ymd", (String)paramMap.get(JKKAdInfChgConstCC.PARAM_KEY_OPE_DATE))` |
| 4 | SET | `reqMap = mapper.setEKK0081B007(param, fixedText, condMap)` |
| 5 | CALL | `resMap = scCall.run(reqMap, handle)` |
| 6 | CALL | `kk0081_b007_lst = mapper.getEKK0081B007(param, fixedText, resMap)` |
| 7 | CALL | `mapper.scResultCheck(param)` |

---

**Block 9** — [SET] Initialize service contract number for device type resolution (L1655)

> Resets `kiki_svc_kei_no` to empty string before beginning the device type resolution loop.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kiki_svc_kei_no = ""` |
| 2 | SET | `kiki_sbt_cd = getMapString(kk341_a010_map, EKK0341A010CBSMsg1List.TAKNKIKI_SBT_CD)` |

---

**Block 10** — [WHILE] Device type resolution service contract loop (L1656-L1690)

> Iterates through service contracts to find the appropriate service contract number for the device based on its equipment type (`kiki_sbt_cd`). The resolution follows a device-type-specific priority:
> - **V-ONU (`E0`)**: Must match TV service (`03`) only. Breaks immediately when found.
> - **Modem/Splitter/Filter/ONU/Multi-router/HGW (`60`/`70`/`90`/`D0`/`R0`/`S0`)**: Prefers network service (`01`: CD00130_NET), falls back to telephone service (`02`: CD00130_TEL) if no network service found. Does NOT break on telephone (continues searching for network in case it appears later).

| # | Type | Code |
|---|------|------|
| 1 | SET | `kk0081_b007_map = svc_ite.next()` |
| 2 | SET | `svc_cd = (String)kk0081_b007_map.get(EKK0081B007CBSMsg1List.SVC_CD)` |

---

**Block 10.1** — [IF] V-ONU type: match TV service (L1659-L1665)

> For V-ONU equipment (`E0`: V-ONU), only a TV service (`03`) contract number is accepted. This is because V-ONU is historically used for TV service delivery.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"E0".equals(kiki_sbt_cd)` |
| 2 | IF | `"03".equals(svc_cd)` [CD00130_TV = "03"] |
| 3 | SET | `kiki_svc_kei_no = (String)kk0081_b007_map.get(EKK0081B007CBSMsg1List.SVC_KEI_NO)` |
| 4 | SET | `break` |

---

**Block 10.2** — [ELSE-IF] Modem/Splitter/Filter/ONU/Multi-router/HGW: match Net/Tel services (L1667-L1690)

> For network-related equipment (Modem `60`, Splitter `70`, Inline Filter `90`, ONU `D0`, Multi-Function Router `R0`, HGW `S0`), the system first searches for a network service (`01`: CD00130_NET), and if not found, uses a telephone service (`02`: CD00130_TEL). The break only occurs for network — telephone is set but not broken, allowing the loop to continue searching for a network service that may appear later.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"60".equals(kiki_sbt_cd) \|\| "70".equals(kiki_sbt_cd) \|\| "90".equals(kiki_sbt_cd) \|\| "D0".equals(kiki_sbt_cd) \|\| "R0".equals(kiki_sbt_cd) \|\| "S0".equals(kiki_sbt_cd)` |
| 2 | IF | `"01".equals(svc_cd)` [CD00130_NET = "01"] |
| 3 | SET | `kiki_svc_kei_no = (String)kk0081_b007_map.get(EKK0081B007CBSMsg1List.SVC_KEI_NO)` |
| 4 | SET | `break` |
| 5 | ELSE-IF | `"02".equals(svc_cd)` [CD00130_TEL = "02"] |
| 6 | SET | `kiki_svc_kei_no = (String)kk0081_b007_map.get(EKK0081B007CBSMsg1List.SVC_KEI_NO)` |
| 7 | | *(no break — network takes priority)* |

---

**Block 11** — [CALL] Update device address for service-contract-linked device (L1694)

> Delegates to `chgIdodiv_EKK0341C200` to persist the updated address data for the device. The `kiki_svc_kei_no` determined by the type-resolution logic is passed as the service contract number for the device.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `chgIdodiv_EKK0341C200(handle, param, fixedText, kk341_a010_map, kiki_svc_kei_no)` |

---

**Block 12** — [SET] Check for contract-linked service list (L1699)

> Begins the second processing loop for contract-linked devices. Retrieves the service contract list from `paramMap`. This list may be null if no contract-linked devices exist.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svc_kei_list = (ArrayList<HashMap<String, Object>>)paramMap.get(SVC_KEI_LIST)` |

---

**Block 13** — [FOR] Iterate contract-linked service list (L1700)

> Iterates through each service contract in the list. Each contract has a `kiki_svc_kei_no` (KKTK service contract number). The loop queries device details and updates their installation addresses.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kk0081_a010_map = each element of svc_kei_list` |
| 2 | SET | `kiki_svc_kei_no = (String)kk0081_a010_map.get(EKK0081A010CBSMsg1List.SVC_KEI_NO)` |

---

**Block 14** — [IF] Non-empty check for contract number (L1702)

> Skips the entire processing for a contract if `kiki_svc_kei_no` is null or empty.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!StringUtils.isEmpty(kiki_svc_kei_no)` |

---

**Block 15** — [CALL] Query device service contract list by contract number (L1706-L1713)

> Fetches device service contracts (EKK0341B002: 機器提供サービス契約一覧照会) linked by the service contract number. This is parallel to Block 3 but uses a different query (contract-number-based vs routing-number-based).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `condMap.clear()` |
| 2 | SET | `condMap.put("key_svc_kei_no", kiki_svc_kei_no)` |
| 3 | SET | `reqMap = mapper.setEKK0341B002(param, fixedText, condMap)` |
| 4 | CALL | `resMap = scCall.run(reqMap, handle)` |
| 5 | CALL | `kk341_b002_lst = mapper.getEKK0341B002(param, fixedText, resMap)` |
| 6 | CALL | `mapper.scResultCheck(param)` |

---

**Block 16** — [WHILE] Iterate device list for contract-linked device (L1716-L1724)

> Same pattern as Block 4 — iterates through devices returned from EKK0341B002, queries their agreement, and prepares for address update.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kk341_b002_ite = kk341_b002_lst.iterator()` |
| 2 | SET | `cur_kikiTk_list = kk341_b002_ite.next()` |
| 3 | CALL | `kktkSvcKeiNo = getMapString(cur_kikiTk_list, EKK0341B501CBSMsg1List.KKTK_SVC_KEI_NO)` |

---

**Block 17** — [CALL] Query device service contract agreement (contract-linked) (L1727-L1735)

> Identical to Block 5 but in the contract-linked context. Queries EKK0341A010 for device agreement details.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `condMap.clear()` |
| 2 | SET | `condMap.put(JKKAdInfChgConstCC.COND_KEY_KKTK_SVC_KEI_NO, kktkSvcKeiNo)` |
| 3 | SET | `condMap.put(JKKAdInfChgConstCC.COND_KEY_OPEDATE, getMapString(paramMap, JKKAdInfChgConstCC.PARAM_KEY_OPE_DATE))` |
| 4 | SET | `reqMap = mapper.setEKK0341A010(param, fixedText, condMap)` |
| 5 | CALL | `resMap = scCall.run(reqMap, handle)` |
| 6 | CALL | `kk341_a010_map = mapper.getEKK0341A010(param, fixedText, resMap)` |
| 7 | CALL | `mapper.scResultCheck(param)` |
| 8 | SET | `tgtStatList = Arrays.asList(JKKAdInfChgConstCC.CD00056_KKTK_STATUS_LIST)` |

---

**Block 18** — [IF] Service status filter check (contract-linked) (L1737-L1743)

> Identical to Block 6 — filters out devices whose status is not in the allowed list.

| # | Type | Code |
|---|------|------|
| 1 | IF | `kk341_a010_map.containsKey(EKK0341A010CBSMsg1List.KKTK_SVC_KEI_STAT)` |
| 2 | SET | `stat = (String)kk341_a010_map.get(EKK0341A010CBSMsg1List.KKTK_SVC_KEI_STAT)` |
| 3 | IF-NOT | `!tgtStatList.contains(stat)` → `continue` |

---

**Block 19** — [SET] Map address fields (contract-linked) (L1746-L1772)

> Identical to Block 7 — copies address data into the device agreement map for the contract-linked device.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_AD_CD, paramMap.get(KAISEN_PLACE_AD_CD))` |
| 2 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_PCD, paramMap.get(PARAM_AD_PCD))` |
| 3 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_STATE_NM, paramMap.get(PARAM_AD_STATE_NM))` |
| 4 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_CITY_NM, paramMap.get(PARAM_AD_CITY_NM))` |
| 5 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_OAZTSU_NM, paramMap.get(PARAM_AD_OAZTSU_NM))` |
| 6 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_AZCHO_NM, paramMap.get(PARAM_AD_AZCHO_NM))` |
| 7 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_BNCHIGO, paramMap.get(PARAM_AD_BNCHIGO))` |
| 8 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_ADRTTM, paramMap.get(PARAM_AD_ADRTTM))` |
| 9 | SET | `kk341_a010_map.put(KIKI_STC_SAKI_ADRRM, paramMap.get(PARAM_AD_ADRRM))` |
| 10 | SET | `kk341_a010_map.put(KEY_SETPLACE_AD_MAN_INPUT_FLG, paramMap.get(MAN_INPUT_FLG))` |
| 11 | SET | `kk341_a010_map.put(KIKI_STC_AD_CHK_LV, "1")` |
| 12 | SET | `kk341_a010_map.put(UPD_DT_KKTK_SVC_KEI_UPD_DTM_BEF, kk341_a010_map.get(UPD_DTM))` |
| 13 | SET | `kk341_a010_map.put(AD_MI_FIX_FLG, paramMap.get(KISN_PLC_AD_MI_FIX_FLG))` |

---

**Block 20** — [CALL] Update device address (contract-linked) (L1767)

> Identical to Block 11 — delegates to `chgIdodiv_EKK0341C200` for the contract-linked device. The `kiki_svc_kei_no` comes directly from the contract (no type resolution needed).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `chgIdodiv_EKK0341C200(handle, param, fixedText, kk341_a010_map, kiki_svc_kei_no)` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_kaisen_ucwk_no` | Field | Service contract routing number — a parent-level grouping key that links multiple service contracts and their associated devices under a single routing chain |
| `kktk_svc_kei_no` | Field | KKTK (機器提供) service contract number — the unique identifier for a device-specific service contract |
| `kiki_sbt_cd` | Field | Equipment type code — classifies the physical equipment (V-ONU, modem, splitter, ONU, router, HGW, etc.) |
| `kiki_svc_kei_no` | Field| Device service contract number — the resolved service contract number associated with a device |
| `svc_cd` | Field | Service code — classifies a service as network (`01`), telephone (`02`), TV (`03`), or hosting (`04`) |
| `stat` (KKTK_SVC_KEI_STAT) | Field | Service status code — current state of a service contract (e.g., `010` Order received, `100` Service active, `220` Stopped) |
| `KIKI_STC_SAKI_AD_CD` | Field | Device installation address code — the address code at the location where the device is installed |
| `KIKI_STC_SAKI_PCD` | Field | Device installation postal code |
| `KIKI_STC_SAKI_STATE_NM` | Field | Device installation prefecture name |
| `KIKI_STC_SAKI_CITY_NM` | Field | Device installation municipality name |
| `KIKI_STC_SAKI_OAZTSU_NM` | Field | Device installation district/block name |
| `KIKI_STC_SAKI_AZCHO_NM` | Field | Device installation town name |
| `KIKI_STC_SAKI_BNCHIGO` | Field | Device installation lot number |
| `KIKI_STC_SAKI_ADRTTM` | Field | Device installation address supplement — building name |
| `KIKI_STC_SAKI_ADRRM` | Field | Device installation address supplement — room number |
| `MAN_INPUT_FLG` | Field | Installation address manual input flag — indicates whether the installation address was manually entered (for home equipment management system integration) |
| `AD_MI_FIX_FLG` | Field | Unconfirmed address flag — indicates whether the installation address has been confirmed |
| `KIKI_STC_AD_CHK_LV` | Field | Device address check level — set to `"1"` for validation level (standard validation) |
| `UPD_DT_KKTK_SVC_KEI_UPD_DTM_BEF` | Field | Pre-update datetime — preserves the original update timestamp before the address change |
| `EKK0341B504` | Entity/SC | Device service contract list (by routing number) — retrieves devices linked via the service contract routing number |
| `EKK0341A010` | Entity/SC | Device service contract agreement — retrieves device agreement details including status, equipment type, and service codes |
| `EKK0081B007` | Entity/SC | Service contract list — retrieves service contract numbers linked to a routing number for device type resolution |
| `EKK0341B002` | Entity/SC | Device service contract list (by contract number) — retrieves devices linked by service contract number |
| `EKK0341C200` | Entity/SC | Device address/update table — the target table updated by `chgIdodiv_EKK0341C200` with new installation address data |
| V-ONU | Business term | VDSL Optical Network Unit — network equipment used for VDSL-based broadband service delivery |
| ONU | Business term | Optical Network Unit — terminal equipment at the customer premise for fiber-optic broadband service |
| HGW | Acronym | Home Gateway — a combined modem/router device that provides broadband connectivity and Wi-Fi access |
| KKTK | Acronym | 機器提供 (Kiki Teikyo) — "Equipment Provision" — NTT West's classification for equipment-related service contracts |
| KIKI_STC_SAKI | Abbreviation | 機器設置先 (Kiki Setchusaki) — "Device Installation Location" — prefix for address fields on device records |
| SVC_KEI | Abbreviation | サービス契約 (Saabisu Keiyaku) — "Service Contract" — prefix for service contract-related fields |
| SAKEI | Abbreviation | 回線内訳 (Kaisen Naiwai) — "Line Breakdown" — the detail-level breakdown of a service contract's line |
| KKSV0004 | Screen | Address change screen (利用場所住所変更) — the customer-facing screen that triggers the address change workflow including this method |
| CD00056_KKTK_STATUS_LIST | Constant | Array of allowed service statuses for device address updates — devices with statuses outside this list are excluded |
| `chgIdodiv_EKK0341C200` | Method | Terminal update method — persists device address changes to the database via the EKK0341C200 service component |
