# Business Logic — JCKCustAddBnktUpdCC.isExistSeikyOpSvcKei() [76 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JCKCustAddBnktUpdCC` |
| Layer | Common Component (CC) — shared business logic utility |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JCKCustAddBnktUpdCC.isExistSeikyOpSvcKei()

This method performs an **existence check for invoice-option service contracts** (請求オプションサービス契約存在チェック). It queries the EKK0441B002 CBS (Invoice-Option Service Contract Batch Inquiry — Combined Search) to retrieve a list of service contracts associated with a given billing classification number (`mtSeikyKeiNo`). The method then filters the results through two exclusion rules — skipping contracts in DSL-terminated (910) or cancelled (920) status, and skipping NHK group unified contracts (payment code E02 with plan code PE0201) — before mapping relevant fields (service contract number, status, and service charge start date) back into the work area map.

The method implements a **query-then-filter routing pattern**: it delegates data retrieval to the `callSC` service component method, then applies business-rule-based filtering in a loop, setting a boolean flag (`existFlg`) to `true` if any qualifying contract record exists. Its role in the larger system is as a shared common component (CC) utility, called exclusively by `execDslSeikyOpSvcKei()` during the processing flow for DSL-related customer addition/updates. It acts as a guard/routing method — the caller checks the returned boolean to determine subsequent processing behavior (e.g., whether to proceed with DSL-specific logic).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["isExistSeikyOpSvcKei(params)"])
    STEP1["Get workMap from param.getMappingWorkArea()"]
    STEP2["Get workDataMap from workMap.get(WORK)"]
    STEP3["Build ekk0441b002inMsg with TEMPLATE_ID, FUNC_CD=1, KEY_SEIKY_KEI_NO"]
    STEP4["Call callSC(handle, scCall, param, fixedText, ekk0441b002inMsg)"]
    STEP5["Extract CAANMsg[] from response.getCAANMsgList(EKK0441B002CBSMSG1LIST)"]
    STEP6["existFlg = false"]
    STEP7{"outMsg != null
&& length > 0"}
    STEP8["Loop: i from 0 to length-1"]
    STEP9["Get seiopsvcKeiStat from response[i].getString(SEIOPSVC_KEI_STAT)"]
    STEP10{"seiopsvcKeiStat equals
SEIOP_SVC_KEI_STAT_DSL_ZM = \"910\" (DSL terminated)
OR
SEIOP_SVC_KEI_STAT_CANCEL_ZM = \"920\" (cancelled)"}
    STEP10_SKIP["continue — skip this record"]
    STEP11["Get seiopsvcKeiPcrs from response[i].getString(PCRS_CD)"]
    STEP12["Get seiopsvcKeiPplan from response[i].getString(PPLAN_CD)"]
    STEP13{"seiopsvcKeiPcrs equals
SEIOP_SVC_KEI_PCRS_CD_NHK = \"E02\" (NHK group contract)
AND
seiopsvcKeiPplan equals
SEIOP_SVC_KEI_PPLAN_CD_NHK = \"PE0201\" (NHK group plan)"}
    STEP13_SKIP["continue — skip this record"]
    STEP14{"isNonNull(SEIOPSVC_KEI_NO)"}
    STEP15["workDataMap.put(seiopsvc_kei_no)
existFlg = true"]
    STEP16{"isNonNull(SEIOPSVC_KEI_STAT)"}
    STEP17["workDataMap.put(seiopsvc_kei_stat)"]
    STEP18{"isNonNull(SVC_CHRG_STAYMD)"}
    STEP19["workDataMap.put(svc_chrg_staymd)"]
    STEP20["i++"]
    STEP21{"i < length"}
    STEP22["workMap.put(WORK, workDataMap)"]
    STEP23["param.setMappingWorkArea(workMap)"]
    STEP24["Return existFlg"]

    START --> STEP1 --> STEP2 --> STEP3 --> STEP4 --> STEP5 --> STEP6 --> STEP7
    STEP7 -->|yes| STEP8
    STEP7 -->|no| STEP22
    STEP8 --> STEP9
    STEP9 --> STEP10
    STEP10 -->|true| STEP10_SKIP --> STEP20
    STEP10 -->|false| STEP11
    STEP11 --> STEP12
    STEP12 --> STEP13
    STEP13 -->|true| STEP13_SKIP --> STEP20
    STEP13 -->|false| STEP14
    STEP14 -->|true| STEP15
    STEP14 -->|false| STEP16
    STEP15 --> STEP16
    STEP16 -->|true| STEP17
    STEP16 -->|false| STEP18
    STEP17 --> STEP18
    STEP18 -->|true| STEP19
    STEP18 -->|false| STEP20
    STEP19 --> STEP20
    STEP20 --> STEP21
    STEP21 -->|true| STEP9
    STEP21 -->|false| STEP22
    STEP22 --> STEP23 --> STEP24 --> END(["Return boolean"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database/session handle used for CBS (Service Component) invocations. Carries the runtime transaction context (connection, user, transaction boundaries). |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object that carries both input parameters and a work area (`Map`) for internal data passing between processing steps. The `getMappingWorkArea()` and `setMappingWorkArea()` methods provide read/write access to the work map shared across the processing pipeline. |
| 3 | `scCall` | `ServiceComponentRequestInvoker` | Service component invocation invoker used to dispatch CBS (Service Component) calls such as the EKK0441B002 inquiry. Carries the invocation context for the Fujitura middleware. |
| 4 | `fixedText` | `String` | A text identifier used for message/error correlation. Passed through to `callSC` for log correlation and error message grouping. |
| 5 | `mtSeikyKeiNo` | `String` | Billing classification number (請求区分番号) — the key used to look up invoice-option service contracts. This value maps to `KEY_SEIKY_KEI_NO` in the EKK0441B002 CBS input and serves as the primary filter criterion for the contract inquiry. |

**External state / instance fields read:**
- None — this method is fully stateless with respect to instance fields. All data comes through parameters.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `callSC` | EKK0441B002 | KK_T_SEIOP_SVC_KEI ( Invoice-Option Service Contract table) | Calls `callSC` to invoke the EKK0441B002 CBS — combined inquiry of invoice-option service contracts filtered by billing classification number (`KEY_SEIKY_KEI_NO`). Returns a `CAANMsg[]` array containing the matched contract records. |
| R | `CAANMsg.getString` (SEIOPSVC_KEI_STAT) | EKK0441B002 | — | Reads the service contract status field from the CBS response. Used to filter out DSL-terminated (910) and cancelled (920) contracts. |
| R | `CAANMsg.getString` (PCRS_CD) | EKK0441B002 | — | Reads the payment service code from the CBS response. Used to identify NHK group contracts (E02). |
| R | `CAANMsg.getString` (PPLAN_CD) | EKK0441B002 | — | Reads the payment plan code from the CBS response. Combined with PCRS_CD to identify NHK group unified plans (PE0201). |
| R | `CAANMsg.getString` (SEIOPSVC_KEI_NO) | EKK0441B002 | — | Reads the invoice-option service contract number. Mapped to `seiopsvc_kei_no` in the work data map if present. |
| R | `CAANMsg.getString` (SEIOPSVC_KEI_STAT) | EKK0441B002 | — | Reads the invoice-option service contract status. Mapped to `seiopsvc_kei_stat` in the work data map if present. |
| R | `CAANMsg.getString` (SVC_CHRG_STAYMD) | EKK0441B002 | — | Reads the service charge start date (YYYYMMDD format). Mapped to `svc_chrg_staymd` in the work data map if present. |
| - | `CAANMsg.isNull` | EKK0441B002 | — | Checks whether individual fields in the CBS response are null. Used as a guard before writing values to the work data map. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC: JCKCustAddBnktUpdCC | `execDslSeikyOpSvcKei()` -> `isExistSeikyOpSvcKei(handle, param, scCall, fixedText, mtSeikyKeiNo)` | `callSC [R] EKK0441B002 (Invoice-Option Service Contract Inquiry)`, `getString [R] SEIOPSVC_KEI_STAT, PCRS_CD, PPLAN_CD, SEIOPSVC_KEI_NO, SVC_CHRG_STAYMD` |

**No screen or batch entry points** were found within 8 hops. The direct caller is exclusively the `execDslSeikyOpSvcKei()` method within `JCKCustAddBnktUpdCC`, which is itself a common component method called during DSL-related customer addition/update processing.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Work area extraction (L2289–L2293)

> Extracts the work area map and its sub-map from the request parameter object.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap = param.getMappingWorkArea()` // Retrieves the mapping work area map |
| 2 | SET | `workDataMap = (HashMap)workMap.get("WORK")` // Gets the WORK sub-map [-> KEY="WORK"] |

**Block 2** — [SET] Input message construction for CBS (L2296–L2302)

> Builds the input message for the EKK0441B002 CBS (Invoice-Option Service Contract Batch Inquiry — Combined Search). Sets the template ID, function code, and billing classification number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0441b002inMsg[][] = { {TEMPLATEID, "EKK0441B002"}, {FUNC_CODE, FUNC_CD_1 = "1"}, {KEY_SEIKY_KEI_NO, mtSeikyKeiNo} }` |

**Block 3** — [CALL] CBS invocation (L2305–L2306)

> Calls `callSC` to execute the EKK0441B002 CBS and extracts the result list from the response.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `ekk0441b002outMsg = callSC(handle, scCall, param, fixedText, ekk0441b002inMsg).getCAANMsgList(EKK0441B002CBSMSG1LIST)` // Queries invoice-option service contracts |

**Block 4** — [SET] Initialize flag (L2308)

| # | Type | Code |
|---|------|------|
| 1 | SET | `existFlg = false` // Default: no matching contract found |

**Block 5** — [IF-ELSE] Null/empty check on CBS response (L2310)

> If the CBS returns null or an empty array, skip the loop entirely and return `false`.

| # | Type | Code |
|---|------|------|
| 1 | IF-ELSE | `if (ekk0441b002outMsg != null && ekk0441b002outMsg.length > 0)` |

**Block 6** — [FOR] Iterate over CBS response records (L2313–L2343)

> Loops through each invoice-option service contract record returned by the CBS.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` // Loop index initialization |
| 2 | IF | `for (i=0; i < ekk0441b002outMsg.length; i++)` |

**Block 6.1** — [IF] Skip DSL-terminated and cancelled contracts (L2315–L2319)

> Filters out records where the service contract status is "DSL terminated" (910) or "cancelled" (920). These are non-active contract states and should not count as existing contracts.

| # | Type | Code |
|---|------|------|
| 1 | SET | `seiopsvcKeiStat = ekk0441b002outMsg[i].getString(SEIOPSVC_KEI_STAT)` // Gets status from response |
| 2 | IF-ELSE | `if (SEIOP_SVC_KEI_STAT_DSL_ZM = "910".equals(seiopsvcKeiStat) || SEIOP_SVC_KEI_STAT_CANCEL_ZM = "920".equals(seiopsvcKeiStat))` |
| 3 | EXEC | `continue` // Skip this record — DSL terminated or cancelled |

**Block 6.2** — [IF] Skip NHK group unified contracts (L2322–L2330, ANK-2248-00-00)

> Reads the payment service code and payment plan code, and skips records where both correspond to the NHK group unified contract (E02 + PE0201). This is a special exclusion added for ANK-2248-00-00 — NHK group contracts are handled by a separate flow and should not be counted here.

| # | Type | Code |
|---|------|------|
| 1 | SET | `seiopsvcKeiPcrs = ekk0441b002outMsg[i].getString(PCRS_CD)` // Gets payment service code [ANK-2248-00-00 ADD] |
| 2 | SET | `seiopsvcKeiPplan = ekk0441b002outMsg[i].getString(PPLAN_CD)` // Gets payment plan code [ANK-2248-00-00 ADD] |
| 3 | IF-ELSE | `if (SEIOP_SVC_KEI_PCRS_CD_NHK = "E02".equals(seiopsvcKeiPcrs) && SEIOP_SVC_KEI_PPLAN_CD_NHK = "PE0201".equals(seiopsvcKeiPplan))` |
| 4 | EXEC | `continue` // Skip this record — NHK group unified contract |

**Block 6.3** — [IF] Map service contract number (L2333–L2337)

> If the SEIOPSVC_KEI_NO field is not null, write it to the work data map and set the existence flag to true. This is the primary determination point — at least one non-null contract number means a contract exists.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (!ekk0441b002outMsg[i].isNull(SEIOPSVC_KEI_NO))` |
| 2 | SET | `workDataMap.put("seiopsvc_kei_no", ekk0441b002outMsg[i].getString(SEIOPSVC_KEI_NO))` // Map contract number to work area |
| 3 | SET | `existFlg = true` // Flag set: at least one contract exists |

**Block 6.4** — [IF] Map service contract status (L2340–L2343)

> If the SEIOPSVC_KEI_STAT field is not null, write it to the work data map for downstream use.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (!ekk0441b002outMsg[i].isNull(SEIOPSVC_KEI_STAT))` |
| 2 | SET | `workDataMap.put("seiopsvc_kei_stat", ekk0441b002outMsg[i].getString(SEIOPSVC_KEI_STAT))` // Map status to work area |

**Block 6.5** — [IF] Map service charge start date (L2346–L2349)

> If the SVC_CHRG_STAYMD field is not null, write it to the work data map for downstream use.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (!ekk0441b002outMsg[i].isNull(SVC_CHRG_STAYMD))` |
| 2 | SET | `workDataMap.put("svc_chrg_staymd", ekk0441b002outMsg[i].getString(SVC_CHRG_STAYMD))` // Map charge start date to work area |

**Block 7** — [EXEC] Persist updated work area (L2352–L2353)

> Writes the updated work data map back into the work map, then sets the work map back into the parameter object.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `workMap.put("WORK", workDataMap)` // Updates the WORK sub-map |
| 2 | EXEC | `param.setMappingWorkArea(workMap)` // Persists work area back to parameter |

**Block 8** — [RETURN] Return existence flag (L2355)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return existFlg` // true if any qualifying contract record was found |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `seiopsvc_kei_no` | Field | Invoice-option service contract number — the unique identifier for an invoice-option service contract line item |
| `seiopsvc_kei_stat` | Field | Invoice-option service contract status — indicates the current lifecycle state of the service contract |
| `svc_chrg_staymd` | Field | Service charge start date (YYYYMMDD) — the date from which the service charge begins to apply |
| `mtSeikyKeiNo` | Field | Billing classification number — the key used to look up invoice-option service contracts for a given billing class |
| `SEIOP_SVC_KEI_STAT_DSL_ZM` | Constant | Service contract status = "910" (DSL terminated) — indicates a DSL (Fiber-to-the-Home) service contract that has been terminated |
| `SEIOP_SVC_KEI_STAT_CANCEL_ZM` | Constant | Service contract status = "920" (cancelled) — indicates a service contract that has been cancelled |
| `SEIOP_SVC_KEI_STAT_UK_ZM` | Constant | Service contract status = "010" (accepted) — indicates a service contract that has been accepted |
| `SEIOP_SVC_KEI_STAT_SHOSA_ZM` | Constant | Service contract status = "020" (under review) — indicates a service contract that is being reviewed |
| `SEIOP_SVC_KEI_PCRS_CD_NHK` | Constant | Payment service code = "E02" — indicates an NHK group unified contract (NHK broadcasting fee bundled service) |
| `SEIOP_SVC_KEI_PPLAN_CD_NHK` | Constant | Payment plan code = "PE0201" — indicates the NHK group unified contract plan |
| `FUNC_CD_1` | Constant | Function code = "1" — the request type for the CBS, indicating an inquiry/add operation |
| `EKK0441B002` | CBS Code | Invoice-Option Service Contract Batch Inquiry (Combined Search) — a CBS that retrieves invoice-option service contract records |
| CBS | Acronym | Component Business Service — the enterprise middleware service invocation layer |
| CC | Acronym | Common Component — shared business logic class used across screens and processes |
| SC | Acronym | Service Component — the underlying service that performs data access and business processing |
| NHK | Business term | Nippon Hoso Kyokai (Japan Broadcasting Corporation) — national public broadcaster; NHK group contracts are a special bundled service category |
| DSL | Business term | Digital Subscriber Line — broadband internet over telephone lines (FTTH — Fiber To The Home) |
| CAANMsg | Type | Fujitsu's enterprise message object used for CBS input/output data exchange |
| Work Area | Concept | A shared HashMap used across the processing pipeline to pass data between methods without explicit parameter passing |
