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

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

## 1. Role

### KKW01033SF01DBean.addListDataInstance()

This method is an X33V framework lifecycle callback that generates and returns an instance of a specific list-based view data item. It is the X33V data bean counterpart to the framework's list-item initialization protocol — when the X33V framework needs to dynamically create a new row in a multi-value (repeating) form field, it invokes this method passing a key that identifies which list item is being requested. This method specializes the generic behavior by resolving the business-level item name "異動理由コード" (Movement Reason Code) and returning the index of the newly appended element.

The method implements the **routing/dispatch pattern**: it inspects the `key` parameter and dispatches to the appropriate initialization logic. Currently it handles one specific service type — the Movement Reason Code list (`ido_rsn_cd`). For any unrecognized key or a null key, it returns -1 to signal that no matching list item exists. Its role in the larger system is to support dynamic row insertion in telecom service contract screens where customers may have multiple movement reason codes associated with a single service order (e.g., multiple change reasons across different contract line items).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance key"])
    COND1{"key == null"}
    COND2{"key equals 異動理由コード"}
    COND3{"ido_rsn_cd_list == null"}
    INIT_LIST["ido_rsn_cd_list = new X33VDataTypeList"]
    CREATE_BEAN["tmpBean = new X33VDataTypeStringBean"]
    ADD_TO_LIST["ido_rsn_cd_list.add tmpBean"]
    RETURN_INDEX["return ido_rsn_cd_list.size - 1"]
    RETURN_M1["return -1"]

    START --> COND1
    COND1 -- true --> RETURN_M1
    COND1 -- false --> COND2
    COND2 -- true --> COND3
    COND3 -- true --> INIT_LIST
    COND3 -- false --> CREATE_BEAN
    INIT_LIST --> CREATE_BEAN
    CREATE_BEAN --> ADD_TO_LIST
    ADD_TO_LIST --> RETURN_INDEX
    COND2 -- false --> RETURN_M1
```

**Branch descriptions:**

| Branch | Condition | Business Meaning |
|--------|-----------|-----------------|
| B1 | `key == null` | Guard clause — the framework passed no key; the bean cannot determine which list item to create. Returns -1 (no valid index). |
| B2 | `key == "異動理由コード"` (Movement Reason Code) | The framework is requesting a new row for the Movement Reason Code list (item ID: `ido_rsn_cd`). The method ensures the underlying `X33VDataTypeList` exists (instantiating it if null), then creates a new `X33VDataTypeStringBean` instance and appends it. Returns the 0-based index of the newly created element. |
| B3 | Key matches neither null nor "異動理由コード" | The framework requested a list item that this bean does not manage. Returns -1. |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The business-level name of the list item for which a new instance should be created. It carries a human-readable item label (in Japanese) that maps to a specific repeating field on the form. Currently the only recognized value is `"異動理由コード"` (Movement Reason Code), which identifies the `ido_rsn_cd` field used to record why a service contract or line item is being moved/changed. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ido_rsn_cd_list` | `X33VDataTypeList` | The backing list for Movement Reason Code entries. May be `null` on first invocation (before the bean is initialized); when non-null, it holds a variable number of `X33VDataTypeStringBean` rows, each representing one movement reason code value. |

## 4. CRUD Operations / Called Services

This method performs **no database operations, no service component (SC/CBS) calls, and no entity/table access**. It is a pure in-memory data bean lifecycle method that manages local view-state lists.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | — | — | — | No CRUD operations. This is a view-layer bean method that manages local in-memory list data only. |

**Internal objects created:**

| Object | Framework Class | Purpose |
|--------|----------------|---------|
| `ido_rsn_cd_list` (if null) | `X33VDataTypeList` (Fujitsu Futurity X33V framework) | Creates the backing list container for movement reason code entries. |
| `tmpBean` | `X33VDataTypeStringBean` (Fujitsu Futurity X33V framework) | Creates a new string data type bean instance representing a single movement reason code value. Initial values are defined internally within the bean class. |

## 5. Dependency Trace

This method is an X33V framework callback — it is not directly called by other application classes. The X33V framework invokes it during view data initialization when dynamically creating list rows.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW010330PJP (KKW01033SF view initialization) | X33V Framework `ViewDataBeanManager` -> `addListDataInstance` | N/A (in-memory bean only) |

**Reverse dependency (what this method ultimately calls):**
- `X33VDataTypeList.<constructor>()` — creates the list container
- `X33VDataTypeStringBean.<constructor>()` — creates a single-row string bean
- `X33VDataTypeList.add(Object)` — appends a bean instance to the list
- `X33VDataTypeList.size()` — reads current list size to compute the returned index

## 6. Per-Branch Detail Blocks

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

Guard clause: returns -1 when no key is provided.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (key == null)` // Guard: reject null key |
| 2 | RETURN | `return -1;` // Return -1 when key is null |

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

Handles the specific list item for Movement Reason Codes. This is the primary business logic path.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `else if (key.equals("異動理由コード"))` // Handle list item "異動理由コード" (Movement Reason Code) [-> String literal: "異動理由コード"] |

**Block 2.1** — [IF] `(ido_rsn_cd_list == null)` — nested inside Block 2 (L800)

If the backing list has not yet been initialized, create a new empty instance.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (ido_rsn_cd_list == null)` // If list is null, generate a new empty instance |
| 2 | SET | `ido_rsn_cd_list = new X33VDataTypeList()` // Initialize the backing list |

**Block 2.2** — [Processing] Create and add the new bean instance (L802-L803)

Regardless of whether the list was just initialized or already existed, create a new string bean and append it.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpBean = new X33VDataTypeStringBean()` // Create instance of the specified data type bean; item initial values are defined internally within each data bean |
| 2 | CALL | `ido_rsn_cd_list.add(tmpBean)` // Append the new bean to the list |
| 3 | RETURN | `return ido_rsn_cd_list.size() - 1;` // Return the 0-based index of the newly added element |

**Block 3** — [ELSE / FALL-THROUGH] Unrecognized key (L806)

The key did not match any recognized list item name.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // Return -1 when no matching item exists |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `異動理由コード` | Field (Japanese) | Movement Reason Code — the reason why a service contract or line item is being moved/changed. This is the human-readable Japanese name used as the key parameter. |
| `ido_rsn_cd` | Field | Item ID for Movement Reason Code list — the internal data field identifier (lowercase underscore format) that maps to the Japanese name "異動理由コード". |
| `X33VDataTypeList` | Framework | A generic mutable list container from the Fujitsu Futurity X33V framework, capable of holding typed bean instances. Used here as the backing store for the Movement Reason Code entries. |
| `X33VDataTypeStringBean` | Framework | A string-typed data bean from the Fujitsu Futurity X33V framework. Each instance represents a single string value in a repeating list field. |
| `X33VDataTypeBeanInterface` | Interface | X33V framework interface that a data bean must implement to participate in the framework's view data management. |
| `X33VListedBeanInterface` | Interface | X33V framework interface indicating this bean supports list-based (repeating) data items. |
| `X33V` | Acronym | X33 View — Fujitsu's web application framework for building data-driven forms in Java EE / JSF environments. |
| `KKW01033SF` | Module | A service screen module for telecom service contract management (SF = Service Form). Part of the K-Opticom billing and service management system. |
| `DBean` | Suffix | Data Bean — a Java class that holds view-layer data and implements X33V framework interfaces for form data binding. |
| `X33SException` | Class | X33V framework exception class thrown by framework-level data bean methods. |

---

*Document generated from source analysis of KKW01033SF01DBean.java (lines 793-813, 21 LOC).*
