# Business Logic — KKW22101SF01DBean.removeElementFromListData() [20 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW22101SF.KKW22101SF01DBean` |
| Layer | Common Component / Bean (Web-tier data structure) |
| Module | `KKW22101SF` (Package: `eo.web.webview.KKW22101SF`) |

## 1. Role

### KKW22101SF01DBean.removeElementFromListData()

This method provides **indexed removal of list-based bean data** from a key-dispatched structure within the KKW22101SF screen bean. In the framework, UI screens bind collections (such as reason codes and optional service contract numbers) to the view layer using String-keyed dispatch — the key serves as a route to a specific `X33VDataTypeList` field on the bean. The method acts as a **shared utility** that any subclass or sibling bean in the web-view layer can call to remove a single entry at a given index from the target list. It implements the **strategy/dispatch pattern** by branching on the key string to select which internal list to mutate. Its role in the larger system is to support **data entry screens where users can dynamically remove individual rows** — for example, removing a migration reason code or an optional service contract line item from a repeater-style table. If the key does not match any registered list or the index falls outside the valid range, the method safely does nothing (no exception is thrown).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["removeElementFromListData key, index"])
    CHECK_NULL["key != null ?"]
    CHECK_KEY1["key equals 異動理由コード"]
    CHECK_INDEX1["index >= 0 && index < ido_rsn_cd_list.size()"]
    REMOVE1["ido_rsn_cd_list.remove(index)"]
    SKIP1["Skip (no match)"]
    CHECK_KEY2["key equals オプションサービス契約番号"]
    CHECK_INDEX2["index >= 0 && index < op_svc_kei_no_list.size()"]
    REMOVE2["op_svc_kei_no_list.remove(index)"]
    SKIP2["Skip (no match)"]
    END_NODE(["Return / Next"])

    START --> CHECK_NULL
    CHECK_NULL -->|false| END_NODE
    CHECK_NULL -->|true| CHECK_KEY1
    CHECK_KEY1 -->|false| CHECK_KEY2
    CHECK_KEY1 -->|true| CHECK_INDEX1
    CHECK_INDEX1 -->|false| SKIP1
    CHECK_INDEX1 -->|true| REMOVE1
    REMOVE1 --> SKIP1
    SKIP1 --> END_NODE
    CHECK_KEY2 -->|false| END_NODE
    CHECK_KEY2 -->|true| CHECK_INDEX2
    CHECK_INDEX2 -->|false| SKIP2
    CHECK_INDEX2 -->|true| REMOVE2
    REMOVE2 --> SKIP2
    SKIP2 --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The dispatch key that identifies which internal list to operate on. Valid values are `"異動理由コード"` (Migration Reason Code — identifies the `ido_rsn_cd_list`) or `"オプションサービス契約番号"` (Optional Service Contract Number — identifies the `op_svc_kei_no_list`). If `null`, the method returns immediately without effect. |
| 2 | `index` | `int` | The zero-based index of the element to remove from the target list. Must be within `[0, list.size()-1]`. If out of bounds, the removal is silently skipped (no exception thrown). |

**Instance fields / external state read:**
| Field | Type | Description |
|-------|------|-------------|
| `ido_rsn_cd_list` | `X33VDataTypeList` | List of migration reason codes (`ido_rsn_cd` — item ID: "異動理由コード"). Each element is a `X33VDataTypeStringBean` wrapping a String value. |
| `op_svc_kei_no_list` | `X33VDataTypeList` | List of optional service contract numbers (`op_svc_kei_no` — item ID: "オプションサービス契約番号"). Each element is a `X33VDataTypeStringBean` wrapping a String value. |

## 4. CRUD Operations / Called Services

This method performs **in-place mutations** of internal bean lists. It does not call any SC (Service Component) or CBS (Common Business Service), nor does it read/write any database tables directly.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `ido_rsn_cd_list.remove(index)` | (local bean) | (in-memory bean list) | Removes an element at the given index from the migration reason codes list. |
| U | `op_svc_kei_no_list.remove(index)` | (local bean) | (in-memory bean list) | Removes an element at the given index from the optional service contract numbers list. |

## 5. Dependency Trace

This method is a base-bean utility with no callers found within the `KKW22101SF` module or any calling class in the codebase. It is defined on `KKW22101SF01DBean` and may be called transitively through the framework's list-editing mechanism (e.g., when a screen controller iterates over selected rows and invokes the bean to remove them).

Subclass beans in other modules (`FUW00912SFBean`, `FUW00926SFBean`, `FUW00964SFBean`, `FUW00927SFBean`, `FUW00901SFBean`, `FUW00919SFBean`, `FUW00931SFBean`, `FUW00917SFBean`, `FUW00907SFBean`, `FUW00957SFBean`) each **override** `removeElementFromListData()` and delegate to `super.removeElementFromListData(key, index)`, meaning they inherit this dispatch logic and add their own list branches on top.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | (None found) | — | — |

**Note:** The method is inherited by 10+ subclass beans across the `FUW*` module family via `super.removeElementFromListData(key, index)`. These subclasses extend the dispatch to support additional list types specific to their screens.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(key != null)` (L1622)

> Guard: If the key is `null`, skip all processing and return immediately. This prevents `NullPointerException` when the subsequent `equals()` comparisons are evaluated.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(key != null)` // Guard against null key [-> prevents NPE on equals()] |
| 2 | GOTO | Block 2 (if true), Block 5 (if false) |

**Block 1.1** — [IF] `key.equals("異動理由コード")` (L1624)

> Branch: Key matches `"異動理由コード"` (Migration Reason Code). The Japanese string `"異動理由コード"` is the literal dispatch key for the reason codes list (item ID: `ido_rsn_cd`). This branch targets the `ido_rsn_cd_list` field.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(key.equals("異動理由コード"))` // Dispatch key: 異動理由コード (Migration Reason Code) [itemID: ido_rsn_cd] |
| 2 | GOTO | Block 1.1.1 (if true), Block 2 (if false) |

**Block 1.1.1** — [IF] `(index >= 0 && index < ido_rsn_cd_list.size())` (L1626)

> Validation + Mutate: Checks that the index is within the valid range of the reason codes list. If valid, removes the element at that index. This implements safe bounded deletion — the framework allows adding rows dynamically and this method removes individual rows when users request it.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(index >= 0 && index < ido_rsn_cd_list.size())` // Verify index is within list bounds |
| 2 | EXEC | `ido_rsn_cd_list.remove(index)` // Remove element at specified index [-> deletes row from reason code list] |
| 3 | GOTO | Block 5 (after removal, continue to next branch check) |

**Block 1.2** — [ELSE] (implicit, L1624 → L1628)

> The key did not match `"異動理由コード"`. Fall through to check the next dispatch key.

| # | Type | Code |
|---|------|------|
| 1 | ELSE | (implicit else of Block 1.1) |
| 2 | GOTO | Block 2 |

**Block 2** — [IF-ELSE-IF] `key.equals("オプションサービス契約番号")` (L1628)

> Branch: Key matches `"オプションサービス契約番号"` (Optional Service Contract Number). The Japanese string is the literal dispatch key for the optional service contract numbers list (item ID: `op_svc_kei_no`). This branch targets the `op_svc_kei_no_list` field.

| # | Type | Code |
|---|------|------|
| 1 | IF | `else if(key.equals("オプションサービス契約番号"))` // Dispatch key: オプションサービス契約番号 (Optional Service Contract Number) [itemID: op_svc_kei_no] |
| 2 | GOTO | Block 2.1 (if true), Block 5 (if false) |

**Block 2.1** — [IF] `(index >= 0 && index < op_svc_kei_no_list.size())` (L1630)

> Validation + Mutate: Checks that the index is within the valid range of the optional service contract numbers list. If valid, removes the element at that index.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(index >= 0 && index < op_svc_kei_no_list.size())` // Verify index is within list bounds |
| 2 | EXEC | `op_svc_kei_no_list.remove(index)` // Remove element at specified index [-> deletes row from optional service list] |
| 3 | GOTO | Block 5 (after removal, exit method) |

**Block 2.2** — [ELSE] (implicit, L1628 → L1632)

> The key did not match `"オプションサービス契約番号"` either. No further dispatch keys are registered. Exit method without any mutation.

| # | Type | Code |
|---|------|------|
| 1 | ELSE | (implicit else of Block 2) |
| 2 | GOTO | Block 5 |

**Block 5** — [END] (L1633)

> Method exit. Return `void` to the caller.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | (implicit `return;`) // Method completes, no return value |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ido_rsn_cd` | Field | Migration reason code — the reason why a service contract is being changed (moved/cancelled/transferred). Stored as a String in each element of `ido_rsn_cd_list`. Item ID: `"異動理由コード"`. |
| `op_svc_kei_no` | Field | Optional service contract number — the identifier for an optional/add-on service contracted by the customer. Stored as a String in each element of `op_svc_kei_no_list`. Item ID: `"オプションサービス契約番号"`. |
| 異動理由コード | Japanese key | "Migration Reason Code" — the dispatch string key that routes to `ido_rsn_cd_list`. Represents the reason for service changes in the telecom workflow. |
| オプションサービス契約番号 | Japanese key | "Optional Service Contract Number" — the dispatch string key that routes to `op_svc_kei_no_list`. Represents add-on services bundled with a primary contract. |
| X33VDataTypeList | Framework type | A typed list container in the X33 web framework that holds `X33VDataTypeBean` instances (e.g., `X33VDataTypeStringBean`). Used for bindable UI list fields. |
| X33VDataTypeBeanInterface | Framework interface | Interface defining the contract for view-layer data beans in the X33 framework. |
| X33VListedBeanInterface | Framework interface | Interface for beans that contain list-type data fields in the X33 view layer. |
| KKW22101SF | Module | A telecom service contract modification screen module — handles UI data for changing/migrating service contracts with optional add-on services. |
| DBean | Abbreviation | Data Bean — the screen-specific bean class that holds all form data, list data, and transient state for a single UI screen. |
