# Business Logic — JZMEnumSwitchCC.interCompany_OPTtelno() [51 LOC]

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

## 1. Role

### JZMEnumSwitchCC.interCompany_OPTtelno()

This method implements the **Inter-company Transfer (OPT Phone Number)** processing workflow, which handles the ENUM (E.164 Number Mapping) service number porting between telecom carriers. In the Japanese telecom domain, OPT (OPtion) refers to the phone number portability system allowing customers to retain their phone numbers when switching service providers.

The method implements a **gate-then-execute** design pattern. It first performs three sequential validation checks — service contract status, phone number status, and aging (hold agreement) status — and returns early with a specific error code if any check fails. Only when all validations pass does it proceed to the core transactional processing: issuing the ENUM deletion and registration Service Order Data (SOD), updating port acceptance information, and updating the phone number master.

This method serves as a **shared utility** called by `JZMEnumSwitchCC.enumSwitch()`, which is the main ENUM switch routing dispatcher. The `enumSwitch` method determines the application content flag (`SINSEI_NAIYO_FLG_2`) and dispatches to this method for the inter-company transfer scenario. This design centralizes all validation and business logic for OPT phone number porting in one place, ensuring consistent behavior regardless of the calling screen.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["interCompany_OPTtelno start"])
    START --> LOG_START["printlnEjbLog start"]

    LOG_START --> CHECK_SVC["serviceKeiStatCheck"]
    CHECK_SVC --> SVC_COND{service check passed?}

    SVC_COND --> |false| SET_ERR2001["inMap.put(ERR_FLG, 2001)"]
    SET_ERR2001 --> RET_PARAM["param.setData; return param"]

    SVC_COND --> |true| CHECK_TELNO["telnoStatJudge handle=02"]
    CHECK_TELNO --> TELNO_COND{telno status passed?}

    TELNO_COND --> |false| CHECK_NOT_JUDGE{NOT_JUDGE = 1?}
    CHECK_NOT_JUDGE --> |true| SET_ERR0002["inMap.put(ERR_FLG, 0002)"]
    SET_ERR0002 --> RET_PARAM

    CHECK_NOT_JUDGE --> |false| SET_ERR2002["inMap.put(ERR_FLG, 2002)"]
    SET_ERR2002 --> RET_PARAM

    TELNO_COND --> |true| CHECK_AGING["agingStatCheck expectedStat=100"]
    CHECK_AGING --> AGING_COND{aging status passed?}

    AGING_COND --> |false| SET_ERR2003["inMap.put(ERR_FLG, 2003)"]
    SET_ERR2003 --> RET_PARAM

    AGING_COND --> |true| CALL_SOD["callJKKHakkoSODCC"]
    CALL_SOD --> CALL_ETU["callETU0151C010"]
    CALL_ETU --> CALL_EZM["callEZM0121C010"]
    CALL_EZM --> LOG_END["printlnEjbLog end"]
    LOG_END --> RET_END["return param"]
```

**Validation Branch Summary:**

| Check | Fails With | Business Meaning |
|-------|-----------|-----------------|
| Service contract status | Error 2001 | Service contract already exists (service status SIF returns 010-220 range) |
| Phone number status + `NOT_JUDGE = "1"` | Error 0002 | Phone number status judgment target is outside scope (excluded from judgment) |
| Phone number status + `NOT_JUDGE = "0"` (default) | Error 2002 | Not within port authorization period |
| Aging status check | Error 2003 | Aging number is null/empty, or aging agreement status is not "In Use" (100) |

**Execution Phase:**
All three validations pass -> process the ENUM transfer:
1. Issue ENUM deletion SOD (terminate port authorization) and ENUM registration SOD (start port authorization)
2. Update port acceptance information: update the cut-over SOD issuance timestamp and set port acceptance status to "050" (work complete)
3. Update the phone number master

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle for the EJB transaction context. Used by all called service methods to access the database. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter container that holds both control data (return codes, error messages) and user data (via `fixedText` key in a HashMap). On error paths, it receives error mapping via `setData`. On success, it carries the processed result back to the caller. |
| 3 | `fixedText` | `String` | Service message key/identifier used to map fixed text templates and error messages. Passed to `param.setData()` and to all called service methods for error message resolution. |
| 4 | `funcCd` | `String` | Business code (work code) identifying the specific business operation context. Passed to `callETU0151C010` and `callEZM0121C010` for logging and transaction routing purposes. |
| 5 | `inMap` | `HashMap<String, Object>` | Parameter map carrying the request context. Contains the phone number at key `"key_telno"`, the aging number at key `"key_aging_no"`, and serves as the error flag carrier -- on failure, `ERR_FLG` is set with a specific error code (2001, 0002, 2002, or 2003). |

**Instance Fields Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `NOT_JUDGE` | `String` | Judgment exclusion flag. Default value is `"0"`. When set to `"1"`, phone numbers outside the judgment scope return error 0002 instead of 2002. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `serviceKeiStatCheck` | JZMEnumSwitchCC | KK_T_SVC_KEI (service contract table) | Reads service contract status to verify the phone number service is not in active contract status (010-220) |
| R | `telnoStatJudge` | JZMEnumSwitchCC | KK_T_PORTOUT_JCD (port judgment table) | Judges phone number status with filter "02" -- validates the number is within port authorization period |
| R | `agingStatCheck` | JZMEnumSwitchCC | KK_T_AGING (aging hold agreement table) | Checks aging (hold agreement) number status, expecting status "100" (In Use) |
| C | `callJKKHakkoSODCC` | JZMEnumSwitchCC | KK_T_SOD (Service Order Data table) | Issues ENUM deletion SOD (port authorization termination) and ENUM registration SOD (port authorization start) |
| U | `callETU0151C010` | ETU0151C010 | KK_T_PORTOUT (port acceptance info table) | Updates port acceptance information: sets cut-over SOD issuance timestamp and updates status to "050" (work complete) |
| U | `callEZM0121C010` | EZM0121C010 | KK_T_TELNO (phone number master table) | Updates the phone number master record for the OPT transfer |
| - | `printlnEjbLog` | JZMEnumSwitchCC | - | EJB log output for audit/debugging (start/end markers) |
| U | `JBSbatAKKshkmRsltInfoTukiawsday.setData` | JBSbatAKKshkmRsltInfoTukiawsday | - | Sets data in result info structure (called internally during service processing) |
| U | `JBSbatAKKshkmRsltInfoTukiaws.setData` | JBSbatAKKshkmRsltInfoTukiaws | - | Sets data in result info structure (called internally during service processing) |
| U | `JBSbatAKKshkmRsltInfoTukiawsRealSkh.setData` | JBSbatAKKshkmRsltInfoTukiawsRealSkh | - | Sets data in result info structure (called internally during service processing) |
| U | `JBSbatAKKshkmRsltInfTkCvsNCnsl.setData` | JBSbatAKKshkmRsltInfTkCvsNCnsl | - | Sets data in result info structure (called internally during service processing) |
| U | `JBSbatKKGetCTITelno.setData` | JBSbatKKGetCTITelno | - | Sets data in result info structure (called internally during service processing) |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `printlnEjbLog` [-], `callEZM0121C010` [-], `callETU0151C010` [-], `callJKKHakkoSODCC` [-], `setData` [-], `setData` [-], `setData` [-], `setData` [-], `setData` [-], `agingStatCheck` [-], `setData` [-], `setData` [-], `setData` [-], `setData` [-], `setData` [-], `setData` [-], `setData` [-], `setData` [-], `setData` [-], `setData` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class: JZMEnumSwitchCC.enumSwitch | `enumSwitch` -> `interCompany_OPTtelno` | `callJKKHakkoSODCC [C] KK_T_SOD`, `callETU0151C010 [U] KK_T_PORTOUT`, `callEZM0121C010 [U] KK_T_TELNO` |

## 6. Per-Branch Detail Blocks

**Block 1** -- [LOG] (L385)

> Logs the start of the inter-company OPT phone number processing method.

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

**Block 2** -- [IF: service contract status check] `serviceKeiStatCheck` (L390)

> Validates that the phone number's service contract status is not in active contract range (010-220). If a service contract exists, this is an error and the method returns early with error flag 2001.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `serviceKeiStatCheck(handle, param, fixedText, (String) inMap.get(JZMEnumSwitchConstCC.KEY_TELNO))` |-> `KEY_TELNO = "key_telno"` |
| 2 | IF | `if (!serviceKeiStatCheck(...))` -- service check fails |

**Block 2.1** -- [nested error handling: service contract exists] (L393)

> Error 2001 -- "Existing contract data error" for inter-company transfer. Sets error flag and returns via the SIF that returns status 010-220.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(JZMEnumSwitchConstCC.ERR_FLG, JZMEnumSwitchConstCC.ENUMCC_ERR_FLG_2001)` |-> `ERR_FLG = "ERR_FLG"`, `ENUMCC_ERR_FLG_2001 = "2001"` |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

**Block 3** -- [IF: phone number status check] `telnoStatJudge` with filter "02" (L398)

> Validates the phone number status using the judgment filter `TELNOSTATJUDGE_02 = "02"`. If the status check fails, further analysis depends on the `NOT_JUDGE` flag to determine which error code to return.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `telnoStatJudge(handle, param, (String) inMap.get(JZMEnumSwitchConstCC.KEY_TELNO), TELNOSTATJUDGE_02)` |-> `TELNOSTATJUDGE_02 = "02"` |
| 2 | IF | `if (!telnoStatJudge(...))` -- status check fails |

**Block 3.1** -- [nested IF: NOT_JUDGE exclusion check] `NOT_JUDGE = "1"` (L400)

> If the instance field `NOT_JUDGE` is `"1"`, the phone number is determined to be outside the judgment target. Returns error 0002 -- indicating the number is excluded from phone number status judgment.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"1".equals(this.NOT_JUDGE)` |-> `NOT_JUDGE = "0"` (default value) |

**Block 3.1.1** -- [nested error: judgment excluded] (L403)

> Error 0002 -- "Phone number status judgment target is outside scope". This applies when `NOT_JUDGE` is explicitly set to "1", indicating the number should not be subject to status judgment.

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

**Block 3.2** -- [nested error: not within port authorization] (L405)

> Error 2002 -- "Not within port authorization error" for inter-company transfer. Applies when `NOT_JUDGE` is not "1" (default "0") and the phone number status check fails -- meaning the number is not within the valid port authorization window.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(JZMEnumSwitchConstCC.ERR_FLG, JZMEnumSwitchConstCC.ENUMCC_ERR_FLG_2002)` |-> `ENUMCC_ERR_FLG_2002 = "2002"` |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

**Block 4** -- [IF: aging status check] `agingStatCheck` (L412)

> Validates the aging (hold agreement) number status. Expects status `"100"` (In Use). If the aging number key is null/empty, it is treated as "no aging scheme data" and triggers an error. If the aging number exists but its status is not "100" (In Use), it also triggers an error.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `agingStatCheck(handle, param, fixedText, (String) inMap.get(JZMEnumSwitchConstCC.KEY_AGING_NO), JZMEnumSwitchConstCC.AGING_STAT_100)` |-> `KEY_AGING_NO = "key_aging_no"`, `AGING_STAT_100 = "100"` |
| 2 | IF | `if (!agingStatCheck(...))` -- aging check fails |

**Block 4.1** -- [nested error handling: aging status invalid] (L416)

> Error 2003 -- "Aging status is not In Use error" for inter-company transfer. Covers two cases: (a) aging number key is null or empty (no aging scheme), and (b) aging number exists but its status is not "100" (In Use).

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(JZMEnumSwitchConstCC.ERR_FLG, JZMEnumSwitchConstCC.ENUMCC_ERR_FLG_2003)` |-> `ENUMCC_ERR_FLG_2003 = "2003"` |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

**Block 5** -- [EXEC: ENUM SOD issuance] (L423)

> Issues both the ENUM deletion SOD (to terminate port authorization at the original carrier) and the ENUM registration SOD (to start port authorization at the receiving carrier). This is the core ENUM transfer transaction.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callJKKHakkoSODCC(handle, param, fixedText)` |

**Block 6** -- [EXEC: port acceptance info update] (L426)

> Updates the port acceptance information: sets the cut-over SOD issuance date-time and updates the port acceptance status to `"050"` (work complete / construction finished).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callETU0151C010(handle, param, fixedText, funcCd)` |

**Block 7** -- [EXEC: phone number master update] (L429)

> Updates the phone number master record to reflect the inter-company transfer.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEZM0121C010(handle, param, fixedText, funcCd)` |

**Block 8** -- [LOG + RETURN: completion] (L431-434)

> Logs the end of processing and returns the parameter container with the processed result.

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KEY_TELNO` | Constant | Phone number map key (`"key_telno"`) -- the customer's phone number used as the primary identifier for ENUM transfer processing |
| `KEY_AGING_NO` | Constant | Aging number map key (`"key_aging_no"`) -- the aging/hold agreement number associated with the service contract |
| `ERR_FLG` | Constant | Error flag map key (`"ERR_FLG"`) -- the map key used to store error classification codes |
| `AGING_STAT_100` | Constant | Aging status "In Use" (`"100"`) -- the expected status indicating the aging agreement is active and in use |
| `AGING_STAT_200` | Constant | Aging status "Recoverable" (`"200"`) -- the aging agreement can be restored/recovered |
| `AGING_STAT_300` | Constant | Aging status "In Aging" (`"300"`) -- the aging agreement is currently in progress |
| `TELNOSTATJUDGE_02` | Constant | Phone number status judgment filter `"02"` -- the specific judgment criteria applied during port authorization validation |
| `NOT_JUDGE` | Field | Judgment exclusion flag (`"0"` default) -- when set to `"1"`, phone numbers excluded from judgment return error 0002 instead of 2002 |
| `SINSEI_NAIYO_FLG_2` | Constant | Application content flag `"2"` -- identifies this processing path as "Inter-company Transfer (OPT Phone Number)" |
| `ENUMCC_ERR_FLG_2001` | Constant | Error code `"2001"` -- Existing contract data error for inter-company transfer; service contract status is in the 010-220 range (SIF range) |
| `ENUMCC_ERR_FLG_2002` | Constant | Error code `"2002"` -- Not within port authorization error for inter-company transfer; the phone number is not in the valid port authorization window |
| `ENUMCC_ERR_FLG_2003` | Constant | Error code `"2003"` -- Aging status is not In Use error for inter-company transfer; the aging agreement number is null, empty, or has a status other than "100" (In Use) |
| `ENUMCC_ERR_FLG_0002` | Constant | Error code `"0002"` -- Phone number status judgment target is outside scope; the number is excluded from status judgment |
| OPT | Business term | OPtion -- Japanese phone number portability system allowing customers to retain their phone numbers when switching carriers |
| ENUM | Business term | E.164 Number Mapping -- a telecom database system that maps traditional phone numbers (E.164 format) to IP-based routing information, enabling number portability in VoIP networks |
| SOD | Acronym | Service Order Data -- the telecom order fulfillment entity/document that triggers operational changes such as ENUM registration, deletion, or status updates |
| Aging | Business term | Aging (hold agreement) -- a contractual hold or reservation on a phone number, typically used during carrier transitions to ensure the number is reserved while porting is processed |
| Port Authorization | Business term | The legal/administrative authorization period during which a customer's phone number can be transferred between carriers |
| `funcCd` | Field | Business code / work code -- identifies the specific business operation context for transaction routing and logging |
| `fixedText` | Field | Service message key -- used to resolve fixed text templates and error message mappings across the application |
| `param` | Field | Request parameter container -- holds both control data (return codes, error messages) and user data for screen-to-backend communication |
| KK_T_SVC_KEI | DB Entity | Service contract table -- stores service contract information including status codes |
| KK_T_PORTOUT | DB Entity | Port acceptance information table -- stores port authorization acceptance data including status ("050" = work complete) |
| KK_T_TELNO | DB Entity | Phone number master table -- stores the authoritative phone number records |
| KK_T_SOD | DB Entity | Service Order Data table -- stores SOD records for service activation/deactivation operations |
| KK_T_AGING | DB Entity | Aging hold agreement table -- stores aging agreement records including status codes |
| KK_T_PORTOUT_JCD | DB Entity | Port judgment table -- stores phone number port judgment data used by `telnoStatJudge` |
| JZMEnumSwitchCC | Class | ENUM Switch Common Component -- the central ENUM service switching/dispatching component handling all ENUM-related operations |
| eo customer core system | Business term | eo Customer Core System -- Fujitsu's customer management system for K-Opticom's eo telecom services |
