# Business Logic — KKW01031SF01DBean.removeElementFromListData() [13 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW01031SF.KKW01031SF01DBean` |
| Layer | Web View / Data Bean (Webview MVC layer — model/view data holder) |
| Module | `KKW01031SF` (Package: `eo.web.webview.KKW01031SF`) |

## 1. Role

### KKW01031SF01DBean.removeElementFromListData()

This method provides a generic **list element removal** operation within the web-view data bean (DBean) framework. It allows a calling screen to remove an item from an internal, polymorphic list map by specifying both the **item name** (`key`) and the **list index** (`index`) to remove. The method acts as a **shared utility** for DBean-based screen data beans — it is designed as a base-class method that is inherited and extended by dozens of subclasses (e.g., `KKW18701SFBean`, `KKW00198SFBean`, `CRW00601SFBean`, `DKW00801SFBean`, and many others), each of which overrides the method to add handling for their own specific list types.

In the base implementation (`KKW01031SF01DBean`), the method handles a single key: **"異動理由コード"** (Change Reason Code, mapped to the instance field `ido_rsn_cd_list`). When the key matches, it performs bounds-checked removal of the element at the given index from the `X33VDataTypeList`. This supports screen workflows where users can dynamically remove arbitrary change reason entries from a repeating list item before submitting a service order or change request.

The method is a **delegation and extension point** — subclasses override it to dispatch removal for their own list types (e.g., `cust_kei_hktgi_list` in `KKW00198SFBean`, `settizumi_stb_list_list` in `KKW18701SFBean`), while also delegating unrecognized keys to `super.removeElementFromListData()` when the key starts with `//` (shared info bean keys). This design implements a **conditional dispatch** pattern common in the X33 web framework's DBean hierarchy.

**Processing branches:**
- **key is null:** Returns immediately without action (safe guard).
- **key equals "異動理由コード" (Change Reason Code):** If index is within bounds of `ido_rsn_cd_list`, removes the element at that index.
- **key is not recognized by this subclass:** Returns without action (subclasses may handle additional keys).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["removeElementFromListData(key, index)"])
    CHECK_NULL["key is not null"]
    CHECK_KEY["key equals异动理由コード"]
    CHECK_INDEX["index within bounds"]
    REMOVE["ido_rsn_cd_list.remove(index)"]
    EXIT(["Return (void)"])

    START --> CHECK_NULL
    CHECK_NULL -->|false| EXIT
    CHECK_NULL -->|true| CHECK_KEY
    CHECK_KEY -->|false| EXIT
    CHECK_KEY -->|true| CHECK_INDEX
    CHECK_INDEX -->|false| EXIT
    CHECK_INDEX -->|true| REMOVE
    REMOVE --> EXIT
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The item name (list identifier) that specifies which list to remove from. In this method, the only handled key is `"異動理由コード"` (Change Reason Code), which maps to the `ido_rsn_cd_list` field — the list of change reason entries associated with a service order. |
| 2 | `index` | `int` | The zero-based index of the element to remove from the identified list. It must be within bounds (0 ≤ index < list size) for the removal to occur. If out of bounds, the method silently does nothing. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ido_rsn_cd_list` | `X33VDataTypeList` | The change reason code list — a polymorphic list of `X33VDataTypeStringBean` items, each containing a reason string for a service change/movement (異動理由). This list is initialized as a new `X33VDataTypeList()` in the constructor. |

## 4. CRUD Operations / Called Services

This method performs **only in-memory list manipulation** — no external service calls, database operations, or entity updates are involved. It directly calls the `remove()` method on a Java `ArrayList` (via `X33VDataTypeList`).

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| (None) | `ido_rsn_cd_list.remove(int)` | — | — | In-memory removal of a list element at the specified index. This is a local Java collection operation, not a database CRUD operation. |

## 5. Dependency Trace

The method `KKW01031SF01DBean.removeElementFromListData()` is a **base-class method** in the DBean inheritance hierarchy. It is not directly called by screens or other beans — instead, it is overridden by many subclasses that extend its functionality. The subclasses follow the pattern of calling `super.removeElementFromListData(key, index)` to handle shared/common keys, then handling their own specific keys.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW18701SF (KKW18701SFBean) | `KKW18701SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` (base class handling for shared info bean keys prefixed with `//`) | — |
| 2 | Screen:KKW00198SF (KKW00198SFBean) | `KKW00198SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` (base class handling for shared info bean keys) | — |
| 3 | Screen:CRW06601SF (CRW06601SFBean) | `CRW06601SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 4 | Screen:CRW00601SF (CRW00601SFBean) | `CRW00601SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 5 | Screen:DKW00801SF (DKW00801SFBean) | `DKW00801SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 6 | Screen:KKW00401SF (KKW00401SFBean) | `KKW00401SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 7 | Screen:WCW03101SF (WCW03101SFBean) | `WCW03101SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 8 | Screen:CRW05005SF (CRW05005SFBean) | `CRW05005SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 9 | Screen:KKW12701SF (KKW12701SFBean) | `KKW12701SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 10 | Screen:KKW12702SF (KKW12702SFBean) | `KKW12702SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 11 | Screen:CHW01110SF (CHW01110SFBean) | `CHW01110SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 12 | Screen:KKW10702SF (KKW10702SFBean) | `KKW10702SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 13 | Screen:FUW00901SF (FUW00901SFBean) | `FUW00901SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 14 | Screen:FUW00907SF (FUW00907SFBean) | `FUW00907SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |
| 15 | Screen:FUW00912SF (FUW00912SFBean) | `FUW00912SFBean.removeElementFromListData(key, index)` → `super.removeElementFromListData(key, index)` | — |

## 6. Per-Branch Detail Blocks

**Block 1** — IF `key != null` (L642)

> Check if the key parameter is non-null. If null, the method returns immediately without performing any operation. This is a null-safety guard.

| # | Type | Code |
|---|------|------|
| 1 | SET | — |
| 2 | RETURN | `return;` // key is null, nothing to do |

**Block 2** — IF-ELSE-IF `key.equals("異動理由コード")` (L644) [異動理由コード="異動理由コード" (Change Reason Code)]

> When the key matches the change reason code item name, this block removes an element from the `ido_rsn_cd_list`. The Japanese comment "異動理由コード(String型。項目ID:ido_rsn_cd)" translates to: "Change Reason Code (String type. Item ID: ido_rsn_cd)".

| # | Type | Code |
|---|------|------|
| 1 | IF | `key.equals("異動理由コード")` // Branch: key identifies the change reason code list |

**Block 2.1** — IF `index >= 0 && index < ido_rsn_cd_list.size()` (L646) [Bounds Check]

> The Japanese comment "指定のインデックスが現在のリストの範囲内にいたら、そのインデックスの内容を削除" translates to: "If the specified index is within the current list range, delete the content at that index". This performs a bounds check to ensure the index is valid before removal.

| # | Type | Code |
|---|------|------|
| 1 | IF | `index >= 0 && index < ido_rsn_cd_list.size()` // Bounds check: index must be non-negative and less than list size |
| 2 | EXEC | `ido_rsn_cd_list.remove(index)` // Remove element at index from the change reason code list |

**Block 3** — ELSE IF (implicit fallthrough)

> If the key does not match "異動理由コード", no action is taken in this base-class implementation. The method simply returns. Subclasses that override this method may handle additional key values.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | Implicit return (void method, no explicit return statement) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ido_rsn_cd` | Field | Change Reason Code — internal tracking ID for the reason why a service change/movement was requested. Stored as a list of string beans. |
| `ido_rsn_cd_list` | Field | Change Reason Code List — an `X33VDataTypeList` containing `X33VDataTypeStringBean` instances, each representing a change reason entry that a user can add or remove dynamically on screen. |
| 異動理由コード | Field (Japanese) | Change Reason Code — the user-facing label for the change reason item. The key used to identify this specific list in the polymorphic map. |
| DBean | Acronym | Data Bean — a web-view model class that holds UI state data for a specific screen, acting as the model in the MVC pattern. |
| X33VDataTypeList | Type | A polymorphic list container used in the X33 web framework to hold mixed-type data items. |
| X33VDataTypeStringBean | Type | A value-holding wrapper for a string data item within an `X33VDataTypeList`. |
| X33SException | Type | The X33 framework's base exception class for screen-level business logic errors. |
| DDD | Acronym | Data Driven Design — the framework pattern where screen data is represented as typed bean objects. |
