# Business Logic — KKW02501SFLogic.setHktgiBean() [79 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW02501SF.KKW02501SFLogic` |
| Layer | Controller (Web Logic — `eo.web.webview.*` package) |
| Module | `KKW02501SF` (Package: `eo.web.webview.KKW02501SF`) |

## 1. Role

### KKW02501SFLogic.setHktgiBean()

This method is an **initial display data bean setter** for the KKW02501SF screen. Its business purpose is to **prepare and propagate key customer contract fields from the inherited/form bean into the screen's output DataBean** so that the HTML/JSF page can display the correct context when the page first renders. Specifically, it performs four data transfer responsibilities: (1) it injects the system operation date (YYMMDD format) into the page-level bean; (2) it copies the SYSID (system ID), service contract number, processing division code, and transfer division code from the source customer-contract row bean into the target screen bean; (3) it **re-creates the "reason for transfer" (ido_rsn) list** in the target bean by iterating over the source's reason codes and memos, allocating new list entries as needed and applying a global memo override (memo-memo correspondence); and (4) it copies the optional service contract number, application number (mskm_no), and application detail number into the screen bean. The method implements a **routing/dispatch pattern** — it reads data from a single source customer-contract record and distributes each field to the appropriate target bean, using a builder-like approach to dynamically size a list of error/transfer reasons.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START["setHktgiBean params"]

    START --> S1["S1: Get operation date via JCCWebCommon.getOpeDate"]
    S1 --> S2["S2: Set unyo_ymd into paramBean[0] UNYO_YMD"]

    S2 --> S3["S3: Get customer contract list from getDataBeanArray"]
    S3 --> S4["S4: Get first element from custKeiHktgiList getDataBean 0"]

    S4 --> S5["S5: Extract SYSID from custKeiHktgiInf set into paramBean[0]"]
    S5 --> S6["S6: Extract svc_kei_no set into paramBean[0]"]
    S6 --> S7["S7: Extract trans_div set into paramBean[0]"]
    S7 --> S8["S8: Extract ido_div set into paramBean[0]"]

    S8 --> S9["S9: Get ido_rsn_list via getDataBeanArray IDO_RSN_LIST"]
    S9 --> S10["S10: Extract ido_rsn_memo from custKeiHktgiInf"]
    S10 --> S11["S11: Get ido_rsn_cd element count GET_COUNT"]

    S11 --> LOOP{For i=0 to cnt-1}

    LOOP -->|Yes| I_GET["I: Get or create ido_rsn_bean"]

    I_GET --> INULL{ido_rsn_bean == null}

    INULL -->|Yes| ISKIP["I: continue skip iteration"]
    INULL -->|No| IPROC["I: Extract ido_rsn_cd at index i"]

    IPROC --> ISET["I: Set ido_rsn_cd into ido_rsn_bean"]
    ISET --> IMEMO["I: Set ido_rsn_memo into ido_rsn_bean"]

    IMEMO --> LOOP

    LOOP -->|No| POST["Post-Loop: Extract op_svc_kei_no"]

    POST --> MSKM["Post-Loop: Extract mskm_no Application Number"]
    MSKM --> MSKMDTL["Post-Loop: Extract mskm_dtl_no Application Detail Number"]
    MSKMDTL --> ENDOF["Return End"]
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `paramBean` | `X31SDataBeanAccess[]` | Array of screen DataBean accessors. Index `[0]` is the primary target bean where all processed data fields are written (operation date, SYSID, service contract number, processing division, transfer division, reason-for-transfer list, optional service contract number, application number, application detail number). |

**Instance/External State Read:**

| Source | Type | Business Description |
|--------|------|---------------------|
| `JCCWebCommon.getOpeDate(this, null)` | Method call | Retrieves the current business operation date from the common date provider |
| `custKeiHktgiInf` (from `paramBean[0].getDataBeanArray().getDataBean(0)`) | Source DataBean row bean | First row of the customer-contract inheritance list — holds SYSID, service contract number, processing division, transfer division, reason codes, memo, optional service contract number, application number, and application detail number. Serves as the data source from which all target bean values are copied. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCWebCommon.getOpeDate` | (Common) | - | Retrieves the current operation date (YYMMDD string) from the system date service |
| R | `OneStopDataBeanAccess.getDataBeanArray` | (DataBean) | - | Retrieves the customer-contract inheritance list bean array from paramBean[0] |
| R | `OneStopDataBeanAccessArray.getDataBean` | (DataBean) | - | Gets the first (index 0) element from the customer-contract list |
| R | `X31SDataBeanAccess.sendMessageString` | (DataBean) | - | Getter — reads SYSID, service contract number, processing division, transfer division, reason code at index i, memo from the source row bean |
| C/R | `OneStopDataBeanAccessArray.getCount` | (DataBean) | - | Reads count of reason-for-transfer list entries, and element count of reason codes |
| R | `OneStopDataBeanAccess.sendMessage` | (DataBean) | - | Getter — retrieves element count of ido_rsn_cd array from source row bean |
| C | `OneStopDataBeanAccessArray.addDataBean` | (DataBean) | - | Creates a new entry in the reason-for-transfer list if the list is shorter than the number of reason codes |
| W | `OneStopDataBeanAccess.sendMessageString` | (DataBean) | - | Setter — writes operation date (unyo_ymd), SYSID, service contract number, processing division, transfer division, reason code, reason memo, optional service contract number, application number, application detail number into paramBean[0] |

**Classification rationale:**
- All operations are **in-memory DataBean manipulation** — no database or SC (Service Component) calls occur within this method.
- `getDataBeanArray`, `getDataBean`, `sendMessageString` (GET mode), `sendMessage` (GET_COUNT), `getCount` are **Read (R)** operations.
- `addDataBean` is **Create (C)** — allocates a new list element.
- `sendMessageString` (SET mode) is **Write (W)** — populates target bean fields.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Logic:KKW02501SFLogic.actionInit | `actionInit` -> `setHktgiBean(paramBean)` | `sendMessageString [W] UNYO_YMD, SYSID, SVC_KEI_NO, TRAN_DIV, IDO_DIV, IDO_RSN_CD_02, IDO_RSN_MEMO_02, OP_SVC_KEI_NO, MSKM_NO, MSKM_DTL_NO`, `addDataBean [C] IDO_RSN_LIST`, `getDataBean [R] HKTGI_CUST_KEI_HKTGI_LIST` |

**Terminal operations summary:**
The method's terminal operations are purely in-memory DataBean writes: `sendMessageString` for each of the 10 top-level fields (operation date, SYSID, service contract number, processing division, transfer division, reason codes, reason memos, optional service contract number, application number, application detail number) and `addDataBean` for dynamic reason list expansion. No database, SC, or CBS endpoints are reached.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Operation date acquisition and write (L855-L857)

> Retrieves the current business operation date and sets it into the screen bean.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `JCCWebCommon.getOpeDate(this, null)` // Retrieves operation date (YYMMDD format) [-> CONSTANT: null parameter means default date source] |
| 2 | SET | `unyo_ymd = "operation_date_string"` // YYYY-MM-DD formatted date string |
| 3 | EXEC | `paramBean[0].sendMessageString(KKW02501SFConst.UNYO_YMD, X31CWebConst.DATABEAN_SET_VALUE, unyo_ymd)` // Sets operation date into screen bean [-> CONSTANT: UNYO_YMD = "運用年月日" (Operation Date)] |

**Block 2** — [SET] Customer contract list extraction (L859-L861)

> Retrieves the customer-contract inheritance list from the form bean and extracts the first row (source data bean).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `paramBean[0].getDataBeanArray(JKKCommonConst.HKTGI_CUST_KEI_HKTGI_LIST)` // Gets customer contract inheritance list [-> CONSTANT: HKTGI_CUST_KEI_HKTGI_LIST = "顧客契約引継リスト" (Customer Contract Inheritance List)] |
| 2 | SET | `custKeiHktgiList = X31SDataBeanAccessArray` // Customer contract list container |
| 3 | CALL | `custKeiHktgiList.getDataBean(0)` // Gets first row from customer contract list |
| 4 | SET | `custKeiHktgiInf = X31SDataBeanAccess` // Source row bean with all fields to be copied |

**Block 3** — [SET] SYSID extraction (L863-L864)

> Extracts the system ID from the source bean and sets it into the screen bean.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `custKeiHktgiInf.sendMessageString(KKW02501SFConst.SYSID_01, X31CWebConst.DATABEAN_GET_VALUE)` // Reads SYSID from source [-> CONSTANT: SYSID_01 = "SYSID"] |
| 2 | SET | `sysid = "system_id_string"` // System identifier string |
| 3 | EXEC | `paramBean[0].sendMessageString(KKW02501SFConst.SYSID, X31CWebConst.DATABEAN_SET_VALUE, sysid)` // Writes SYSID to screen bean [-> CONSTANT: SYSID = "SYSID"] |

**Block 4** — [SET] Service contract number extraction (L866-L867)

> Extracts the service contract number (svc_kei_no) from the source bean and sets it into the screen bean.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `custKeiHktgiInf.sendMessageString(KKW02501SFConst.SVC_KEI_NO_01, X31CWebConst.DATABEAN_GET_VALUE)` // Reads service contract number from source [-> CONSTANT: SVC_KEI_NO_01 = "サービス契約番号"] |
| 2 | SET | `svc_kei_no = "service_contract_number_string"` |
| 3 | EXEC | `paramBean[0].sendMessageString(KKW02501SFConst.SVC_KEI_NO, X31CWebConst.DATABEAN_SET_VALUE, svc_kei_no)` // Writes to screen bean [-> CONSTANT: SVC_KEI_NO = "サービス契約番号"] |

**Block 5** — [SET] Processing division extraction (L869-L870)

> Extracts the processing division code (trans_div) from the source bean and sets it into the screen bean.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `custKeiHktgiInf.sendMessageString(KKW02501SFConst.TRAN_DIV_01, X31CWebConst.DATABEAN_GET_VALUE)` // Reads processing division code [-> CONSTANT: TRAN_DIV_01 = "処理区分"] |
| 2 | SET | `trans_div = "processing_division_code_string"` |
| 3 | EXEC | `paramBean[0].sendMessageString(KKW02501SFConst.TRAN_DIV, X31CWebConst.DATABEAN_SET_VALUE, trans_div)` // Writes to screen bean [-> CONSTANT: TRAN_DIV = "処理区分"] |

**Block 6** — [SET] Transfer division extraction (L872-L873)

> Extracts the transfer/division code (ido_div) from the source bean and sets it into the screen bean.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `custKeiHktgiInf.sendMessageString(KKW02501SFConst.IDO_DIV_01, X31CWebConst.DATABEAN_GET_VALUE)` // Reads transfer division code [-> CONSTANT: IDO_DIV_01 = "異動区分"] |
| 2 | SET | `ido_div = "transfer_division_code_string"` |
| 3 | EXEC | `paramBean[0].sendMessageString(KKW02501SFConst.IDO_DIV, X31CWebConst.DATABEAN_SET_VALUE, ido_div)` // Writes to screen bean [-> CONSTANT: IDO_DIV = "異動区分"] |

**Block 7** — [SET] Reason-for-transfer list retrieval (L875)

> Retrieves the reason-for-transfer list container from the screen bean for later population.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `paramBean[0].getDataBeanArray(KKW02501SFConst.IDO_RSN_LIST)` // Gets reason list container [-> CONSTANT: IDO_RSN_LIST = "異動理由リスト" (Reason for Transfer List)] |
| 2 | SET | `ido_rsn_list = X31SDataBeanAccessArray` |

**Block 8** — [SET] Reason memo extraction (L877-L878)

> Extracts the reason memo from the source bean. This memo value is used to override each row's individual memo in the reason list (memo-memo correspondence feature).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `custKeiHktgiInf.sendMessageString(KKW02501SFConst.IDO_RSN_MEMO_01, X31CWebConst.DATABEAN_GET_VALUE)` // Reads memo text from source [-> CONSTANT: IDO_RSN_MEMO_01 = "異動理由メモ" (Reason for Transfer Memo)] |
| 2 | SET | `ido_rsn_memo = "memo_text_string"` // Shared memo for all reason rows |

**Block 9** — [SET] Reason code count retrieval (L881)

> Gets the number of reason codes that need to be iterated over in the following loop.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `custKeiHktgiInf.sendMessage(KKW02501SFConst.IDO_RSN_CD_01, X31CWebConst.DATABEAN_GET_COUNT)` // Gets count of reason code elements [-> CONSTANT: IDO_RSN_CD_01 = "異動理由コード" (Reason for Transfer Code), uses GET_COUNT mode] |
| 2 | SET | `cnt = (Integer) result` // Number of reason codes to process |

**Block 10** — [FOR LOOP] Reason code list iteration (L884-L923)

> Iterates over each reason code index. For each index, ensures the target list has a bean at that index (creating one if needed), then copies the reason code and the global memo (memo-memo correspondence) into the list entry.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` // Loop counter initialized to 0 |
| 2 | TEST | `i < cnt` // Loop continues while i is less than reason code count |
| 3 | SET | `ido_rsn_bean = null` // Initialize bean reference to null |
| 4 | TEST (Block 10.1) | `ido_rsn_list.getCount() - 1 >= i` // Check if list already has an element at index i [-> Uses getCount() method on list] |
| 5 | SET (Block 10.1-Yes) | `ido_rsn_bean = ido_rsn_list.getDataBean(i)` // Reuse existing list element |
| 6 | SET (Block 10.1-No) | `ido_rsn_bean = ido_rsn_list.addDataBean()` // Create new list element [-> C: addDataBean on IDO_RSN_LIST] |
| 7 | TEST (Block 10.2) | `ido_rsn_bean == null` // Safety check — skip if bean creation failed |
| 8 | EXEC (Block 10.2-Yes) | `continue` // Skip this iteration |
| 9 | EXEC | `custKeiHktgiInf.sendMessageString(KKW02501SFConst.IDO_RSN_CD_01, X31CWebConst.DATABEAN_GET_VALUE, i)` // Reads reason code at index i from source [-> CONSTANT: IDO_RSN_CD_01 = "異動理由コード"] |
| 10 | SET | `ido_rsn_cd = "reason_code_string"` |
| 11 | EXEC | `ido_rsn_bean.sendMessageString(KKW02501SFConst.IDO_RSN_CD_02, X31CWebConst.DATABEAN_SET_VALUE, ido_rsn_cd)` // Writes reason code to list entry [-> CONSTANT: IDO_RSN_CD_02 = "異動理由コード"] |
| 12 | EXEC | `ido_rsn_bean.sendMessageString(KKW02501SFConst.IDO_RSN_MEMO_02, X31CWebConst.DATABEAN_SET_VALUE, ido_rsn_memo)` // Writes shared memo to list entry (memo-memo correspondence override) [-> CONSTANT: IDO_RSN_MEMO_02 = "異動理由メモ"] |

**Block 10.1** — [IF] List element exists check (L887-L890)

> Conditionally retrieves existing list element or creates a new one.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ido_rsn_bean = ido_rsn_list.getDataBean(i)` // Get existing element |
| -- | OR | |
| 1 | SET | `ido_rsn_bean = ido_rsn_list.addDataBean()` // Create new element |

**Block 10.2** — [IF-ELSE] Null safety guard (L892-L895)

> Skips processing if the bean reference is null (should not normally occur, but guards against NPE).

| # | Type | Code |
|---|------|------|
| 1 | TEST | `ido_rsn_bean == null` |
| 2 | EXEC | `continue` // Skip this loop iteration |

**Block 11** — [SET] Optional service contract number extraction (L919-L920)

> Copies the optional service contract number (op_svc_kei_no) from the source bean to the screen bean.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `custKeiHktgiInf.sendMessageString(KKW02501SFConst.OP_SVC_KEI_NO_01, X31CWebConst.DATABEAN_GET_VALUE, 0)` // Reads optional service contract number [-> CONSTANT: OP_SVC_KEI_NO_01 = "オプションサービス契約番号"] |
| 2 | SET | `op_svc_kei_no = "optional_service_contract_number_string"` |
| 3 | EXEC | `paramBean[0].sendMessageString(KKW02501SFConst.OP_SVC_KEI_NO, X31CWebConst.DATABEAN_SET_VALUE, op_svc_kei_no)` // Writes to screen bean [-> CONSTANT: OP_SVC_KEI_NO = "オプションサービス契約番号"] |

**Block 12** — [SET] Application number extraction (L922-L923)

> Copies the application number (mskm_no) from the source bean to the screen bean.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `custKeiHktgiInf.sendMessageString(KKW02501SFConst.MSKM_NO_01, X31CWebConst.DATABEAN_GET_VALUE)` // Reads application number [-> CONSTANT: MSKM_NO_01 = "申請番号"] |
| 2 | SET | `mskm_no = "application_number_string"` |
| 3 | EXEC | `paramBean[0].sendMessageString(KKW02501SFConst.MSKM_NO, X31CWebConst.DATABEAN_SET_VALUE, mskm_no)` // Writes to screen bean [-> CONSTANT: MSKM_NO = "申請番号"] |

**Block 13** — [SET] Application detail number extraction (L925-L926)

> Copies the application detail number (mskm_dtl_no) from the source bean to the screen bean.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `custKeiHktgiInf.sendMessageString(KKW02501SFConst.MSKM_DTL_NO_01, X31CWebConst.DATABEAN_GET_VALUE)` // Reads application detail number [-> CONSTANT: MSKM_DTL_NO_01 = "申請明細番号"] |
| 2 | SET | `mskm_dtl_no = "application_detail_number_string"` |
| 3 | EXEC | `paramBean[0].sendMessageString(KKW02501SFConst.MSKM_DTL_NO, X31CWebConst.DATABEAN_SET_VALUE, mskm_dtl_no)` // Writes to screen bean [-> CONSTANT: MSKM_DTL_NO = "申請明細番号"] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `unyo_ymd` | Field | Operation date — current business date in YYYY-MM-DD format, used for audit/tracking on the screen |
| SYSID | Field | System ID — internal system identifier associated with the customer contract record |
| `svc_kei_no` | Field | Service contract number — the unique identifier for a service contract line (サービス契約番号) |
| `trans_div` | Field | Processing division code — classifies the type of processing being performed (処理区分) |
| `ido_div` | Field | Transfer/division code — indicates the transfer type for the contract (異動区分), e.g., change, cancellation, transfer |
| `ido_rsn_cd` | Field | Reason for transfer code — the specific code explaining why a transfer/change is being made (異動理由コード) |
| `ido_rsn_memo` | Field | Reason for transfer memo — free-text explanation accompanying the reason code (異動理由メモ) |
| IDO_RSN_LIST | Field | Reason for transfer list — a list/array of reason-for-transfer entries (異動理由リスト) |
| `op_svc_kei_no` | Field | Optional service contract number — the contract number for an optional/add-on service (オプションサービス契約番号) |
| `mskm_no` | Field | Application number — the overall application identifier for the submission (申請番号) |
| `mskm_dtl_no` | Field | Application detail number — the line-item identifier within an application (申請明細番号) |
| HKTGI_CUST_KEI_HKTGI_LIST | Field | Customer contract inheritance list — list of customer contract records carried over from a previous screen or prior step (顧客契約引継リスト) |
| DATABEAN_GET_VALUE | Constant | Mode flag for DataBean accessor — indicates a read/GET operation on a bean field |
| DATABEAN_SET_VALUE | Constant | Mode flag for DataBean accessor — indicates a write/SET operation on a bean field |
| DATABEAN_GET_COUNT | Constant | Mode flag for DataBean accessor — indicates a count retrieval operation on a bean's array/list field |
| JCCWebCommon | Class | Web common utility class providing shared screen-level helper methods including `getOpeDate` and `getScreenInfo` |
| X31SDataBeanAccess | Class | DataBean access wrapper — provides `sendMessageString` and `sendMessage` methods to read/write bean fields |
| X31SDataBeanAccessArray | Class | DataBean array access wrapper — provides list operations like `getDataBean`, `addDataBean`, `getCount` |
| OneStopDataBeanAccess | Class | One-stop unified DataBean access interface — provides `getDataBeanArray`, `sendMessage`, `sendMessageString` |
| X31CWebConst | Class | Web constants definition class — defines mode constants such as `DATABEAN_GET_VALUE`, `DATABEAN_SET_VALUE`, `DATABEAN_GET_COUNT` |
| JKKCommonConst | Class | Common constants definition class — defines shared constants such as `HKTGI_CUST_KEI_HKTGI_LIST` |
| KKW02501SFConst | Class | Screen-specific constants definition class — defines all field key constants for the KKW02501SF screen |
| KKW02501SF | Screen module | Screen module identifier — a K-Opticom web screen module for customer contract operations |
| actionInit | Method | Initialization entry point that calls `setHktgiBean` to prepare the screen bean before invoking the service |
| memo-memo correspondence | Feature | A feature where a single global reason memo (`ido_rsn_memo`) is applied to all rows in the reason-for-transfer list, overriding individual row memos |
| DataBean | Pattern | A data transfer object used in this framework to pass structured data between screens, logic layers, and services |
