# Business Logic — JKKHakkoSODCC.checkTakinoRT() [745 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKHakkoSODCC` |
| Layer | CC/Common Component (shared business logic coordination layer) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKHakkoSODCC.checkTakinoRT()

This method performs a **multi-function router (MRT) router-function availability check** for a given service contract number. It is a shared utility called by dozens of order control and screen methods across the Fujitsu eo customer core system. The business purpose is to determine whether the customer's MRT device (multi-function router or eo Home Gateway) has its router function active, and if so, which type of order action is appropriate.

The method classifies the MRT status into **six return codes** that drive downstream order issuance logic:
- **0**: No valid multi-function router (contract terminated, cancelled, or no compatible equipment option service contract)
- **1**: Router function only in use (MRT set, but VA function is off — router-only scenario)
- **2**: MRT set, cancellation/deletion order target (latest request type code is 03 or 08 — indicates MRT is being cancelled)
- **3**: MRT set, cancellation/order-target for contracted-into-disconnection (MRT disconnected due to a discrepancy trigger)
- **4**: MRT set, change order target (latest request type code is 02 or 04 — change/modify order is latest)
- **9**: MRT set, new order not yet issued (MRT is active but no order has been submitted)

The method handles both **eo Light Net** (SVC_KIND_NET="1", router function `KKOP_SVC_CD_RT="G01"`) and **eo Light Tel** (SVC_KIND_TEL="2", VA function `KKOP_SVC_CD_VA="G02"`) service types. It implements a **routing/dispatch design pattern**: it first identifies the service kind, then follows distinct query paths for Tel vs non-Tel services, and finally dispatches to appropriate service component (SC) calls based on equipment-provided service codes (MRT, HGW, BBR, etc.). The method is a critical shared utility called by approximately 100+ caller methods, including all major order control screens (DSL order, tel number change, cancellation, new network, VLAN-ID change, write-in info addition, etc.).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START["checkTakinoRT handle param"]
    
    START --> CHK_PRC["Check prc_grp_cd is blank"]
    
    CHK_PRC --> Yes1["Yes"]
    CHK_PRC --> No1["No"]
    
    Yes1 --> GET_SVC["Call getSvcKeiList"]
    GET_SVC --> SET_PRG["SET prc_grp_cd from result"]
    SET_PRG --> SVC_KIND
    
    No1 --> SVC_KIND["svc_kind = jdgSvcKind"]
    
    SVC_KIND --> INIT["SET mrt_dsl_flg = 0"]
    INIT --> TEL_FLANK["SVC_KIND_TEL svc_kind"]
    
    TEL_FLANK -->|Yes| TEL_BRANCH["Service is Tel"]
    TEL_FLANK -->|No| NONTEL_BRANCH["Service is not Tel"]
    
    TEL_BRANCH --> FETCH_UCWK["Build inHashUcwk svc_kei_ucwk_no gene_add_dtm"]
    FETCH_UCWK --> CALL_0191["Call EKK0191A010SC funcCode 2"]
    CALL_0191 --> SET_VACHG["SET va_kiki_chg_no from result"]
    SET_VACHG --> FETCH_KISN
    
    NONTEL_BRANCH --> FETCH_KISN["Fetch service line inner lines"]
    
    FETCH_KISN --> IN_HASH_KISN["Build inHashKisnUcwk svc_kei_no"]
    IN_HASH_KISN --> CALL_0251["Call EKK0251B003SCCAAMsg funcCode 1"]
    CALL_0251 --> KISN_LOOP["Loop msgListKisnUcwk"]
    
    KISN_LOOP --> K_STAT["Check svc_kei_kaisen_ucwk_stat blank"]
    K_STAT -->|Yes| K_CONT["Continue next"]
    K_STAT -->|No| K_SET["SET takino_svc_kei_kaisen_ucwk_no gadtm"]
    K_SET --> K_BREAK["Break"]
    K_CONT --> K_END["Next item"]
    
    K_END --> K_BLANK["Check takino_svc_kei_kaisen_ucwk_no blank"]
    K_BLANK -->|Yes| RET0A["Return 0"]
    
    K_BLANK -->|No| CALL_0341B["Call EKK0341B504SC funcCode 1"]
    CALL_0341B --> KKT_LOOP["Loop msgListKktk"]
    
    KKT_LOOP --> KKT_SVCD["Check KKTK_SVC_CD MRT or HGW"]
    KKT_SVCD -->|No| KKT_CONT["Continue next"]
    KKT_SVCD -->|Yes| TEL_CON["Check svc_kind TEL and svc_kei_ucwk_no not null"]
    
    TEL_CON -->|Yes| DEV_CHK["Check va_kiki_chg_no mismatch"]
    DEV_CHK -->|Yes| KOKAN_CHK["Check kokanBfKiki"]
    KOKAN_CHK -->|Empty| KKT_CONT
    KOKAN_CHK -->|Not empty| USE_KOKAN["Use kokanBfKiki hash"]
    DEV_CHK -->|No same device| DEV_MATCH
    USE_KOKAN --> DEV_MATCH
    
    TEL_CON -->|No| DEV_MATCH
    
    DEV_MATCH --> STAT920["Check SVC_KEI_STAT_920"]
    STAT920 -->|Yes| KKT_CONT
    
    STAT920 -->|No| STAT910["Check SVC_KEI_STAT_910"]
    STAT910 -->|Yes| MS_CHK["mskm_dtl_no match"]
    MS_CHK -->|No| KKT_CONT
    MS_CHK -->|Yes| IDO_CHK["ido_div DSL or TEKKYO or KYOSEI or CANCEL"]
    IDO_CHK -->|Yes| SET2["SET mrt_dsl_flg 2"]
    IDO_CHK -->|No| KKT_CONT
    SET2 --> SET_KKT_VARS["SET takino_kktk_svc_kei_no gadtm model_cd kiki_seizo_no"]
    
    STAT910 -->|No active| STAT_ACTIVE["Check SVC_KEI_STAT 020 or 030 or 100 or 210 or 220"]
    STAT_ACTIVE -->|Yes| SEIZO_CHK["Check KIKI_SEIZO_NO blank"]
    SEIZO_CHK -->|Yes| SET1["SET mrt_dsl_flg 1"]
    SEIZO_CHK -->|No| SET_KKT_VARS
    SET1 --> SET_KKT_VARS
    
    STAT_ACTIVE -->|No| KKT_CONT
    
    SET_KKT_VARS --> FLG0["Check mrt_dsl_flg 0"]
    
    KKT_CONT --> KKT_NEXT["Next item"]
    KKT_NEXT --> KKT_END2["End loop"]
    KKT_END2 --> FLG0
    
    FLG0 -->|Yes| RET0B["Return 0"]
    FLG0 -->|No| CALL_2811["Call EKK2811B010SC funcCode 1"]
    CALL_2811 --> OPS_LOOP["Loop msgListKkop"]
    
    OPS_LOOP --> OPS_CD["Check NET RT or TEL VA"]
    OPS_CD -->|No| OPS_CONT["Continue next"]
    OPS_CD -->|Yes| CALL_1041["Call EKK1041B001SC"]
    
    CALL_1041 --> EMPTY_CHK["Check resultOdrSet empty"]
    EMPTY_CHK -->|Yes| RET9A["Return 9 MRT set new order not issued"]
    EMPTY_CHK -->|No| OP_STAT["Check SVC_KEI_STAT 910 or 920"]
    
    OP_STAT -->|Yes| MS_MATCH["mskm_dtl_no match"]
    MS_MATCH -->|Yes| MRT_FLG["Check mrt_dsl_flg"]
    MRT_FLG -->|1| RET4["Return 4 MRT set change order"]
    MRT_FLG -->|2| RET3["Return 3 MRT set cancellation order"]
    MRT_FLG -->|Other| OPS_CONT
    MS_MATCH -->|No| OPS_CONT
    
    OP_STAT -->|No active| ODR_LOOP["Loop resultOdrSet"]
    ODR_LOOP --> ODR_MATCH["takino_kktk_svc_kei_no match"]
    ODR_MATCH -->|No| ODR_CONT["Continue next"]
    ODR_CONT --> ODR_NEXT["Next item"]
    ODR_NEXT --> ODR_END["End loop"]
    ODR_END --> RET9B["Return 9 MRT set new order not issued"]
    
    ODR_MATCH -->|Yes| CALL_1041A["Call EKK1041A010SC funcCode 1"]
    CALL_1041A --> GET_ODR["GET mrt_skbt_cd yokyu_sbt_cd"]
    GET_ODR --> YOK24["yokyu_sbt_cd matches 024"]
    YOK24 -->|Yes| YOK38["yokyu_sbt_cd matches 038"]
    YOK38 -->|Yes 03 or 08| RET2["Return 2 MRT set cancellation order"]
    YOK38 -->|No 02 or 04| RT_CHK["svc_kind TEL and RT only"]
    RT_CHK -->|Yes| RET1["Return 1 Router function only"]
    RT_CHK -->|No| RET4A["Return 4 New change order latest"]
    
    YOK24 -->|No other| OPS_CONT
    
    RET0A --> END1["End"]
    RET0B --> END1
    RET9A --> END1
    RET1 --> END1
    RET2 --> END1
    RET3 --> END1
    RET4 --> END1
    RET4A --> END1
    RET9B --> END1
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session manager handle carrying database connections and transaction context. Used by all SC calls to execute queries against the order fulfillment database. |
| 2 | `param` | `IRequestParameterReadWrite` | Parameter object containing a model group and control map. Provides `getData(JKKHakkoSODConstCC.HAKKOSODCCWORKMAP)` to access the work map which may contain an alternate `svc_kei_no`. Also passed to all service component calls. |

**Instance fields read by this method:**

| Field | Business Description |
|-------|---------------------|
| `this.prc_grp_cd` | Price group code — if blank, triggers fallback to `getSvcKeiList` to resolve it |
| `this.svc_kei_no1` | Primary service contract number — used as fallback when the work map does not contain `svc_kei_no` |
| `this.svc_kei_ucwk_no[]` | Service contract inner line number array — may be null; if not null, indicates a Tel service where inner-line number was supplied |
| `this.svc_kei_ucwk_gadtm[]` | Service contract inner line registration datetime array — used for versioned lookups of inner line data |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKHakkoSODCC.getSvcKeiList` | EKK0081A010 | KK_T_SVC_KEI (service contract table) | Fetches service contract agreement to resolve price group code when `prc_grp_cd` is blank |
| R | `JKKHakkoSODCC.callEKK0191A010SC` | EKK0191A010 | KK_T_SVC_KEI_UCWK (service contract inner line table) | Service contract inner line agreement — retrieves VA equipment change number and inner line data. Called twice (funcCode 2 and funcCode 4) for pre-reservation application date consideration. |
| R | `JKKHakkoSODCC.callEKK0251B003SCCAAMsg` | EKK0251B003 | KK_T_SVC_KEI_Kaisen (service contract line inner line table) | Current service line inner line list (currently in-use) — retrieves active/disconnected contract lines |
| R | `JKKHakkoSODCC.callEKK0341B504SC` | EKK0341B504 | KK_T_KKTSVKEI (equipment-provided service contract table) | Equipment-provided service contract list for a given service contract line inner line — checks MRT/HGW status |
| R | `JKKHakkoSODCC.callEKK0341B029SC` | EKK0341B029 | KK_T_KKTSVKEI | Equipment-provided service agreement via device change number — handles future-dated reserved records where main flow cannot obtain them |
| R | `JKKHakkoSODCC.callEKK0341B021SC` | EKK0341B021 | KK_T_KKTSVKEI | Equipment-provided service contract list (reservation) — handles device in exchange (status 110) scenario |
| R | `JKKHakkoSODCC.callEKK2811B010SC` | EKK2811B010 | KK_T_KKOPSVKEI (equipment option service contract table) | Equipment option service contract list — checks if router or VA function is available |
| R | `JKKHakkoSODCC.callEKK1041B001SC` | EKK1041B001 | KK_T_ODR_SET (order settings table) | Order settings list — retrieves pending/active order configurations |
| R | `JKKHakkoSODCC.callEKK1041A010SC` | EKK1041A010 | KK_T_ODR_SET details | Order settings agreement — retrieves detailed order settings including router function code and request type code |
| R | `JKKHakkoSODCC.getShuriKokanBfKiki` | - | In-memory (repair-exchange device data) | Retrieves pre-exchange device data when the device is under repair/exchange |

## 5. Dependency Trace

### Direct callers of checkTakinoRT (pre-computed):

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKHakkoSODCC.dslOdrCtrl` | `dslOdrCtrl` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504, EKK2811B010 [R] |
| 2 | `JKKHakkoSODCC.findZ1OrderAtKK1041` | `findZ1OrderAtKK1041` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504 [R] |
| 3 | `JKKHakkoSODCC.findZ1OrderAtKK1041SvcKeiUcwk` | `findZ1OrderAtKK1041SvcKeiUcwk` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504 [R] |
| 4 | `JKKHakkoSODCC.htelNoDslOdrCtrl` | `htelNoDslOdrCtrl` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504, EKK2811B010 [R] |
| 5 | `JKKHakkoSODCC.htelNoInfoChgeOdrCtrl` | `htelNoInfoChgeOdrCtrl` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504, EKK2811B010 [R] |
| 6 | `JKKHakkoSODCC.htelNoKaihkOdrCtrl` | `htelNoKaihkOdrCtrl` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504, EKK2811B010 [R] |
| 7 | `JKKHakkoSODCC.jdgSvcKind` | `jdgSvcKind` -> `checkTakinoRT` (indirect, via jdgSvcKind call) | SVC_KIND_TEL="2" [R] |
| 8 | `JKKHakkoSODCC.jdgOdr163` | `jdgOdr163` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504 [R] |
| 9 | `JKKHakkoSODCC.kaihkOdrCtrl` | `kaihkOdrCtrl` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504, EKK2811B010 [R] |
| 10 | `JKKHakkoSODCC.newNet` | `newNet` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504, EKK2811B010 [R] |
| 11 | `JKKHakkoSODCC.opSetOdrCtrl` | `opSetOdrCtrl` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504, EKK2811B010 [R] |
| 12 | `JKKHakkoSODCC.setChgePWForRouterConInfo` | `setChgePWForRouterConInfo` -> `checkTakinoRT` | calls EKK0251B003 [R] |
| 13 | `JKKHakkoSODCC.telNoChge` | `telNoChge` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504, EKK2811B010 [R] |
| 14 | `JKKHakkoSODCC.vLanIdChgOdrCtrl` | `vLanIdChgOdrCtrl` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504, EKK2811B010 [R] |
| 15 | `JKKHakkoSODCC.wribInfoAddOdrCtrl` | `wribInfoAddOdrCtrl` -> `checkTakinoRT` | calls EKK0251B003, EKK0341B504, EKK2811B010 [R] |

## 6. Per-Branch Detail Blocks

### Block 1 — IF (prc_grp_cd is blank) (L23100)

> If the price group code (`prc_grp_cd`) is blank (not set), retrieve it from the service contract agreement to avoid errors during Z1 processing when changing phone information.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0081A010Element = getSvcKeiList(handle, param, this.svc_kei_no1)` // Service contract agreement [-> TEMPLATE_ID_EKK0081A010] |
| 2 | SET | `this.prc_grp_cd = (String)eKK0081A010Element.get(EKK0081A010CBSMsg1List.PRC_GRP_CD)` // Price group code [-> CONSTANT: PRC_GRP_CD] |

### Block 2 — SET (svc_kind determination) (L23112)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svc_kind = jdgSvcKind()` // Determine service type (NET=1, TEL=2, MOB=4, ADSL=5, ELSE=99) |
| 2 | SET | `mrt_dsl_flg = 0` // MRT DSL flag: 0=No valid RT, 1=Active (not cancelled), 2=Simultaneous cancellation |
| 3 | SET | `va_kiki_chg_no = ""` // Device change number (VA equipment) |

### Block 3 — IF (svc_kind == TEL and svc_kei_ucwk_no[0] != null) (L23125)

> If the service is Tel type and a service contract inner line number exists, fetch VA equipment change number from the service contract inner line agreement. This is needed for MRT phone disconnection scenarios.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inHashUcwk.put(SVC_KEI_UCWK_NO, svc_kei_ucwk_no[0])` // Service contract inner line number [-> CONSTANT: SVC_KEI_UCWK_NO="svc_kei_ucwk_no"] |
| 2 | IF | `svc_kei_ucwk_gadtm[0] != null` (L23132) — If registration datetime is not blank, include it in query |
| 3 | SET | `inHashUcwk.put(GENE_ADD_DTM, svc_kei_ucwk_gadtm[0])` // Versioned lookup [-> CONSTANT: GENE_ADD_DTM="gene_add_dtm"] |
| 4 | CALL | `statusCode = callEKK0191A010SC(param, handle, inHashUcwk, resultHashUcwk, FUNC_CODE_2)` // funcCode=2 [-> CONSTANT: FUNC_CODE_2="2"] |
| 5 | IF | `0 != statusCode` — throw CCException with SCCallException |
| 6 | SET | `eKK0191A010Hash = resultHashUcwk.get(TEMPLATE_ID_EKK0191A010)` // Service contract inner line agreement result [-> CONSTANT: TEMPLATE_ID_EKK0191A010="EKK0191A010"] |
| 7 | SET | `va_kiki_chg_no = (String)eKK0191A010Hash.get(EKK0191A010CBSMsg1List.VA_KIKI_CHG_NO)` // Equipment change number |

### Block 4 — SET (Fetch service line inner lines) (L23163)

> Regardless of service type, always fetch the service contract line inner lines (currently in use) to identify any MRT-associated lines.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = (HashMap)param.getData(HAKKOSODCCWORKMAP)` // Work map [-> CONSTANT: HAKKOSODCCWORKMAP="HakkoSODCCWORK"] |
| 2 | IF | `inMap == null OR !inMap.containsKey(SVC_KEI_NO)` (L23165) — Use `this.svc_kei_no1` as fallback |
| 3 | SET | `inHashKisnUcwk.put(SVC_KEI_NO, this.svc_kei_no1)` // Service contract number [-> CONSTANT: SVC_KEI_NO="svc_kei_no"] |
| 4 | ELSE | `inHashKisnUcwk.put(SVC_KEI_NO, inMap.get(SVC_KEI_NO))` // Use work map value |
| 5 | CALL | `statusCode = callEKK0251B003SCCAAMsg(param, handle, inHashKisnUcwk, resultHashKisnUcwk, FUNC_CODE_1)` // Current service line inner line list [-> CONSTANT: FUNC_CODE_1="1"] |
| 6 | IF | `0 != statusCode` — throw CCException with SCCallException |
| 7 | SET | `msgListKisnUcwk = (CAANMsg[])resultHashKisnUcwk.get(TEMPLATE_ID_EKK0251B003)` [-> CONSTANT: TEMPLATE_ID_EKK0251B003="EKK0251B003"] |

### Block 5 — FOR LOOP (msgListKisnUcwk) (L23174)

> Iterate over service line inner lines to find the first one associated with MRT. Skip cancelled entries.

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0251B003Hash = msgListKisnUcwk[i].getMsgData()` |
| 2 | GET | `svc_kei_kaisen_ucwk_stat = eKK0251B003Hash.get(SVC_KEI_KAISEN_UCWK_STAT)` // Service contract line inner line status [-> CONSTANT: SVC_KEI_KAISEN_UCWK_NO="svc_kei_kaisen_ucwk_no"] |
| 3 | IF | `isBlank(svc_kei_kaisen_ucwk_stat)` (L23181) — Cancelled item, continue to next |
| 4 | SET | `takino_svc_kei_kaisen_ucwk_no = eKK0251B003Hash.get(SVC_KEI_KAISEN_UCWK_NO)` // MRT contract line inner line number |
| 5 | SET | `takino_svc_kei_kaisen_ucwk_gadtm = eKK0251B003Hash.get(GENE_ADD_DTM)` // Registration datetime |
| 6 | RETURN | `break` (exit loop after first valid entry) |

### Block 6 — IF (takino_svc_kei_kaisen_ucwk_no is blank) (L23197)

> If no MRT contract line inner line number could be obtained, it means only cancelled MRT contract lines exist. Return 0 (No valid MRT).

| # | Type | Code |
|---|------|------|
| 1 | IF | `isBlank(takino_svc_kei_kaisen_ucwk_no)` — Return 0: No valid multi-function router |
| 2 | RETURN | `0` |

### Block 7 — SET (Fetch equipment-provided service contract list) (L23201)

> Query the equipment-provided service contract list for the MRT-associated line to check device status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inHashKktk.put(SVC_KEI_KAISEN_UCWK_NO, takino_svc_kei_kaisen_ucwk_no)` // MRT contract line inner line number |
| 2 | CALL | `statusCode = callEKK0341B504SC(param, handle, inHashKktk, resultHashKktk, FUNC_CODE_1)` |
| 3 | IF | `0 != statusCode` — throw CCException with SCCallException |
| 4 | SET | `msgListKktk = (CAANMsg[])resultHashKktk.get(TEMPLATE_ID_EKK0341B504)` [-> CONSTANT: TEMPLATE_ID_EKK0341B504="EKK0341B504"] |
| 5 | SET | `svcKeiUcwkNo = nullToBlank(svc_kei_ucwk_no[0])` // ANK-3238: null-safe |
| 6 | SET | `tmp_kktk_svc_kei_stat = ""` |

### Block 8 — FOR LOOP (msgListKktk) — MRT/HGW branch (L23211)

> Iterate equipment-provided service contract records. Filter for MRT (`KKTK_SVC_CD_MRT="C024"`) or HGW (`KKTK_SVC_CD_HGW="C025"`).

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK0341B504Hash = msgListKktk[i].getMsgData()` |
| 2 | GET | `kktk_svc_kei_stat = eKK0341B504Hash.get(KKTK_SVC_KEI_STAT)` // Equipment-provided service status |
| 3 | GET | `kktk_svc_cd = eKK0341B504Hash.get(KKTK_SVC_CD)` // Equipment-provided service code |
| 4 | IF | `KKTK_SVC_CD_MRT == kktk_svc_cd OR KKTK_SVC_CD_HGW == kktk_svc_cd` (ANK-4315: added HGW) [-> CONSTANTS: MRT="C024", HGW="C025"] |
| 5 | IF | `SVC_KIND_TEL == svc_kind` — Retrieve pre-exchange device data if under repair (ANK-3238) |
| 6 | CALL | `kokanBfKiki = getShuriKokanBfKiki(handle, param, svc_kei_no1, svcKeiUcwkNo, va_kiki_chg_no, ...)` |

### Block 8.1 — IF (device mismatch for Tel service) (L23240)

> For Tel service, if the device change number doesn't match the one from the contract inner line, skip non-matching records (unless under repair exchange).

| # | Type | Code |
|---|------|------|
| 1 | IF | `SVC_KIND_TEL == svc_kind AND svc_kei_ucwk_no[0] != null` |
| 2 | IF | `isBlank(va_kiki_chg_no) OR va_kiki_chg_no != KIKI_CHG_NO` [-> CONSTANT: KIKI_CHG_NO="kiki_chg_no"] — Device mismatch |
| 3 | IF | `kokanBfKiki == null OR isEmpty()` — Continue to next (different device, skip) |

### Block 8.2 — IF (status == 920 cancelled) (L23272)

> Skip entries that have been cancelled (status 920: Cancelled).

| # | Type | Code |
|---|------|------|
| 1 | IF | `SVC_KEI_STAT_920 == kktk_svc_kei_stat` [-> CONSTANT: SVC_KEI_STAT_920="920"] — Cancelled, continue |
| 2 | RETURN | `continue` |

### Block 8.3 — IF (status == 910 terminated) (L23274)

> When status is 910 (Terminated), check if the application detail number matches and the discrepancy division indicates DSL, TEKKYO, KYOSEI, or CANCEL. This indicates the MRT was disconnected due to a discrepancy event.

| # | Type | Code |
|---|------|------|
| 1 | IF | `SVC_KEI_STAT_910 == kktk_svc_kei_stat` [-> CONSTANT: SVC_KEI_STAT_910="910"] |
| 2 | GET | `mskm_dtl_no_local = eKK0341B504Hash.get(MSKM_DTL_NO)` // Application detail number [-> CONSTANT: MSKM_DTL_NO="mskm_dtl_no"] |
| 3 | IF | `mskm_dtl_no.equals(mskm_dtl_no_local) AND (IDO_DIV_DSL OR IDO_DIV_TEKKYODSL OR IDO_DIV_KYOSEIDSL OR IDO_DIV_CANCEL.equals(ido_div))` [-> CONSTANTS: DSL="00005", TEKKYODSL="00006", KYOSEIDSL="00007", CANCEL="00008"] |
| 4 | IF | `kokanBfKiki != null AND !isEmpty()` — Use kokanBfKiki hash (repair exchange) |
| 5 | SET | `takino_kktk_svc_kei_no = eKK0341B504Hash.get(KKTK_SVC_KEI_NO)` // Equipment-provided service contract number |
| 6 | SET | `takino_kktk_svc_kei_gadtm = eKK0341B504Hash.get(GENE_ADD_DTM)` |
| 7 | SET | `taknkiki_model_cd_takino = eKK0341B504Hash.get(TAKNKIKI_MODEL_CD)` // Home device model code |
| 8 | SET | `kiki_seizo_no_takino = eKK0341B504Hash.get(KIKI_SEIZO_NO)` // Device serial number |
| 9 | SET | `mrt_dsl_flg = 2` // Simultaneous cancellation |

### Block 8.4 — IF (active status) (L23296)

> When status is 020 (Inspection complete), 030 (Settlement complete), 100 (Service in progress), 210 (Suspended/Discontinued), or 220 (Stopped), check for serial number and set MRT flag.

| # | Type | Code |
|---|------|------|
| 1 | IF | `SVC_KEI_STAT_020 OR 030 OR 100 OR 210 OR 220 == kktk_svc_kei_stat` [-> CONSTANTS: 020="020", 030="030", 100="100", 210="210", 220="220"] |
| 2 | IF | `KIKI_SEIZO_NO is blank` [-> CONSTANT: KIKI_SEIZO_NO="kiki_seizo_no"] — No serial number |
| 3 | IF | `kokanBfKiki != null AND !isEmpty()` — Use kokanBfKiki hash for repair exchange |
| 4 | ELSE | `return 9` (MRT set, new order not issued) — ANK-3238 fix |
| 5 | SET | `takino_kktk_svc_kei_no = eKK0341B504Hash.get(KKTK_SVC_KEI_NO)` |
| 6 | SET | `takino_kktk_svc_kei_gadtm = eKK0341B504Hash.get(GENE_ADD_DTM)` |
| 7 | SET | `taknkiki_model_cd_takino = eKK0341B504Hash.get(TAKNKIKI_MODEL_CD)` |
| 8 | SET | `kiki_seizo_no_takino = eKK0341B504Hash.get(KIKI_SEIZO_NO)` |
| 9 | SET | `mrt_dsl_flg = 1` |

### Block 9 — IF/ELSE (mrt_dsl_flg == 0) after KKT loop (L23448)

> If no MRT was found in the main equipment-provided service loop, check for future-dated reserved records (OM-2016-0001250, ANK-3412-17-00). This handles the case where MRT reservation is pending for future move-in dates.

| # | Type | Code |
|---|------|------|
| 1 | IF | `mrt_dsl_flg == 0 AND SVC_KIND_TEL == svc_kind AND !isNullBlank(va_kiki_chg_no)` [-> CONSTANTS: SVC_KIND_TEL="2"] |
| 2 | CALL | `msgEKK0341B029 = callEKK0341B029SC(handle, param, FUNC_CD_3, null, va_kiki_chg_no, "20991231")` [-> CONSTANT: FUNC_CD_3="3"] — Fetch future-dated MRT records |
| 3 | IF | `msgEKK0341B029 != null` — Process MRT/HGW records |
| 4 | GET | `kktkSvcKeiStat = msgEKK0341B029.getString(KKTK_SVC_KEI_STAT)` |
| 5 | IF | `SVC_KEI_STAT_910 == kktkSvcKeiStat` — Same logic as Block 8.3 (termination via discrepancy) |
| 6 | IF | `SVC_KEI_STAT_020/030/100/210/220 == kktkSvcKeiStat` — Same logic as Block 8.4 (active) |

### Block 9.1 — IF (mrt_dsl_flg == 0, second check after OM-2018-0000651) (L23519)

> Second reserved record check: re-fetch VA equipment change number with funcCode 4 (reservation application date consideration), then query equipment-provided services again.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inHashUcwk.put(SVC_KEI_UCWK_NO, svc_kei_ucwk_no[0])` |
| 2 | CALL | `statusCode = callEKK0191A010SC(param, handle, inHashUcwk, resultHashUcwk, FUNC_CODE_4)` [-> CONSTANT: FUNC_CODE_4="4"] |
| 3 | SET | `va_kiki_chg_no = eKK0191A010Hash.get(VA_KIKI_CHG_NO)` |
| 4 | CALL | `msgEKK0341B029 = callEKK0341B029SC(handle, param, FUNC_CD_3, null, va_kiki_chg_no, "20991231")` |
| 5 | IF | `SVC_KEI_STAT_020/030/100/210/220` with no serial — `return 9` |

### Block 10 — IF (mrt_dsl_flg == 0, ANK-3412-17-00) (L23630)

> Third fallback: query reserved equipment-provided service contracts (reservation list) to handle devices in exchange (status 110).

| # | Type | Code |
|---|------|------|
| 1 | IF | `mrt_dsl_flg == 0 AND SVC_KIND_TEL == svc_kind AND !isNullBlank(va_kiki_chg_no)` |
| 2 | CALL | `msgEKK0341B021List = callEKK0341B021SC(handle, param, FUNC_CD_1, this.svc_kei_no1)` [-> CONSTANT: FUNC_CD_1="1"] |
| 3 | FOR | Loop `msgEKK0341B021List` |
| 4 | GET | `cur_kktk_svc_cd = msgEKK0341B021.getString(CUR_KKTK_SVC_CD)` |
| 5 | IF | `(MRT or HGW == cur_kktk_svc_cd) AND va_kiki_chg_no == RSV_KIKI_CHG_NO` — Reservation matches device change number |
| 6 | IF | `RSV_KIKI_SEIZO_NO is NOT blank` |
| 7 | SET | `takino_kktk_svc_kei_no = msgEKK0341B021.getString(KKTK_SVC_KEI_NO)` |
| 8 | SET | `takino_kktk_svc_kei_gadtm = msgEKK0341B021.getString(RSV_GENE_ADD_DTM)` |
| 9 | SET | `taknkiki_model_cd_takino = msgEKK0341B021.getString(RSV_TAKNKIKI_MODEL_CD)` |
| 10 | SET | `kiki_seizo_no_takino = msgEKK0341B021.getString(RSV_KIKI_SEIZO_NO)` |
| 11 | SET | `mrt_dsl_flg = 1` |
| 12 | RETURN | `break` |

### Block 11 — IF/ELSE (mrt_dsl_flg == 0 final) (L23676)

> Final check: if mrt_dsl_flg is still 0, no MRT exists — return 0. Otherwise, proceed to equipment option service contract check.

| # | Type | Code |
|---|------|------|
| 1 | IF | `mrt_dsl_flg == 0` — No valid multi-function router |
| 2 | RETURN | `0` |
| 3 | ELSE | Proceed to equipment option service contract |

### Block 12 — SET (Fetch equipment option service contract) (L23683)

> Query the equipment option service contract list using the MRT equipment-provided service contract number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inHashKkOP.put(KKTK_SVC_KEI_NO, takino_kktk_svc_kei_no)` // Equipment-provided service contract number [-> CONSTANT: KKTK_SVC_KEI_NO="kktk_svc_kei_no"] |
| 2 | CALL | `statusCode = callEKK2811B010SC(param, handle, inHashKkOP, resultHashKkOP, FUNC_CODE_1)` |
| 3 | IF | `0 != statusCode` — throw CCException with SCCallException |
| 4 | SET | `msgListKkop = (CAANMsg[])resultHashKkOP.get(TEMPLATE_ID_EKK2811B010)` [-> CONSTANT: TEMPLATE_ID_EKK2811B010="EKK2811B010"] |

### Block 13 — FOR LOOP (msgListKkop) (L23695)

> Iterate equipment option service contract records. Check for Router function (NET) or VA function (TEL).

| # | Type | Code |
|---|------|------|
| 1 | SET | `eKK2811B010Hash = msgListKkop[i].getMsgData()` |
| 2 | GET | `kkop_svc_cd = eKK2811B010Hash.get(KKOP_SVC_CD)` // Equipment option service code |
| 3 | GET | `kkop_svc_kei_no = eKK2811B010Hash.get(KKOP_SVC_KEI_NO)` |
| 4 | GET | `kkop_svc_kei_gadtm = eKK2811B010Hash.get(GENE_ADD_DTM)` |
| 5 | IF | `(SVC_KIND_NET == svc_kind AND KKOP_SVC_CD_RT == kkop_svc_cd) OR (SVC_KIND_TEL == svc_kind AND KKOP_SVC_CD_VA == kkop_svc_cd)` [-> CONSTANTS: SVC_KIND_NET="1", SVC_KIND_TEL="2", KKOP_SVC_CD_RT="G01", KKOP_SVC_CD_VA="G02"] |

### Block 13.1 — CALL EKK1041B001 (order settings) (L23702)

> Fetch order settings list for the MRT/VA. If empty, MRT is set but no order has been issued yet.

| # | Type | Code |
|---|------|------|
| 1 | SET | `resultOdrSet = new ArrayList<HashMap<String, Object>>()` |
| 2 | CALL | `resultOdrSet = callEKK1041B001SC(param, handle, ORDER_SBT_CD_TEL, SVC_ORDER_CD_MRT, null, null, taknkiki_model_cd_takino, kiki_seizo_no_takino)` |
| 3 | IF | `resultOdrSet.size() == 0` — MRT retained but order not issued |
| 4 | RETURN | `9` (MRT set, new order not issued) |

### Block 13.2 — IF (kkop_svc_kei_stat == 910 or 920) (L23712)

> If the equipment option service contract is terminated or cancelled, check discrepancy match.

| # | Type | Code |
|---|------|------|
| 1 | GET | `kkop_svc_kei_stat = eKK2811B010Hash.get(KKOP_SVC_KEI_STAT)` |
| 2 | IF | `SVC_KEI_STAT_910 OR SVC_KEI_STAT_920 == kkop_svc_kei_stat` |
| 3 | GET | `mskm_dtl_no_local = eKK2811B010Hash.get(MSKM_DTL_NO)` |
| 4 | IF | `mskm_dtl_no.equals(mskm_dtl_no_local)` — Same cancellation/disconnection |
| 5 | IF | `mrt_dsl_flg == 1` — Return 4 (MRT active, option cancelled = change order target) |
| 6 | ELSE IF | `mrt_dsl_flg == 2` — Return 3 (MRT simultaneous cancellation) |

### Block 13.3 — FOR LOOP (resultOdrSet) (L23736)

> Iterate order settings records to determine the latest request type code and router function code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `odrSet = resultOdrSet.get(j)` |
| 2 | GET | `odrSetNo = odrSet.get(ODR_SET_NO)` |
| 3 | GET | `kktkSvcKeiNo = odrSet.get(KKTK_SVC_KEI_NO)` |
| 4 | IF | `!takino_kktk_svc_kei_no.equals(kktkSvcKeiNo)` — Skip non-matching records (OM-2014-0003355) |
| 5 | CALL | `statusCode = callEKK1041A010SC(param, handle, inHashOdrSet, resultHashOdrSet, FUNC_CODE_1)` |
| 6 | SET | `msgListOdrSet = (CAANMsg[])resultHashOdrSet.get(TEMPLATE_ID_EKK1041A010)` |
| 7 | GET | `mrt_skbt_cd = eKK1041A010Hash.get(TAKINORT_KINO_CD_RT)` // Router function code [-> CONSTANT: TAKINORT_KINO_CD_RT="A"] |
| 8 | GET | `yokyu_sbt_cd = eKK1041A010Hash.get(RCNT_YOKYU_SBT_CD)` // Request type code [-> CONSTANT: YOKYU_SBT_CD="yokyu_sbt_cd"] |

### Block 13.3.1 — IF (yokyu_sbt_cd matches 02 or 04) (L23777)

> If the latest request type is 02 (Change) or 04 (Add), check if router-only.

| # | Type | Code |
|---|------|------|
| 1 | IF | `yokyu_sbt_cd.matches("0[24]")` |
| 2 | IF | `SVC_KIND_TEL == svc_kind` |
| 3 | IF | `isBlank(mrt_skbt_cd) OR TAKINORT_KINO_CD_RT == mrt_skbt_cd` — Router-only (no VA) [-> CONSTANT: TAKINORT_KINO_CD_RT="A"] |
| 4 | RETURN | `1` (Router function only) |
| 5 | RETURN | `4` (New/Change order is latest) |

### Block 13.3.2 — IF (yokyu_sbt_cd matches 03 or 08) (L23792)

> If the latest request type is 03 (Cancellation) or 08 (Destruction), the MRT is being cancelled.

| # | Type | Code |
|---|------|------|
| 1 | IF | `yokyu_sbt_cd.matches("0[38]")` |
| 2 | RETURN | `2` (MRT set, cancellation/deletion order) |

### Block 13.3.3 — Final return 9 (L23806)

> If we reach here, MRT is active (mrt_dsl_flg=1), option service is active, order settings records exist but none match the current MRT equipment-provided service contract number. This means the MRT is set but no new order has been issued.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `9` (MRT set, new order not issued) [OM-2016-0000004: Changed from 0 to 9] |

### Block 14 — ELSE (no option service) (L23813)

> If no option service is associated with the MRT, reset the option service contract number and return 0.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kkop_svc_kei_no = ""` — Reset (IT1-2013-0001732) |
| 2 | RETURN | `0` (SOD issuance target: no option service) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mrt_dsl_flg` | Field | MRT DSL flag — internal state variable tracking multi-function router status: 0=No valid RT, 1=Active, 2=Simultaneous cancellation |
| `va_kiki_chg_no` | Field | VA equipment change number — identifies the specific device change cycle for VA (Virtual Access) equipment |
| `svc_kind` | Field | Service type code — classifies the service as Net (1), Tel (2), Mob (4), ADSL (5), or Else (99) |
| `prc_grp_cd` | Field | Price group code — billing category code (e.g., "02" for eo Light Net Home type) |
| `svc_kei_ucwk_no` | Field | Service contract inner line number — internal tracking ID for service contract line items |
| `svc_kei_kaisen_ucwk_no` | Field | Service contract line inner line number — identifies the line item within a contract |
| `takino_svc_kei_kaisen_ucwk_no` | Field | MRT-associated service contract line inner line number — the specific line item linked to the MRT device |
| `takino_kktk_svc_kei_no` | Field | MRT equipment-provided service contract number — the service contract number for the MRT-equipped line |
| `kktk_svc_kei_stat` | Field | Equipment-provided service status — current state of the equipment-provided service contract |
| `kktk_svc_cd` | Field | Equipment-provided service code — identifies service type (MRT, HGW, BBR, Tel VA, etc.) |
| `kkop_svc_cd` | Field | Equipment option service code — identifies the option service type (G01=Router, G02=VA) |
| `mskm_dtl_no` | Field | Application detail number — internal application reference number used to match cancellation events |
| `ido_div` | Field | Discrepancy division — classifies the type of contract discrepancy event (DSL, TEKKYO, KYOSEI, CANCEL) |
| `yokyu_sbt_cd` | Field | Request type code — classifies order type: 02=Change, 03=Cancellation, 04=Add, 08=Destruction |
| `mrt_skbt_cd` | Field | MRT function code — identifies which MRT functions are active: A=Router only, B=VA only, C=Both |
| `kiki_seizo_no` | Field | Device serial number — unique manufacturing serial number of the MRT device |
| `taknkiki_model_cd` | Field | Home device model code — identifies the model type of the home equipment |
| `kkop_svc_kei_stat` | Field | Equipment option service contract status — current state (020=Inspection, 030=Settlement, 100=In-service, 210=Suspended, 910=Terminated, 920=Cancelled) |
| `FUNC_CODE_1` | Constant | Function code: "1" — standard query mode |
| `FUNC_CODE_2` | Constant | Function code: "2" — VA-specific query mode (funcCode 2) |
| `FUNC_CODE_4` | Constant | Function code: "4" — reservation application date consideration mode |
| `SVC_KIND_NET` | Constant | "1" — eo Light Net service type |
| `SVC_KIND_TEL` | Constant | "2" — eo Light Tel service type |
| `KKTK_SVC_CD_MRT` | Constant | "C024" — Multi-function Router equipment-provided service code |
| `KKTK_SVC_CD_HGW` | Constant | "C025" — eo Home Gateway equipment-provided service code |
| `KKTK_SVC_CD_TEL_VA` | Constant | "C004" — Tel service VA equipment code |
| `KKOP_SVC_CD_RT` | Constant | "G01" — Router function option service code |
| `KKOP_SVC_CD_VA` | Constant | "G02" — VA function option service code |
| `TAKINORT_KINO_CD_RT` | Constant | "A" — Router function only |
| `TAKINORT_KINO_CD_VA` | Constant | "B" — VA function only |
| `TAKINORT_KINO_CD_DBL` | Constant | "C" — Both functions in use |
| `SVC_KEI_STAT_020` | Constant | "020" — Inspection complete |
| `SVC_KEI_STAT_030` | Constant | "030" — Settlement complete |
| `SVC_KEI_STAT_100` | Constant | "100" — Service in progress |
| `SVC_KEI_STAT_210` | Constant | "210" — Suspended/Discontinued |
| `SVC_KEI_STAT_220` | Constant | "220" — Stopped |
| `SVC_KEI_STAT_910` | Constant | "910" — Terminated (contract cancelled) |
| `SVC_KEI_STAT_920` | Constant | "920" — Cancelled (order cancelled) |
| `IDO_DIV_DSL` | Constant | "00005" — Disconnection discrepancy |
| `IDO_DIV_TEKKYODSL` | Constant | "00006" — Withdrawal (disconnection) discrepancy |
| `IDO_DIV_KYOSEIDSL` | Constant | "00007" — Forced disconnection confirmation discrepancy |
| `IDO_DIV_CANCEL` | Constant | "00008" — Cancellation discrepancy |
| RT | Business term | Router — the router function of a multi-function router device |
| VA | Business term | Virtual Access — the telecommunication/Virtual Access function of a multi-function router (eo Light Tel phone service) |
| MRT | Business term | Multi-function Router — a home gateway device that provides both router and VA (phone) functions |
| HGW | Business term | eo Home Gateway — the newer generation home gateway device (ANX-4315), functionally equivalent to MRT |
| BBR | Business term | Broadband Router — legacy router service code (C014) |
| SOD | Acronym | Service Order Data — the order issuance system in Fujitsu's eo customer core |
| SC | Acronym | Service Component — the backend service layer that executes database operations |
| KKT | Acronym | Kiki Teikyo (Equipment Provision) — equipment-provided services (router/VA/BBR) |
| KKOP | Acronym | Kiki Option — equipment option services (router/VA subscription) |
| EKK | Acronym | eo-kaku Kei (Service Contract) — SC prefix for service contract related modules |
| EKK0191 | Module | Service contract inner line agreement module — eo Light Tel inner line lookup |
| EKK0251 | Module | Service contract line inner line list — current line query |
| EKK0341 | Module | Equipment-provided service contract module — MRT/HGW device status query |
| EKK2811 | Module | Equipment option service contract module — router/VA option status query |
| EKK1041 | Module | Order settings module — order configuration and request type lookup |
