# Business Logic — KKW00804SFLogic.setHktgiBean() [23 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00804SF.KKW00804SFLogic` |
| Layer | Controller (Web Logic — part of the KKW00804SF screen module) |
| Module | `KKW00804SF` (Package: `eo.web.webview.KKW00804SF`) |

## 1. Role

### KKW00804SFLogic.setHktgiBean()

This method is responsible for **restructuring customer contract succession data** by extracting key identifiers from a nested DataBean list and writing them into the primary parameter DataBean for downstream processing. It acts as a **data transformation/alignment layer** that normalizes data from a list-based structure into a flat parameter object, ensuring consistency across the screen's DataBeans. Specifically, it reads the **system ID (sysid)**, **service detail number (svc_kei_no)**, and **migration division (ido_div)** from the first entry of the customer contract succession list (`CUST_KEI_HKTGI_LIST`), then copies these values back into the root parameter DataBean (`paramBean[0]`) under their base field keys. Additionally, it sets the **sub-operation service code** to `D04` (HP/CAPA broadband service), which classifies the contract operation type for subsequent workflow routing. This method is called during the `actionInit()` flow, meaning it executes at screen initialization to prepare the DataBean state before the main screen processing begins. The method also performs a debug DataBean dump via `JSYwebLog` to aid in troubleshooting by logging the full state of all DataBeans after transformation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setHktgiBean(paramBean)"])
    START --> GET_LIST["getDataBeanArray(CUST_KEI_HKTGI_LIST)"]
    GET_LIST --> GET_SUB["getDataBean(0) - Get first customer contract succession bean"]
    GET_SUB --> GET_SYSID["sendMessageString(SYSID_02, DATABEAN_GET_VALUE)"]
    GET_SYSID --> GET_SVC["sendMessageString(SVC_KEI_NO_02, DATABEAN_GET_VALUE)"]
    GET_SVC --> GET_IDO["sendMessageString(IDO_DIV_02, DATABEAN_GET_VALUE)"]
    GET_IDO --> SET_SYSID["sendMessageString(SYSID, DATABEAN_SET_VALUE, sysid)"]
    SET_SYSID --> SET_SVC["sendMessageString(SVC_KEI_NO, DATABEAN_SET_VALUE, svc_kei_no)"]
    SET_SVC --> SET_IDO["sendMessageString(IDO_DIV, DATABEAN_SET_VALUE, ido_div)"]
    SET_IDO --> SET_SBOP["sendMessageString(SBOP_SVC_CD, DATABEAN_SET_VALUE, SBOP_SVC_CD_HPCAPA=D04)"]
    SET_SBOP --> LOG["println(DataBean_Dump, dumpDatabean())"]
    LOG --> END(["Return"])
```

The method follows a **read-then-write linear pipeline** pattern with no conditional branches. It operates in three phases:

1. **Data Extraction**: Reads the customer contract succession list and retrieves the first entry's key fields (sysid, svc_kei_no, ido_div).
2. **Data Alignment**: Writes the extracted values back to the root parameter DataBean, effectively promoting list-level data to the top-level scope.
3. **Service Code Assignment & Logging**: Sets the sub-operation service code to identify this as an HP/CAPA broadband service, then logs the full DataBean state for debugging.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `paramBean` | `X31SDataBeanAccess[]` | The primary DataBean array passed by the calling screen action (`actionInit()`). Index 0 contains the main screen DataBean which holds the customer contract succession list and is the target for all write-back operations. |

**External State Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `SBOP_SVC_CD_HPCAPA` | `String` (instance field, resolved to `"D04"`) | Sub-operation service code constant for HP/CAPA (high-capacity broadband) services. This identifies the contract operation type as a broadband-related service. `[-> SBOP_SVC_CD_HPCAPA="D04" (JKKHakkoSODConstCC.java:983)]` |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `OneStopDataBeanAccessArray.getDataBeanArray` | OneStopDataBeanAccessArray | - | Reads the customer contract succession list from `paramBean[0]` by key `CUST_KEI_HKTGI_LIST`. Retrieves the array of DataBean entries representing contract succession records. |
| R | `OneStopDataBeanAccess.getDataBean` | OneStopDataBeanAccess | - | Gets the first entry (index 0) from the customer contract succession list. Retrieves the primary contract record for data extraction. |
| R | `OneStopDataBeanAccess.sendMessageString` | OneStopDataBeanAccess | - | Reads string values (sysid, svc_kei_no, ido_div) from the subbean with key `_02` suffixed identifiers (e.g., `SYSID_02`). This is a DataBean field accessor. |
| R | `OneStopDataBeanAccess.sendMessageString` (set) | OneStopDataBeanAccess | - | Writes string values (sysid, svc_kei_no, ido_div) into `paramBean[0]` using base keys (without `_02` suffix). Promotes list-level data to root DataBean. |
| R | `OneStopDataBeanAccess.sendMessageString` (set) | OneStopDataBeanAccess | - | Writes the sub-operation service code (`SBOP_SVC_CD_HPCAPA = "D04"`) into `paramBean[0]`. Tags the operation as an HP/CAPA broadband service. |
| - | `JSYwebLog.println` | JSYwebLog | - | Logs the full DataBean dump at `DataBean_Dump` level for debugging. Calls `dumpDatabean()` to serialize the current DataBean state. |

All operations are **DataBean-level reads and writes** — no direct database CRUD operations occur in this method. The actual persistence is handled by callers or downstream methods in the screen workflow.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | KKW00804SFLogic | `actionInit()` -> `setHktgiBean()` | `sendMessageString` [-], `getDataBean` [R], `getDataBeanArray` [R] |

**Terminal operations reached from this method:**

| Terminal | Type | Description |
|----------|------|-------------|
| `sendMessageString` (get) | R | Reads SYSID_02, SVC_KEI_NO_02, IDO_DIV_02 from subbean |
| `sendMessageString` (set) | U | Writes SYSID, SVC_KEI_NO, IDO_DIV, SBOP_SVC_CD to paramBean[0] |
| `getDataBeanArray` | R | Retrieves CUST_KEI_HKTGI_LIST DataBean array |
| `getDataBean` | R | Gets first entry (index 0) from the succession list |
| `JSYwebLog.println` | - | Debug DataBean dump logging |

## 6. Per-Branch Detail Blocks

This method has no conditional branches — it executes as a flat linear sequence of operations.

**Block 1** — [DATA EXTRACTION] (L790-792)

> Extracts the customer contract succession list from `paramBean[0]` and retrieves the first contract record.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cust_kei_hktgi_list = paramBean[0].getDataBeanArray(CUST_KEI_HKTGI_LIST)` // Retrieves the customer contract succession list from the root DataBean. `[-> CUST_KEI_HKTGI_LIST]` |
| 2 | CALL | `subbean = cust_kei_hktgi_list.getDataBean(0)` // Gets the first entry (index 0) from the succession list, representing the primary contract record. |

**Block 2** — [FIELD EXTRACTION] (L794-796)

> Reads the three key identification fields from the first contract record. These fields use the `_02` suffixed keys, indicating a secondary/sub-form version of the fields.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sysid = subbean.sendMessageString(SYSID_02, DATABEAN_GET_VALUE)` // Extracts the system ID from the subbean. `[-> SYSID_02]` |
| 2 | SET | `svc_kei_no = subbean.sendMessageString(SVC_KEI_NO_02, DATABEAN_GET_VALUE)` // Extracts the service detail number from the subbean. `[-> SVC_KEI_NO_02]` |
| 3 | SET | `ido_div = subbean.sendMessageString(IDO_DIV_02, DATABEAN_GET_VALUE)` // Extracts the migration/division classification from the subbean. `[-> IDO_DIV_02]` |

**Block 3** — [DATA ALIGNMENT / WRITE-BACK] (L799-801)

> Writes the extracted values into the root parameter DataBean (`paramBean[0]`) under the base (non-suffixed) field keys. This promotes the list-level data to the top-level scope for downstream use.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(SYSID, DATABEAN_SET_VALUE, sysid)` // Writes sysid to root DataBean. `[-> SYSID]` |
| 2 | EXEC | `paramBean[0].sendMessageString(SVC_KEI_NO, DATABEAN_SET_VALUE, svc_kei_no)` // Writes svc_kei_no to root DataBean. `[-> SVC_KEI_NO]` |
| 3 | EXEC | `paramBean[0].sendMessageString(IDO_DIV, DATABEAN_SET_VALUE, ido_div)` // Writes ido_div to root DataBean. `[-> IDO_DIV]` |

**Block 4** — [SERVICE CODE ASSIGNMENT] (L804)

> Sets the sub-operation service code to identify this as an HP/CAPA broadband service operation. This tags the contract for proper workflow routing in downstream processing.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(SBOP_SVC_CD, DATABEAN_SET_VALUE, SBOP_SVC_CD_HPCAPA)` // Sets sub-operation service code to "D04" (HP/CAPA broadband). `[-> SBOP_SVC_CD, SBOP_SVC_CD_HPCAPA="D04" (JKKHakkoSODConstCC.java:983)]` |

**Block 5** — [DEBUG LOGGING] (L807)

> Logs the full DataBean state for debugging/troubleshooting purposes.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `JSYwebLog.println(DataBean_Dump, getClass(), dumpDatabean(), null, null, null)` // Dumps the complete DataBean state to the log for debugging. `[-> DataBean_Dump]` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `cust_kei_hktgi_list` | Field | Customer contract succession list — an array of DataBean entries representing customer contracts being transferred/assumed in the current operation |
| `subbean` | Field | Sub-form DataBean — the first entry in the customer contract succession list containing the primary contract record data |
| `sysid` | Field | System ID — unique identifier for the system or system component managing the contract |
| `svc_kei_no` | Field | Service detail number — internal tracking number identifying the specific service detail line item |
| `ido_div` | Field | Migration division — classification code indicating the type of service migration or porting operation being performed |
| `SBOP_SVC_CD` | Field | Sub-operation service code — classification code used to categorize the type of sub-operation (e.g., broadband, voicemail) |
| `SBOP_SVC_CD_HPCAPA` | Constant | Sub-operation service code for HP/CAPA broadband — value `"D04"`, identifies HP/CAPA high-capacity broadband services |
| `CUST_KEI_HKTGI_LIST` | Constant | Key for the customer contract succession list DataBean array in the paramDataBean |
| `SYSID_02` | Constant | Key for the system ID in the subbean (secondary form, index 02) |
| `SVC_KEI_NO_02` | Constant | Key for the service detail number in the subbean (secondary form, index 02) |
| `IDO_DIV_02` | Constant | Key for the migration division in the subbean (secondary form, index 02) |
| `SYSID` | Constant | Base key for the system ID in the root DataBean |
| `SVC_KEI_NO` | Constant | Base key for the service detail number in the root DataBean |
| `IDO_DIV` | Constant | Base key for the migration division in the root DataBean |
| `DATABEAN_GET_VALUE` | Constant | Command flag indicating a Read operation on a DataBean field |
| `DATABEAN_SET_VALUE` | Constant | Command flag indicating a Write operation on a DataBean field |
| HP/CAPA | Business term | High-capacity broadband service — a Fujitsu broadband offering. `D04` is the service code identifying this service type |
| DataBean | Technical | A structured data container used throughout the framework to hold screen-level data. Uses `sendMessageString()` for field access |
| JSYwebLog | Technical | Framework logging utility for outputting debug and trace messages |
| actionInit() | Method | Screen initialization action — the entry point method that calls `setHktgiBean()` to prepare DataBeans before screen rendering |
