# Business Logic — KKW01030SF01DBean.addListDataInstance() [21 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKA15101SF.KKW01030SF01DBean` |
| Layer | Web/View Data Bean (Package: `eo.web.webview.KKA15101SF`) |
| Module | `KKA15101SF` (Package: `eo.web.webview.KKA15101SF`) |

## 1. Role

### KKW01030SF01DBean.addListDataInstance()

This method is a **dynamic list-item factory** for the web data bean `KKW01030SF01DBean`. Its business purpose is to lazily instantiate and register a new list element on-demand, based on a string key that identifies the type of data item being added. Within the Fujitsu X33 Web Framework, this method fulfills the `X33VListedBeanInterface` contract, enabling the framework to grow data structures at runtime — for example, when a user requests to add another row to a repeating table on a screen.

Currently, this method implements **one active routing branch**: when the key is the Japanese literal `"異動理由コード"` (IDO_RSN_CD, meaning "Change Reason Code"), it ensures the `ido_rsn_cd_list` field holds a non-null `X33VDataTypeList`, creates a new `X33VDataTypeStringBean` (a framework string data type bean), appends it to the list, and returns its index. For all other keys — including null inputs — the method returns -1 to signal that no item was added.

The method acts as a **shared utility within the screen's data bean tier**, called either directly by the screen controller or indirectly by the X33 framework during postback processing. It is a lightweight, non-persistent operation: no database or service component interaction occurs. Its role is purely to manage in-memory view state for list-type UI components.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance(String key)"])

    START --> CheckNull["Key is null?"]

    CheckNull --> |Yes| ReturnNull(["Return -1"])
    CheckNull --> |No| CheckKey["Check key value"]

    CheckKey --> |異動理由コード| InitBean["Initialize X33VDataTypeStringBean"]
    CheckKey --> |Other| ReturnOther(["Return -1"])

    InitBean --> AddToList["Add bean to ido_rsn_cd_list"]

    AddToList --> ReturnIndex["Return list size - 1"]

    ReturnNull --> END(["End"])
    ReturnOther --> END
    ReturnIndex --> END
```

**CRITICAL — Constant Resolution:**

The method branches on a Japanese string literal rather than a named constant file:

| Condition | Value | Business Meaning |
|-----------|-------|------------------|
| `key.equals("異動理由コード")` | `"異動理由コード"` (IDO_RSN_CD) | Change Reason Code — the reason code for a service status change (e.g., suspension, cancellation, transfer) |

No additional constant definition file maps this literal; the value is hardcoded as a screen-specific key. In broader codebase constant files (e.g., `KKSV0238_KKSV0238OP_KKSV023803CC`), the field name `IDO_RSN_CD_LIST` is defined as `"ido_rsn_cd_list"`, representing the session-scoped map key for the change reason code list data.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | A screen-specific data item identifier used to determine which list to populate. When the value matches `"異動理由コード"` (IDO_RSN_CD — Change Reason Code), the method initializes or extends the list of change reason code entries for the current view session. Currently, this is the only supported key; all other values (including null) result in a -1 return. |

**Instance fields read by this method:**

| Field | Type | Access Pattern | Business Description |
|-------|------|----------------|---------------------|
| `ido_rsn_cd_list` | `X33VDataTypeList` | Null check + `.add()` | The backing list that stores `X33VDataTypeStringBean` instances, each representing one change reason code entry in the UI. Lazily initialized to `null`; the first call with the matching key creates it. |

## 4. CRUD Operations / Called Services

This method performs **no CRUD operations** and calls **no external services** (SC, CBS, DAO, or database layers). It operates entirely within the web data bean's in-memory state.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| *(none)* | — | — | — | This method is a pure view-state factory with no persistence or service-tier interaction. |

**Framework method calls made within this method:**

| No | Call | Type | Description |
|----|------|------|-------------|
| 1 | `ido_rsn_cd_list = new X33VDataTypeList()` | Constructor | Allocates a new X33 framework dynamic data list for storing string-typed view beans |
| 2 | `new X33VDataTypeStringBean()` | Constructor | Allocates a new X33 framework string-typed data bean (the list element type) |
| 3 | `ido_rsn_cd_list.add(tmpBean)` | X33 API | Appends the newly created string bean to the change reason code list, incrementing its size |

## 5. Dependency Trace

This method has **no direct callers found** in the codebase via search. It is a standard data bean method provided by the X33 framework pattern — typically invoked indirectly by:

1. **Screen controllers** within `KKA15101SF` that dynamically add rows to a change reason code repeater control during postback handling.
2. **The X33VListedBeanInterface** framework itself, which may call this method during view state reconstruction.

Multiple other bean classes in the broader codebase (e.g., `FUW00901SFBean`, `FUW00919SFBean`, `FUW00927SFBean`) override this same method with their own key routing logic, often delegating to `super.addListDataInstance(key)` for unsupported keys — confirming that this is a well-known framework pattern for data bean list management.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen: Internal (KKA15101SF) | *(Framework/internal)* Screen controller → `KKW01030SF01DBean.addListDataInstance` | *(none — pure view-state operation)* |
| 2 | Framework | `X33VListedBeanInterface` contract → `super.addListDataInstance(key)` (subclass delegation from FUW009xxSFBean classes) | *(none — pure view-state operation)* |

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(key == null)` (L617)

> Null guard: if the caller passes a null key, the method returns -1 immediately. This is a defensive check preventing NullPointerException downstream.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // Returns -1 when key is null — no item added (Japanese: "nullの場合、-1で返す" — "Returns -1 if null") |

---

**Block 2** — ELSE-IF `(key.equals("異動理由コード"))` (L621)

> Matches the hardcoded key for the Change Reason Code list. The Japanese string `"異動理由コード"` translates to "Change Reason Code" and identifies the item ID `ido_rsn_cd` used in the repeater UI control.

**Block 2.1** — IF `(ido_rsn_cd_list == null)` (L622)

> Null check on the backing list. On first invocation with this key, the list has not yet been created.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ido_rsn_cd_list = new X33VDataTypeList();` // Allocates a new empty X33 dynamic data list (Japanese: "リストがnullの場合、新しい空のインスタンスを生成" — "If list is null, generate a new empty instance") |

**Block 2.2** — (L625) — unconditional, runs after Block 2.1 or skipped

| # | Type | Code |
|---|------|------|
| 1 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` // Creates a new string-type data bean instance (Japanese: "データタイプビューン型の指定したデータタイプビューンのインスタンスを生成する。なお、データタイプビューンの項目初期値設定は、各データビューン内で定義" — "Generates an instance of the specified data type bean for the data type. Note: initial value settings for data type beans are defined within each data bean itself)") |
| 2 | CALL | `ido_rsn_cd_list.add(tmpBean);` // Appends the new string bean to the list |
| 3 | RETURN | `return ido_rsn_cd_list.size() - 1;` // Returns the zero-based index of the newly added element (Japanese: "追加された要素のインデックス番号" — "Index number of the added element") |

---

**Block 3** — ELSE-IF (implicit, no key matches) / FALLTHROUGH (L631)

> This code path is reached when the key does not match `"異動理由コード"`. The method falls through to return -1, indicating no supported item type was found.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // Returns -1 when no matching item is found (Japanese: "該当する項目がない場合、-1を返す" — "Returns -1 when there is no corresponding item") |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ido_rsn_cd_list` | Field | Change Reason Code list — an in-memory list that holds multiple change reason code entries, used in repeater UI controls on the service change/migration screen |
| `ido_rsn_cd` | Field | Change Reason Code — the individual reason code (e.g., suspension, cancellation, transfer) for a service status change event |
| `"異動理由コード"` | Literal | Japanese: "Idou Riyuu Koodo" — Change Reason Code. The hardcoded UI key used to identify the change reason code repeater control in the data bean |
| `X33VListedBeanInterface` | Interface | Fujitsu X33 Framework interface that enables a data bean to support dynamic list items via methods like `addListDataInstance()` and `removeElementFromListData()` |
| `X33VDataTypeList` | Class | X33 Framework dynamic list container — a framework class that holds typed data bean instances and supports index-based access |
| `X33VDataTypeStringBean` | Class | X33 Framework string data bean — a value-holding wrapper for string data that the X33 view layer can bind to UI controls |
| `X33SException` | Class | X33 Framework checked exception — thrown by data bean methods that encounter framework-level errors during view state manipulation |
| `KKA15101SF` | Module | Service status change/registration screen module — the web screen that handles service contract status modifications (e.g., suspending, resuming, or transferring services) |
| `KKW01030SF01DBean` | Class | Web data bean for screen KKW01030SF01 — holds view state including change reason codes, service detail numbers, and other repeater/list items for the service status change screen |
| KKSV0234 / KKSV0238 / KKSV0240 | Screen IDs | Other screens in the codebase that also use `ido_rsn_cd_list` for their change reason code functionality, sharing the same constant pattern |
