# Business Logic — JZMEnumSwitchCC.portOut_OPTtelno_Cancel() [53 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JZMEnumSwitchCC` |
| Layer | CC/Common Component (Business logic routing and dispatch class) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JZMEnumSwitchCC.portOut_OPTtelno_Cancel()

This method implements the **Port-Out (OPT Phone Number) Cancellation** business operation within the ENUM switch subsystem of the K-Opticom customer core system. It handles the cancellation (withdrawal) of a previously initiated port-out request for an OPT phone number, effectively undoing a number-port-out process before it completes. The method acts as a **dispatching common component (CC)** called by the central ENUM switch router (`enumSwitch`), specifically triggered when the application request flag (`key_sinsei_naiyo_flg`) is set to `"5"` (Port-Out OPT Phone Number - Cancellation).

The method implements a **three-phase guard-check pattern**: it validates (1) that no active contract data exists for the phone number, (2) that the phone number is genuinely in a "port-out in progress" state, and (3) that the aging key (equipment tracking key) is in the "in use" status. Only when all three checks pass does it proceed to execute the cancellation workflow, which issues an ENUM deletion Service Order Data (SOD) and updates the port-out receipt status, phone number master, and aging key status records. If any check fails, the method sets a specific error flag (ERR_FLG) on the input map and returns immediately, allowing the caller to handle the error appropriately.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["portOut_OPTtelno_Cancel"])
    LOG1["printlnEjbLog: start"]
    START --> LOG1
    LOG1 --> CHK1["serviceKeiStatCheck"]
    CHK1 -->|true| CHK2["telnoStatJudge
TELNOSTATJUDGE_02 = 02"]
    CHK1 -->|false| ERR1["inMap.put ERR_FLG, ENUMCC_ERR_FLG_5001
param.setData(fixedText, inMap)
return param"]
    CHK2 -->|true| CHK3["agingStatCheck
AGING_STAT_100 = 100"]
    CHK2 -->|false| NJS["NOT_JUDGE check
NOT_JUDGE = 1"]
    NJS -->|true| ERR2["inMap.put ERR_FLG, ENUMCC_ERR_FLG_0002
param.setData(fixedText, inMap)
return param"]
    NJS -->|false| ERR3["inMap.put ERR_FLG, ENUMCC_ERR_FLG_5002
param.setData(fixedText, inMap)
return param"]
    CHK3 -->|true| UPD1["callJKKHakkoSODCC
ENUM deletion SOD issuance"]
    CHK3 -->|false| ERR4["inMap.put ERR_FLG, ENUMCC_ERR_FLG_5003
param.setData(fixedText, inMap)
return param"]
    UPD1 --> UPD2["callETU0151C010
Port-out receipt status update"]
    UPD2 --> UPD3["callEZM0121C010
Phone number master update"]
    UPD3 --> UPD4["callEZM0111C010
Aging key status update"]
    UPD4 --> LOG2["printlnEjbLog: end"]
    LOG2 --> END(["return param"])
```

**Constant Resolution Notes:**
- `TELNOSTATJUDGE_02 = "02"` (Port-out NOT in progress check flag)
- `NOT_JUDGE = "0"` (Member field; when `"1"`, the judgment is excluded/skipped)
- `AGING_STAT_100 = "100"` (Aging status: "In Use")
- `ENUMCC_ERR_FLG_5001 = "5001"` — Port-Out Cancellation: existing contract data error
- `ENUMCC_ERR_FLG_0002 = "0002"` — Phone status judgment excluded from scope
- `ENUMCC_ERR_FLG_5002 = "5002"` — Port-Out Cancellation: not in port-out progress error
- `ENUMCC_ERR_FLG_5003 = "5003"` — Port-Out Cancellation: aging status not "In Use" error

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle used for all subsequent service component calls (aging key status check, SOD issuance, master updates). Represents the database connection context for the current transaction. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object that carries business data and error information. Modified via `setData` to propagate error flag and message when validation fails; returned to caller on success. |
| 3 | `fixedText` | `String` | Service message string used as a parameter to `param.setData()` for setting error messages. Provides fixed/error message text to the response. |
| 4 | `funcCd` | `String` | Business code used by update service components (`callETU0151C010`, `callEZM0121C010`, `callEZM0111C010`) to identify the business context of the port-out receipt, phone number master, and aging key updates. |
| 5 | `inMap` | `HashMap<String, Object>` | Parameter map carrying phone number (`key_telno`) and aging number (`key_aging_no`) values used across validation checks, and the error flag (`ERR_FLG`) field where error codes are written on failure. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `this.NOT_JUDGE` | `String` | Flag indicating whether phone status judgment should be skipped. Default is `"0"`. When `"1"`, the judgment exclusion path is taken, returning error code `ENUMCC_ERR_FLG_0002` (judgment excluded from scope) instead of `ENUMCC_ERR_FLG_5002` (not in port-out progress). |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JZMEnumSwitchCC.serviceKeiStatCheck` | - | - | Reads service contract status for the phone number to verify no active contract data exists |
| R | `JZMEnumSwitchCC.telnoStatJudge` | - | - | Reads and validates phone number status to confirm port-out progress state |
| R | `JZMEnumSwitchCC.agingStatCheck` | - | - | Reads aging key status to verify the aging equipment is in "In Use" state |
| C | `JZMEnumSwitchCC.callJKKHakkoSODCC` | JKKHakkoSODCC | - | Issues ENUM deletion SOD (Service Order Data) for port-out termination |
| U | `JZMEnumSwitchCC.callETU0151C010` | ETU0151C010 | - | Updates port-out receipt status to "030" (CSV export completed) and clears the receipt timestamp |
| U | `JZMEnumSwitchCC.callEZM0121C010` | EZM0121C010 | - | Updates the phone number master record |
| U | `JZMEnumSwitchCC.callEZM0111C010` | EZM0111C010 | - | Updates aging key status from "In Use" (100) to "Recoverable" (200) |
| - | `JZMEnumSwitchCC.printlnEjbLog` | - | - | Logs start/end boundary markers to the EJB log for traceability |
| - | `JBSbatAKKshkmRsltInfoTukiawsday.setData` | - | - | Sets result info data for port-out receipt (called internally by `callETU0151C010`) |
| - | `JBSbatAKKshkmRsltInfoTukiaws.setData` | - | - | Sets result info data for port-out processing (called internally by `callJKKHakkoSODCC`) |
| - | `JBSbatAKKshkmRsltInfoTukiawsRealSkh.setData` | - | - | Sets real-time port-out schedule result info (called internally by `callJKKHakkoSODCC`) |
| - | `JBSbatAKKshkmRsltInfTkCvsNCnsl.setData` | - | - | Sets CVS consultation result info (called internally by `callETU0151C010`) |
| - | `JBSbatKKGetCTITelno.setData` | - | - | Sets CTI phone number data (called internally by `callEZM0121C010`) |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JZMEnumSwitchCC.enumSwitch` | `enumSwitch` (central ENUM switch router) -> `portOut_OPTtelno_Cancel` | `printlnEjbLog [-]`, `callEZM0111C010 [U] aging key status`, `callEZM0121C010 [U] phone number master`, `callETU0151C010 [U] port-out receipt status`, `callJKKHakkoSODCC [C] ENUM deletion SOD`, `setData [-]` (multiple result info setters) |

**Call Chain Detail:** The central ENUM switch dispatcher `JZMEnumSwitchCC.enumSwitch()` evaluates the application request flag (`key_sinsei_naiyo_flg`) and routes to `portOut_OPTtelno_Cancel()` when the flag equals `"5"` (Port-Out OPT Phone Number - Cancellation). This is the only known direct caller.

## 6. Per-Branch Detail Blocks

### Block 1 — [LOG] (L557)

> Logs the method start marker to the EJB log for traceability.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printlnEjbLog("JZMEnumSwitchCC:portOut_OPTtelno_Cancel:start")` |

### Block 2 — [IF] (L562) `serviceKeiStatCheck` contract validation

> **Business description:** Validates that no active service contract data exists for the given phone number. If contract data is found (status codes 010-220), this indicates the phone number is still under active contract and port-out cancellation cannot proceed. Sets error flag `ENUMCC_ERR_FLG_5001` and returns immediately. Japanese comment: 「電話番号サービス契約ステータスチェック」(Phone number service contract status check).

| # | Type | Code |
|---|------|------|
| 1 | SET | `result = serviceKeiStatCheck(handle, param, fixedText, inMap.get(KEY_TELNO))` [-> `KEY_TELNO = "key_telno"`] |
| 2 | IF | `if (!result)` (serviceKeiStatCheck returns false) |

#### Block 2.1 — [ELSE] Contract data exists — early return (L564-567)

> Japanese comment: 「サービス契約データがある場合、エラー(ステータスが010~220を取得するSIF)。エラーフラグを持たせて呼出元へ返す。」(When service contract data exists — SIF that obtains status 010-220 — set error flag and return to caller.)

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(ERR_FLG, ENUMCC_ERR_FLG_5001)` [-> `ERR_FLG = "ERR_FLG"`, `ENUMCC_ERR_FLG_5001 = "5001"`] |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

### Block 3 — [IF] (L571) `telnoStatJudge` phone number status check

> **Business description:** Validates that the phone number is genuinely in "port-out in progress" state. Calls `telnoStatJudge` with `TELNOSTATJUDGE_02 = "02"` (port-out NOT in progress flag). If the check fails, further evaluation is needed based on the `NOT_JUDGE` member field. Japanese comment: 「電話番号状態チェック」(Phone number status check).

| # | Type | Code |
|---|------|------|
| 1 | SET | `result = telnoStatJudge(handle, param, inMap.get(KEY_TELNO), TELNOSTATJUDGE_02)` [-> `TELNOSTATJUDGE_02 = "02"`] |
| 2 | IF | `if (!result)` (telnoStatJudge returns false) |

#### Block 3.1 — [IF] (L572) `NOT_JUDGE` exclusion check

> Japanese comment: 「電話番号状態判定：判定対象外の場合、エラーフラグを持たせて呼出元へ返す。」(Phone number status judgment: when excluded from judgment scope, set error flag and return to caller.)

| # | Type | Code |
|---|------|------|
| 1 | SET | `NOT_JUDGE_CHECK = "1".equals(this.NOT_JUDGE)` [-> `NOT_JUDGE = "0"` (default)] |
| 2 | IF | `if ("1".equals(this.NOT_JUDGE))` |

##### Block 3.1.1 — [IF-THEN] Judgment excluded — early return (L574-577)

> Japanese comment: 「電話番号状態判定：判定対象外の場合、エラーフラグを持たせて呼出元へ返す。」(Phone number status judgment: when excluded from judgment scope, set error flag and return to caller.)

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(ERR_FLG, ENUMCC_ERR_FLG_0002)` [-> `ENUMCC_ERR_FLG_0002 = "0002"`] |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

##### Block 3.1.2 — [ELSE-IF] Not port-out in progress — early return (L580-583)

> Japanese comment: 「ポートアウト中でない場合、エラーフラグを持たせて呼出元へ返す。」(When not in port-out progress, set error flag and return to caller.)

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(ERR_FLG, ENUMCC_ERR_FLG_5002)` [-> `ENUMCC_ERR_FLG_5002 = "5002"`] |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

### Block 4 — [IF] (L588) `agingStatCheck` aging status check

> **Business description:** Validates the aging key (equipment tracking key) status. The aging key must be in "In Use" state (`AGING_STAT_100 = "100"`). If the key is null, empty, or in any status other than "In Use", the check fails. Japanese comment: 「エイジングステータスチェック」(Aging status check).

| # | Type | Code |
|---|------|------|
| 1 | SET | `result = agingStatCheck(handle, param, fixedText, inMap.get(KEY_AGING_NO), AGING_STAT_100)` [-> `KEY_AGING_NO = "key_aging_no"`, `AGING_STAT_100 = "100"`] |
| 2 | IF | `if (!result)` (agingStatCheck returns false) |

#### Block 4.1 — [ELSE] Aging status invalid — early return (L590-594)

> Japanese comment: 「Key_エイジング番号がnullまたは、空の場合、エイジングスキーマにデータ無しと判定し、エラーフラグを持たせて呼出元へ返す。Key_エイジング番号がある場合、エイジング一貫照会で取得し、ステータスが使用以外の場合、エラーフラグを持たせて呼出元へ返す。」(When aging key is null or empty, determine that no data exists in the aging schema, set error flag and return to caller. When aging key exists, retrieve via aging consistency check, and if status is not "In Use", set error flag and return to caller.)

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(ERR_FLG, ENUMCC_ERR_FLG_5003)` [-> `ENUMCC_ERR_FLG_5003 = "5003"`] |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

### Block 5 — [UPDATE SEQUENCE] (L598-606)

> **Business description:** All three validation checks passed. Execute the port-out cancellation workflow: issue an ENUM deletion SOD (Service Order Data) to terminate the port-out, then update the port-out receipt status, phone number master, and aging key status records in sequence. Japanese comment: 「発行・更新処理」(Issuance/Update processing).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callJKKHakkoSODCC(handle, param, fixedText)` — Issue ENUM deletion SOD (port-out termination) |
| 2 | CALL | `callETU0151C010(handle, param, fixedText, funcCd)` — Update port-out receipt status to "030" (CSV export completed) and clear timestamp |
| 3 | CALL | `callEZM0121C010(handle, param, fixedText, funcCd)` — Update phone number master |
| 4 | CALL | `callEZM0111C010(handle, param, fixedText, funcCd)` — Update aging key status from "In Use" (100) to "Recoverable" (200) |

### Block 6 — [RETURN] (L607-608)

> Logs the method end marker and returns the processed parameter object.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printlnEjbLog("JZMEnumSwitchCC:portOut_OPTtelno_Cancel:end")` |
| 2 | RETURN | `return param` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| Port-Out | Business term | Number Portability (NP) process — allowing a customer to retain their phone number when switching between telecom operators |
| OPT Phone Number | Business term | OPT-branded telephone number provided by K-Opticom (an ISP/telecom operator in Japan) |
| ENUM | Business term | Electronic Numbering — a telephone numbering plan in which all or most of the numbers in the national telephone numbering plan are allocated to non-telephone uses (e.g., VoIP), enabling telephone numbers to be routed via internet protocols |
| SOD | Acronym | Service Order Data — order data issued through the central order system for service activation, modification, or cancellation |
| ENUM deletion SOD | Business term | A Service Order Data record that signals the deletion/removal of ENUM mappings when a port-out is terminated or cancelled |
| Aging Key | Field | Equipment tracking key (`key_aging_no`) — an internal identifier for telecom equipment/ports assigned to a service line |
| Aging Status | Field | Status of the aging key (equipment port) — `100` = In Use, `200` = Recoverable, `300` = In Aging |
| serviceKeiStatCheck | Method | Service contract status check — verifies whether active contract data exists for a phone number (status codes 010-220 indicate active contracts) |
| telnoStatJudge | Method | Phone number status judgment — validates the port-out progress state of a phone number |
| agingStatCheck | Method | Aging status check — validates that the aging key (equipment port) is in the expected "In Use" status |
| callJKKHakkoSODCC | Method | Call to Service Order Data issuance common component — issues SOD records for ENUM deletion |
| callETU0151C010 | Method | Service component for updating port-out receipt status — sets status to "030" (CSV export completed) and clears the receipt timestamp |
| callEZM0121C010 | Method | Service component for updating the phone number master record |
| callEZM0111C010 | Method | Service component for updating aging key status — transitions from "In Use" (100) to "Recoverable" (200) |
| `key_telno` | Field | Map key for the phone number value — retrieved from `inMap` for validation and update operations |
| `key_aging_no` | Field | Map key for the aging/equipment key number — used by `agingStatCheck` to look up the current aging key status |
| `ERR_FLG` | Field | Error flag field in `inMap` — stores the error code set when validation fails |
| `ENUMCC_ERR_FLG_5001` | Constant | Error code "5001" — Port-Out Cancellation: existing contract data error (phone number still under active contract) |
| `ENUMCC_ERR_FLG_0002` | Constant | Error code "0002" — Phone number status judgment excluded from scope (NOT_JUDGE flag is set) |
| `ENUMCC_ERR_FLG_5002` | Constant | Error code "5002" — Port-Out Cancellation: not in port-out progress error (phone number does not have port-out in progress state) |
| `ENUMCC_ERR_FLG_5003` | Constant | Error code "5003" — Port-Out Cancellation: aging status is not "In Use" error (aging key status is invalid for cancellation) |
| `TELNOSTATJUDGE_02` | Constant | Phone number status judgment flag "02" — checks for "port-out NOT in progress" state |
| `NOT_JUDGE` | Field | Member field default `"0"` — when set to `"1"`, phone number status judgment is excluded from scope |
| `funcCd` | Parameter | Business code — identifies the business context for update operations (receipt status, master updates) |
| `fixedText` | Parameter | Service message string — passed to `param.setData()` for error message propagation |
| K-Opticom | Business term | Japanese internet/telecom service provider (the system owner) |
| CSV export completed | Business term | Port-out receipt status "030" indicating the CSV data export process has finished |
| Recoverable | Business term | Aging key status "200" — equipment/port is no longer in use and can be reassigned |
