# Business Logic — KKW00810SFLogic.initServiceFormBean() [85 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00810SF.KKW00810SFLogic` |
| Layer | Controller / Screen Logic (Web layer — `eo.web.webview` package) |
| Module | `KKW00810SF` (Package: `eo.web.webview.KKW00810SF`) |

## 1. Role

### KKW00810SFLogic.initServiceFormBean()

This method initializes the service form bean for the **Fixed Global IP Access Information Registration screen** (固定グローバルIPアクセス情報登録画面). Its primary business purpose is to **transfer customer contract succession data** (顧客契約引継リスト) from the input-side form bean into the processing-side form bean, preparing it for downstream business logic execution. Specifically, it retrieves operational metadata (the operation date), extracts customer contract succession list items, and migrates key fields — system ID (SYSID), relocation division (IDO_DIV), service contract number (SVC_KEI_NO), and relocation reason details — from the source data bean (suffixed with `_01`) to the target data bean (with standard suffix). The method also maps relocation reason code/memo pairs into an EKK1091 detail bean array for screen display. It uses the **transformation/routing pattern**, delegating data access through the `X31SDataBeanAccess` messaging API and array manipulation through `X31SDataBeanAccessArray`. This method serves as a shared initialization utility called by the screen's init action (`actionInitKKW00810`), ensuring form state is consistent before the screen renders.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initServiceFormBean(svcFormBean)"])
    START --> GET_OPE_DATE["Get Operation Date"]
    GET_OPE_DATE --> SET_UNYO_YMD["Set unyo_ymd = JCCWebCommon.getOpeDate"]
    SET_UNYO_YMD --> SET_UNYO_YMD_VALUE["Set UNYO_YMD to svcFormBean"]
    SET_UNYO_YMD_VALUE --> GET_DATA_BEAN_ARRAY["Get CUST_KEI_HKTGI_LIST array"]
    GET_DATA_BEAN_ARRAY --> GET_FIRST_BEAN["Get first bean from array (index 0)"]
    GET_FIRST_BEAN --> TRANSFER_SYSID["Transfer SYSID_01 -> SYSID"]
    TRANSFER_SYSID --> TRANSFER_IDO_DIV["Transfer IDO_DIV_01 -> IDO_DIV"]
    TRANSFER_IDO_DIV --> TRANSFER_SVC_KEI_NO["Transfer SVC_KEI_NO_01 -> SVC_KEI_NO"]
    TRANSFER_SVC_KEI_NO --> GET_IDO_RSN_MEMO["Get IDO_RSN_MEMO_01 into local variable"]
    GET_IDO_RSN_MEMO --> GET_EKK1091_ARRAY["Get EKK1091D010CBSMSG1LIST array"]
    GET_EKK1091_ARRAY --> CLEAR_ARRAY["Clear EKK1091 array"]
    CLEAR_ARRAY --> GET_COUNT["Get IDO_RSN_CD_01 count as maxIndex"]
    GET_COUNT --> LOOP_CHECK{"i < maxIndex?"}
    LOOP_CHECK -->|true| ADD_DATA_BEAN["Add new data bean to EKK1091 array"]
    ADD_DATA_BEAN --> GET_RSN_CD["Get IDO_RSN_CD_01 value at index i"]
    GET_RSN_CD --> SET_RSN_CD_06["Set IDO_RSN_CD_06 with the reason code"]
    SET_RSN_CD_06 --> SET_RSN_MEMO_06["Set IDO_RSN_MEMO_06 with the shared memo"]
    SET_RSN_MEMO_06 --> INCREMENT["Increment i"]
    INCREMENT --> LOOP_CHECK
    LOOP_CHECK -->|false| END_NODE(["End / Return"])
```

The method executes as a linear sequence with one loop:

1. **Operation Date Retrieval** — Fetches the current operation date from the system and stores it into the service form bean under `UNYO_YMD`.
2. **Customer Contract Succession List Access** — Retrieves the customer contract succession list (`CUST_KEI_HKTGI_LIST`) as an `X31SDataBeanAccessArray` and accesses the first entry (index 0) as the source bean.
3. **Field Transfer Phase** — Transfers four scalar fields from the source bean (keyed by `_01` suffixed constants) to the target svcFormBean (standard suffixed constants):
   - System ID: `SYSID_01` → `SYSID`
   - Relocation Division: `IDO_DIV_01` → `IDO_DIV`
   - Service Contract Number: `SVC_KEI_NO_01` → `SVC_KEI_NO`
4. **Relocation Reason Memo Capture** — Captures the relocation reason memo (`IDO_RSN_MEMO_01`) into a local variable, as the same memo applies to all relocation reason code entries.
5. **Relocation Reason Detail Mapping Loop** — Clears the EKK1091 detail bean array, then iterates over each relocation reason code entry, copying the reason code (`IDO_RSN_CD_01` → `IDO_RSN_CD_06`) and the shared memo (`IDO_RSN_MEMO_06`) into new detail beans.

Note: Several fields are **commented out** (options service contract number, processing division, application number, etc.) — these were historically transferred but are currently disabled.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `svcFormBean` | `X31SDataBeanAccess` | The service form bean accessor that holds the input-side data (with `_01` suffixed fields) and receives the initialized output-side data (standard suffixed fields). It carries the customer contract succession list and operates as the primary data interchange object between the screen and business logic. |

**Instance Fields / External State:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `unyo_ymd` | `String` | Operation date string (YYYY-MM-DD format) — stores the retrieved system date for form display |

**Constants Read (via KKW00810SFConst):**

| Constant | Value (Key) | Business Meaning |
|----------|-------------|------------------|
| `UNYO_YMD` | `"UNYO_YMD"` | Operation date key for the form bean |
| `CUST_KEI_HKTGI_LIST` | `"CUST_KEI_HKTGI_LIST"` | Customer contract succession list array |
| `SYSID_01` | `"SYSID_01"` | System ID from input-side form (source) |
| `SYSID` | `"SYSID"` | System ID for output-side form (target) |
| `IDO_DIV_01` | `"IDO_DIV_01"` | Relocation division from input-side |
| `IDO_DIV` | `"IDO_DIV"` | Relocation division for output-side |
| `SVC_KEI_NO_01` | `"SVC_KEI_NO_01"` | Service contract number from input-side |
| `SVC_KEI_NO` | `"SVC_KEI_NO"` | Service contract number for output-side |
| `IDO_RSN_MEMO_01` | `"IDO_RSN_MEMO_01"` | Relocation reason memo from input-side |
| `EKK1091D010CBSMSG1LIST` | `"EKK1091D010CBSMSG1LIST"` | EKK1091 relocation reason detail bean array |
| `IDO_RSN_CD_01` | `"IDO_RSN_CD_01"` | Relocation reason code in input-side (loop index) |
| `IDO_RSN_CD_06` | `"IDO_RSN_CD_06"` | Relocation reason code in EKK1091 detail output |
| `IDO_RSN_MEMO_06` | `"IDO_RSN_MEMO_06"` | Relocation reason memo in EKK1091 detail output |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCWebCommon.getOpeDate` | JCCWebCommon | - | Reads the current operation date (YYYY-MM-DD) from the system/business logic layer |
| R | `svcFormBean.getDataBeanArray(KKW00810SFConst.CUST_KEI_HKTGI_LIST)` | X31SDataBeanAccess | - | Reads the customer contract succession list array from the input-side form bean |
| R | `obj.getDataBean(0)` | X31SDataBeanAccess | - | Retrieves the first (and typically only) element from the succession list |
| R | `bean.sendMessageString(KEY, DATABEAN_GET_VALUE)` | X31SDataBeanAccess | - | Reads scalar field values (SYSID, IDO_DIV, SVC_KEI_NO, IDO_RSN_MEMO_01) from the source bean |
| R | `bean.sendMessage(KEY, DATABEAN_GET_COUNT)` | X31SDataBeanAccess | - | Gets the count of relocation reason code entries (loop upper bound) |
| C | `ekk1091d010Arr.addDataBean()` | X31SDataBeanAccessArray | - | Creates a new detail bean entry in the EKK1091 relocation reason array |
| W | `ekk1091d010Arr.clearArray()` | X31SDataBeanAccessArray | - | Clears all existing entries in the EKK1091 array before repopulating |
| W | `svcFormBean.sendMessageString(KEY, DATABEAN_SET_VALUE, value)` | X31SDataBeanAccess | - | Sets output-side form bean fields (UNYO_YMD, SYSID, IDO_DIV, SVC_KEI_NO) |
| W | `ekk1091d010dtlBean.sendMessageString(KEY, DATABEAN_SET_VALUE, value)` | X31SDataBeanAccess | - | Sets relocation reason code and memo fields into EKK1091 detail beans |

**CRUD Summary:**
- **Read (R):** Operation date query, form bean field reads, array access, element count retrieval
- **Create (C):** New EKK1091 detail beans created per relocation reason code entry
- **Write (W):** Output-side form bean fields set, EKK1091 detail bean fields populated, array cleared

**No direct database operations** — this method operates entirely at the form bean/transfer layer. Database access (if any) occurs in downstream SC/CBS components.

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `getDataBeanArray` [R], `getDataBean` [R], `addDataBean` [C], `clearArray` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `KKW00810SFLogic.actionInitKKW00810()` | `actionInitKKW00810()` → `initServiceFormBean(svcFormBean)` | `sendMessageString` [W], `getDataBeanArray` [R], `getDataBean` [R], `addDataBean` [C], `clearArray` [W] |

**Explanation:** This method is called from `actionInitKKW00810()` within the same class (`KKW00810SFLogic`). The `actionInitKKW00810` action is the init handler for the Fixed Global IP Access Information Registration screen. This method prepares the form bean state before the screen renders, transferring input-side data to output-side format.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] (L784)

> Retrieves the operation date and stores it in the instance field and form bean.

| # | Type | Code |
|---|------|------|
| 1 | SET | `unyo_ymd = JCCWebCommon.getOpeDate(this, null);` // Get operation date [-> JCCWebCommon.getOpeDate] |
| 2 | SET | `svcFormBean.sendMessageString(KKW00810SFConst.UNYO_YMD, X31CWebConst.DATABEAN_SET_VALUE, unyo_ymd);` // Set operation date to form bean [-> UNYO_YMD="UNYO_YMD"] |

**Block 2** — [GET] (L788)

> Retrieves the customer contract succession list from the form bean and extracts the first (and typically sole) entry.

| # | Type | Code |
|---|------|------|
| 1 | SET | `X31SDataBeanAccessArray obj = svcFormBean.getDataBeanArray(KKW00810SFConst.CUST_KEI_HKTGI_LIST);` // Get customer contract succession list [-> CUST_KEI_HKTGI_LIST="CUST_KEI_HKTGI_LIST"] |
| 2 | SET | `X31SDataBeanAccess bean = obj.getDataBean(0);` // Get first element from succession list |

**Block 3** — [SET, EXEC] (L791–803)

> Transfers four scalar fields from the source bean (input-side, `_01` suffix) to the target form bean (output-side, standard suffix). Each field is read via `sendMessageString` with `DATABEAN_GET_VALUE` and written back via `sendMessageString` with `DATABEAN_SET_VALUE`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String str = null;` // Initialize temporary transfer variable |
| 2 | EXEC | `str = bean.sendMessageString(KKW00810SFConst.SYSID_01, X31CWebConst.DATABEAN_GET_VALUE);` // Read SYSID from source [-> SYSID_01="SYSID_01"] |
| 3 | EXEC | `svcFormBean.sendMessageString(KKW00810SFConst.SYSID, X31CWebConst.DATABEAN_SET_VALUE, str);` // Write SYSID to target [-> SYSID="SYSID"] |
| 4 | EXEC | `str = bean.sendMessageString(KKW00810SFConst.IDO_DIV_01, X31CWebConst.DATABEAN_GET_VALUE);` // Read relocation division from source [-> IDO_DIV_01="IDO_DIV_01"] |
| 5 | EXEC | `svcFormBean.sendMessageString(KKW00810SFConst.IDO_DIV, X31CWebConst.DATABEAN_SET_VALUE, str);` // Write relocation division to target [-> IDO_DIV="IDO_DIV"] |
| 6 | EXEC | `str = bean.sendMessageString(KKW00810SFConst.SVC_KEI_NO_01, X31CWebConst.DATABEAN_GET_VALUE);` // Read service contract number from source [-> SVC_KEI_NO_01="SVC_KEI_NO_01"] |
| 7 | EXEC | `svcFormBean.sendMessageString(KKW00810SFConst.SVC_KEI_NO, X31CWebConst.DATABEAN_SET_VALUE, str);` // Write service contract number to target [-> SVC_KEI_NO="SVC_KEI_NO"] |
| 8 | SET | `String ido_rsn_memo = bean.sendMessageString(KKW00810SFConst.IDO_RSN_MEMO_01, X31CWebConst.DATABEAN_GET_VALUE);` // Read relocation reason memo into local variable (shared across all reason code entries) [-> IDO_RSN_MEMO_01="IDO_RSN_MEMO_01"] |

**Block 4** — [GET, CLEAR, FOR LOOP] (L806–821)

> Maps relocation reason code/memo pairs from the source bean into the EKK1091 detail bean array. The array is first cleared, then repopulated by iterating over each reason code entry. The relocation reason memo is **shared** across all entries (read once, written to each detail bean).

| # | Type | Code |
|---|------|------|
| 1 | SET | `X31SDataBeanAccessArray ekk1091d010Arr = svcFormBean.getDataBeanArray(KKW00810SFConst.EKK1091D010CBSMSG1LIST);` // Get EKK1091 detail array [-> EKK1091D010CBSMSG1LIST="EKK1091D010CBSMSG1LIST"] |
| 2 | EXEC | `ekk1091d010Arr.clearArray();` // Clear all existing entries before repopulating |
| 3 | SET | `Integer maxIndex = (Integer)bean.sendMessage(KKW00810SFConst.IDO_RSN_CD_01, X31CWebConst.DATABEAN_GET_COUNT);` // Get count of reason code entries [-> IDO_RSN_CD_01="IDO_RSN_CD_01"] |
| 4 | FOR | `for(int i = 0; i < maxIndex; i++)` // Iterate over each relocation reason code entry |
| 4.1 | SET | `X31SDataBeanAccess ekk1091d010dtlBean = ekk1091d010Arr.addDataBean();` // Create new EKK1091 detail bean |
| 4.2 | SET | `String ido_rsn_cd = bean.sendMessageString(KKW00810SFConst.IDO_RSN_CD_01, X31CWebConst.DATABEAN_GET_VALUE, i);` // Read reason code at index i [-> IDO_RSN_CD_01="IDO_RSN_CD_01"] |
| 4.3 | SET | `ekk1091d010dtlBean.sendMessageString(KKW00810SFConst.IDO_RSN_CD_06, X31CWebConst.DATABEAN_SET_VALUE, ido_rsn_cd);` // Set reason code in detail [-> IDO_RSN_CD_06="IDO_RSN_CD_06"] |
| 4.4 | SET | `ekk1091d010dtlBean.sendMessageString(KKW00810SFConst.IDO_RSN_MEMO_06, X31CWebConst.DATABEAN_SET_VALUE, ido_rsn_memo);` // Set shared reason memo in detail [-> IDO_RSN_MEMO_06="IDO_RSN_MEMO_06"] // 異動理由メモ対応 Start/End |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `unyo_ymd` | Field | Operation date — the current business date (YYYY-MM-DD) used as a reference timestamp for form processing |
| `CUST_KEI_HKTGI_LIST` | Field | Customer contract succession list — list of customer contracts being transferred/successed during service changes |
| `HKTGI` | Acronym | 引継 (Hikitsuke) — succession/transfer of customer contracts between service entities |
| `SYSID` | Field | System ID — identifies the system or service node associated with the customer contract |
| `IDO_DIV` | Field | Relocation division (異動区分) — classifies the type of service relocation/migration (e.g., same building, different building) |
| `IDO` | Acronym | 異動 (Idou) — relocation/migration in the context of service contract changes |
| `SVC_KEI_NO` | Field | Service contract number (サービス契約番号) — unique identifier for a service contract line item |
| `KEI` | Acronym | 契約 (Keiyaku) — contract |
| `NO` | Acronym | Number |
| `IDO_RSN_CD` | Field | Relocation reason code (異動理由コード) — classification code for why a service relocation occurred |
| `IDO_RSN_MEMO` | Field | Relocation reason memo (異動理由メモ) — free-text explanation for the relocation reason |
| `RSN` | Acronym | Reason |
| `EKK1091D010CBSMSG1LIST` | Field | EKK1091 relocation reason detail bean array — holds structured relocation reason code/memo pairs for screen display |
| `UNYO_YMD` | Field | Operation date field key in the form bean (運用年月日) |
| `_01` / `_06` | Suffix | Data bean field naming convention — `_01` suffixed fields belong to the input-side (source) bean; standard or `_06` suffixed fields belong to the output-side (target/detail) bean |
| `X31SDataBeanAccess` | Class | Service Data Bean Access — the messaging-based API for reading/writing form bean fields |
| `X31SDataBeanAccessArray` | Class | Array of service data beans — manages a list of `X31SDataBeanAccess` entries |
| `DATABEAN_GET_VALUE` | Constant | Message type for reading a value from a data bean |
| `DATABEAN_SET_VALUE` | Constant | Message type for setting a value in a data bean |
| `DATABEAN_GET_COUNT` | Constant | Message type for retrieving the count of values for a given field |
| `DATABEAN_ADD_VALUE` | Constant | Message type for adding a new value (currently unused — commented out) |
| Fixed Global IP | Business term | 固定グローバルIP — a static public IP address assigned to a customer for internet access, managed in the KKW00810SF screen |
| JCCWebCommon | Class | Common Web utility class providing shared operations such as `getOpeDate()` |
| `actionInitKKW00810` | Method | Init action handler for the KKW00810 screen — calls `initServiceFormBean` to prepare form state |
| KKW00810SF | Module | Fixed Global IP Access Information Registration screen module |
