# Business Logic — FUW01901SFLogic.chkRelationServiceError() [82 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW01901SF.FUW01901SFLogic` |
| Layer | Service (Web View Logic — sits between the View/Controller layer and the Business Logic layer) |
| Module | `FUW01901SF` (Package: `eo.web.webview.FUW01901SF`) |

## 1. Role

### FUW01901SFLogic.chkRelationServiceError()

This method performs exception classification and routing for relation check errors that occur during email address addition subscription processing (`FUW01901SF` — the Mail Access Addition Subscription logic class). When a downstream service call throws a `JCCWebServiceException`, this method inspects the exception's embedded error metadata (template ID, item ID, status, and error flag) to determine the specific business error scenario and dispatch the appropriate handling path.

The method implements a **template-based dispatch pattern**: it branches on a combination of `templateid` (which identifies the service IF that raised the error) and `errFlg`/`itemid` pairs (which identify the specific validation failure). This allows a single error-inspection method to handle errors originating from multiple distinct service operations without needing to know which specific service was invoked — the metadata itself tells it.

The method handles seven distinct business error scenarios across four service templates: (1) **contract state errors** for optional service codes exceeding their upper limit (EKK0361D010), (2) **UI pass-through** that propagates the original exception for screen display when optional mail account 1 validation fails, (3) **usage limit errors** when all desired mail accounts are null during front-end submission, (4) **update-unavailable errors** due to concurrent modification detection via timestamp comparison, (5) **usage limit errors** for carrier record email accounts already in aging registration (EKK0361C030/EKK0361C010), and (6) **usage limit errors** for aging target values already registered (EZM0111D010). Any error that does not match one of these known patterns is treated as a system error.

In the larger system, this method serves as the **error interpretation layer** for the Mail Access Addition Subscription screen (`KKSV0202`). It is called from the screen's submission handlers (`cfm()` and `mskm()`) after service IF calls return, ensuring that users receive user-friendly, context-appropriate error messages rather than raw service-layer exception details. It never performs CRUD operations itself — it is a pure error routing and translation method.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["Start: chkRelationServiceError"])
    CHECK_SE("Check: se != null")
    GET_MSG("se.getMessageList() -> msgResult")
    GET_MORE("msgResult.getMessageMoreInfoList() -> moreInfo")
    GET_INFO("info = moreInfo[0]")
    EXTRACT("Extract: templateid, itemid, status, errFlg from info")

    CHECK_SE -->|true| GET_MSG
    GET_MSG --> GET_MORE
    GET_MORE --> GET_INFO
    GET_INFO --> EXTRACT

    CHECK_STATUS{"status == RELATION_ERR<br>(1100)"}
    EXTRACT --> CHECK_STATUS

    CHECK_STATUS -->|false| SYS_ERROR["System Error:<br>throw ERROR_CODE_0002"]
    CHECK_STATUS -->|true| CHECK_TEMPLATE1{"templateid == EKK0361D010"}

    CHECK_TEMPLATE1 -->|true| CHECK_BRANCH1{errFlg==ED<br>itemid==op_svc_cd}
    CHECK_BRANCH1 -->|true| BRANCH1["Contract State Error<br>throw ERROR_CODE_0102"]
    CHECK_BRANCH1 -->|false| CHECK_BRANCH1B{errFlg==EB<br>itemid==kibo_ml_account_1}
    CHECK_BRANCH1B -->|true| BRANCH1B["Pass original exception<br>(SE) to screen"]
    CHECK_BRANCH1B -->|false| CHECK_BRANCH1C{errFlg==EB<br>itemid==mskm_dtl_no}
    CHECK_BRANCH1C -->|true| BRANCH1C["Usage Limit Error<br>throw ERROR_CODE_0101"]

    CHECK_TEMPLATE1 -->|false| CHECK_TEMPLATE2{"templateid == EKK0361C030"}
    CHECK_TEMPLATE2 -->|true| CHECK_BRANCH2{errFlg==ED<br>itemid==op_svc_kei_no}
    CHECK_BRANCH2 -->|true| BRANCH2["Usage Limit Error<br>throw ERROR_CODE_0101"]
    CHECK_BRANCH2 -->|false| CHECK_BRANCH2B{errFlg==EE<br>itemid==op_svc_kei_no}
    CHECK_BRANCH2B -->|true| BRANCH2B["Usage Limit Error<br>throw ERROR_CODE_0101"]

    CHECK_TEMPLATE2 -->|false| CHECK_TEMPLATE3{"templateid == EKK0361C010"}
    CHECK_TEMPLATE3 -->|true| CHECK_BRANCH3{errFlg==EE<br>itemid==op_svc_kei_no}
    CHECK_BRANCH3 -->|true| BRANCH3["Usage Limit Error<br>throw ERROR_CODE_0101"]
    CHECK_BRANCH3 -->|false| CHECK_TEMPLATE4{"templateid == EZM0111D010"}

    CHECK_TEMPLATE4 -->|true| CHECK_BRANCH4{errFlg==EA<br>itemid==aging_tg_value}
    CHECK_BRANCH4 -->|true| BRANCH4["Usage Limit Error<br>throw ERROR_CODE_0101"]
    CHECK_BRANCH4 -->|false| SYS_ERROR

    CHECK_TEMPLATE3 -->|false| CHECK_TEMPLATE4

    BRANCH1 --> END_NODE(["Return / Propagate"])
    BRANCH1B --> END_NODE
    BRANCH1C --> END_NODE
    BRANCH2 --> END_NODE
    BRANCH2B --> END_NODE
    BRANCH3 --> END_NODE
    BRANCH4 --> END_NODE
    SYS_ERROR --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `se` | `JCCWebServiceException` | A web service exception thrown by a downstream service IF call during the Mail Access Addition Subscription flow. Contains structured error metadata: a message list with template ID, item ID, status code, error flag, and item check error flag. Represents any error that occurred during a service contract validation, carrier record check, or aging registration lookup. |

**Class-level constants used** (resolved from source):

| Constant Name | Resolved Value | Business Meaning |
|--------------|---------------|-----------------|
| `JPCModelConstant.RELATION_ERR` | `1100` | Internal schema relation check error status — the threshold value indicating that the service returned a relation-check-level error (as opposed to a data-level or system-level error) |
| `JFUStrConst.RELATION_CHECK_ERR_ED` | `"ED"` | Relation check error flag ED — indicates a constraint violation (e.g., upper limit exceeded, already registered) |
| `JFUStrConst.RELATION_CHECK_ERR_EB` | `"EB"` | Relation check error flag EB — indicates an input validation failure (e.g., all required fields null) |
| `JFUStrConst.RELATION_CHECK_ERR_EA` | `"EA"` | Relation check error flag EA — indicates a record conflict or concurrency issue (e.g., already updated/registered) |
| `JFUStrConst.RELATION_CHECK_ERR_EE` | `"EE"` | Relation check error flag EE — indicates a duplicate registration in aging |

| Constant Name | Resolved Value | Business Meaning |
|--------------|---------------|-----------------|
| `EKK0361D010` | `"EKK0361D010"` | Service IF ID — Service contract validation (optional service code, mail account checks) |
| `EKK0361C030` | `"EKK0361C030"` | Service IF ID — Carrier record email account check |
| `EKK0361C010` | `"EKK0361C010"` | Service IF ID — Carrier record email account check (alternative path) |
| `EZM0111D010` | `"EZM0111D010"` | Service IF ID — Aging target registration existence check |

| Constant Name | Resolved Value | Business Meaning |
|--------------|---------------|-----------------|
| `OP_SVC_CD` | `"op_svc_cd"` | Service item ID — Optional service code field (the service code being validated) |
| `KIBO_ML_ACCOUNT_1` | `"kibo_ml_account_1"` | Service item ID — Desired mail account 1 (user-input email address field) |
| `MSKM_DTL_NO` | `"mskm_dtl_no"` | Service item ID — Mail access detail number (references the mail account detail row) |
| `UPD_DTM_BF` | `"upd_dtm_bf"` | Service item ID — Update date/time before (timestamp used for concurrency control) |
| `OP_SVC_KEI_NO` | `"op_svc_kei_no"` | Service item ID — Optional service type number (identifies the service type being checked) |
| `AGING_TG_VALUE` | `"aging_tg_value"` | Service item ID — Aging target value (the value being checked for existing aging registration) |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCWebServiceException.getMessageList` | - | - | Calls `getMessageList()` on the exception parameter to retrieve the structured error message list |
| R | `X31CMessageResult.getMessageMoreInfoList` | - | - | Calls `getMessageMoreInfoList()` on the message result to extract the more-info array containing template/item metadata |
| R | `X31CMessageMoreInfo.getTemplateId` | - | - | Extracts the template ID string that identifies which service IF raised the error |
| R | `X31CMessageMoreInfo.getItemId` | - | - | Extracts the item ID string that identifies which field the error relates to |
| R | `X31CMessageMoreInfo.getStatus` | - | - | Extracts the status code string (checked against RELATION_ERR = 1100) |
| R | `X31CMessageMoreInfo.getItemCheckErr` | - | - | Extracts the error flag string (ED/EB/EA/EE) that classifies the error type |

This method performs **no direct CRUD operations** on database tables. It is a pure exception-inspection and dispatch method. All data access happens at a lower layer (the service IFs that originally threw the exception).

## 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: `getMessageList` [R], `getMessageMoreInfoList` [R], `getTemplateId` [R], `getItemId` [R], `getStatus` [R], `getItemCheckErr` [R]  # NOSONAR

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

**Notes:**
- `cfm()` and `mskm()` are submission handler methods within the same `FUW01901SFLogic` class, invoked during the Mail Access Addition Subscription screen flow.
- Both callers invoke service IF calls (EKK0361D010, EKK0361C030, EKK0361C010, EZM0111D010) and pass any resulting `JCCWebServiceException` to this method for error classification.
- The actual screen entry point (`KKSV0202`) is outside the 8-hop scope but is the parent screen for this entire logic class.

## 6. Per-Branch Detail Blocks

**Block 1** — TRY BLOCK (implicit, lines 915-996)

The method body is a single try block (the entire method is exception-inspecting logic that assumes the parameter is non-null and well-formed).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `X31CMessageResult msgResult = se.getMessageList();` // Retrieve error message list from exception |
| 2 | CALL | `X31CMessageMoreInfo[] moreInfo = msgResult.getMessageMoreInfoList();` // Extract more-info array |
| 3 | SET | `X31CMessageMoreInfo info = moreInfo[0];` // Related check always has exactly 1 error — take index 0 |
| 4 | SET | `String templateid = info.getTemplateId();` // Template ID identifying the originating service IF |
| 5 | SET | `String itemid = info.getItemId();` // Item ID identifying the field that caused the error |
| 6 | SET | `String status = info.getStatus();` // Status code to classify error severity |
| 7 | SET | `String errFlg = info.getItemCheckErr();` // Error flag (ED/EB/EA/EE) classifying the error type |

**Block 2** — IF (condition `String.valueOf(JPCModelConstant.RELATION_ERR).equals(status)`) [RELATION_ERR="1100"] (L923)

> If the error status matches the relation-check error code, enter the related-check error handling block. The status code 1100 indicates a schema-level relation check error (as opposed to a pure data error or system error).

**Block 2.1** — IF (nested condition `EKK0361D010.equals(templateid) && JFUStrConst.RELATION_CHECK_ERR_ED.equals(errFlg) && OP_SVC_CD.equals(itemid)`) [EKK0361D010="EKK0361D010"] [RELATION_CHECK_ERR_ED="ED"] [OP_SVC_CD="op_svc_cd"] (L927)

> **Contract State Error:** The optional service code has an associated "Option Service Code" of "E Mail" and the number of "Option Services" has exceeded the upper limit. This occurs when a user tries to subscribe to more optional services than allowed.
> **Action:** Throw a `JCCBusinessException` with error code 0102 (contract state error).

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0102);` // Contract state error — service limit exceeded |

**Block 2.2** — ELSE-IF (nested condition `EKK0361D010.equals(templateid) && JFUStrConst.RELATION_CHECK_ERR_EB.equals(errFlg) && KIBO_ML_ACCOUNT_1.equals(itemid)`) [EKK0361D010="EKK0361D010"] [RELATION_CHECK_ERR_EB="EB"] [KIBO_ML_ACCOUNT_1="kibo_ml_account_1"] (L934)

> **UI Pass-Through Error:** The "Option Service" check produced an NG (error) word for the "Desired Mail Account 1" field. The original exception should be re-thrown so the screen can display the error in context.
> **Action:** Propagate the original `JCCWebServiceException` (`se`) — the screen will render the error message.

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw se;` // Re-throw original exception for screen display |

**Block 2.3** — ELSE-IF (nested condition `EKK0361D010.equals(templateid) && JFUStrConst.RELATION_CHECK_ERR_EB.equals(errFlg) && MSKM_DTL_NO.equals(itemid)`) [EKK0361D010="EKK0361D010"] [RELATION_CHECK_ERR_EB="EB"] [MSKM_DTL_NO="mskm_dtl_no"] (L942)

> **Usage Limit Error:** During a front-end (web) submission, all three desired mail accounts ("Desired Mail Account 1", "Desired Mail Account 2", "Desired Mail Account 3") are null. This is a usage limit violation — the user cannot submit with no mail accounts specified.
> **Action:** Throw a `JCCBusinessException` with error code 0101 (usage limit error).

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0101);` // Usage limit error — all mail accounts null |

**Block 2.4** — ELSE-IF (nested condition `EKK0361D010.equals(templateid) && JFUStrConst.RELATION_CHECK_ERR_EA.equals(errFlg) && UPD_DTM_BF.equals(itemid)`) [EKK0361D010="EKK0361D010"] [RELATION_CHECK_ERR_EA="EA"] [UPD_DTM_BF="upd_dtm_bf"] (L950)

> **Update-Unavailable Error (Timestamp Check):** The specified "Service Contract" has already been updated by another process. The `upd_dtm_bf` (update date/time before) timestamp check detected a concurrent modification. This is a classic optimistic locking conflict.
> **Action:** Throw a `JCCBusinessException` with error code 0204 (update-unavailable error).

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0204);` // Update-unavailable error — record was modified by another user |

**Block 2.5** — ELSE-IF (nested condition `EKK0361C030.equals(templateid) && JFUStrConst.RELATION_CHECK_ERR_ED.equals(errFlg) && OP_SVC_KEI_NO.equals(itemid)`) [EKK0361C030="EKK0361C030"] [RELATION_CHECK_ERR_ED="ED"] [OP_SVC_KEI_NO="op_svc_kei_no"] (L957)

> **Usage Limit Error (Carrier Record — Duplicate Aging):** For all three desired mail accounts (1, 2, and 3), the corresponding aging registration already exists. The carrier record check (EKK0361C030) found a duplicate.
> **Action:** Throw a `JCCBusinessException` with error code 0101 (usage limit error).

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0101);` // Usage limit error — aging already registered |

**Block 2.6** — ELSE-IF (nested condition `EKK0361C010.equals(templateid) && JFUStrConst.RELATION_CHECK_ERR_EE.equals(errFlg) && OP_SVC_KEI_NO.equals(itemid)`) [EKK0361C010="EKK0361C010"] [RELATION_CHECK_ERR_EE="EE"] [OP_SVC_KEI_NO="op_svc_kei_no"] (L965)

> **Usage Limit Error (Carrier Record — Alternative Path):** Same scenario as Block 2.5 but routed through the alternative carrier record service IF (EKK0361C010). For all three desired mail accounts, the aging registration already exists.
> **Action:** Throw a `JCCBusinessException` with error code 0101 (usage limit error).

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0101);` // Usage limit error — aging already registered (alt path) |

**Block 2.7** — ELSE-IF (nested condition `EKK0361C030.equals(templateid) && JFUStrConst.RELATION_CHECK_ERR_EE.equals(errFlg) && OP_SVC_KEI_NO.equals(itemid)`) [EKK0361C030="EKK0361C030"] [RELATION_CHECK_ERR_EE="EE"] [OP_SVC_KEI_NO="op_svc_kei_no"] (L973)

> **Usage Limit Error (Carrier Record — EE flag):** For all three desired mail accounts, the aging registration already exists. This is a duplicate check (EE flag) through the EKK0361C030 carrier record service IF. Note: this branch has the same condition as Block 2.5 but with a different error flag (EE instead of ED), representing a slightly different duplicate scenario.
> **Action:** Throw a `JCCBusinessException` with error code 0101 (usage limit error).

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0101);` // Usage limit error — aging already registered (EE flag) |

**Block 2.8** — ELSE-IF (nested condition `EZM0111D010.equals(templateid) && JFUStrConst.RELATION_CHECK_ERR_EA.equals(errFlg) && AGING_TG_VALUE.equals(itemid)`) [EZM0111D010="EZM0111D010"] [RELATION_CHECK_ERR_EA="EA"] [AGING_TG_VALUE="aging_tg_value"] (L981)

> **Usage Limit Error (Aging Registration Check):** The specified "Aging Type Code and Aging Target Value" already exists in the aging registration system. The EZM0111D010 service IF detected that the requested aging configuration is already registered, preventing duplicate aging entries.
> **Action:** Throw a `JCCBusinessException` with error code 0101 (usage limit error).

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0101);` // Usage limit error — aging target already registered |

**Block 3** — FINAL STATEMENT (L987-L988)

> **System Error:** If the error status is NOT the relation-check code (1100), or if none of the known template/item/flag combinations match, this is an unhandled error condition treated as a system error.
> **Action:** Throw a `JCCBusinessException` with error code 0002 (system error).

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0002);` // System error — unhandled error condition |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `RELATION_ERR` | Constant | Relation check error code (1100) — indicates the service returned a schema-level relation validation error, as opposed to a pure data error or system-level error |
| `RELATION_CHECK_ERR_EA` | Constant | Relation check error flag "EA" — indicates a record conflict, concurrency issue, or "already exists" condition |
| `RELATION_CHECK_ERR_EB` | Constant | Relation check error flag "EB" — indicates an input validation failure, such as all required fields being null |
| `RELATION_CHECK_ERR_ED` | Constant | Relation check error flag "ED" — indicates a constraint violation, such as an upper limit exceeded or duplicate registration |
| `RELATION_CHECK_ERR_EE` | Constant | Relation check error flag "EE" — indicates a duplicate aging registration for carrier record checks |
| EKK0361D010 | Service IF ID | Service contract validation service — checks optional service codes, mail account limits, and contract state |
| EKK0361C030 | Service IF ID | Carrier record check service (path 1) — validates that desired mail accounts are not already registered in aging |
| EKK0361C010 | Service IF ID | Carrier record check service (path 2, alternative) — same validation as EKK0361C030 via a different processing path |
| EZM0111D010 | Service IF ID | Aging registration existence check — verifies that an aging target value has not already been registered |
| `op_svc_cd` | Field | Optional service code — the service code identifier being validated in the service contract check |
| `kibo_ml_account_1` | Field | Desired mail account 1 — the first of three user-input email address fields for optional service subscription |
| `mskm_dtl_no` | Field | Mail access detail number — the internal detail row identifier for mail access entries |
| `upd_dtm_bf` | Field | Update date/time before — a timestamp field used in optimistic locking to detect concurrent modifications |
| `op_svc_kei_no` | Field | Optional service type number — identifies the service type in carrier record aging checks |
| `aging_tg_value` | Field | Aging target value — the value being validated to ensure it is not already registered in the aging system |
| `EKK0361D010Net` / `EKK0361D010Mob` | Service IF variants | Network and mobile variants of the service contract IF (EKK0361D010) |
| Mail Access Addition | Business process | The subscription flow for adding an email address to the optional mail access service (module FUW01901SF) |
| Aging (エイジング) | Business concept | A telecom business process for tracking and managing registered service configurations over time |
| Option Service | Business concept | Additional services (e.g., email) that customers can subscribe to alongside their primary internet service |
| Contract State Error | Error type | Business error (ERROR_CODE_0102) — the service contract has reached its maximum number of optional services |
| Usage Limit Error | Error type | Business error (ERROR_CODE_0101) — the requested operation exceeds the allowed usage limits (duplicate registration, null fields) |
| Update-Unavailable Error | Error type | Business error (ERROR_CODE_0204) — the record was modified by another user since it was last read (optimistic lock failure) |
| System Error | Error type | Internal error (ERROR_CODE_0002) — an unexpected or unhandled error condition that indicates a system-level problem |
| Front-end (フロント) | Context | The web-based customer-facing portal where users submit their optional service subscription requests |
| `JCCBusinessException` | Exception class | Business-level exception thrown for expected error conditions with user-friendly messages |
| `JCCWebServiceException` | Exception class | Service-layer exception thrown when a downstream service call fails; contains structured error metadata |
| Template ID | Data field | Identifies which service IF generated the error (e.g., EKK0361D010, EZM0111D010) |
| Error Flag | Data field | A two-letter code (EA/EB/EC/ED/EE/EF) that classifies the type of relation check error |

---

*Document generated from source analysis of FUW01901SFLogic.chkRelationServiceError(). Source file: source/koptWebF/src/eo/web/webview/FUW01901SF/FUW01901SFLogic.java, lines 915-996 (82 LOC).*
