# Business Logic — JKKHakkoSODCC.htelNoInfoChgeOdrCtrl() [544 LOC]

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

## 1. Role

### JKKHakkoSODCC.htelNoInfoChgeOdrCtrl()

This method implements the **Optical Phone Number Information Change Order Control** process (light telephone number information change order control processing). It is the central orchestrator that determines which Service Order Data (SOD) orders must be generated when a customer's phone number information is changed. The method handles a single service contract (`svc_kei_no`) and evaluates multiple dimensions of change — VA (Virtual Apartment) model/model change number, port number, emergency notification details, and option service settings — to produce the appropriate set of SOD orders.

The method processes **five distinct SOD order types** based on detected changes: (1) OLS (optical line system) setting/registration when a VA device is detected but not yet ordered, (2) OLS setting with VA model change, (3) OLS setting with port number change, (4) option service settings update, and (5) emergency notification detail changes. For multi-function routers (Takino routers), it additionally generates SOD orders for router setting/registration and router setting/changes depending on the number of linked lines.

The method uses a **routing/dispatch design pattern**: it first performs pre-checks (Z1 order check, device manufacturing number check), then fetches pre/post-change agreement data and device lists through service component calls, iterates over device records to detect changes, and dispatches to the appropriate `addSOD` or `addTakinoSOD` method based on the detected condition. It is a **shared utility** called by the broader `hakkoSOD()` entry point method, meaning any screen triggering an order dispatch will flow through this control logic.

The method also handles the **EG (Ethernet Gateway) switching scenario**: when a VLAN is taken after EG replacement and the work is not yet complete, it substitutes the device list with data from a specialized query to ensure correct SOD generation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["htelNoInfoChgeOdrCtrl"])
    
    START --> INIT["Initialize Maps from sodMap"]
    INIT --> EXTRACT["Extract: svc_kei_no, svc_kei_ucwk_no, change timestamps"]
    
    EXTRACT --> Z1_CHECK["isExecuteZ1OrderCheck"]
    Z1_CHECK --> Z1_HAS_CHECK{"Check needed?"}
    Z1_HAS_CHECK -- true --> Z1_ORDERED{"isZ1Ordered?"}
    Z1_ORDERED -- true (already ordered) --> KIKI_CHECK["Continue"]
    Z1_ORDERED -- false (not ordered) --> Z1_RETURN["Log + return param (skip)"]
    Z1_HAS_CHECK -- false --> KIKI_CHECK
    
    KIKI_CHECK --> KIKI_EXEC["isExecuteKikiSeizoNoCheck"]
    KIKI_EXEC --> KIKI_NEEDS{"Check needed?"}
    KIKI_NEEDS -- true --> KIKI_DO["Run KikiSeizoNoCheck"]
    KIKI_NEEDS -- false --> PRE_CHANGE["Continue"]
    KIKI_DO --> PRE_CHANGE
    
    PRE_CHANGE --> CALL_PRE["callEKK0191A010SC - Pre-change agreement"]
    CALL_PRE --> EXTRACT_PRE["Extract: modelCd, kikiChgNo, portNo, emg fields"]
    EXTRACT_PRE --> CALL_POST["callEKK0191A010SC - Post-change agreement"]
    CALL_POST --> EXTRACT_POST["Extract same fields for post-change"]
    
    EXTRACT_POST --> CALL_VLAN["getEKK0251B001SC - Service line details"]
    CALL_VLAN --> CALL_DEV["callEKK0341B008SC - Device provision"]
    CALL_DEV --> CALL_DEV2["callEKK0341B008_02SC - EG switching"]
    CALL_DEV2 --> CALL_AGREEMENT["callEKK0191B001SC - Service agreement detail"]
    
    CALL_AGREEMENT --> TAKINO["checkTakinoRT"]
    TAKINO --> TAKINO_CHECK{"takino_flg"}
    
    TAKINO_CHECK -- 0 --> LOOP_START["For each device in msgEKK0341B008SCList"]
    TAKINO_CHECK -- 2,4,9 --> TAKINO_ROUTER_SOD["Takino Router SOD logic"]
    
    LOOP_START --> DEVICE_LOOP{"Device?"}
    DEVICE_LOOP -- VA --> VA_CHECK{"VA model/chg changed?"}
    VA_CHECK -- yes --> OLS_CHECK{"OLS already ordered?"}
    OLS_CHECK -- no --> SOD_207["addSOD ODR_NAIYO_CD_207 OLS Set/Reg"]
    OLS_CHECK -- yes --> SOD_256["addSOD ODR_NAIYO_CD_256 OLS Set/VA Change"]
    VA_CHECK -- no --> PORT_CHECK{"Port changed?"}
    PORT_CHECK -- yes --> SOD_255["addSOD ODR_NAIYO_CD_255 OLS Set/Port Change"]
    PORT_CHECK -- no --> LOOP_NEXT["Next device"]
    
    SOD_207 --> LOOP_NEXT
    SOD_256 --> LOOP_NEXT
    SOD_255 --> LOOP_NEXT
    LOOP_NEXT --> DEVICE_LOOP
    
    DEVICE_LOOP -- done --> FINAL_SAME_TRN["getSame_trn_no"]
    
    FINAL_SAME_TRN --> OP_CHECK{"chaf_opsvkei_no not blank?"}
    OP_CHECK -- yes --> OP_SET["opSetOdrCtrl - Option settings"]
    OP_CHECK -- no --> EMG_CHECK["Continue"]
    OP_SET --> EMG_CHECK
    
    EMG_CHECK --> EMG_COMPARE{"Emergency fields changed?"}
    EMG_COMPARE -- yes --> SOD_251["addSOD ODR_NAIYO_CD_251 Emergency Change"]
    EMG_COMPARE -- no --> RETURN
    
    SOD_251 --> RETURN["return param"]
    TAKINO_ROUTER_SOD --> RETURN
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session handle carrying session manager context; used to propagate session state across all service component calls (EKK database queries, business logic execution) |
| 2 | `param` | `IRequestParameterReadWrite` | Parameter object containing the model group and control map; accumulates SOD orders through method calls (returned with updated orders appended); acts as the request/response carrier for screen-level operations |
| 3 | `fixedText` | `String` | User-defined arbitrary string; passed through to downstream methods (e.g., `opSetOdrCtrl`) for logging, traceability, or business-rule text attachment |
| 4 | `sodMap` | `HashMap<String, Object>` | Service Order Data map — the central data container holding nested sub-maps for service contract info (`SVC_KEI_INFO`), service contract detail info (`SVC_KEI_UCWK_INFO`), and option service contract info (`OPSVKEI_INFO`); all change detection derives data from these sub-maps |

**Instance fields read/written:**

| Field | Usage |
|-------|-------|
| `svc_kei_ucwk_no` | Set to post-change service contract detail number (returned for downstream use) |
| `svc_kei_ucwk_gadtm` | Set to post-change service contract detail registration timestamp |
| `kktk_svc_kei_no` | Set to device provision service contract number (per-loop) |
| `kktk_svc_kei_gadtm` | Set to device provision service contract registration timestamp (per-loop) |
| `taknkiki_model_cd` | Set to VA home device model code (per-loop) |
| `kiki_seizo_no` | Set to device manufacturing number (per-loop) |
| `same_trn_no` | Set to same processing number retrieved via `getSame_trn_no` |
| `ido_div` | Read (instance field) — difference division code used in VA comparison logic |
| `kiki_seizo_no_takino` | Read (instance field) — Takino router device manufacturing number, read elsewhere |
| `kkop_svc_kei_no` | Read (instance field) — KKOP service contract number, read elsewhere |
| `taknkiki_model_cd_takino` | Read (instance field) — Takino router model code, read elsewhere |
| `takino_kktk_svc_kei_no` | Read (instance field) — Takino device provision service contract number |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callEKK0191A010SC` | EKK0191A010SC | KK_T_SVC_KEI_UCWK (Pre-change service agreement detail for optical telephone) | Fetches pre-change service agreement detail data including VA model code, device change number, port number, and emergency notification address fields |
| R | `callEKK0191A010SC` | EKK0191A010SC | KK_T_SVC_KEI_UCWK (Post-change service agreement detail for optical telephone) | Fetches post-change service agreement detail data — same fields as pre-change but for the new service contract line |
| R | `getEKK0251B001SC` | EKK0251B001SC | KK_T_SVC_KEI_KAISEN_UCWK (Service line detail) | Retrieves service line details including line detail number and registration timestamp for the given service contract number |
| R | `callEKK0341B008SC` | EKK0341B008SC | KK_T_KKTK_SVC_KEI (Device provision service contract) | Queries device provision records (VA, ONU, router, etc.) linked to the service contract; returns CAANMsg array for iteration |
| R | `callEKK0341B008_02SC` | EKK0341B008_02SC | KK_T_KKTK_SVC_KEI (EG switching device records) | Specialized device query for EG switching scenario; returns records for change-over VA detection |
| R | `callEKK0191B001SC` | EKK0191B001SC | KK_T_SVC_KEI_UCWK (Service agreement detail for optical telephone) | Lists service agreement details with status flags; used for Takino router SOD count logic |
| C | `addSOD` | JKKHakkoSODCC | KK_T_ODR_HAKKO (Order issuance table) | Creates a new SOD order with the specified order content code (207, 251, 255, or 256) |
| C | `addSOD` | JKKHakkoSODCC | KK_T_ODR_HAKKO (Order issuance table) | Creates OLS setting/registration order (ODR_NAIYO_CD_207 = "207") when VA device detected but not yet ordered |
| C | `addSOD` | JKKHakkoSODCC | KK_T_ODR_HAKKO (Order issuance table) | Creates OLS setting/VA change order (ODR_NAIYO_CD_256 = "256") when VA model or change number differs |
| C | `addSOD` | JKKHakkoSODCC | KK_T_ODR_HAKKO (Order issuance table) | Creates OLS setting/port change order (ODR_NAIYO_CD_255 = "255") when port number differs |
| C | `addSOD` | JKKHakkoSODCC | KK_T_ODR_HAKKO (Order issuance table) | Creates emergency notification change order (ODR_NAIYO_CD_251 = "251") when any emergency field changed |
| C | `addTakinoSOD` | JKKHakkoSODCC | KK_T_ODR_HAKKO (Order issuance table) | Creates Takino router setting/registration order (ODR_NAIYO_CD_406 = "406") or setting/change orders (415, 416, 407) |
| R | `findOlsOrderAtKK1041` | JKKHakkoSODCC | KK_T_KK1041 (OLS order table) | Queries whether a specific OLS order already exists for the given device model code and manufacturing number |
| R | `findZ1OrderHasBeenSentSvcKeiUcwk` | JKKHakkoSODCC | - | Checks if a Z1 order has already been issued for the service contract |
| R | `getSame_trn_no` | JKKHakkoSODCC | - | Retrieves the same processing number for duplicate-order detection |
| - | `checkTakinoRT` | JKKHakkoSODCC | - | Checks whether the customer has a multi-function (Takino) router installed; returns flag: 0=no, 2/4/9=has router |
| - | `isExecuteZ1OrderCheck` | JKKHakkoSODCC | - | Determines if Z1 order pre-check is required for this transaction |
| - | `isExecuteKikiSeizoNoCheck` | JKKHakkoSODCC | - | Determines if device manufacturing number check is required |
| - | `isKikiSeizoNoCheck` | JKKHakkoSODCC | - | Performs the actual device manufacturing number validation |
| - | `isRegalVaKiki` | JKKHakkoSODCC | - | Determines whether a device record qualifies as a valid VA (Virtual Apartment) device for SOD generation |
| - | `isBlank` | JKKHakkoSODCC | - | Utility method checking if a string is null or blank |
| - | `shkkaMap` | JKKHakkoSODCC | - | Utility method to clone/copy a HashMap |
| - | `shkkaChr` | JKKHakkoSODCC | - | Utility method to safely extract a character string with null/blank handling |
| - | `opSetOdrCtrl` | JKKHakkoSODCC | - | Controls option service settings order processing (when option service contract number exists) |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKHakkoSODCC.hakkoSOD()` | `hakkoSOD()` -> `htelNoInfoChgeOdrCtrl()` | `addSOD [C] KK_T_ODR_HAKKO`, `addTakinoSOD [C] KK_T_ODR_HAKKO`, `callEKK0191A010SC [R] KK_T_SVC_KEI_UCWK`, `callEKK0341B008SC [R] KK_T_KKTK_SVC_KEI`, `callEKK0341B008_02SC [R] KK_T_KKTK_SVC_KEI`, `callEKK0191B001SC [R] KK_T_SVC_KEI_UCWK`, `getEKK0251B001SC [R] KK_T_SVC_KEI_KAISEN_UCWK`, `findOlsOrderAtKK1041 [R] KK_T_KK1041`, `findZ1OrderHasBeenSentSvcKeiUcwk [R] Z1 order table`, `getSame_trn_no [R] same processing table`, `opSetOdrCtrl [C] KK_T_ODR_HAKKO` |

**Terminal operations from this method:**

| Operation | Type | Entity / DB |
|-----------|------|-------------|
| `addSOD(ODR_NAIYO_CD_207)` | C | KK_T_ODR_HAKKO — OLS setting/registration |
| `addSOD(ODR_NAIYO_CD_251)` | C | KK_T_ODR_HAKKO — Emergency notification change |
| `addSOD(ODR_NAIYO_CD_255)` | C | KK_T_ODR_HAKKO — OLS setting/port change |
| `addSOD(ODR_NAIYO_CD_256)` | C | KK_T_ODR_HAKKO — OLS setting/VA change |
| `addTakinoSOD(ODR_NAIYO_CD_406)` | C | KK_T_ODR_HAKKO — Takino router setting/registration |
| `addTakinoSOD(ODR_NAIYO_CD_407)` | C | KK_T_ODR_HAKKO — Takino router setting/change (registration) |
| `addTakinoSOD(ODR_NAIYO_CD_415)` | C | KK_T_ODR_HAKKO — Takino router setting/change (VA change #1) |
| `addTakinoSOD(ODR_NAIYO_CD_416)` | C | KK_T_ODR_HAKKO — Takino router setting/change (VA change #2) |
| `opSetOdrCtrl` | C | KK_T_ODR_HAKKO — Option service settings |
| `callEKK0191A010SC` | R | KK_T_SVC_KEI_UCWK — Service agreement detail (pre/post-change) |
| `callEKK0341B008SC` | R | KK_T_KKTK_SVC_KEI — Device provision service contract |
| `callEKK0341B008_02SC` | R | KK_T_KKTK_SVC_KEI — EG switching device records |
| `callEKK0191B001SC` | R | KK_T_SVC_KEI_UCWK — Service agreement detail listing |
| `getEKK0251B001SC` | R | KK_T_SVC_KEI_KAISEN_UCWK — Service line detail |
| `findOlsOrderAtKK1041` | R | KK_T_KK1041 — OLS order query |
| `findZ1OrderHasBeenSentSvcKeiUcwk` | R | Z1 order table |
| `getSame_trn_no` | R | Same processing number table |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] (L16367) Initialize method execution

| # | Type | Code |
|---|------|------|
| 1 | SET | `statusCode = 0` // Service interface execution status flag |
| 2 | EXEC | `shkkaMap(svc_kei_info_Map)` // Deep-copy service contract info from sodMap |
| 3 | EXEC | `shkkaMap(svc_kei_ucwk_info_Map)` // Deep-copy service contract detail info |
| 4 | EXEC | `shkkaMap(opsvkei_info_Map)` // Deep-copy option service contract info |

**Block 2** — [SET] (L16381) Extract parameters for optical phone number change

| # | Type | Code |
|---|------|------|
| 1 | SET | `svc_kei_no` = svc_kei_info_Map.get(INFO_SVC_KEI_NO) // Service contract number |
| 2 | SET | `svc_kei_ucwk_no` = svc_kei_ucwk_info_Map.get(INFO_SVC_KEI_UCWK_NO) // Post-change service contract detail number |
| 3 | SET | `chbf_svc_kei_ucwk_gene_add_dtm` = svc_kei_ucwk_info_Map.get(INFO_CHBF_SVC_KEI_UCWK_GENE_ADD_DTM) // Pre-change service contract detail registration timestamp |
| 4 | SET | `chaf_svc_kei_ucwk_gene_add_dtm` = svc_kei_ucwk_info_Map.get(INFO_CHAF_SVC_KEI_UCWK_GENE_ADD_DTM) // Post-change service contract detail registration timestamp |
| 5 | SET | `chaf_opsvkei_no` = opsvkei_info_Map.get(INFO_CHAF_OPSVKEI_NO) // Post-change option service contract number |

**Block 3** — [IF] (L16407) Z1 Order execution check

> Determine if Z1 order pre-check is necessary. Z1 orders are initial service orders that must be completed before certain downstream SOD generation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `isExecuteZ1OrderCheckResult` = `isExecuteZ1OrderCheck(handle, param)` // Determine if Z1 check is required |
| 2 | IF | `isExecuteZ1OrderCheckResult` == true [FLG_ON="1"] |

**Block 3.1** — [IF] (L16410) Z1 order already issued?

> If Z1 check is needed but Z1 has NOT yet been issued, terminate early — no further processing. This prevents duplicate or out-of-order SOD generation.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printBpDebugLog(..., "htelNoInfoChgeOdrCtrl#isExecuteZ1OrderCheckResult:true:not issued")` |
| 2 | RETURN | `return param` // Early exit |

**Block 3.2** — [ELSE-IF] (L16416) Z1 order already issued

> If Z1 check is needed AND Z1 has already been issued, proceed with processing.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printBpDebugLog(..., "htelNoInfoChgeOdrCtrl#isExecuteZ1OrderCheckResult:true:issued")` |

**Block 3.3** — [ELSE] (L16420) Z1 check not needed

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printBpDebugLog(..., "htelNoInfoChgeOdrCtrl#isExecuteZ1OrderCheckResult:false")` |

**Block 4** — [IF] (L16430) Device manufacturing number check

> Determine whether device manufacturing number validation is required for this transaction.

| # | Type | Code |
|---|------|------|
| 1 | SET | `isKikiSeizoNoCheckResult = false` |
| 2 | IF | `isExecuteKikiSeizoNoCheck(handle, param)` == true [FLG_ON="1"] |

**Block 4.1** — [IF] (L16434) Execute device check

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printBpDebugLog(..., "htelNoInfoChgeOdrCtrl#isExecuteKikiSeizoNoCheck:true")` |
| 2 | SET | `isKikiSeizoNoCheckResult` = `isKikiSeizoNoCheck(handle, param, svc_kei_no, svc_kei_ucwk_no)` |

**Block 4.2** — [ELSE] (L16439) Skip device check

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printBpDebugLog(..., "htelNoInfoChgeOdrCtrl#isExecuteKikiSeizoNoCheck:false")` |

**Block 5** — [SET] (L16462) Fetch pre-change service agreement detail

> Query pre-change optical telephone service agreement detail from EKK0191A010SC, including VA model code, device change number, port number, and emergency notification address fields (address code, postal code, prefecture, city, district, block, building, room, contractor name, contractor katakana).

| # | Type | Code |
|---|------|------|
| 1 | SET | `chbf_InHashUcwk` = new HashMap // Pre-change input hash |
| 2 | SET | `chbf_resultHashUcwk` = new HashMap // Pre-change result hash |
| 3 | SET | `chbf_InHashUcwk.put(SVC_KEI_UCWK_NO, svc_kei_ucwk_no)` |
| 4 | SET | `chbf_InHashUcwk.put(GENE_ADD_DTM, chbf_svc_kei_ucwk_gene_add_dtm)` |
| 5 | CALL | `statusCode` = `callEKK0191A010SC(param, handle, chbf_InHashUcwk, chbf_resultHashUcwk, FUNC_CODE_1)` |
| 6 | IF | `statusCode` != 0 → throw `CCException(SCCallException)` |
| 7 | SET | `chbfEKK0191A010Hash` = result map (TEMPLATE_ID_EKK0191A010) |
| 8 | SET | `chbf_vaTaknkikiModelCd` = `shkkaChr(VA_TAKNKIKI_MODEL_CD)` // Pre-change VA home device model code |
| 9 | SET | `chbf_vaKikiChgNo` = `shkkaChr(VA_KIKI_CHG_NO)` // Pre-change VA device change number |
| 10 | SET | `chbf_vaPortNo` = `shkkaChr(VA_PORT_NO)` // Pre-change VA port number |
| 11-21 | SET | `chbf_emgAdCd`, `chbf_emgHoseiPcd`, `chbf_emgStateNm`, `chbf_emgCityNm`, `chbf_emgOaztsuNm`, `chbf_emgAzchoNm`, `chbf_emgBnchigo`, `chbf_emgAdrttm`, `chbf_emgAdrrm`, `chbf_emgKshNm`, `chbf_emgKshKana` // Pre-change emergency notification fields |

**Block 6** — [SET] (L16495) Fetch post-change service agreement detail

> Same structure as Block 5 but for post-change data. The post-change timestamps and service contract detail number are used as query parameters.

| # | Type | Code |
|---|------|------|
| 1 | SET | `chaf_InHashUcwk` = new HashMap // Post-change input hash |
| 2 | SET | `chaf_InHashUcwk.put(SVC_KEI_UCWK_NO, svc_kei_ucwk_no)` |
| 3 | SET | `chaf_InHashUcwk.put(GENE_ADD_DTM, chaf_svc_kei_ucwk_gene_add_dtm)` |
| 4 | CALL | `statusCode` = `callEKK0191A010SC(param, handle, chaf_InHashUcwk, chaf_resultHashUcwk, FUNC_CODE_1)` |
| 5 | IF | `statusCode` != 0 → throw `CCException(SCCallException)` |
| 6-16 | SET | Extract `chaf_vaTaknkikiModelCd`, `chaf_vaKikiChgNo`, `chaf_vaPortNo`, and all `chaf_emg*` emergency notification fields |

**Block 7** — [SET] (L16518) Store instance fields and fetch service line details

| # | Type | Code |
|---|------|------|
| 1 | SET | `this.svc_kei_ucwk_no[0]` = `svc_kei_ucwk_no` // Post-change service contract detail number |
| 2 | SET | `this.svc_kei_ucwk_gadtm[0]` = `chaf_svc_kei_ucwk_gene_add_dtm` |
| 3 | CALL | `eKK0251B001Hash` = `getEKK0251B001SC(param, handle, svc_kei_no, FUNC_CODE_1)` // Service line details |
| 4 | SET | `this.svc_kei_kaisen_ucwk_no` = line detail number |
| 5 | SET | `this.svc_kei_kaisen_ucwk_gadtm` = line registration timestamp |

**Block 8** — [SET] (L16531) Fetch device provision records

> Query device provision service contracts linked to the service contract number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inHashKktk` = new HashMap, `resultHashKktk` = new HashMap |
| 2 | SET | `inHashKktk.put(SVC_KEI_NO, svc_kei_no)` |
| 3 | CALL | `statusCode` = `callEKK0341B008SC(param, handle, inHashKktk, resultHashKktk, FUNC_CODE_1)` |
| 4 | IF | `statusCode` != 0 → throw `CCException` |
| 5 | SET | `msgEKK0341B008SCList` = DEVICE_PROVISION_TEMPLATE_ID array |

**Block 9** — [CALL] (L16543) EG switching device query

> Additional device query specifically for EG (Ethernet Gateway) switching scenario. Used when VLAN is taken after EG replacement. Substitutes VA device list when a change-over VA exists.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `statusCode` = `callEKK0341B008_02SC(param, handle, inHashKktk, resultHashKktk, FUNC_CODE_4)` |
| 2 | IF | `statusCode` != 0 → throw `CCException` |
| 3 | SET | `msgEKK0341B008_02SCList` = DEVICE_PROVISION_TEMPLATE_ID array |

**Block 9.1** — [IF] (L16550) Change-over VA device substitution

> If EG switching query returned results, check if a VA device exists with matching change number and EG switching division code ("00067"). If so, substitute the main device list.

| # | Type | Code |
|---|------|------|
| 1 | IF | `msgEKK0341B008_02SCList` != null && length > 0 |

**Block 9.1.1** — [FOR] (L16553) Iterate EG switching results

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0341B022SCHash` = device data from iteration |
| 2 | SET | `kktkSvcCd` = KKTK_SVC_CD |
| 3 | SET | `kikiChgNo` = KIKI_CHG_NO |
| 4 | SET | `idoDiv` = IDO_DIV |

**Block 9.1.2** — [IF] (L16561) VA device with EG switching

| # | Type | Code |
|---|------|------|
| 1 | IF | `KKTK_SVC_CD_HTEL_VA` ("C004") == kktkSvcCd |

**Block 9.1.2.1** — [IF] (L16564) Change number matches AND EG switching division

> VA device change number matches post-change AND division code is "00067" (EG switching).

| # | Type | Code |
|---|------|------|
| 1 | IF | `chaf_vaKikiChgNo` == kikiChgNo && "00067" == idoDiv |
| 2 | SET | `msgEKK0341B008SCList` = `msgEKK0341B008_02SCList` // Substitute device list |

**Block 9.1.2.2** — [ELSE] (L16567) Continue to next record

> Not a matching VA + EG switching device — skip to next EG switching record.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | (implicit continue in for loop) |

**Block 10** — [CALL] (L16580) Fetch service agreement detail listing

> Query service agreement details for optical telephone. Used for Takino router line counting logic.

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgEKK0191B001SCList` = "EKK0191B001" from result hash |

**Block 11** — [IF] (L16589) Multi-function router check

> Check if customer has a multi-function (Takino) router. The `takino_flg` return value determines processing path: 0 = no Takino router, 2/4/9 = has router with different configurations.

| # | Type | Code |
|---|------|------|
| 1 | SET | `takino_flg` = `checkTakinoRT(handle, param)` |
| 2 | IF | `takino_flg` == 0 // No multi-function router |

**Block 11.1** — [FOR] (L16593) Iterate device provision records

> Main device iteration loop. For each device linked to the service contract, extract device info and determine if VA-related changes require SOD generation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0341B008SCHash` = device data from iteration |
| 2 | SET | `kktkSvcKeiNo` = KKTK_SVC_KEI_NO |
| 3 | SET | `kktkGeneAddDtm` = GENE_ADD_DTM |
| 4 | SET | `kktkKikiSeizoNo` = KIKI_SEIZO_NO |
| 5 | SET | `chbf_vaTaknkikiModelCd` = TAKNKIKI_MODEL_CD (from device provision, not agreement) |
| 6 | SET | `chaf_vaTaknkikiModelCd` = TAKNKIKI_MODEL_CD |
| 7 | SET | `this.kktk_svc_kei_no[0]` = `kktkSvcKeiNo` |
| 8 | SET | `this.kktk_svc_kei_gadtm[0]` = `kktkGeneAddDtm` |
| 9 | SET | `this.taknkiki_model_cd[0]` = `chaf_vaTaknkikiModelCd` |
| 10 | SET | `this.kiki_seizo_no[0]` = `kktkKikiSeizoNo` |

**Block 11.1.1** — [IF] (L16653) VA device change detection

> Check if the VA device model code or change number has changed between pre and post agreement.

| # | Type | Code |
|---|------|------|
| 1 | SET | `isNotVAchanged` = `isRegalVaKiki(handle, param, eKK0341B008SCHash, chaf_vaTaknkikiModelCd, null, ido_div, chaf_vaKikiChgNo, kokanBfKiki)` |
| 2 | IF | `isNotVAchanged` == true (device is valid VA and model/chg unchanged) |

**Block 11.1.1.1** — [IF] (L16661) VA model or change number changed

> The VA home device model code or VA device change number differs between pre and post agreement — this indicates a VA device change was performed.

| # | Type | Code |
|---|------|------|
| 1 | IF | `chaf_vaTaknkikiModelCd` != `chbf_vaTaknkikiModelCd` OR `chaf_vaKikiChgNo` != `chbf_vaKikiChgNo` |

**Block 11.1.1.1.1** — [IF] (L16665) OLS order already exists?

> Query whether an OLS order already exists for this device. If not, generate OLS setting/registration (207). If yes, generate OLS setting/VA change (256).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isOrderedOls` = `findOlsOrderAtKK1041(param, handle, taknkiki_model_cd[0], kiki_seizo_no[0], kktk_svc_kei_no[0])` |
| 2 | IF | `isOrderedOls` == false |

**Block 11.1.1.1.1.1** — [SET] (L16723) Generate OLS setting/registration SOD (207)

> Z1 order has been issued — generate OLS setting/registration order (ODR_NAIYO_CD_207).

| # | Type | Code |
|---|------|------|
| 1 | IF | `isZ1Ordered` == true |
| 2 | CALL | `param` = `addSOD(handle, param, ODR_NAIYO_CD_207)` // OLS Set/Registration |

**Block 11.1.1.1.2** — [ELSE] (L16741) Generate OLS setting/VA change SOD (256)

> Z1 order has been issued OR device manufacturing number check was performed — generate OLS setting/VA change order (ODR_NAIYO_CD_256).

| # | Type | Code |
|---|------|------|
| 1 | IF | `isZ1Ordered` == true OR `isKikiSeizoNoCheckResult` == true |
| 2 | CALL | `param` = `addSOD(handle, param, ODR_NAIYO_CD_256)` // OLS Set/VA Change |

**Block 11.1.2** — [IF] (L16764) Port number change detection

> VA is not changed but port number changed. Generate OLS setting/port change SOD (255). Only applies when not a Takino router.

| # | Type | Code |
|---|------|------|
| 1 | IF | `isBlank(kiki_seizo_no_takino)` OR `isBlank(kkop_svc_kei_no)` (not Takino router) |
| 2 | IF | `isNotVAchanged` == true AND `chaf_vaPortNo` != `chbf_vaPortNo` |

**Block 11.1.2.1** — [IF] (L16775) Generate OLS setting/port change SOD (255)

> Z1 order issued OR device manufacturing number check performed — generate port change SOD (ODR_NAIYO_CD_255).

| # | Type | Code |
|---|------|------|
| 1 | IF | `isZ1Ordered` == true OR `isKikiSeizoNoCheckResult` == true |
| 2 | CALL | `param` = `addSOD(handle, param, ODR_NAIYO_CD_255)` // OLS Set/Port Change |

**Block 12** — [ELSE] (L16801) Takino router processing path

> Multi-function router (`takino_flg` != 0) — handle Takino router-specific SOD generation.

| # | Type | Code |
|---|------|------|
| 1 | IF | `chaf_vaTaknkikiModelCd` != `chbf_vaTaknkikiModelCd` OR `chaf_vaKikiChgNo` != `chbf_vaKikiChgNo` (VA changed) |

**Block 12.1** — [CALL] (L16810) OLS check for Takino router

> Perform "VA not shipped" check for Takino router mother device — runs findOlsOrderAtKK1041 for Takino router devices.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `findOlsOrderAtKK1041(param, handle, taknkiki_model_cd_takino, kiki_seizo_no_takino, takino_kktk_svc_kei_no)` |

**Block 12.2** — [IF] (L16815) Takino flag 2 or 9

> Router is configured (flag 2 or 9). In current implementation, no SOD is registered here since the shipping completion batch handles it (OM-2016-0000004).

| # | Type | Code |
|---|------|------|
| 1 | IF | `takino_flg` == 2 OR `takino_flg` == 9 |

**Block 12.3** — [ELSE-IF] (L16819) Takino flag 4 — Count linked lines

> Router flag 4: count valid service agreement details linked to the VA device change number. Excludes canceled, completed, and received statuses.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ucwkCount` = 0 |
| 2 | FOR | Iterate `msgEKK0191B001SCList` |
| 3 | SET | `ucwkStat` = SVC_KEI_UCWK_STAT |
| 4 | SET | `vaKikiChgNo` = VA_KIKI_CHG_NO |
| 5 | IF | `ucwkStat` matches SVC_KEI_STAT_910 OR SVC_KEI_STAT_920 OR SVC_KEI_STAT_010 → continue (skip) |
| 6 | IF | `vaKikiChgNo` == `chaf_vaKikiChgNo` → `ucwkCount++` |
| 7 | IF | `ucwkCount` <= 1 |

**Block 12.3.1** — [IF] (L16846) <= 1 valid line → generate line change SOD (415)

> If one or fewer valid lines, generate Takino router setting/change SOD with VA change #1 (ODR_NAIYO_CD_415).

| # | Type | Code |
|---|------|------|
| 1 | IF | `isZ1Ordered` == true OR `isKikiSeizoNoCheckResult` == true |
| 2 | CALL | `param` = `addTakinoSOD(handle, param, ODR_NAIYO_CD_415)` // Takino Router Setting/Change VA #1 |

**Block 12.3.2** — [ELSE] (L16857) > 1 valid line → generate line change SOD (416)

> If more than one valid line, generate Takino router setting/change SOD with VA change #2 (ODR_NAIYO_CD_416).

| # | Type | Code |
|---|------|------|
| 1 | IF | `isZ1Ordered` == true OR `isKikiSeizoNoCheckResult` == true |
| 2 | CALL | `param` = `addTakinoSOD(handle, param, ODR_NAIYO_CD_416)` // Takino Router Setting/Change VA #2 |

**Block 12.4** — [ELSE-IF] (L16865) Takino flag 1

> Router flag 1: generate Takino router setting/change SOD with registration (ODR_NAIYO_CD_407).

| # | Type | Code |
|---|------|------|
| 1 | IF | `isZ1Ordered` == true |
| 2 | CALL | `param` = `addTakinoSOD(handle, param, ODR_NAIYO_CD_407)` // Takino Router Setting/Change Registration |

**Block 13** — [SET] (L16871) Retrieve same processing number

| # | Type | Code |
|---|------|------|
| 1 | SET | `sameTrnNo` = new String[1] |
| 2 | CALL | `getSame_trn_no(param, handle, null, sameTrnNo)` |
| 3 | SET | `this.same_trn_no` = `sameTrnNo[0]` |

**Block 14** — [IF] (L16886) Option service settings control

> If post-change option service contract number is not blank, delegate to option settings order control.

| # | Type | Code |
|---|------|------|
| 1 | IF | `isBlank(chaf_opsvkei_no)` == false |
| 2 | CALL | `opSetOdrCtrl(handle, param, fixedText, sodMap)` // Option service settings order processing |

**Block 15** — [IF] (L16894) Emergency notification change detection

> Compare all 11 emergency notification address fields (address code, postal code, prefecture, city, district, block, building, room, contractor name, contractor katakana) between pre and post agreement. If ANY field differs, generate emergency change SOD (251).

| # | Type | Code |
|---|------|------|
| 1 | IF | `chaf_emgAdCd` != `chbf_emgAdCd` OR `chaf_emgHoseiPcd` != `chbf_emgHoseiPcd` OR `chaf_emgStateNm` != `chbf_emgStateNm` OR `chaf_emgCityNm` != `chbf_emgCityNm` OR `chaf_emgOaztsuNm` != `chbf_emgOaztsuNm` OR `chaf_emgAzchoNm` != `chbf_emgAzchoNm` OR `chaf_emgBnchigo` != `chbf_emgBnchigo` OR `chaf_emgAdrttm` != `chbf_emgAdrttm` OR `chaf_emgAdrrm` != `chbf_emgAdrrm` OR `chaf_emgKshNm` != `chbf_emgKshNm` OR `chaf_emgKshKana` != `chbf_emgKshKana` |

**Block 15.1** — [IF] (L16902) Generate emergency change SOD (251)

> Z1 order has been issued — generate emergency notification change order (ODR_NAIYO_CD_251).

| # | Type | Code |
|---|------|------|
| 1 | IF | `isZ1Ordered` == true |
| 2 | CALL | `param` = `addSOD(handle, param, ODR_NAIYO_CD_251)` // Emergency notification change |

**Block 16** — [RETURN] (L16908)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` — Returns the accumulated parameter with all generated SOD orders |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `htelNoInfoChgeOdrCtrl` | Method | Phone Number Information Change Order Control — orchestrates SOD generation for optical telephone number changes |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity representing a work order issued to the field |
| `svc_kei_no` | Field | Service Contract Number — unique identifier for a customer's service line contract |
| `svc_kei_ucwk_no` | Field | Service Contract Detail Number — internal tracking ID for a specific service contract line item / change instance |
| `svc_kei_ucwk_stat` | Field | Service Contract Detail Status — status code (010=unprocessed, 910=canceled, 920=received) |
| `OPSVKEI_INFO` | Field | Option Service Contract Information — map containing optional add-on service data (e.g., internet, IPTV) |
| OLS | Acronym | Optical Line System — the fiber optic network termination equipment installed at the customer premises |
| VA | Acronym | Virtual Apartment — FTTH (Fiber To The Home) service for multi-dwelling units; also refers to the VA modem/router device |
| `chbf_*` prefix | Field | "Change Before" — pre-change data prefix (e.g., `chbf_vaTaknkikiModelCd` = pre-change VA model code) |
| `chaf_*` prefix | Field | "Change After" — post-change data prefix (e.g., `chaf_vaTaknkikiModelCd` = post-change VA model code) |
| `GeneAddDtm` | Field | Generation Registration Timestamp — YYYYMMDDHHmmSS format timestamp when a record was first created in the database |
| KKTK_SVC_CD | Field | KK (Keiyaku Kikaku) Teleservice Code — device/service type code from the KKTK_SVC_CD constant table (e.g., "C004" = optical telephone VA) |
| `IDO_DIV` | Field | Difference Division Code — classification code for the type of change (e.g., "00067" = EG switching) |
| EG | Acronym | Ethernet Gateway — network equipment at the customer premises for broadband connectivity |
| `takino_flg` | Field | Takino (multi-function router) flag — 0=no Takino router, 1=registered, 2=active, 4=active with lines, 9=active pending shipping |
| Takino Router | Business term | Multi-function router (brand name "Takino") — Fujitsu's branded router providing WiFi, NAT, and routing for FTTH services |
| `ODR_NAIYO_CD_207` | Constant | "207" — OLS Setting/Registration order content code |
| `ODR_NAIYO_CD_251` | Constant | "251" — Emergency Notification Change order content code |
| `ODR_NAIYO_CD_255` | Constant | "255" — OLS Setting/Port Change order content code |
| `ODR_NAIYO_CD_256` | Constant | "256" — OLS Setting/VA Change order content code |
| `ODR_NAIYO_CD_406` | Constant | "406" — Takino Router Setting/Registration (VA function registration) |
| `ODR_NAIYO_CD_407` | Constant | "407" — Takino Router Setting/Change (VA function registration change) |
| `ODR_NAIYO_CD_415` | Constant | "415" — Takino Router Setting/Change (VA Change #1 line) |
| `ODR_NAIYO_CD_416` | Constant | "416" — Takino Router Setting/Change (VA Change #2 line) |
| Z1 Order | Business term | Initial service order — the first order that must be issued for a new service before downstream orders can proceed |
| Emergency Notification | Business term | Emergency notification address — mandatory address information for emergency services (110/119 in Japan), stored with address code, postal code, prefecture, city, district, block, building, room, contractor name |
| `SVC_KEI_STAT_010` | Constant | "010" — Unprocessed status |
| `SVC_KEI_STAT_910` | Constant | "910" — Canceled status |
| `SVC_KEI_STAT_920` | Constant | "920" — Received status |
| `EKK0191A010SC` | SC Code | Service agreement detail query service component for optical telephone (pre/post-change) |
| `EKK0341B008SC` | SC Code | Device provision service contract listing service component |
| `EKK0341B008_02SC` | SC Code | EG switching device query service component |
| `EKK0191B001SC` | SC Code | Service agreement detail listing for optical telephone |
| `EKK0251B001SC` | SC Code | Service line detail inquiry service component |
| KK_T_SVC_KEI_UCWK | Entity | Service contract detail table — stores agreement details for optical telephone contracts |
| KK_T_KKTK_SVC_KEI | Entity | Device provision service contract table — stores device-to-contract linkage records |
| KK_T_SVC_KEI_KAISEN_UCWK | Entity | Service line detail table — stores service line-level detail records |
| KK_T_KK1041 | Entity | OLS order table — stores OLS (optical line system) order records |
| KK_T_ODR_HAKKO | Entity | Order issuance table — stores all SOD orders issued by the system |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service |
| `FUNC_CODE_1` | Constant | Function code "1" — standard processing mode for SC calls |
| `FUNC_CODE_4` | Constant | Function code "4" — EG switching specific processing mode |
