# Business Logic — JZMEnumSwitchCC.chkItenToki() [74 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JZMEnumSwitchCC` |
| Layer | Common Component / Business Support (EJB business logic helper) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JZMEnumSwitchCC.chkItenToki()

The `chkItenToki()` method performs a **Tokyu Registration Completion Check** in the K-Opticom telecom service provisioning system. It is a validation guard that prevents service orders from proceeding when a telephone number is in the middle of a Tokyu (transfer-of-service) registration process. In Japanese business terms: "Touki-touroku-zumi chekku shori" means "registered Tokyu status check processing."

The method iterates through all service contracts associated with a given phone number, drills down to their service detail records for eo optical telephone, and then checks each detail's approval data for incomplete transfer registration flags. Specifically, it verifies whether any **termination/pause registration** (Kaishaku/Shuushi Touki code) or **post-transfer registration** (Iten-saki Kaitsuu-go Touki code) is active without a corresponding completion date. If any such incomplete state is found, the method returns `false` to block the calling screen/BMS from proceeding.

The method follows a **gateway validation pattern** — it is invoked as a pre-flight check within several switch-case branches of the `JZMEnumSwitchCC` enum router (port-out, inter-company transfer, and batch abolition workflows). If the check fails, an error flag (`ENUMCC_ERR_FLG_1002`, `ENUMCC_ERR_FLG_4002`, or `ENUMCC_ERR_FLG_7002`) is set by the caller, preventing potentially conflicting service modifications from being applied to a phone number that is mid-transfer.

The method uses a **layered data-fetch-and-validate strategy**, querying three CBS (Common Business Service) screens in sequence: EKK0081B033 (Service Contract List by Phone Number), EKK0191B001 (Service Detail List for eo Optical Telephone by Contract Number), and EKK0191A010 (Service Detail Approval for eo Optical Telephone). Only the intersection of all three result sets is examined, ensuring the check applies exclusively to records linked to the target phone number.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["chkItenToki start"])
    LOG1["printlnEjbLog: start"]
    MAPPER["new JZMEnumSwitchMapperCC"]
    MAP_IN1["editInMsgEKK0081B033: map input for Service Contract List by Phone Number"]
    CALL_SVC1["callSvcInter EKK0081B033: invoke Service Contract List CBS"]
    GET_LIST1["getCAANMsgList EKK0081B033CBSMSG1LIST"]
    CHECK_LIST1{"ekk0081B033OutList is non-empty?"}
    LOOP1["for idx = 0 to list length"]
    GET_MAP1["getMsgData -> ekk0081B033Map"]
    MAP_IN2["editInMsgEKK0191B001: map input by svc_kei_no"]
    CALL_SVC2["callSvcInter EKK0191B001: invoke Service Detail List CBS"]
    GET_LIST2["getCAANMsgList EKK0191B001CBSMSG1LIST"]
    CHECK_LIST2{"ekk0191B001OutList is non-empty?"}
    LOOP2["for idx2 = 0 to list length"]
    GET_MAP2["getMsgData -> ekk0191B001Map"]
    GET_TELNO["get telno from map"]
    CHECK_TELNO{"getTelNo equals input telno?"}
    LOOP_SKIP["continue: skip mismatched record"]
    MAP_IN3["editInMsgEKK0191A010: map input by svc_kei_ucwk_no"]
    CALL_SVC3["callSvcInter EKK0191A010: invoke Service Detail Approval CBS"]
    GET_LIST3["getCAANMsgList EKK0191A010CBSMSG1LIST"]
    CHECK_LIST3{"ekk0191A010OutList is non-empty?"}
    LOOP3["for idx3 = 0 to list length"]
    GET_MAP3["getMsgData -> ekk0191A010Map"]
    EXTRACT["Extract: dsl_pause_toki_sbt_cd, dsl_pause_toki_end_ymd, itens_opaf_toki_sbt_cd, itens_opaf_toki_end_ymd"]
    CHECK_TOKI{"Any incomplete Tokyu registration?"}
    LOG_FALSE["printlnEjbLog: false_01_end"]
    RETURN_FALSE["return false"]
    LOG_TRUE["printlnEjbLog: true_end"]
    RETURN_TRUE["return true"]

    START --> LOG1
    LOG1 --> MAPPER
    MAPPER --> MAP_IN1
    MAP_IN1 --> CALL_SVC1
    CALL_SVC1 --> GET_LIST1
    GET_LIST1 --> CHECK_LIST1
    CHECK_LIST1 -- true --> LOOP1
    CHECK_LIST1 -- false --> LOG_TRUE
    LOOP1 --> GET_MAP1
    GET_MAP1 --> MAP_IN2
    MAP_IN2 --> CALL_SVC2
    CALL_SVC2 --> GET_LIST2
    GET_LIST2 --> CHECK_LIST2
    CHECK_LIST2 -- true --> LOOP2
    CHECK_LIST2 -- false --> LOOP1_END["end of idx loop"]
    LOOP2 --> GET_MAP2
    GET_MAP2 --> GET_TELNO
    GET_TELNO --> CHECK_TELNO
    CHECK_TELNO -- false --> LOOP_SKIP
    LOOP_SKIP --> LOOP1_END
    CHECK_TELNO -- true --> MAP_IN3
    MAP_IN3 --> CALL_SVC3
    CALL_SVC3 --> GET_LIST3
    GET_LIST3 --> CHECK_LIST3
    CHECK_LIST3 -- true --> LOOP3
    CHECK_LIST3 -- false --> LOOP1_END
    LOOP3 --> GET_MAP3
    GET_MAP3 --> EXTRACT
    EXTRACT --> CHECK_TOKI
    CHECK_TOKI -- true --> LOG_FALSE
    LOG_FALSE --> RETURN_FALSE
    RETURN_FALSE --> LOOP1_END
    CHECK_TOKI -- false --> LOOP1_END
    LOOP1_END --> LOOP1
    LOG_TRUE --> RETURN_TRUE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session handle carrying session manager and context information. Used as the first argument in all `callSvcInter` invocations to maintain transaction and session state across CBS calls. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object containing a model group and control map. Passed through mapper methods to supply request-level context (e.g., function code, operator ID, search parameters) for each CBS call. |
| 3 | `fixedText` | `String` | User-specified arbitrary string used as a key/identifier for the request context. Passed to `callSvcInter` and `printlnEjbLog` to correlate log entries and response mappings to a specific request. |
| 4 | `telno` | `String` | Key phone number — the telephone number used as the primary search criterion. Used to query service contracts (EKK0081B033), and later to validate that service detail records (EKK0191B001) belong to the same phone number. This is the business key driving the entire validation. |

**External/Instance State:**
- `JZMEnumSwitchMapperCC` — instantiated within the method (`enumSwitchMapper`) to call input-mapping methods. Each mapper call prepares request data for the corresponding CBS.

## 4. CRUD Operations / Called Services

The method performs three sequential service calls, each fetching data for validation purposes. All three CBS operations are **Read (R)** operations since the method only queries data — it never creates, updates, or deletes records.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JZMEnumSwitchMapperCC.editInMsgEKK0081B033` | EKK0081B033 | - | Maps input parameters to EKK0081B033 request structure (Service Contract List by Phone Number) |
| R | `JZMEnumSwitchCC.callSvcInter` (EKK0081B033) | EKK0081B033SC | KK_T_SVC_KEI, KK_T_KAISEN_TG_SVKEI, KK_T_SVC_KEI_UCWK, KK_T_SVKEIUW_EOH_TEL | Invokes Service Contract List CBS to retrieve contracts associated with the given phone number |
| U | `JZMEnumSwitchMapperCC.editInMsgEKK0191B001` | EKK0191B001 | - | Maps input parameters to EKK0191B001 request structure (Service Detail List by Contract Number) using svc_kei_no from previous result |
| R | `JZMEnumSwitchCC.callSvcInter` (EKK0191B001) | EKK0191B001SC | KK_T_SVC_KEI_UCWK, KK_T_SVC_KEI, KK_T_KKTK_SVC_KEI, KK_T_SVKEIUW_EOH_TEL | Invokes Service Detail List CBS to retrieve service details for each contract |
| U | `JZMEnumSwitchMapperCC.editInMsgEKK0191A010` | EKK0191A010 | - | Maps input parameters to EKK0191A010 request structure (Service Detail Approval) using svc_kei_ucwk_no from previous result |
| R | `JZMEnumSwitchCC.callSvcInter` (EKK0191A010) | EKK0191A010SC | KK_T_SVKEIUW_EOH_TEL, KK_T_SVC_KEI_UCWK | Invokes Service Detail Approval CBS to retrieve approval data containing Tokyu registration fields |
| - | `JZMEnumSwitchCC.printlnEjbLog` | - | - | EJB log output (debug tracing) — start, false_01_end, true_end |

**CRUD Classification Rationale:**
- **EditInMsg** methods are classified as **U** (Update of internal state) since they populate request maps, not persist data.
- **callSvcInter** methods are classified as **R** (Read) since the EKK0081B033, EKK0191B001, and EKK0191A010 CBS screens are lookup/query screens that select from tables without performing writes.
- **printlnEjbLog** is classified as **-** (side-effect/log only, not a CRUD operation).

**Entity/DB Tables (from SQL facility files JSYejbEKK*.TPDA):**
- **EKK0081B033**: `KK_T_SVC_KEI` (service contract), `KK_T_KAISEN_TG_SVKEI` (contract routing detail), `KK_T_SVC_KEI_UCWK` (service contract work detail), `KK_T_SVKEIUW_EOH_TEL` (eo optical telephone service detail)
- **EKK0191B001**: `KK_T_SVC_KEI_UCWK`, `KK_T_SVC_KEI`, `KK_T_KKTK_SVC_KEI` (transfer-related contract), `KK_T_SVKEIUW_EOH_TEL`
- **EKK0191A010**: `KK_T_SVKEIUW_EOH_TEL`, `KK_T_SVC_KEI_UCWK`

## 5. Dependency Trace

The method `chkItenToki` is called by three private methods within `JZMEnumSwitchCC`, each representing a different service order workflow:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `portOut_OPTtelno` | `portOut_OPTtelno` -> `chkItenToki` | `callSvcInter EKK0081B033 [R] KK_T_SVC_KEI`, `callSvcInter EKK0191B001 [R] KK_T_SVC_KEI_UCWK`, `callSvcInter EKK0191A010 [R] KK_T_SVKEIUW_EOH_TEL` |
| 2 | CBS: `interCompany_Othertelno` | `interCompany_Othertelno` -> `chkItenToki` | `callSvcInter EKK0081B033 [R] KK_T_SVC_KEI`, `callSvcInter EKK0191B001 [R] KK_T_SVC_KEI_UCWK`, `callSvcInter EKK0191A010 [R] KK_T_SVKEIUW_EOH_TEL` |
| 3 | CBS: `bmpAbolition_OtherComp_Cancel` | `bmpAbolition_OtherComp_Cancel` -> `chkItenToki` | `callSvcInter EKK0081B033 [R] KK_T_SVC_KEI`, `callSvcInter EKK0191B001 [R] KK_T_SVC_KEI_UCWK`, `callSvcInter EKK0191A010 [R] KK_T_SVKEIUW_EOH_TEL` |

**Caller Contexts:**
1. **portOut_OPTtelno** (L258-367): Port-out (FTTH telephone number) application processing. Calls `chkItenToki` at line 273 after checking service contract status. On failure, sets error flag `ENUMCC_ERR_FLG_1002`.

2. **interCompany_Othertelno** (L508-540): Inter-company transfer (other company telephone number) processing. Calls `chkItenToki` at line 523 after checking service contract status. On failure, sets error flag `ENUMCC_ERR_FLG_4002`.

3. **bmpAbolition_OtherComp_Cancel** (L687-739): Batch port-out (N port telephone number) cancellation processing. Calls `chkItenToki` at line 702 after checking service contract status. On failure, sets error flag `ENUMCC_ERR_FLG_7002`.

The callers are invoked by screen-level CBS methods (e.g., `JSCSV002801CC.interCompany_OtherTelno_Switch`). No direct screen entry points (KKSV*) were traced within 8 hops.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialize mapper (L788)

| # | Type | Code |
|---|------|------|
| 1 | LOG | `printlnEjbLog("JZMEnumSwitchCC:chkItenToki:start")` // Log entry point |
| 2 | SET | `JZMEnumSwitchMapperCC enumSwitchMapper = new JZMEnumSwitchMapperCC()` // Create mapper instance for input mapping |

**Block 2** — [CALL + SET] Fetch Service Contract List by Phone Number (L792-799)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `enumSwitchMapper.editInMsgEKK0081B033(param, telno)` // Map input for Service Contract List by phone number |
| 2 | SET | `HashMap<String, Object> inMapEKK0081B033 = ...` // Request map for EKK0081B033 CBS |
| 3 | CALL | `callSvcInter(handle, param, inMapEKK0081B033, fixedText)` // Call Service Contract List CBS |
| 4 | SET | `outCAANMsgEKK0081B033 = ...` // Response message |
| 5 | EXEC | `outCAANMsgEKK0081B033.getCAANMsgList(EKK0081B033CBSMsg.EKK0081B033CBSMSG1LIST)` // Extract contract list |
| 6 | SET | `CAANMsg[] ekk0081B033OutList = ...` // Array of service contract records |

**Block 3** — [IF + FOR] Iterate over contracts (L801-845)

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (ekk0081B033OutList != null && ekk0081B033OutList.length > 0)` (L801) — Check if any contracts exist for the phone number |
| 2 | FOR | `for (int idx = 0; idx < ekk0081B033OutList.length; idx++)` (L802) |
| 3 | SET | `HashMap ekk0081B033Map = ekk0081B033OutList[idx].getMsgData()` (L804) // Current contract's data map |

**Block 3.1** — [CALL + SET] Fetch Service Detail List for eo Optical Telephone (L807-812)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `enumSwitchMapper.editInMsgEKK0191B001(param, (String) ekk0081B033Map.get("svc_kei_no"))` // Map input for Service Detail List by svc_kei_no (service contract number) |
| 2 | SET | `kk191b001_paramMap = ...` // Request map for EKK0191B001 CBS |
| 3 | CALL | `callSvcInter(handle, param, kk191b001_paramMap, fixedText)` // Call Service Detail List CBS |
| 4 | EXEC | `outCAANMsgEKK0191B001.getCAANMsgList(EKK0191B001CBSMsg.EKK0191B001CBSMSG1LIST)` // Extract detail list |
| 5 | SET | `CAANMsg[] ekk0191B001OutList = ...` // Array of service detail records |

**Block 3.1.1** — [IF + FOR] Iterate over service details (L814-844)

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (ekk0191B001OutList != null && ekk0191B001OutList.length > 0)` (L814) — Check if any details exist |
| 2 | FOR | `for (int idx2 = 0; idx2 < ekk0191B001OutList.length; idx2++)` (L815) |
| 3 | SET | `HashMap ekk0191B001Map = ekk0191B001OutList[idx2].getMsgData()` (L817) // Current detail's data map |

**Block 3.1.1.1** — [IF + SET] Phone number match check (L820-822)

| # | Type | Code |
|---|------|------|
| 1 | SET | `String getTelNo = (String) ekk0191B001Map.get("telno")` (L821) // Extract phone number from service detail |
| 2 | IF | `if (!getTelNo.equals(telno))` (L822) — Verify this detail's phone number matches the input telno |
| 3 | EXEC | `continue;` (L823) // Skip to next record if mismatched |

**Block 3.1.1.2** — [CALL + SET] Fetch Service Detail Approval data (L826-834)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `enumSwitchMapper.editInMsgEKK0191A010(param, (String) ekk0191B001Map.get("svc_kei_ucwk_no"))` // Map input for Service Detail Approval by svc_kei_ucwk_no (service detail work number) |
| 2 | SET | `inMapEKK0191A010 = ...` // Request map for EKK0191A010 CBS |
| 3 | CALL | `callSvcInter(handle, param, inMapEKK0191A010, fixedText)` // Call Service Detail Approval CBS |
| 4 | EXEC | `outCAANMsgEKK0191A010.getCAANMsgList(EKK0191A010CBSMsg.EKK0191A010CBSMSG1LIST)` // Extract approval list |
| 5 | SET | `CAANMsg[] ekk0191A010OutList = ...` // Array of approval records |

**Block 3.1.1.2.1** — [IF + FOR] Iterate over approval records (L836-844)

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (ekk0191A010OutList != null && ekk0191A010OutList.length > 0)` (L836) — Check if approval records exist |
| 2 | FOR | `for (int idx3 = 0; idx3 < ekk0191A010OutList.length; idx3++)` (L837) |
| 3 | SET | `HashMap ekk0191A010Map = ekk0191A010OutList[idx3].getMsgData()` (L839) // Current approval record's data map |

**Block 3.1.1.2.1.1** — [SET] Extract Tokyu registration fields (L842-845)

> Tokyu Registration Completion Check

| # | Type | Code |
|---|------|------|
| 1 | SET | `String dsl_pause_toki_sbt_cd = (String) ekk0191A010Map.get(DSL_PAUSE_TOKI_SBT_CD)` (L844) // Termination/pause Tokyu type code |
| 2 | SET | `String dsl_pause_toki_end_ymd = (String) ekk0191A010Map.get(DSL_PAUSE_TOKI_END_YMD)` (L845) // Termination/pause Tokyu completion date |
| 3 | SET | `String itens_opaf_toki_sbt_cd = (String) ekk0191A010Map.get(ITENS_OPAF_TOKI_SBT_CD)` (L846) // Post-transfer Tokyu type code |
| 4 | SET | `String itens_opaf_toki_end_ymd = (String) ekk0191A010Map.get(ITENS_OPAF_TOKI_END_YMD)` (L847) // Post-transfer Tokyu completion date |

**Block 3.1.1.2.1.2** — [IF + RETURN] Incomplete Tokyu registration detection (L850-853)

> Error if Tokyu is in progress due to transfer-source cancellation or transfer-start

| # | Type | Code |
|---|------|------|
| 1 | IF | `if ((dsl_pause_toki_sbt_cd != null && !"".equals(dsl_pause_toki_sbt_cd) && (dsl_pause_toki_end_ymd == null || "".equals(dsl_pause_toki_end_ymd))) || (itens_opaf_toki_sbt_cd != null && !"".equals(itens_opaf_toki_sbt_cd) && (itens_opaf_toki_end_ymd == null || "".equals(itens_opaf_toki_end_ymd))))` (L850-852) — Check if either: (a) a termination/pause Tokyu code is set but has no end date, OR (b) a post-transfer Tokyu code is set but has no end date |
| 2 | LOG | `printlnEjbLog("JZMEnumSwitchCC:chkItenToki:false_01_end")` (L853) // Log the failure condition |
| 3 | RETURN | `return false` (L854) // Block the calling workflow — Tokyu is still pending |

**Block 4** — [LOG + RETURN] Success path (L856-857)

> If no incomplete Tokyu registrations are found across all contracts, details, and approval records, the method returns true to allow the workflow to proceed.

| # | Type | Code |
|---|------|------|
| 1 | LOG | `printlnEjbLog("JZMEnumSwitchCC:chkItenToki:true_end")` (L856) // Log successful completion |
| 2 | RETURN | `return true` (L857) // No incomplete Tokyu found — workflow may proceed |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `chkItenToki` | Method | Tokyu Registration Completion Check — validates that no pending transfer-of-service registration exists for a phone number |
| Touki (Tokyu) | Business term | Transfer of telecommunications service — the process of transferring a phone number from one service provider or location to another |
| Touki-touroku-zumi | Field concept | Registration completed — indicates whether a Tokyu registration process has reached its final completion state |
| `telno` | Field | Telephone number — the primary search key used to look up service contracts and details |
| `svc_kei_no` | Field | Service contract number — internal identifier for a service contract line item (used as link between EKK0081B033 and EKK0191B001) |
| `svc_kei_ucwk_no` | Field | Service detail work number — internal tracking ID for service contract sub-details (used as link between EKK0191B001 and EKK0191A010) |
| DSL_PAUSE_TOKI_SBT_CD | Field | Termination/Pause Tokyu type code — indicates whether a termination or pause-based Tokyu registration is in progress |
| DSL_PAUSE_TOKI_END_YMD | Field | Termination/Pause Tokyu completion date — YYYYMMDD date when the termination/pause Tokyu was completed; null/empty means still in progress |
| ITENS_OPAF_TOKI_SBT_CD | Field | Post-transfer Tokyu type code — indicates whether a post-transfer-start Tokyu registration is in progress |
| ITENS_OPAF_TOKI_END_YMD | Field | Post-transfer Tokyu completion date — YYYYMMDD date when the post-transfer Tokyu was completed; null/empty means still in progress |
| EKK0081B033 | Screen/CBS | Service Contract List by Phone Number — screen that returns all service contracts linked to a telephone number |
| EKK0191B001 | Screen/CBS | Service Detail List for eo Optical Telephone by Contract Number — screen that returns service details for a given service contract |
| EKK0191A010 | Screen/CBS | Service Detail Approval for eo Optical Telephone — screen that returns approval data including Tokyu registration fields |
| eo optical telephone | Business term | eo Hikari Denwa — NTT's fiber-optic telephone service brand; the primary service line type handled by this check |
| KK_T_SVC_KEI | Table | Service contract master table — stores core service contract records |
| KK_T_SVC_KEI_UCWK | Table | Service contract work detail table — stores sub-detail records for service contracts |
| KK_T_SVKEIUW_EOH_TEL | Table | eo optical telephone service detail table — stores telephone number and related data for eo services |
| KK_T_KAISEN_TG_SVKEI | Table | Contract routing detail table — stores routing information for contract changes |
| KK_T_KKTK_SVC_KEI | Table | Transfer-related contract table — stores contracts involved in company transfers |
| callSvcInter | Method | Service component inter-call — generic method to invoke a CBS (Common Business Service) with session handle, parameter, request map, and fixed text |
| editInMsgEKK*.**** | Method | Input message mapper — prepares the request HashMap for a CBS call by setting schema-specific parameters from the IRequestParameterReadWrite object |
| EJB | Acronym | Enterprise JavaBean — the application server technology used for this business logic component |
| CBS | Acronym | Common Business Service — the shared service layer that handles database operations via SQL facility |
| CAANMsg | Type | CAAN message container — generic message wrapper used for CBS request/response data exchange |
| Port-out | Business term | Port-out — Number portability process where a customer transfers their phone number to a different provider (FTTH) |
| Inter-company transfer | Business term | Shigya-saikan Iten — Transfer of service between different telecom providers (other company phone number) |
| ENUM | Acronym | ENUM switch — the enum-based routing component that dispatches service orders to appropriate handlers |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity used in port-out processing |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service |
