# Business Logic — FUW03501SFLogic.chkServiceIfError() [56 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW03501SF.FUW03501SFLogic` |
| Layer | Service Logic (Webview — Business Logic Layer) |
| Module | `FUW03501SF` (Package: `eo.web.webview.FUW03501SF`) |

## 1. Role

### FUW03501SFLogic.chkServiceIfError()

This method serves as the **service IF related-check error handler** for the Digital Add-On Service Application screen (FUW03501SF). It receives a `JCCWebServiceException` — which carries structured validation results returned from upstream service interface (SC/CBS) checks — and translates those raw error signals into user-facing business exceptions with precise error categorization. The method operates as a **dispatch pattern**: it inspects the combination of template ID, error flag, and item ID embedded in the exception's more-info payload, then routes to the appropriate `JCCBusinessException` throw based on the specific failure scenario. Four distinct error scenarios are handled: (1) **Contract Error** when the Option Service Contract count exceeds the allowed limit for Digital Add-On connections; (2) **Usage Restriction Error** when the Plan Start Date (or Digital Add-On Change Application Period) falls before the operational date; and (3) **Update Restriction Error** when Option Service Contract Number and Service Cost Code are set while the Option Service Code indicates a Digital Add-On connection context. Any error combination not matching these four explicit branches falls through to a generic System Error. The method is called directly from `cfm()` (the confirm/preview screen processing) and `mskm()` (the mask/screen processing), meaning it protects the application workflow from invalid service states before data submission.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["chkServiceIfError(se: JCCWebServiceException)"])
    EXTRACT["Extract message info from se"]
    EXTRACT2["Get moreInfo[0]"]
    EXTRACT3["templateid = getTemplateId()"]
    EXTRACT4["itemid = getItemId()"]
    EXTRACT5["status = getStatus()"]
    EXTRACT6["errFlg = getItemCheckErr()"]
    COND1{"status == RELATION_ERR"}
    COND2{"templateid == EKK0361D010"}
    COND3{"errFlg == EG"}
    COND4{"itemid == op_svc_cd"}
    THROW1["throw JCCBusinessException(ERROR_CODE_0102) Contract Error"]
    COND5{"templateid == EKK0351C120"}
    COND6{"errFlg == EC"}
    COND7{"itemid == op_svc_kei_no"}
    THROW2["throw JCCBusinessException(ERROR_CODE_0102) Contract Error"]
    COND8{"templateid == EKK0351C120"}
    COND9{"errFlg == EA"}
    COND10{"itemid == plan_staymd"}
    THROW3["throw JCCBusinessException(ERROR_CODE_0101) Usage Restriction Error"]
    COND11{"templateid == EKK0351C120"}
    COND12{"errFlg == EE"}
    COND13{"itemid == pcrs_cd"}
    THROW4["throw JCCBusinessException(ERROR_CODE_0204) Update Restriction Error"]
    THROW5["throw JCCBusinessException(ERROR_CODE_0002) System Error"]
    ELSE_BRANCH["else branch - System Error"]

    START --> EXTRACT
    EXTRACT --> EXTRACT2
    EXTRACT2 --> EXTRACT3
    EXTRACT3 --> EXTRACT4
    EXTRACT4 --> EXTRACT5
    EXTRACT5 --> EXTRACT6
    EXTRACT6 --> COND1
    COND1 -- true --> COND2
    COND2 -- true --> COND3
    COND3 -- true --> COND4
    COND4 -- true --> THROW1
    COND4 -- false --> COND5
    COND2 -- false --> COND5
    COND3 -- false --> COND5
    COND5 -- true --> COND6
    COND6 -- true --> COND7
    COND7 -- true --> THROW2
    COND7 -- false --> COND8
    COND5 -- false --> COND8
    COND6 -- false --> COND8
    COND8 -- true --> COND9
    COND9 -- true --> COND10
    COND10 -- true --> THROW3
    COND10 -- false --> COND11
    COND8 -- false --> COND11
    COND9 -- false --> COND11
    COND11 -- true --> COND12
    COND12 -- true --> COND13
    COND13 -- true --> THROW4
    COND13 -- false --> THROW5
    COND11 -- false --> THROW5
    COND12 -- false --> THROW5
    COND1 -- false --> ELSE_BRANCH
    ELSE_BRANCH --> THROW5
    THROW1 --> END1(["End"])
    THROW2 --> END2(["End"])
    THROW3 --> END3(["End"])
    THROW4 --> END4(["End"])
    THROW5 --> END5(["End"])
```

**Constant Resolutions:**
- `JPCModelConstant.RELATION_ERR = "1100"` — Status code indicating a related-check (relational validation) error from the service IF.
- `EKK0361D010` — Service IF-ID for Option Service Contract checks (Digital Add-On connection context).
- `EKK0351C120` — Service IF-ID for plan/date-related contract checks.
- `JFUStrConst.RELATION_CHECK_ERR_EG = "EG"` — Error flag for Option Service Contract count exceeding limit.
- `JFUStrConst.RELATION_CHECK_ERR_EC = "EC"` — Error flag for contract state conflict.
- `JFUStrConst.RELATION_CHECK_ERR_EA = "EA"` — Error flag for date validation failure (operational date).
- `JFUStrConst.RELATION_CHECK_ERR_EE = "EE"` — Error flag for update-restricted state.
- `JFUStrConst.ERROR_CODE_0102` — Contract Error (契約エラー).
- `JFUStrConst.ERROR_CODE_0101` — Usage Restriction Error (利用制限エラー).
- `JFUStrConst.ERROR_CODE_0204` — Update Restriction Error (更新不可エラー).
- `JFUStrConst.ERROR_CODE_0002` — System Error (システムエラー).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `se` | `JCCWebServiceException` | The service IF exception returned from an upstream SC/CBS call. It carries a structured error payload (`X31CMessageResult`) containing template ID (service IF identifier), item ID (the field that failed validation), status code (error category), and error flag (specific error type). This is the sole input that drives all conditional branches. |

**Instance fields read by this method (constants resolved at compile time):**

| Field Name | Resolved Value | Business Description |
|------------|---------------|---------------------|
| `EKK0361D010` | `"EKK0361D010"` | Service IF-ID for Option Service Contract validation |
| `EKK0351C120` | `"EKK0351C120"` | Service IF-ID for plan/date contract validation |
| `OP_SVC_CD` | `"op_svc_cd"` | Item ID constant — Option Service Code field identifier |
| `OP_SVC_KEI_NO` | `"op_svc_kei_no"` | Item ID constant — Option Service Contract Number field identifier |
| `PLAN_STAYMD` | `"plan_staymd"` | Item ID constant — Plan Start Year/Month/Day field identifier |
| `PCRS_CD` | `"pcrs_cd"` | Item ID constant — Service Cost Code field identifier |

## 4. CRUD Operations / Called Services

This method does **not** perform any direct database CRUD operations or SC/CBS calls. It is purely an error-dispatch logic layer that inspects exception metadata and throws business exceptions. All terminal read operations (`getStatus` calls) are on the exception's own payload objects (the `X31CMessageMoreInfo` chain).

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `se.getMessageList` | - | - | Reads the message list from `JCCWebServiceException` to extract `X31CMessageResult` |
| R | `msgResult.getMessageMoreInfoList` | - | - | Reads the structured error info array from the message result |
| R | `info.getTemplateId` | - | - | Reads the template ID (service IF identifier) from the error info |
| R | `info.getItemId` | - | - | Reads the item ID (failed validation field name) from the error info |
| R | `info.getStatus` | - | - | Reads the error status code (e.g., `RELATION_ERR = 1100`) |
| R | `info.getItemCheckErr` | - | - | Reads the specific error flag (e.g., `"EG"`, `"EC"`, `"EA"`, `"EE"`) |

**Note:** The method is called **by** methods that may perform CRUD operations (e.g., `cfm()`, `mskm()`), but this method itself only reads exception metadata and throws exceptions.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 2 methods.
Terminal operations from this method: `getStatus` [R], `getStatus` [R], `getStatus` [R], `getStatus` [R], `getStatus` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `FUW03501SFLogic.cfm()` | `cfm()` -> `chkServiceIfError(se)` | `getStatus` [R] from exception payload |
| 2 | `FUW03501SFLogic.mskm()` | `mskm()` -> `chkServiceIfError(se)` | `getStatus` [R] from exception payload |

**Caller descriptions:**
- **`cfm()`** — Confirm/screen processing for Digital Add-On Service Application. Invoked during the confirm step when the user reviews service details before submission. If service IF validation fails at this stage, `chkServiceIfError` translates the error into a user-facing exception.
- **`mskm()`** — Mask/screen processing (input validation screen). Invoked when the user is on the input/mask screen and service IF checks have been executed. Errors from service validation are routed here for categorization.

## 6. Per-Branch Detail Blocks

**Block 1** — TRY-CATCH equivalent (exception payload extraction) (L830)

> Extracts structured error information from the incoming `JCCWebServiceException`. The method retrieves the message result, accesses the first element of the more-info array (since related-check errors always have exactly one entry), and pulls the four key fields: template ID, item ID, status, and error flag.

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgResult = se.getMessageList()` // Get exception message list (例外情報を取得) |
| 2 | SET | `moreInfo = msgResult.getMessageMoreInfoList()` // Get the more-info array |
| 3 | SET | `info = moreInfo[0]` // Take the first (and only) related-check error element (関連チェック系は必ずエラーが1つのため0番目から取得する) |
| 4 | SET | `templateid = info.getTemplateId()` // Template ID identifying the service IF |
| 5 | SET | `itemid = info.getItemId()` // Item ID identifying which field failed |
| 6 | SET | `status = info.getStatus()` // Error status code |
| 7 | SET | `errFlg = info.getItemCheckErr()` // Specific error flag |

**Block 2** — IF `(status == JPCModelConstant.RELATION_ERR)` [RELATION_ERR="1100"] (L838)

> Main conditional: checks whether the error status indicates a "related-check error" from the service IF. If not, falls through to the generic System Error.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `String.valueOf(JPCModelConstant.RELATION_ERR).equals(status)` // Compare status against RELATION_ERR (関連チェックエラー) |

**Block 2.1** — ELSE-IF `(EKK0361D010 == templateid && errFlg == "EG" && itemid == "op_svc_cd")` [EKK0361D010="EKK0361D010", EG="EG", op_svc_cd="op_svc_cd"] (L841)

> **Option Service Contract Count Exceeded.** When the template is the Option Service Contract IF (EKK0361D010), the error flag is EG (contract count error), and the failing field is the Option Service Code, this means the number of Option Service Contracts for Digital Add-On connections has exceeded the permitted limit. This is classified as a **Contract Error**.
> Original comment: 「ダイアルアップ接続」の「オプションサービス契約」の件数が上限を超えた場合、エラー (If the number of "Option Service Contracts" for "Digital Add-On Connection" exceeds the limit, error)

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0102)` // Contract Error (契約エラー) |

**Block 2.2** — ELSE-IF `(EKK0351C120 == templateid && errFlg == "EC" && itemid == "op_svc_kei_no")` [EKK0351C120="EKK0351C120", EC="EC", op_svc_kei_no="op_svc_kei_no"] (L848)

> **Contract State Error.** When the template is the plan/date contract IF (EKK0351C120), the error flag is EC (contract error), and the failing field is the Option Service Contract Number, this represents a contract state conflict (e.g., the Option Service Contract Number is in an invalid state for Digital Add-On changes). Classified as a **Contract Error**.
> Original comment: ダイアルアップ接続の件数が上限を超えた場合、エラー (If the number of Digital Add-On connections exceeds the limit, error)

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0102)` // Contract Error (契約エラー) |

**Block 2.3** — ELSE-IF `(EKK0351C120 == templateid && errFlg == "EA" && itemid == "plan_staymd")` [EKK0351C120="EKK0351C120", EA="EA", plan_staymd="plan_staymd"] (L855)

> **Usage Restriction Error — Date Validation Failure.** When the template is the plan/date contract IF (EKK0351C120), the error flag is EA (date validation error), and the failing field is the Plan Start Year/Month/Day. This means the calculated period between "Plan Start Date" and "(Digital Add-On Change Application Deadline)" results in a date that is before the operational date. The user is restricted from proceeding. Classified as a **Usage Restriction Error**.
> Original comment: 「プラン開始年月日」と「(ダイアルアップ接続変更申請不可期間)」の算定期間が運用日付以降の日付の場合、エラー (If the calculated period between "Plan Start Year/Month/Day" and "(Digital Add-On Change Application Inapplicable Period)" is not on or after the operational date, error)

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0101)` // Usage Restriction Error (利用制限エラー) |

**Block 2.4** — ELSE-IF `(EKK0351C120 == templateid && errFlg == "EE" && itemid == "pcrs_cd")` [EKK0351C120="EKK0351C120", EE="EE", pcrs_cd="pcrs_cd"] (L862)

> **Update Restriction Error — Service Cost Code Conflict.** When the template is the plan/date contract IF (EKK0351C120), the error flag is EE (update-restricted error), and the failing field is the Service Cost Code. This indicates that the Option Service Contract Number and Service Cost Code are both set, and the Option Service Code context indicates a Digital Add-On connection — a state that prohibits further updates. Classified as an **Update Restriction Error**.
> Original comment: 「オプションサービス契約番号」、「料金コストコード」が設定されていて、「オプションサービスコード」が「ダイアルアップ接続」の場合 (When "Option Service Contract Number" and "Service Cost Code" are set, and "Option Service Code" is "Digital Add-On Connection")

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0204)` // Update Restriction Error (更新不可エラー) |

**Block 3** — ELSE (unmatched condition) (L869)

> **Fallback System Error.** Any error condition that does not match the four explicitly-handled scenarios above, as well as any case where `status` is not `RELATION_ERR`, falls through here and is classified as a generic System Error.
> Original comment: 上記以外の場合、システムエラー (For cases other than the above, system error)

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0002)` // System Error (システムエラー) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `chkServiceIfError` | Method | Service IF error handler — processes validation errors returned from upstream service interface calls |
| `se` | Parameter | JCCWebServiceException — the exception carrying structured error data from service IF validation |
| `templateid` | Field | Template ID — identifies which service IF (EKK0361D010 or EKK0351C120) produced the error |
| `itemid` | Field | Item ID — identifies which form field (op_svc_cd, op_svc_kei_no, plan_staymd, pcrs_cd) failed validation |
| `status` | Field | Error status code — indicates the category of error (e.g., RELATION_ERR = 1100 for related-check errors) |
| `errFlg` | Field | Error flag — the specific error type (EG, EC, EA, EE) returned by the service IF |
| `moreInfo` | Field | X31CMessageMoreInfo array — carries structured error details from the service IF |
| `JPCModelConstant.RELATION_ERR` | Constant | Status value "1100" — indicates a relational/related-check validation error from the service layer |
| EKK0361D010 | Constant | Service IF-ID for Option Service Contract validation — handles Option Service Contract counting and limits |
| EKK0351C120 | Constant | Service IF-ID for plan/date contract validation — handles plan start dates and operational date constraints |
| `RELATION_CHECK_ERR_EA` | Constant | Error flag "EA" — date validation failure (Plan Start Date vs. operational date) |
| `RELATION_CHECK_ERR_EC` | Constant | Error flag "EC" — contract state error (contract number conflict) |
| `RELATION_CHECK_ERR_EE` | Constant | Error flag "EE" — update-restricted error (cannot modify in current state) |
| `RELATION_CHECK_ERR_EG` | Constant | Error flag "EG" — contract count exceeded (Option Service Contract limit) |
| `ERROR_CODE_0101` | Constant | Usage Restriction Error (利用制限エラー) — user cannot proceed due to date/value constraints |
| `ERROR_CODE_0102` | Constant | Contract Error (契約エラー) — contract-related validation failure |
| `ERROR_CODE_0204` | Constant | Update Restriction Error (更新不可エラー) — record is in a state that prevents updates |
| `ERROR_CODE_0002` | Constant | System Error (システムエラー) — generic/system-level error fallback |
| `op_svc_cd` | Field | Option Service Code — identifies the type of option service (e.g., Digital Add-On connection) |
| `op_svc_kei_no` | Field | Option Service Contract Number — the contract number for an Option Service |
| `plan_staymd` | Field | Plan Start Year/Month/Day — the date when the service plan begins |
| `pcrs_cd` | Field | Service Cost Code — the cost code associated with a service charge plan |
| Digital Add-On | Business term | デアル (De-aru) — Digital Add-On connection service, an internet connectivity add-on service |
| FUW03501SF | Module | Digital Add-On Service Application screen — the web screen for applying for Digital Add-On services |
| `cfm()` | Method | Confirm screen processing — shows user a summary of service details before submission |
| `mskm()` | Method | Mask/input screen processing — handles input validation on the entry screen |
| SC | Acronym | Service Component — backend service layer component that handles business logic |
| CBS | Acronym | Common Business Service — shared service layer component used across screens |
| JCCBusinessException | Type | Application-level business exception — thrown for user-facing validation errors |
| X31CMessageResult | Type | Message result wrapper — holds structured error messages from service IF calls |
| X31CMessageMoreInfo | Type | Extended message info — carries detailed error metadata (template ID, item ID, status, error flag) |
| JCCWebServiceException | Type | Web service exception — wraps service IF call failures with structured error payloads |
