# Business Logic — KKW12601SFLogic.setPulldownSelected() [77 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW12601SF.KKW12601SFLogic` |
| Layer | Controller (Web layer — screen logic class) |
| Module | `KKW12601SF` (Package: `eo.web.webview.KKW12601SF`) |

## 1. Role

### KKW12601SFLogic.setPulldownSelected()

This method is a **view-state initialization and restoration utility** for the KKW12601 screen — the **Subscribed Service Letter List Display** (加入御礼書一覧照会). Its business purpose is to configure the selection state of four dropdown controls and one checkbox on the search form before rendering the page.

The method branches on a single boolean switch: the `search_flg` parameter. When `search_flg` equals `"1"` (Search: Yes), the method enters **search result restoration mode**. It reads previously-entered search criteria from the form's data bean — data type code, new addition identification flag, send exclusion flag, and unsent flag — and uses `getPulldownSelected()` to look up each value against the corresponding dropdown's code list. The matching index and code name are written back to each pulldown, so the user sees their prior selections preserved on re-display (e.g., after a search action triggers a page refresh).

When `search_flg` does **not** equal `"1"` (i.e., on initial screen load, clear, or reset), the method enters **initialization mode**. It resets the data type and new addition pulldowns to an empty first option (index `"0"`), selects the "send target" option (`SEND_JGI_SEND = "1"`) for the send exclusion pulldown, and checks the "Unsent" (未送信) checkbox by default — establishing a sensible default search state.

This method acts as a **shared page-preparation utility** called at the end of `actionClear()` and `actionInit()`, ensuring consistent UI state regardless of how the screen is entered. It implements a **branching dispatch pattern** driven by the search flag constant, with no CRUD operations — it purely manipulates the presentation-layer data bean.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setPulldownSelected bean, search_flg"])

    START --> S1["S1: Get pulldown data beans from bean"]

    S1 --> S2["S2: Extract data_sbt_list, newaddskbt_list, sendjgi_list"]
    S2 --> COND1{"search_flg equals<br/>SEARCH_FLG_Y = 1<br/>Search Yes?"}

    COND1 -->|Yes| SEARCH_BRANCH["Search branch"]
    COND1 -->|No| INIT_BRANCH["Initialization branch"]

    SEARCH_BRANCH --> S3["Get search_data_sbt_cd from bean"]
    S3 --> S4["Create selParamDatasbt list"]
    S4 --> S5["CALL getPulldownSelected datasbtBean"]
    S5 --> S6["SET datasbtBean selectedIndex"]
    S6 --> S7["Get search_new_add_skbt_f from bean"]
    S7 --> S8["Create selParamNewaddskbt list"]
    S8 --> S9["CALL getPulldownSelected newaddskbtBean"]
    S9 --> S10["SET newaddskbtBean selectedIndex"]
    S10 --> S11["Get search_send_jgi_flg from bean"]
    S11 --> S12["Create selParamSendjgi list"]
    S12 --> S13["CALL getPulldownSelected sendjgiBean"]
    S13 --> S14["SET sendjgiBean selectedIndex"]
    S14 --> S15["Get search_mi_send from bean"]
    S15 --> COND2{"search_mi_send equals<br/>MI_SEND_FLG_Y = 1<br/>Unsent?"}
    COND2 -->|Yes| S16["SET MI_SEND checkbox = true"]
    COND2 -->|No| S17["SET MI_SEND checkbox = false"]
    S16 --> END1(["End"])
    S17 --> END1

    INIT_BRANCH --> S18["SET datasbtBean selectedIndex 0"]
    S18 --> S19["SET newaddskbtBean selectedIndex 0"]
    S19 --> S20["Create selParam list"]
    S20 --> S21["CALL getPulldownSelected sendjgiBean SEND_JGI_SEND"]
    S21 --> S22["SET sendjgiBean selectedIndex"]
    S22 --> S23["SET MI_SEND checkbox = true"]
    S23 --> END1
```

**Key constant resolutions:**
- `SEARCH_FLG_Y` = `"1"` — Search flag value meaning "Yes" (search request). When `search_flg` equals `"1"`, the method restores the user's prior search criteria into the dropdowns.
- `MI_SEND_FLG_Y` = `"1"` — Unsent flag value meaning "Unsent". When the unsent search criterion equals `"1"`, the "Unsent" checkbox is checked.
- `SEND_JGI_SEND` = `"1"` — Send exclusion flag value meaning "Send target" (from `JKKCommonConst.SEND_JGI_SEND`). In initialization mode, the send exclusion pulldown defaults to "Send target".

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `bean` | `X31SDataBeanAccess` | The screen's form data access object. Provides read/write access to the search form's data beans, including pulldown code lists and previously-entered search criteria. In business terms, this is the **presentation-layer state container** for the Subscribed Service Letter List screen. |
| 2 | `search_flg` | `String` | Search flag indicator. Controls which of two processing modes the method enters: `"1"` (Search: Yes — restore prior search criteria into dropdowns) or any other value such as `"0"` (Search: No — initialize dropdowns to defaults). This is the **dispatch switch** for the method's entire control flow. |

**Instance fields / external state read:**
- `KKW12601SFConst.DATA_SBT_INFO` — Data type information key (「データ種別情報」)
- `KKW12601SFConst.NEW_ADD_SKBT_INFO` — New addition identification information key (「新規追加識別情報」)
- `KKW12601SFConst.SEND_JGI_INFO` — Send exclusion information key (「送信除外情報」)
- `KKW12601SFConst.MI_SEND` — Unsent key (「未送信」)
- `KKW12601SFConst.INDEX_01` — Index key (「添え字」)
- `KKW12601SFConst.SEARCH_DATA_SBT_CD` — Search data type code key (「検索用データ種別コード」)
- `KKW12601SFConst.SEARCH_NEW_ADD_SKBT_F` — Search new addition identification flag key (「検索用新規追加識別フラグ」)
- `KKW12601SFConst.SEARCH_SEND_JGI_FLG` — Search send exclusion flag key (「検索用送信除外フラグ」)
- `KKW12601SFConst.SEARCH_MI_SEND` — Search unsent key (「検索用未送信」)
- `SEND_JGI_SEND` — Local constant `"1"` (Send target — 送信対象)
- `MI_SEND_FLG_Y` — Local constant `"1"` (Unsent — 未送信)
- `SEARCH_FLG_Y` — Local constant `"1"` (Search Yes — 検索フラグ「要」)
- `X31CWebConst.DATABEAN_GET_VALUE` / `DATABEAN_SET_VALUE` / `DATABEAN_GET_COUNT` — Data bean access mode constants
- `KKW12601SFConst.CD_DIV_LIST_01` — Code list key (「コードリスト」)
- `KKW12601SFConst.CD_DIV_NM_LIST_01` — Code name list key (「コード名リスト」)

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `OneStopDataBeanAccessArray.getDataBeanArray(String)` | OneStopDataBeanAccessArray | - | Reads data bean arrays for pulldown code lists (data type, new addition, send exclusion) from the form bean. |
| R | `OneStopDataBeanAccess.getDataBean(int)` | OneStopDataBeanAccess | - | Extracts the first data bean (index 0) from each array — the actual pulldown control bean. |
| R | `OneStopDataBeanAccess.sendMessageString(String, String)` | OneStopDataBeanAccess | - | Reads previously-entered search criteria values from the form bean (e.g., search data type code, search unsent flag). |
| R | `OneStopDataBeanAccess.sendMessageString(String, String, int)` | OneStopDataBeanAccess | - | Enumerates code list entries by index in `getPulldownSelected()` to find a matching code. |
| R | `OneStopDataBeanAccess.sendMessage(int, String)` | OneStopDataBeanAccess | - | Gets the count of code list entries in `getPulldownSelected()`. |
| R | `OneStopDataBeanAccess.sendMessage(String, String, int)` | OneStopDataBeanAccess | - | Gets code value and code name at a given index in `getPulldownSelected()`. |
| - | `OneStopDataBeanAccess.sendMessageString(String, String, String)` | OneStopDataBeanAccess | - | Sets the selectedIndex of each pulldown data bean to the computed index string. |
| R | `KKW12601SFLogic.getPulldownSelected(X31SDataBeanAccess, String, ArrayList)` | KKW12601SFLogic | - | Internal method that searches a code list for a matching code and returns the index and code name. |
| R | `OneStopDataBeanAccess.sendMessageBoolean(String, String, boolean)` | OneStopDataBeanAccess | - | Sets the MI_SEND (Unsent) checkbox checked/unchecked state. |

**No database or entity operations.** This method operates entirely within the presentation layer (form data bean) and does not invoke any SC/CBS, mapper, or data persistence component. All operations are Read (R) or non-CRUD state writes on the in-memory data bean.

## 5. Dependency Trace

### Direct Callers

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Controller:KKW12601SFLogic | `actionClear` -> `setPulldownSelected` | `sendMessageString` [-] (data bean state write) |
| 2 | Controller:KKW12601SFLogic | `actionInit` -> `setPulldownSelected` | `sendMessageString` [-] (data bean state write) |

**Call context:**
- `actionClear()` — Invoked when the user clicks the "Clear" (クリア) button on the search form. After resetting search criteria fields, it calls `setPulldownSelected(bean, SEARCH_FLG_N)` (i.e., `"0"`) to reset all dropdowns to their default/initial state.
- `actionInit()` — Invoked on the initial screen load. After populating dropdown code lists, it calls `setPulldownSelected(bean, SEARCH_FLG_Y)` (i.e., `"1"`), but since no prior search criteria exist on first load, the dropdowns simply render their default first options.

**Terminal operations:** All terminal operations are in-memory data bean state writes (`sendMessageString` for pulldown selectedIndex, `sendMessageBoolean` for checkbox state). No data is persisted, queried, or routed to downstream services.

## 6. Per-Branch Detail Blocks

**Block 1** — [EXTRACT/SETUP] (L1618)

> Extract three data bean arrays from the form bean and retrieve their first element — each corresponds to a dropdown control on the search form.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `datasbtlist = bean.getDataBeanArray(KKW12601SFConst.DATA_SBT_INFO)` // Get data type info pulldown array |
| 2 | EXEC | `datasbtBean = datasbtlist.getDataBean(0)` // Extract first data bean |
| 3 | EXEC | `newaddskbtlist = bean.getDataBeanArray(KKW12601SFConst.NEW_ADD_SKBT_INFO)` // Get new addition identification info pulldown array |
| 4 | EXEC | `newaddskbtBean = newaddskbtlist.getDataBean(0)` // Extract first data bean |
| 5 | EXEC | `sendjgilist = bean.getDataBeanArray(KKW12601SFConst.SEND_JGI_INFO)` // Get send exclusion info pulldown array |
| 6 | EXEC | `sendjgiBean = sendjgilist.getDataBean(0)` // Extract first data bean |

**Block 2** — [IF] `(SEARCH_FLG_Y.equals(search_flg))` [SEARCH_FLG_Y="1"] (L1633)

> Search criteria restoration branch. When the search flag is "1" (Search: Yes), this block restores the user's previously-entered search criteria into the dropdowns so they persist after a page refresh.

**Block 2.1** — [SETUP/EXEC/CALL] — Data type pulldown (L1637)

> Retrieve the data type code from the search criteria and set the corresponding pulldown index.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `search_data_sbt_cd = bean.sendMessageString(KKW12601SFConst.SEARCH_DATA_SBT_CD, X31CWebConst.DATABEAN_GET_VALUE)` // Get search data type code |
| 2 | SET | `selParamDatasbt = new ArrayList<String>()` // Create result holder list |
| 3 | CALL | `getPulldownSelected(datasbtBean, search_data_sbt_cd, selParamDatasbt)` // Find matching index in code list |
| 4 | EXEC | `datasbtBean.sendMessageString(KKW12601SFConst.INDEX_01, X31CWebConst.DATABEAN_SET_VALUE, selParamDatasbt.get(0))` // Set selectedIndex to matched index |

**Block 2.2** — [SETUP/EXEC/CALL] — New addition identification pulldown (L1644)

> Retrieve the new addition identification flag from search criteria and set the corresponding pulldown index.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `search_new_add_skbt_f = bean.sendMessageString(KKW12601SFConst.SEARCH_NEW_ADD_SKBT_F, X31CWebConst.DATABEAN_GET_VALUE)` // Get search new addition flag |
| 2 | SET | `selParamNewaddskbt = new ArrayList<String>()` // Create result holder list |
| 3 | CALL | `getPulldownSelected(newaddskbtBean, search_new_add_skbt_f, selParamNewaddskbt)` // Find matching index in code list |
| 4 | EXEC | `newaddskbtBean.sendMessageString(KKW12601SFConst.INDEX_01, X31CWebConst.DATABEAN_SET_VALUE, selParamNewaddskbt.get(0))` // Set selectedIndex to matched index |

**Block 2.3** — [SETUP/EXEC/CALL] — Send exclusion pulldown (L1652)

> Retrieve the send exclusion flag from search criteria and set the corresponding pulldown index.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `search_send_jgi_flg = bean.sendMessageString(KKW12601SFConst.SEARCH_SEND_JGI_FLG, X31CWebConst.DATABEAN_GET_VALUE)` // Get search send exclusion flag |
| 2 | SET | `selParamSendjgi = new ArrayList<String>()` // Create result holder list |
| 3 | CALL | `getPulldownSelected(sendjgiBean, search_send_jgi_flg, selParamSendjgi)` // Find matching index in code list |
| 4 | EXEC | `sendjgiBean.sendMessageString(KKW12601SFConst.INDEX_01, X31CWebConst.DATABEAN_SET_VALUE, selParamSendjgi.get(0))` // Set selectedIndex to matched index |

**Block 2.4** — [IF/ELSE] `(MI_SEND_FLG_Y.equals(search_mi_send))` [MI_SEND_FLG_Y="1"] (L1662)

> Handle the "Unsent" (未送信) checkbox. If the search criteria specifies "Unsent" = "1", check the checkbox; otherwise uncheck it.

**Block 2.4.1** — [IF] `MI_SEND_FLG_Y.equals(search_mi_send)` [MI_SEND_FLG_Y="1"] (L1665)

> The search criteria specifies "Unsent" — check the checkbox.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `bean.sendMessageBoolean(KKW12601SFConst.MI_SEND, X31CWebConst.DATABEAN_SET_VALUE, true)` // Set MI_SEND checkbox to checked |

**Block 2.4.2** — [ELSE] (L1669)

> The search criteria does not specify "Unsent" — uncheck the checkbox.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `bean.sendMessageBoolean(KKW12601SFConst.MI_SEND, X31CWebConst.DATABEAN_SET_VALUE, false)` // Set MI_SEND checkbox to unchecked |

**Block 3** — [ELSE] — Initialization (L1674)

> Default state initialization branch. When the search flag is NOT "1" (e.g., on initial load or clear), reset all dropdowns to default values and check the "Unsent" checkbox.

**Block 3.1** — [EXEC] — Data type pulldown default (L1678)

> Reset data type pulldown to empty first option (index "0").

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `datasbtBean.sendMessageString(KKW12601SFConst.INDEX_01, X31CWebConst.DATABEAN_SET_VALUE, "0")` // Set to empty selection |

**Block 3.2** — [EXEC] — New addition pulldown default (L1681)

> Reset new addition identification pulldown to empty first option (index "0").

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `newaddskbtBean.sendMessageString(KKW12601SFConst.INDEX_01, X31CWebConst.DATABEAN_SET_VALUE, "0")` // Set to empty selection |

**Block 3.3** — [SETUP/CALL/EXEC] — Send exclusion pulldown default (L1684)

> Resolve the send exclusion pulldown to the "Send target" option (SEND_JGI_SEND = "1").

| # | Type | Code |
|---|------|------|
| 1 | SET | `selParam = new ArrayList<String>()` // Create result holder list |
| 2 | CALL | `getPulldownSelected(sendjgiBean, SEND_JGI_SEND, selParam)` // Look up "1" (Send target) in code list |
| 3 | EXEC | `sendjgiBean.sendMessageString(KKW12601SFConst.INDEX_01, X31CWebConst.DATABEAN_SET_VALUE, selParam.get(0))` // Set selectedIndex to matched index |

**Block 3.4** — [EXEC] — Unsent checkbox default (L1689)

> Default the "Unsent" checkbox to checked.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `bean.sendMessageBoolean(KKW12601SFConst.MI_SEND, X31CWebConst.DATABEAN_SET_VALUE, true)` // Set MI_SEND checkbox to checked (default) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `DATA_SBT_INFO` | Constant Key | Data type information (データ種別情報) — identifies the pulldown array containing service detail type codes and names |
| `NEW_ADD_SKBT_INFO` | Constant Key | New addition identification information (新規追加識別情報) — identifies the pulldown array for new/additional service identification flags |
| `SEND_JGI_INFO` | Constant Key | Send exclusion information (送信除外情報) — identifies the pulldown array for send/exclusion status flags |
| `MI_SEND` | Constant Key | Unsent (未送信) — the checkbox controlling whether to filter for unsent records |
| `INDEX_01` | Constant Key | Index key (添え字) — the data bean key for setting/getting pulldown selection index |
| `SEARCH_FLG_Y` | Constant | `"1"` — Search flag "Yes" (検索フラグ「要」). Triggers search criteria restoration mode |
| `SEARCH_FLG_N` | Constant | `"0"` — Search flag "No" (検索フラグ「不要」). Triggers initialization mode |
| `MI_SEND_FLG_Y` | Constant | `"1"` — Unsent flag "Unsent" (未送信フラグ「未送信」). Indicates unsent records |
| `SEND_JGI_SEND` | Constant | `"1"` — Send target (送信対象). The send exclusion flag value meaning "include in send" |
| `CD_DIV_LIST_01` | Constant Key | Code list (コードリスト) — the data bean key for accessing dropdown code value entries |
| `CD_DIV_NM_LIST_01` | Constant Key | Code name list (コード名リスト) — the data bean key for accessing dropdown code name entries |
| `X31SDataBeanAccess` | Class | Screen-level data bean access class providing get/set operations on form fields and nested data beans |
| `X31SDataBeanAccessArray` | Class | Array wrapper for data beans — holds multiple rows of structured form data |
| `X31CWebConst` | Class | Web-layer constants class defining data bean operation mode constants (GET_VALUE, SET_VALUE, GET_COUNT) |
| `JKKCommonConst` | Class | Common business constants shared across screens — defines SEND_JGI_SEND, SEND_JGI_JGI, etc. |
| `getPulldownSelected()` | Method | Internal utility that searches a code list (by iterating indices) for a matching code and returns the matching index and code name |
| `actionInit()` | Method | Screen initialization action handler — calls setPulldownSelected on initial page load |
| `actionClear()` | Method | Clear action handler — resets form fields and calls setPulldownSelected to reset dropdowns |
| KKW12601SF | Module | Subscribed Service Letter List Screen (加入御礼書一覧照会画面) — a telecom operator screen for displaying and searching delivered service letters |
| 加入御礼書 | Business term | Subscribed Service Confirmation Letter — a notification document sent to customers upon service subscription |
| 照会 | Business term | Inquiry/Display — the screen type that allows searching and displaying records |
| データ種別 | Business term | Data type (データしゅべつ) — classifies the category of service detail (e.g., FTTH, Mail, ENUM) |
| 新規追加識別 | Business term | New addition identification (しんきついかしてきべつ) — flag indicating whether a service line is a new addition |
| 送信除外 | Business term | Send exclusion (そうしんじょがい) — controls whether a record is excluded from letter dispatch |
| 未送信 | Business term | Unsent (みそうしん) — flag indicating a record has not yet been dispatched |
