---

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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00810SF.KKW00810SF01DBean` |
| Layer | Web View Bean (Controller/View Component Layer) |
| Module | `KKW00810SF` (Package: `eo.web.webview.KKW00810SF`) |

## 1. Role

### KKW00810SF01DBean.addListDataInstance()

This method is responsible for dynamically generating a list-item instance on-demand for a specific business data field identified by a Japanese-language key string. It implements the **on-demand list factory pattern** within the X33V (Fujitsu Futurity) web client framework, which uses data-type beans and typed list containers to represent repeating UI components. The method handles a single repeating list item: the "Error Reason Code" (`動的理由コード`), which is a simple String-type field (item ID: `ido_rsn_cd`) used to capture the reason code when a service contract change fails validation. It first performs a null-check on the key; if null, it returns -1 immediately. If the key matches the "Error Reason Code" label, it lazily initializes the `ido_rsn_cd_list` field (an `X33VDataTypeList`) if it has not yet been created, then instantiates an `X33VDataTypeStringBean`, appends it to the list, and returns the index of the newly added element. This is a lightweight data-binding helper method with no external service or database calls, operating purely on in-memory state within the view bean.

## 2. Processing Pattern (Detailed Business Logic)

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

    START --> CheckNull{"key is null?"}

    CheckNull -->|Yes| RETURN_MINUS_1["Return -1 (null key)"]

    CheckNull -->|No| CheckCondition{"key equals
'動的理由コード'
(Error Reason Code)?"}

    CheckCondition -->|No| RETURN_MINUS_2["Return -1 (no matching item)"]

    CheckCondition -->|Yes| CheckList{"ido_rsn_cd_list is null?"}

    CheckList -->|Yes| InitList["ido_rsn_cd_list = new X33VDataTypeList()"]
    InitList --> CreateBean["Create tmpBean
(X33VDataTypeStringBean)"]

    CheckList -->|No| CreateBean

    CreateBean --> AddBean["ido_rsn_cd_list.add(tmpBean)"]

    AddBean --> RETURN_INDEX["Return
ido_rsn_cd_list.size() - 1"]

    RETURN_MINUS_1 --> END_NODE(["Return / Next"])
    RETURN_MINUS_2 --> END_NODE
    RETURN_INDEX --> END_NODE
```

**Processing summary:**

1. **Null check** — If `key` is `null`, return `-1` immediately (no processing).
2. **Condition branch** — Check if `key` equals `"動的理由コード"` (Error Reason Code).
3. **Lazy initialization** — If the `ido_rsn_cd_list` field is `null`, create a new empty `X33VDataTypeList()`.
4. **Bean instantiation** — Create a new `X33VDataTypeStringBean` instance.
5. **List append** — Add the bean instance to the `ido_rsn_cd_list`.
6. **Return index** — Return the zero-based index of the newly added element (`size() - 1`).
7. **Fallback** — If the key does not match, return `-1` (no matching item).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The display label of the repeating list item whose instance should be generated. Currently, only the value `"動的理由コード"` (Error Reason Code) is recognized. This key serves as a routing discriminator — it determines which list field and data type bean are created. Other values cause the method to return `-1`. |
| — | `this.ido_rsn_cd_list` | `X33VDataTypeList` | Instance field storing the list of error reason code entries. Read before append to check if lazy initialization is needed. |

## 4. CRUD Operations / Called Services

This method performs **no external service calls or database operations**. All processing occurs within the in-memory view bean. It only manipulates local list state.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| N/A | *(none)* | *(none)* | *(none)* | No external SC/CBS calls or database operations. This is a pure in-memory view bean helper method. |

**Method calls within this method:**

| # | Called Method | Type | Description |
|---|--------------|------|-------------|
| 1 | `new X33VDataTypeList()` | SET | Instantiates an empty typed list container for `ido_rsn_cd_list` (lazy initialization) |
| 2 | `new X33VDataTypeStringBean()` | SET | Instantiates a String-type data bean representing a single error reason code value |
| 3 | `X33VDataTypeList.add(X33VDataTypeBeanInterface)` | SET | Appends the newly created `tmpBean` to the `ido_rsn_cd_list` |
| 4 | `X33VDataTypeList.size()` | READ | Returns the current list size to compute the return index |

## 5. Dependency Trace

No callers were found in the codebase that directly invoke `KKW00810SF01DBean.addListDataInstance(String key)` on the `KKW00810SF01DBean` instance. This method is a standard X33V framework lifecycle method — it is invoked indirectly by the **X33V view framework runtime** via the `X33VListedBeanInterface` contract when the UI layer needs to instantiate a repeating list row on demand (e.g., when the user clicks an "Add" button for the Error Reason Code section in the screen).

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | X33V Framework Runtime | `X33VListedBeanInterface.addListDataInstance(key)` -> `KKW00810SF01DBean.addListDataInstance(key)` | *(none — in-memory only)* |

## 6. Per-Branch Detail Blocks

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

> Null guard: If the key is null, return -1 immediately. This is a fast-fail pattern to prevent `NullPointerException` in subsequent string comparisons.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // Return -1 if key is null // nullの場合、-1で返す |

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

> Route to the "Error Reason Code" repeating list item. This item is a String-type field (item ID: `ido_rsn_cd`) used to capture the reason code when a service contract change encounters an error condition.

| # | Type | Code |
|---|------|------|
| 1 | IF-ELSE | `if (ido_rsn_cd_list == null)` // Check if list has been initialized // リストがnullの場合、新しい空のインスタントを生成 |
| 2 | SET | `ido_rsn_cd_list = new X33VDataTypeList();` // Lazy-initialize empty list // リストがnullの場合、新しい空のインスタントを生成 |
| 3 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` // Create String-type data bean instance // データタイプビューン型の指定したデータタイプビューンのインスタントを生成する |
| 4 | CALL | `ido_rsn_cd_list.add(tmpBean);` // Append bean to list // リストに追加 |
| 5 | RETURN | `return ido_rsn_cd_list.size() - 1;` // Return the zero-based index of the newly added element |

**Block 3** — ELSE (default) (L514)

> Fallback: If the key does not match any recognized repeating list item label, return -1.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // Return -1 when no matching item exists // 該当する項目がない場合、-1を返す |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `動的理由コード` | Field | Error Reason Code — a String-type repeating list field (item ID: `ido_rsn_cd`) that captures the reason why a service contract change could not be processed. Used in error display sections. |
| `ido_rsn_cd_list` | Field | Error Reason Code List — an `X33VDataTypeList` that holds multiple error reason code entries. |
| X33V | Acronym | Fujitsu Futurity X33V — a Java-based web application framework for enterprise GUI development. Provides data-type beans and listed-bean interfaces for managing repeating UI sections. |
| `X33VDataTypeList` | Class | A typed list container provided by the X33V framework that holds instances of a specific data type bean. |
| `X33VDataTypeStringBean` | Class | A data-type bean wrapping a `String` value within the X33V framework. Used to represent a single String field in a repeating list. |
| `X33VListedBeanInterface` | Interface | The X33V contract that view beans must implement to support dynamically generated repeating list items (e.g., add/remove/clear list rows). |
| `X33VDataTypeBeanInterface` | Interface | The X33V contract for bean fields that can be dynamically loaded from properties, enabling runtime data type discovery. |
| `X33SException` | Class | An X33V framework exception class for service-layer errors thrown by web bean methods. |
| K-Opticom | Business term | The telecommunications service provider whose billing and order management system this code supports. |
| SF | Acronym | Screen — a screen-level module in the K-Opticom application naming convention. |
| DBean | Acronym | Display Bean — a view-layer data bean that holds screen data and implements X33V interfaces. |
| 動的理由 (ido no riyuu) | Japanese term | Error reason / reason for change failure — explains why a service contract modification could not proceed. |
| コード (koodo) | Japanese term | Code — a classification code or identifier. |

---
