# Business Logic — KKW00147SFLogic.configureVAChoicePulldown() [560 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00147SF.KKW00147SFLogic` |
| Layer | Service (Web Logic / Business Controller) |
| Module | `KKW00147SF` (Package: `eo.web.webview.KKW00147SF`) |

## 1. Role

### KKW00147SFLogic.configureVAChoicePulldown()

This method builds and populates a **VA (customer premises equipment / 家庭機器) selection pulldown** on the Phone Number Registration screen (KKW00147). The Phone Number Registration screen is used for managing telephone number operations for **eo Hikari Denwa** (fiber-optic phone service) subscribers, including number addition, phone number changes, and other service modifications.

The method implements a **conditional dispatch pattern** based on the `ido_div` (displacement/division category 異動区分) field, which determines the operation type. It has three distinct branches:

1. **Number Addition Branch (`IDO_DIV_BANGO_TSUIKA` — 番号追加)**: When adding a new phone number, the method iterates over all equipment provision service contracts from the data bean array, filters for VA-type equipment (eo phone VA, eo multi-function router/TKNRT, or Home Gateway/HGW), and for devices that have 2 or more LAN ports (or are TKNRT/HGW type regardless of port count), it groups them by model code and equipment change number into a `vaMap` TreeMap. If no matching VA devices are found, it falls back to the default eo multi-function router. If a service contract detail number exists, it retrieves the VA model code from the service contract detail agreement for pre-selection. The method then iterates the `vaMap` to build pulldown entries combining model code, model name, and serial number, and adds items to both the main pulldown (`vaBean`) and the temporary device list (`kikiArray`).

2. **Phone Number Change Branch (`IDO_DIV_DENWA_HENKO` — 電話番号情報変更)**: When changing an existing phone number, the method iterates the same equipment list, filters for VA-compatible devices, but only includes devices whose equipment change number matches the previously set `vaKikiChgNo` from the service contract detail bean. For matched devices, it adds them directly to the pulldown without `vaMap` grouping, and sets the auto-select index to `vaCnt`.

3. **Other Branch (default)**: For all other scenarios (e.g., initial display, number cancellation, port-out), the method loops through equipment data to find a device matching the `vaKikiChgNo` and breaks on the first match. If no matching equipment provision service contract is found, it performs a secondary rescan of the `outputMap` for data from `KKSV006426SC` (cancellation screen) and `KKSV006411SC` screens, cross-referencing device model codes to find a matching VA device. It then adds exactly one pulldown entry based on the resolved device.

After whichever branch executes, the method sets **pre-change device information** (service contract number, model code, model name, serial number, change number) on the form bean for audit/traceability, sets the pulldown index for pre-selection, stores the model-to-service-code mapping via `JCCWebCommon.setScreenInfo` for screen state retention, and sets the fixed-value display fields (VA model code, model name, serial number).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["configureVAChoicePulldown(svcFormBean, outputMap)"])
    START --> GET["Get kk0341Arr and svcKeiUcwkTelBean"]
    GET --> INIT["Initialize: vaMap, va fields, kiki_svc_no, genkoVAFlag, index, vaCnt"]
    INIT --> CLEAR["Clear vaBean lists and kikiArray"]
    CLEAR --> CHECK_DIV{Check ido_div}

    CHECK_DIV -->|"IDO_DIV_BANGO_TSUIKA<br/>Number Addition"| BR1["Branch 1: Number Addition"]
    CHECK_DIV -->|"IDO_DIV_DENWA_HENKO<br/>Phone Number Change"| BR2["Branch 2: Phone Change"]
    CHECK_DIV -->|"Other"| BR3["Branch 3: Other"]

    BR1 --> BT_LOOP["Loop kk0341Arr"]
    BT_LOOP --> BT_GET["Extract device info"]
    BT_GET --> BT_FILT{VA or TKNRT or HGW?}
    BT_FILT -->|"Yes"| BT_MATCH{chgNo match?}
    BT_MATCH -->|"Yes"| BT_SET["Set va fields"]
    BT_MATCH -->|"No"| BT_CHK2{ports >= 2<br/>or TKNRT or HGW?}
    BT_SET --> BT_CHK2
    BT_CHK2 -->|"Yes"| BT_MODEL{TKNRT or HGW?}
    BT_CHK2 -->|"No"| BT_NEXT
    BT_MODEL -->|"Yes"| BT_DEFMODEL["Set default modelNm"]
    BT_DEFMODEL --> BT_PUTMAP["vaMap.put(seizoYmd, info)"]
    BT_PUTMAP --> BT_STORE["kiki_svc_no.put()"]
    BT_STORE --> BT_FLAG["genkoVAFlag = true"]
    BT_FLAG --> BT_NEXT
    BT_NEXT --> BT_EMPTY{vaMap empty?}
    BT_EMPTY -->|"Yes"| BT_FB["Fallback TKNRT model"]
    BT_EMPTY -->|"No"| BT_SVC
    BT_FB --> BT_SVC["Get svcKeiUcwkNo"]
    BT_SVC --> BT_SVCNULL{not null?}
    BT_SVCNULL -->|"Yes"| BT_GETMODEL["Get vaModelCd from bean"]
    BT_SVCNULL -->|"No"| BT_ITERATE
    BT_GETMODEL --> BT_ITERATE["Iterate vaMap"]
    BT_ITERATE --> BT_ADD1["Add to vaBean and kikiArray"]
    BT_ADD1 --> BT_FINAL

    BR2 --> DH_LOOP["Loop kk0341Arr"]
    DH_LOOP --> DH_GET["Extract device info"]
    DH_GET --> DH_TKNRT{TKNRT or HGW?}
    DH_TKNRT -->|"Yes"| DH_DEFMODEL["Set default modelNm"]
    DH_DEFMODEL --> DH_FILT{VA or TKNRT or HGW?}
    DH_TKNRT -->|"No"| DH_FILT
    DH_FILT -->|"Yes"| DH_MATCH{chgNo match?}
    DH_MATCH -->|"Yes"| DH_SET["Set va fields, index=vaCnt"]
    DH_MATCH -->|"No"| DH_NEXT
    DH_SET --> DH_ADD["Add to vaBean and kikiArray"]
    DH_ADD --> DH_NEXT
    DH_NEXT --> DH_FINAL["Set before-change fields"]

    BR3 --> OT_LOOP["Loop kk0341Arr"]
    OT_LOOP --> OT_FILT{VA or TKNRT or HGW?}
    OT_FILT -->|"Yes"| OT_MATCH{chgNo match?}
    OT_MATCH -->|"Yes"| OT_SET["Set va fields, index=0, break"]
    OT_MATCH -->|"No"| OT_NEXT
    OT_SET --> OT_CHK{"svcKeiNo empty?"}
    OT_NEXT --> OT_CHK
    OT_CHK -->|"Yes"| OT_RESCAN["Rescan KKSV006426SC<br/>and KKSV006411SC"]
    OT_RESCAN --> OT_REMATCH{match + chgNo?}
    OT_REMATCH -->|"Yes"| OT_BACK["Set va fields, index=0, break"]
    OT_BACK --> OT_ADD
    OT_CHK -->|"No"| OT_ADD["Add single entry"]
    OT_ADD --> OT_FINAL

    BT_FINAL["Set before-change fields"]
    DH_FINAL --> SET_DISPLAY["Set display fields, index, setScreenInfo"]
    OT_FINAL --> SET_DISPLAY
    SET_DISPLAY --> END(["Return void"])
```

**Branch description:**

- **START**: Entry point. Receives `svcFormBean` (the form data bean) and `outputMap` (output from prior SC calls).
- **GET/INIT**: Retrieves the equipment provision service contract list (`kk0341Arr`) from `EKK0341B002DATA` and the service contract detail bean for eo phone (`svcKeiUcwkTelBean`) from `EKK0191A010DATA`. Initializes all working variables.
- **CLEAR**: Clears the existing VA pulldown list and the temporary device pulldown list.
- **CHECK_DIV**: Routes to the appropriate branch based on the `ido_div` value.

- **Branch 1 — Number Addition**: Loops over equipment list, filters VA-type devices, checks port count or TKNRT/HGW type, builds a grouped `vaMap`, optionally sets fallback defaults, retrieves the service contract detail model code for pre-selection, then iterates the map to populate the pulldown.
- **Branch 2 — Phone Number Change**: Loops over equipment list, filters VA-type devices, only includes devices matching `vaKikiChgNo`, adds directly to pulldown (no `vaMap` grouping), and sets the index.
- **Branch 3 — Other**: Loops to find a matching device. If not found, rescans the `outputMap` for cancellation screen data (`KKSV006426SC`/`KKSV006411SC`), cross-references model codes, and adds a single pulldown entry.

- **SET_DISPLAY**: Sets pre-change fields, fixed-value display fields, pulldown index, and persists the model-to-service-code mapping.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `svcFormBean` | `X31SDataBeanAccess` | The main service form data bean that holds all screen data, including the equipment provision service contract list (`EKK0341B002DATA`), the service contract detail bean for eo phone (`EKK0191A010DATA`), the VA choice pulldown bean (`VA_CHOICE`), and the temporary device pulldown list (`KIKIPULLDOWN_LIST`). It is both read from (to extract device data) and written to (to populate pulldown options and set form fields). |
| 2 | `outputMap` | `HashMap<String, Object>` | The output map from prior Service Component (SC) calls. Used in the "Other" branch to retrieve device data from the cancellation screen (`KKSV006426SC`), specifically the `EKK0341B002CBSMsg1List` which contains device info from rescinding operations. Also checked for `KKSV006411SC` data containing EZM0411B060CBSMsg1List child records for model code cross-referencing. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ido_div` | `String` | Displacement division category — the operation type discriminator. Values include `IDO_DIV_BANGO_TSUIKA` (Number Addition), `IDO_DIV_DENWA_HENKO` (Phone Number Change), or other values that trigger the default branch. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `X31SDataBeanAccessArray.getDataBeanArray` | KKW00147SF | In-memory DataBean (EKK0341B002DATA) | Retrieves the equipment provision service contract list — contains all customer premises equipment (VA devices) associated with the service. |
| R | `X31SDataBeanAccessArray.getDataBeanArray` | KKW00147SF | In-memory DataBean (EKK0191A010DATA) | Retrieves the service contract detail agreement for eo phone — contains the VA device change number and model info for pre-selection. |
| R | `X31SDataBeanAccess.getDataBean` | KKW00147SF | In-memory DataBean | Gets individual data bean from arrays for field extraction. |
| R | `X31SDataBeanAccess.sendMessageString` | KKW00147SF | In-memory DataBean | Reads string fields from data beans: device type code, model code, model name, serial number, change number, port count, service contract number, service code, etc. |
| EXEC | `X31SDataBeanAccess.sendMessage` | KKW00147SF | In-memory DataBean | Clears pulldown list items (`DATABEAN_CLEAR`) on the VA choice bean. |
| EXEC | `X31SDataBeanAccessArray.clearArray` | KKW00147SF | In-memory DataBean | Clears the temporary device pulldown list items. |
| C | `X31SDataBeanAccess.sendMessageString` | KKW00147SF | In-memory DataBean | Adds value entries to pulldown lists (`DATABEAN_ADD_VALUE`) — populates code list and display name list for VA model/serial combos. |
| C | `X31SDataBeanAccessArray.addDataBean` | KKW00147SF | In-memory DataBean | Adds a new device entry to the temporary pulldown array for intermediate storage. |
| EXEC | `X31SDataBeanAccess.sendMessageString` | KKW00147SF | In-memory DataBean | Sets individual device fields on the temporary bean: model code, serial number, change number, display name. |
| EXEC | `X31SDataBeanAccess.sendMessageString` | KKW00147SF | In-memory DataBean | Sets pre-change device info fields on `svcFormBean`: service contract number, model code, model name, serial number, change number. |
| EXEC | `X31SDataBeanAccess.sendMessageString` | KKW00147SF | In-memory DataBean | Sets fixed-value display fields: VA model code, model name, serial number. |
| EXEC | `X31SDataBeanAccess.sendMessageString` | KKW00147SF | In-memory DataBean | Sets the pulldown index (`INDEX_01`) for auto-selection pre-population. |
| - | `JCCWebCommon.setScreenInfo` | JCCWebCommon | Screen state (session) | Persists the model code to service code mapping (`kiki_svc_no`) to screen info for retention across requests. |
| - | `KKW00147SFLogic.isNull` | KKW00147SFLogic | — | Utility method to check if a string is null or empty. |
| R | `outputMap.get` | — | — | Reads cancellation screen data from `KKSV006426SC` and `KKSV006411SC` for device fallback resolution. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `KKW00147SFLogic.editServiceFormBean()` | `editServiceFormBean` -> `configureVAChoicePulldown(svcFormBean, outputMap)` | `setScreenInfo [-]` (screen state); `DATABEAN_SET_VALUE` x23 (form bean fields) |

**Caller Details:**
- `editServiceFormBean` is the parent method that orchestrates all post-SC-call form bean editing. It is called from `actionInitKKW00147()` during screen initialization. The `editServiceFormBean` method sets up the `ido_div` discriminator, calls `configureVAChoicePulldown`, and then continues with other pulldown configurations (e.g., `configureVAPortPulldown`).

**Terminal operations from this method:**
- `setScreenInfo` (JCCWebCommon) — persists model-to-service-code mapping
- `DATABEAN_SET_VALUE` x23 — sets various form bean fields including pre-change info, fixed-value display, and pulldown index
- `DATABEAN_ADD_VALUE` xN — adds pulldown entries (count varies by branch)

## 6. Per-Branch Detail Blocks

**Block 1** — [SET/INIT] (L1458)

> Initializes working data structures and variables.

| # | Type | Code |
|---|------|------|
| 1 | GET | `kk0341Arr = svcFormBean.getDataBeanArray(KKW00147SFConst.EKK0341B002DATA)` // Equipment provision service contract list |
| 2 | GET | `svcKeiUcwkTelBean = svcFormBean.getDataBeanArray(KKW00147SFConst.EKK0191A010DATA).getDataBean(0)` // Service contract detail for eo phone |
| 3 | SET | `vaMap = new HashMap<String, TreeMap<String, String[]>>()` // Groups VA devices by model code + change number |
| 4 | SET | `vaKktkSvcKeiNo = ""` // Equipment provision service contract number |
| 5 | SET | `vaModelCd = ""` // VA device model code |
| 6 | SET | `vaModelNm = ""` // VA device model name |
| 7 | SET | `vaSeizoNo = ""` // VA device serial number |
| 8 | SET | `vaKikiChgNo = ""` // VA device change number |
| 9 | SET | `kiki_svc_no = new HashMap<String, Object>()` // Model code to service code mapping |
| 10 | SET | `genkoVAFlag = false` // Flag indicating VA devices exist |
| 11 | SET | `index = 0` // VA pulldown initial index |
| 12 | SET | `vaCnt = 0` // VA device counter |

**Block 2** — [EXEC/CLEAR] (L1482)

> Clears existing pulldown data before repopulation.

| # | Type | Code |
|---|------|------|
| 1 | GET | `vaBean = svcFormBean.getDataBeanArray(KKW00147SFConst.VA_CHOICE).getDataBean(0)` // VA choice pulldown bean |
| 2 | EXEC | `vaBean.sendMessage(CD_DIV_LIST_01, DATABEAN_CLEAR)` // Clear code list |
| 3 | EXEC | `vaBean.sendMessage(CD_DIV_NM_LIST_01, DATABEAN_CLEAR)` // Clear display name list |
| 4 | GET | `kikiArray = svcFormBean.getDataBeanArray(KKW00147SFConst.KIKIPULLDOWN_LIST)` // Temporary device pulldown |
| 5 | EXEC | `kikiArray.clearArray()` // Clear temporary pulldown items |

---

### Block 3 — [IF] `IDO_DIV_BANGO_TSUIKA` (Number Addition) (L1488)

> Branch for adding a new phone number. Iterates equipment list, filters VA-compatible devices, groups them by model and change number, handles port count logic, and builds pulldown entries.

**Block 3.1** — [SET] Get vaKikiChgNo (L1491)

| # | Type | Code |
|---|------|------|
| 1 | GET | `vaKikiChgNo = svcKeiUcwkTelBean.sendMessageString(KKW00147SFConst.VA_KIKI_CHG_NO_06, DATABEAN_GET_VALUE)` // Change number from service contract detail |

**Block 3.2** — [FOR] Loop over kk0341Arr (L1493)

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0; i < kk0341Arr.getCount(); i++` |
| 2 | GET | `bean = kk0341Arr.getDataBean(i)` |
| 3 | GET | `kikiSbtCd = bean.sendMessageString(TAKNKIKI_SBT_CD_07, DATABEAN_GET_VALUE)` // Device type code |
| 4 | GET | `kikiModelCd = bean.sendMessageString(TAKNKIKI_MODEL_CD_07, DATABEAN_GET_VALUE)` // Model code |
| 5 | GET | `kikiModelNm = bean.sendMessageString(TAKNKIKI_MODEL_NM_07, DATABEAN_GET_VALUE)` // Model name |
| 6 | GET | `kikiSeizoNo = bean.sendMessageString(KIKI_SEIZO_NO_07, DATABEAN_GET_VALUE)` // Serial number |
| 7 | GET | `kikiChgNo = bean.sendMessageString(KIKI_CHG_NO_07, DATABEAN_GET_VALUE)` // Change number |
| 8 | GET | `ports = bean.sendMessageString(PORT_CNT_07, DATABEAN_GET_VALUE)` // Port count |
| 9 | GET | `seizoYmd = bean.sendMessageString(SEIZO_STAYMD_07, DATABEAN_GET_VALUE)` // Manufacturing stay date |
| 10 | GET | `kktkSvcKeiNo = bean.sendMessageString(KKTK_SVC_KEI_NO_07, DATABEAN_GET_VALUE)` // Service contract number |
| 11 | GET | `kktkSvcCd = bean.sendMessageString(KKTK_SVC_CD_07, DATABEAN_GET_VALUE)` // Service code |

**Block 3.2.1** — [IF] Equipment type filter: `KKTK_SBT_CD_VA="50"` OR `KKTK_SVC_CD_TKNRT="C024"` OR `KKTK_SVC_CD_HGW="C025"` (L1507)

> ANK-4315-00-00: Added HGW support. Original code only checked VA or TKNRT. Now also includes HGW (eo Home Gateway).

| # | Type | Code |
|---|------|------|
| 1 | IF | `KKTK_SBT_CD_VA="50".equals(kikiSbtCd) || KKTK_SVC_CD_TKNRT="C024".equals(kktkSvcCd) || KKTK_SVC_CD_HGW="C025".equals(kktkSvcCd)` // Device is VA type, eo multi-function router, or home gateway |

**Block 3.2.1.1** — [IF] Change number match: `kikiChgNo.equals(vaKikiChgNo)` (L1514)

> If the device change number matches the current VA device's change number, capture its service contract info.

| # | Type | Code |
|---|------|------|
| 1 | SET | `vaKktkSvcKeiNo = kktkSvcKeiNo` // Capture service contract number |
| 2 | SET | `vaModelCd = kikiModelCd` // Capture model code |
| 3 | SET | `vaModelNm = kikiModelNm` // Capture model name |
| 4 | SET | `vaSeizoNo = kikiSeizoNo` // Capture serial number |

**Block 3.2.1.2** — [IF] Port count check: `2 <= Integer.parseInt(ports)` OR TKNRT OR HGW (L1525)

> ANK-4315-00-00: Added HGW condition. Original only checked ports >= 2 or TKNRT.

| # | Type | Code |
|---|------|------|
| 1 | IF | `2 <= Integer.parseInt(ports) || KKTK_SVC_CD_TKNRT="C024".equals(kktkSvcCd) || KKTK_SVC_CD_HGW="C025".equals(kktkSvcCd)` // 2+ ports or TKNRT or HGW type |

**Block 3.2.1.2.1** — [IF-ELSE-IF] Default model name for TKNRT and HGW (L1531)

> If the model code is null or empty, set a default model name.

| # | Type | Code |
|---|------|------|
| 1 | IF | `KKTK_SVC_CD_TKNRT="C024".equals(kktkSvcCd)` // eo multi-function router |
| 2 | IF | `kikiModelCd == null || "".equals(kikiModelCd)` |
| 3 | SET | `kikiModelNm = TKNRT_TAKNKIKI_MODEL_NM = "eo multi-function router"` // Default model name for TKNRT |
| 4 | ELSE-IF | `KKTK_SVC_CD_HGW="C025".equals(kktkSvcCd)` // Home gateway |
| 5 | IF | `kikiModelCd == null || "".equals(kikiModelCd)` |
| 6 | SET | `kikiModelNm = HGW_TAKNKIKI_MODEL_NM = "eo Home Gateway"` // Default model name for HGW |

**Block 3.2.1.2.2** — [SET] Build vaMap entry (L1544)

| # | Type | Code |
|---|------|------|
| 1 | GET | `tm = vaMap.get(kikiModelCd + KIKI_SEP=":" + kikiChgNo)` |
| 2 | IF | `tm == null` |
| 3 | SET | `tm = new TreeMap<String, String[]>()` |
| 4 | SET | `tm.put(seizoYmd, new String[]{kikiModelNm, kikiSeizoNo})` // Map manufacturing date to [model name, serial number] |
| 5 | SET | `vaMap.put(kikiModelCd + KIKI_SEP + kikiChgNo, tm)` // Store in outer map |
| 6 | SET | `kiki_svc_no.put(kikiModelCd, kktkSvcCd)` // Store model to service code mapping |
| 7 | SET | `genkoVAFlag = true` // Mark VA devices exist |

**Block 3.3** — [IF] Fallback when no VA devices found: `vaMap.size() <= 0` (L1561)

> If no matching VA devices were found in the loop, set the default model to eo multi-function router (TKNRT).

| # | Type | Code |
|---|------|------|
| 1 | IF | `vaMap.size() <= 0` |
| 2 | SET | `vaModelCd = TKNRT_TAKNKIKI_MODEL_CD = ""` // Fallback model code |
| 3 | SET | `vaModelNm = TKNRT_TAKNKIKI_MODEL_NM = "eo multi-function router"` // Fallback model name |
| 4 | SET | `tm = new TreeMap<String, String[]>()` |
| 5 | SET | `tm.put("", new String[]{vaModelNm, ""})` // Empty key entry |
| 6 | SET | `vaMap.put(vaModelCd + KIKI_SEP, tm)` |

**Block 3.4** — [SET] Get service contract detail number (L1574)

| # | Type | Code |
|---|------|------|
| 1 | GET | `svcKeiUcwkNo = svcFormBean.sendMessageString(KKW00147SFConst.SVC_KEI_UCWK_NO, DATABEAN_GET_VALUE)` |

**Block 3.5** — [IF] Set model code from bean if svcKeiUcwkNo not null (L1592)

> When a service contract detail number exists, override the model code from the bean.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!isNull(svcKeiUcwkNo)` |
| 2 | GET | `vaModelCd = svcKeiUcwkTelBean.sendMessageString(KKW00147SFConst.VA_TAKNKIKI_MODEL_CD_06, DATABEAN_GET_VALUE)` |

**Block 3.6** — [SET] Null-safe defaults (L1595)

| # | Type | Code |
|---|------|------|
| 1 | SET | `if (vaModelCd == null) { vaModelCd = "" }` |
| 2 | SET | `if (vaKikiChgNo == null) { vaKikiChgNo = "" }` |

**Block 3.7** — [FOR] Iterate vaMap to build pulldown entries (L1599)

| # | Type | Code |
|---|------|------|
| 1 | SET | `kikiInfo = kikiModelCd_kikiChgNo.split(KIKI_SEP=":")` |
| 2 | SET | `kikiModelCd = "", kikiModelNm = "", kikiSeizoNo = "", kikiChgNo = ""` |
| 3 | IF | `kikiInfo.length > 0` |
| 4 | SET | `kikiModelCd = kikiInfo[0]` // Split key to get model code |
| 5 | IF | `kikiInfo.length > 1` |
| 6 | SET | `kikiChgNo = kikiInfo[1]` // Split key to get change number |
| 7 | IF | `(kikiModelCd + ":" + kikiChgNo).equals(vaModelCd + ":" + vaKikiChgNo)` // Self-owned device match |
| 8 | SET | `index = vaCnt` // Mark as pre-selected |
| 9 | GET | `tm = vaMap.get(kikiModelCd_kikiChgNo)` |
| 10 | GET | `seizoYmd = tm.lastKey()` |
| 11 | GET | `kikiInfo2 = tm.get(seizoYmd)` |
| 12 | SET | `kikiModelNm = kikiInfo2[0]` |
| 13 | SET | `kikiSeizoNo = kikiInfo2[1]` |
| 14 | SET | `cdDiv = kikiModelCd + ":" + kikiChgNo` // Pulldown code value |
| 15 | SET | `cdDivNm = kikiModelCd + " " + kikiModelNm + " " + kikiSeizoNo` // Display text |
| 16 | EXEC | `vaBean.sendMessageString(CD_DIV_LIST_01, DATABEAN_ADD_VALUE, cdDiv)` |
| 17 | EXEC | `vaBean.sendMessageString(CD_DIV_NM_LIST_01, DATABEAN_ADD_VALUE, cdDivNm)` |
| 18 | C | `kikiBean = kikiArray.addDataBean()` // Add temporary device entry |
| 19 | EXEC | `kikiBean.sendMessageString(VA_TAKNKIKI_MODEL_CD_27, DATABEAN_SET_VALUE, kikiModelCd)` |
| 20 | EXEC | `kikiBean.sendMessageString(VA_KIKI_SEIZO_NO_27, DATABEAN_SET_VALUE, kikiSeizoNo)` |
| 21 | EXEC | `kikiBean.sendMessageString(VA_KIKI_CHG_NO_27, DATABEAN_SET_VALUE, kikiChgNo)` |
| 22 | EXEC | `kikiBean.sendMessageString(DISP_NAME_27, DATABEAN_SET_VALUE, cdDivNm)` |
| 23 | SET | `vaCnt++` |

---

### Block 4 — [ELSE-IF] `IDO_DIV_DENWA_HENKO` (Phone Number Change) (L1675)

> Branch for changing an existing phone number. Only includes devices whose change number matches the current VA device.

**Block 4.1** — [SET] Get vaKikiChgNo (L1679)

| # | Type | Code |
|---|------|------|
| 1 | GET | `vaKikiChgNo = svcKeiUcwkTelBean.sendMessageString(KKW00147SFConst.VA_KIKI_CHG_NO_06, DATABEAN_GET_VALUE)` |

**Block 4.2** — [FOR] Loop over kk0341Arr (L1681)

> Similar extraction to Block 3.2 but with different downstream logic.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0; i < kk0341Arr.getCount(); i++` |
| 2 | GET | `bean = kk0341Arr.getDataBean(i)` |
| 3 | GET | `kikiSbtCd`, `kikiModelCd`, `kikiModelNm`, `kikiSeizoNo`, `kikiChgNo`, `kktkSvcKeiNo`, `kktkSvcCd` from bean |

**Block 4.2.1** — [IF-ELSE-IF] Default model names for TKNRT and HGW (L1696)

> Same default model name logic as Block 3.2.1.2.1.

**Block 4.2.2** — [IF] Equipment type filter + Change number match (L1712)

> ANK-4315-00-00: Added HGW. OM-2013-0002939: Changed logic to only include matching devices (previously included all devices, now only chgNo-matching ones).

| # | Type | Code |
|---|------|------|
| 1 | IF | `KKTK_SBT_CD_VA="50".equals(kikiSbtCd) || KKTK_SVC_CD_TKNRT="C024".equals(kktkSvcCd) || KKTK_SVC_CD_HGW="C025".equals(kktkSvcCd)` |
| 2 | IF | `kikiChgNo.equals(vaKikiChgNo)` // Only include if change number matches |
| 3 | SET | `vaKktkSvcKeiNo = kktkSvcKeiNo` |
| 4 | SET | `vaModelCd = kikiModelCd` |
| 5 | SET | `vaModelNm = kikiModelNm` |
| 6 | SET | `vaSeizoNo = kikiSeizoNo` |
| 7 | SET | `index = vaCnt` // Auto-select matched device |
| 8 | SET | `cdDiv = kikiModelCd + ":" + kikiChgNo` |
| 9 | SET | `cdDivNm = kikiModelCd + " " + kikiModelNm + " " + kikiSeizoNo` |
| 10 | EXEC | `vaBean.sendMessageString(CD_DIV_LIST_01, DATABEAN_ADD_VALUE, cdDiv)` |
| 11 | EXEC | `vaBean.sendMessageString(CD_DIV_NM_LIST_01, DATABEAN_ADD_VALUE, cdDivNm)` |
| 12 | C | `kikiBean = kikiArray.addDataBean()` |
| 13 | EXEC | Set modelCd, kikiSeizoNo, kikiChgNo, cdDivNm on kikiBean |
| 14 | SET | `vaCnt++` |

---

### Block 5 — [ELSE] Other (default) (L1759)

> Default branch for all other scenarios (initial display, number cancellation, port-out). Loops to find a matching device, falls back to rescanning cancellation screen data.

**Block 5.1** — [SET] Get vaKikiChgNo (L1763)

| # | Type | Code |
|---|------|------|
| 1 | GET | `vaKikiChgNo = svcKeiUcwkTelBean.sendMessageString(KKW00147SFConst.VA_KIKI_CHG_NO_06, DATABEAN_GET_VALUE)` |

**Block 5.2** — [FOR] Loop over kk0341Arr (L1765)

> Same extraction pattern, but only captures the first match.

**Block 5.2.1** — [IF] Equipment type filter (L1781)

> Same VA/TKNRT/HGW filter as previous branches.

**Block 5.2.2** — [IF] Change number match + break (L1794)

> First matching device wins; sets va fields and breaks out of loop.

| # | Type | Code |
|---|------|------|
| 1 | IF | `kikiChgNo.equals(vaKikiChgNo)` |
| 2 | SET | `vaKktkSvcKeiNo = kktkSvcKeiNo` |
| 3 | SET | `vaModelCd = kikiModelCd` |
| 4 | SET | `vaModelNm = kikiModelNm` |
| 5 | SET | `vaSeizoNo = kikiSeizoNo` |
| 6 | SET | `index = 0` |
| 7 | BREAK | Loop exits |

**Block 5.3** — [IF] Secondary rescans via outputMap (IK1-2013-0000147) (L1805)

> If no matching equipment provision service contract was found during the loop, rescans cancellation screen data from `KKSV006426SC` and `KKSV006411SC`.

| # | Type | Code |
|---|------|------|
| 1 | IF | `StringUtils.isEmpty(vaKktkSvcKeiNo)` |
| 2 | GET | `kksv006426scMap = outputMap.get("KKSV006426SC")` |
| 3 | IF | `kksv006426scMap != null` |
| 4 | GET | `childList = kksv006426scMap.get("EKK0341B002CBSMsg1List")` |
| 5 | IF | `childList != null` |

**Block 5.3.1** — [IF] Check for KKSV006411SC data (L1820)

> Optional: cross-reference with KKSV006411SC data for model code matching.

| # | Type | Code |
|---|------|------|
| 1 | IF | `outputMap.containsKey("KKSV006411SC")` |
| 2 | GET | `kKSV006411SCMap = outputMap.get("KKSV006411SC")` |
| 3 | IF | `kKSV006411SCMap != null && kKSV006411SCMap.size() > 0` |
| 4 | GET | `kKSV006411SCchildList = kKSV006411SCMap.get("EZM0411B060CBSMsg1List")` |

**Block 5.3.2** — [FOR] Inner loop over childList (L1830)

> For each device from the cancellation screen, cross-reference with KKSV006411SC child data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kKSV006425SCFlg = false` |
| 2 | FOR | Loop over `kKSV006411SCchildList` |
| 3 | GET | `kKSV006411SCchildMap = kKSV006411SCchildList.get(j)` |
| 4 | IF | `kKSV006411SCchildMap.get("taknkiki_model_cd").equals(childMap.get("taknkiki_model_cd"))` // Model code match |
| 5 | SET | `kKSV006425SCFlg = true` |
| 6 | SET | `taknkiki_sbt_cd = kKSV006411SCchildMap.get("takkiki_sbt_cd")` |
| 7 | BREAK | |

**Block 5.3.3** — [SET] Extract device info from childMap (L1843)

| # | Type | Code |
|---|------|------|
| 1 | SET | `kikiSbtCd = kKSV006425SCFlg ? taknkiki_sbt_cd : new String()` |
| 2 | SET | `kikiModelCd = childMap.get("taknkiki_model_cd")` |
| 3 | SET | `kikiModelNm = childMap.get("taknkiki_model_cd_nm")` |
| 4 | SET | `kikiSeizoNo = childMap.get("kiki_seizo_no")` |
| 5 | SET | `kikiChgNo = childMap.get("kiki_chg_no")` |
| 6 | SET | `kktkSvcKeiNo = childMap.get("kktk_svc_kei_no")` |
| 7 | SET | `kktkSvcCd = childMap.get("kktk_svc_cd")` |

**Block 5.3.4** — [IF] Equipment type filter on rescanned device (L1856)

> Same VA/TKNRT/HGW check on the rescanned device data.

**Block 5.3.5** — [IF-ELSE-IF] Default model name for TKNRT/HGW (L1862)

> Same default model name logic as other branches.

**Block 5.3.6** — [IF] Change number match on rescanned device (L1880)

| # | Type | Code |
|---|------|------|
| 1 | IF | `kikiChgNo.equals(vaKikiChgNo)` |
| 2 | SET | `vaKktkSvcKeiNo = kktkSvcKeiNo` |
| 3 | SET | `vaModelCd = kikiModelCd` |
| 4 | SET | `vaModelNm = kikiModelNm` |
| 5 | SET | `vaSeizoNo = kikiSeizoNo` |
| 6 | SET | `index = 0` |
| 7 | BREAK | |

**Block 5.4** — [SET] Build single pulldown entry (L1905)

> After whichever path resolved, build one pulldown entry from the `va*` fields.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cdDiv = vaModelCd + ":" + vaKikiChgNo` |
| 2 | SET | `cdDivNm = vaModelCd + " " + vaModelNm + " " + vaSeizoNo` |
| 3 | EXEC | `vaBean.sendMessageString(CD_DIV_LIST_01, DATABEAN_ADD_VALUE, cdDiv)` |
| 4 | EXEC | `vaBean.sendMessageString(CD_DIV_NM_LIST_01, DATABEAN_ADD_VALUE, cdDivNm)` |
| 5 | C | `kikiBean = kikiArray.addDataBean()` |
| 6 | EXEC | `kikiBean.sendMessageString(VA_TAKNKIKI_MODEL_CD_27, DATABEAN_SET_VALUE, vaModelCd)` |
| 7 | EXEC | `kikiBean.sendMessageString(VA_KIKI_SEIZO_NO_27, DATABEAN_SET_VALUE, vaSeizoNo)` |
| 8 | EXEC | `kikiBean.sendMessageString(VA_KIKI_CHG_NO_27, DATABEAN_SET_VALUE, vaKikiChgNo)` |
| 9 | EXEC | `kikiBean.sendMessageString(DISP_NAME_27, DATABEAN_SET_VALUE, cdDivNm)` |

**Block 5.5** — [SET] Store empty service code (L1914)

| # | Type | Code |
|---|------|------|
| 1 | SET | `kiki_svc_no.put(vaModelCd, "")` |

---

### Block 6 — [SET] Final field population (L1920)

> Sets all pre-change and fixed-value display fields regardless of which branch was taken.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `svcFormBean.sendMessageString(CHBF_KKTK_SVC_KEI_NO, DATABEAN_SET_VALUE, vaKktkSvcKeiNo)` // Pre-change service contract number |
| 2 | EXEC | `svcFormBean.sendMessageString(VA_MODEL_CD_BEFORE, DATABEAN_SET_VALUE, vaModelCd)` // Pre-change model code |
| 3 | EXEC | `svcFormBean.sendMessageString(VA_MODEL_NM_BEFORE, DATABEAN_SET_VALUE, vaModelNm)` // Pre-change model name |
| 4 | EXEC | `svcFormBean.sendMessageString(VA_SEIZO_NO_BEFORE, DATABEAN_SET_VALUE, vaSeizoNo)` // Pre-change serial number |
| 5 | EXEC | `svcFormBean.sendMessageString(VA_KIKI_CHG_NO_BEFORE, DATABEAN_SET_VALUE, vaKikiChgNo)` // Pre-change change number |
| 6 | EXEC | `svcFormBean.sendMessageString(INDEX_01, DATABEAN_SET_VALUE, String.valueOf(index))` // Pulldown index for pre-selection |
| 7 | EXEC | `svcFormBean.sendMessageString(VA_MODEL_CD, DATABEAN_SET_VALUE, vaModelCd)` // Fixed display: model code |
| 8 | EXEC | `svcFormBean.sendMessageString(VA_MODEL_NM, DATABEAN_SET_VALUE, vaModelNm)` // Fixed display: model name |
| 9 | EXEC | `svcFormBean.sendMessageString(VA_SEIZO_NO, DATABEAN_SET_VALUE, vaSeizoNo)` // Fixed display: serial number |
| 10 | EXEC | `JCCWebCommon.setScreenInfo(this, KKW00147_KKTK_SVC_NO_LIST, kiki_svc_no)` // Persist model-to-service-code mapping |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ido_div` | Field | Displacement division category — operation type discriminator that routes processing to the correct branch |
| `VA` | Acronym | Virtual Access / 家庭機器 (customer premises equipment) — end-user devices at the subscriber's location |
| `VA_CHOICE` | Field | VA selection — the pulldown bean key for VA device selection on the screen |
| `KKTK_SBT_CD_VA = "50"` | Constant | Equipment type code for eo phone VA (eo 電話用VA) |
| `KKTK_SVC_CD_TKNRT = "C024"` | Constant | Equipment provision service code for eo multi-function router (eo 光多機能ルーター) |
| `KKTK_SVC_CD_HGW = "C025"` | Constant | Equipment provision service code for eo home gateway (eo ホームゲートウェイ) — added in ANK-4315-00-00 |
| `TKNRT_TAKNKIKI_MODEL_NM = "eo 光多機能ルーター"` | Constant | Default model name for eo multi-function router |
| `HGW_TAKNKIKI_MODEL_NM = "eo ホームゲートウェイ"` | Constant | Default model name for eo home gateway |
| `KIKI_SEP = ":"` | Constant | Separator character used to join model code and change number in composite keys |
| `CD_SEP = "."` | Constant | Separator character used in code lists |
| `EKK0341B002DATA` | Field | Equipment provision service contract list — data bean holding all customer premises equipment records |
| `EKK0191A010DATA` | Field | Service contract detail agreement for eo phone — data bean for the eo Hikari Denwa service contract |
| `KKIPULLDOWN_LIST` | Field | Temporary device pulldown list — intermediate storage for device data |
| `kk0341Arr` | Variable | Equipment provision service contract array extracted from the form bean |
| `svcKeiUcwkTelBean` | Variable | Service contract detail bean specifically for eo phone — contains VA change number and model code |
| `vaMap` | Variable | HashMap grouping VA devices by model code + change number key, with inner TreeMap mapping manufacturing dates to [model name, serial number] |
| `kiki_svc_no` | Variable | HashMap mapping model code to service code for screen info persistence |
| `genkoVAFlag` | Variable | Flag indicating that at least one VA-compatible device was found |
| `CD_DIV_LIST_01` | Field | Code value list for pulldown — stores the composite code (e.g., "modelCd:chgNo") |
| `CD_DIV_NM_LIST_01` | Field | Display name list for pulldown — stores the human-readable text (e.g., "modelCd modelNm kikiSeizoNo") |
| `CHBF_KKTK_SVC_KEI_NO` | Field | Pre-change equipment provision service contract number — audit trail field |
| `VA_MODEL_CD_BEFORE` | Field | Pre-change VA model code |
| `VA_MODEL_NM_BEFORE` | Field | Pre-change VA model name |
| `VA_SEIZO_NO_BEFORE` | Field | Pre-change VA serial number |
| `VA_KIKI_CHG_NO_BEFORE` | Field | Pre-change VA device change number |
| `INDEX_01` | Field | Pulldown pre-selection index |
| `VA_MODEL_CD` | Field | Fixed display: VA model code |
| `VA_MODEL_NM` | Field | Fixed display: VA model name |
| `VA_SEIZO_NO` | Field | Fixed display: VA serial number |
| `VA_KIKI_CHG_NO_06` | Field | VA device change number from service contract detail bean (suffix 06) |
| `VA_TAKNKIKI_MODEL_CD_06` | Field | VA device model code from service contract detail bean (suffix 06) |
| `TAKNKIKI_SBT_CD_07` | Field | Customer premises equipment type code from equipment list (suffix 07) |
| `TAKNKIKI_MODEL_CD_07` | Field | Customer premises equipment model code from equipment list (suffix 07) |
| `TAKNKIKI_MODEL_NM_07` | Field | Customer premises equipment model name from equipment list (suffix 07) |
| `KIKI_SEIZO_NO_07` | Field | Customer premises equipment serial number from equipment list (suffix 07) |
| `KIKI_CHG_NO_07` | Field | Customer premises equipment change number from equipment list (suffix 07) |
| `PORT_CNT_07` | Field | Number of LAN ports on the equipment (suffix 07) |
| `SEIZO_STAYMD_07` | Field | Equipment manufacturing/stay date (suffix 07) |
| `KKTK_SVC_KEI_NO_07` | Field | Equipment provision service contract number from equipment list (suffix 07) |
| `KKTK_SVC_CD_07` | Field | Equipment provision service code from equipment list (suffix 07) |
| `VA_TAKNKIKI_MODEL_CD_27` | Field | VA device model code field on temporary bean (suffix 27) |
| `VA_KIKI_SEIZO_NO_27` | Field | VA device serial number field on temporary bean (suffix 27) |
| `VA_KIKI_CHG_NO_27` | Field | VA device change number field on temporary bean (suffix 27) |
| `DISP_NAME_27` | Field | Display name field on temporary bean (suffix 27) |
| `SVC_KEI_UCWK_NO` | Field | Service contract detail number |
| `EKK0341B002CBSMsg1List` | Field | Child data list from KKSV006426SC output — contains device information from cancellation screen |
| `EZM0411B060CBSMsg1List` | Field | Child data list from KKSV006411SC output — contains equipment details for model code cross-reference |
| `KKSV006426SC` | Field | Screen output key for cancellation screen SC results |
| `KKSV006411SC` | Field | Screen output key for equipment detail screen SC results |
| `KKW00147_KKTK_SVC_NO_LIST` | Field | Screen info key for persisting equipment provision service contract number list |
| eo Hikari Denwa | Business term | eo Fiber-Optic Phone service — K-Opticom's VoIP/phone service over fiber network |
| eo multi-function router (TKNRT) | Business term | eo 光多機能ルーター — K-Opticom's multi-function router device for eo Hikari Denwa subscribers |
| eo Home Gateway (HGW) | Business term | eo ホームゲートウェイ — K-Opticom's home gateway device, added in ANK-4315-00-00 |
| Number Addition (番号追加) | Business term | Process of adding a new phone number to an existing service |
| Phone Number Change (電話番号情報変更) | Business term | Process of changing an existing phone number while retaining the service |
| DATABEAN_CLEAR | Constant | Message constant to clear all items from a data bean list |
| DATABEAN_ADD_VALUE | Constant | Message constant to append a value to a data bean list |
| DATABEAN_SET_VALUE | Constant | Message constant to set a single value in a data bean field |
| DATABEAN_GET_VALUE | Constant | Message constant to retrieve a single value from a data bean field |
| JCCWebCommon.setScreenInfo | Method | Utility method to persist screen state data (e.g., model-to-service-code mapping) to session for retention across requests |
