# Business Logic — KKW02404SFLogic.setDataInit() [57 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW02404SF.KKW02404SFLogic` |
| Layer | Controller (Web presentation-layer logic) |
| Module | `KKW02404SF` (Package: `eo.web.webview.KKW02404SF`) |

## 1. Role

### KKW02404SFLogic.setDataInit()

This method performs **initial display data setup** (Japanese: 画面DataBeanに必要な項目をセットします) for the Fixed Global IP Address Information Cancellation screen. Its business purpose is to prepare and populate the screen's DataBean with the values needed for an initial (first-time) page render when a user navigates to cancel their fixed global IP address service.

Specifically, the method handles three interconnected business concerns. First, it retrieves the operational date (`USE_YMD`) from the incoming data bean and decomposes it into year, month, and day components, which are then assigned to the cancellation date fields (`USE_ENDYMD_YEAR`, `USE_ENDYMD_MON`, `USE_ENDYMD_DAY`). Second, it constructs an aging information record — a single-entry list containing the aging type code `"002"` (representing a cancellation/termination event) and the aging target value (`FIXIPAD`, i.e., "IP Address"). Third, it normalizes the service cancellation date (`USE_ENDYMD`) by stripping out a sentinel "max date" value (`"20991231"`) that indicates an indefinite/active subscription, replacing it with an empty string for display purposes. Finally, it sets the update-state-permissible flag (`CHG_KAHI_FLG`) to `true`, signaling that the screen data may be modified by the user.

The method follows the **builder/delegation pattern**: it delegates data extraction to the `X31SDataBeanAccess` interface via `sendMessageString`/`getDataBeanArray`/`addDataBean` calls, and relies on the `substring` utility for date field decomposition. It acts as the **initialization entry point** for the KKW02404SF screen module, called during `actionClear` and `actionInit` operations.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setDataInit(paramBean)"])
    START --> GET_YMD["Get USE_YMD from paramBean[0]"]
    GET_YMD --> GET_AGING_LIST["Get AGING_INFO_LIST array"]
    GET_AGING_LIST --> NEW_AGING_BEAN["Create new bean via addDataBean"]
    NEW_AGING_BEAN --> GET_FIXIPAD["Get FIXIPAD string from paramBean[0]"]
    GET_FIXIPAD --> SET_AGING_SBT_CD["Set AGING_SBT_CD to 002 on aging bean"]
    SET_AGING_SBT_CD --> SET_AGING_TG_VALUE["Set AGING_TG_VALUE on aging bean"]
    SET_AGING_TG_VALUE --> SUBSTR_YEAR["Extract year from unyo_ymd substring"]
    SUBSTR_YEAR --> SUBSTR_MON["Extract month from unyo_ymd substring"]
    SUBSTR_MON --> SUBSTR_DAY["Extract day from unyo_ymd substring"]
    SUBSTR_DAY --> GET_SVC_ENDYMD["Get USE_ENDYMD from paramBean[0]"]
    GET_SVC_ENDYMD --> CHECK_MAX_YMD{Is svc_endymd equal to 20991231?}
    CHECK_MAX_YMD -->|Yes| SET_ENDYMD_EMPTY["Set USE_ENDYMD to empty string"]
    CHECK_MAX_YMD -->|No| SET_ENDYMD_VALUE["Set USE_ENDYMD to svc_endymd value"]
    SET_ENDYMD_EMPTY --> SET_CHG_FLG["Set CHG_KAHI_FLG to true"]
    SET_ENDYMD_VALUE --> SET_CHG_FLG
    SET_CHG_FLG --> END_NODE(["Return"])
```

**Constant Resolution Reference:**
- `FIXIPAD = "IPアドレス"` [-> FIXIPAD="IPアドレス" (KKW02404SFConst.java:38)]
- `AGING_SBT_CD constant value = "002"` [-> AGING_SBT_CD="002" (KKW02404SFLogic.java:75)]
- `MAX_YMD = "20991231"` [-> MAX_YMD="20991231" (JKKCommonConst.java:3924)]

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `paramBean` | `X31SDataBeanAccess[]` | Array of screen data beans carrying operational data between the UI and business logic layer. `paramBean[0]` is the primary bean containing all initial screen data fields, including the operational date (`USE_YMD`), cancellation date (`USE_ENDYMD`), and the aging information list structure. The array serves as the single contract for screen-to-logic data passing. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `X31SDataBeanAccess.sendMessageString` | (in-memory data bean) | - | Retrieves the operational date (`USE_YMD`) value from the data bean |
| R | `OneStopDataBeanAccess.getDataBeanArray` | OneStopDataBeanAccess | - | Retrieves the aging information list array (`AGING_INFO_LIST`) from the data bean |
| C | `OneStopDataBeanAccessArray.addDataBean` | OneStopDataBeanAccessArray | - | Creates a new entry in the aging information list for the fixed global IP aging record |
| R | `X31SDataBeanAccess.sendMessageString` | (in-memory data bean) | - | Retrieves the fixed global IP address identifier (`FIXIPAD`) for aging target value |
| W | `X31SDataBeanAccess.sendMessageString` | (in-memory data bean) | - | Sets the aging type code field (`AGING_SBT_CD`) to `"002"` (cancellation event type) on the new aging bean |
| W | `X31SDataBeanAccess.sendMessageString` | (in-memory data bean) | - | Sets the aging target value field (`AGING_TG_VALUE`) to the IP address identifier on the new aging bean |
| W | `X31SDataBeanAccess.sendMessageString` | (in-memory data bean) | - | Sets the cancellation date year field (`USE_ENDYMD_YEAR`) to the extracted year substring |
| W | `X31SDataBeanAccess.sendMessageString` | (in-memory data bean) | - | Sets the cancellation date month field (`USE_ENDYMD_MON`) to the extracted month substring |
| W | `X31SDataBeanAccess.sendMessageString` | (in-memory data bean) | - | Sets the cancellation date day field (`USE_ENDYMD_DAY`) to the extracted day substring |
| R | `X31SDataBeanAccess.sendMessageString` | (in-memory data bean) | - | Retrieves the current service cancellation date (`USE_ENDYMD`) for normalization check |
| W | `X31SDataBeanAccess.sendMessageString` | (in-memory data bean) | - | Sets the normalized cancellation date (`USE_ENDYMD`) — either empty (if max date sentinel) or original value |
| W | `X31SDataBeanAccess.sendMessageBoolean` | (in-memory data bean) | - | Sets the update-state-permissible flag (`CHG_KAHI_FLG`) to `true`, enabling screen editing |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `KKW02404SFLogic.actionClear()` | `actionClear()` -> `setDataInit(paramBean)` | `sendMessageString (R) USE_YMD`, `sendMessageString (W) USE_ENDYMD_YEAR/MON/DAY`, `sendMessageString (W) USE_ENDYMD`, `sendMessageBoolean (W) CHG_KAHI_FLG`, `addDataBean (C) AGING_INFO_LIST` |
| 2 | `KKW02404SFLogic.actionInit()` | `actionInit()` -> `setDataInit(paramBean)` | `sendMessageString (R) USE_YMD`, `sendMessageString (W) USE_ENDYMD_YEAR/MON/DAY`, `sendMessageString (W) USE_ENDYMD`, `sendMessageBoolean (W) CHG_KAHI_FLG`, `addDataBean (C) AGING_INFO_LIST` |

Both callers reside within the same `KKW02404SFLogic` class and represent screen lifecycle operations: `actionClear` handles form reset/clear actions, while `actionInit` handles the initial screen load. No external screen/batch entry points (e.g., `KKSV*` screens) were found within 8 hops, indicating this method is a purely internal logic helper invoked during screen initialization and clearing.

## 6. Per-Branch Detail Blocks

**Block 1** — [EXEC] `(Operational date retrieval, L216)`

> Retrieves the operational date string (`USE_YMD`) from the primary data bean. This represents the system's operational date, used as the basis for initializing the cancellation date fields. Originally commented out (IT1-2012-0001599), it was re-added as part of version v4.00 to use the operational date as the default value for the cancellation date in the cancellation mode.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `String unyo_ymd = paramBean[0].sendMessageString(KKW02404SFConst.USE_YMD, X31CWebConst.DATABEAN_GET_VALUE)` // Retrieves operational date [-> USE_YMD="運用年月日" (KKW02404SFConst.java:129)] |

**Block 2** — [EXEC] `(Aging information list retrieval, L218)`

> Retrieves the aging information list data bean array. This list will hold aging (processing tracking/audit trail) records for the current screen session.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `X31SDataBeanAccessArray aging_info_list = paramBean[0].getDataBeanArray(KKW02404SFConst.AGING_INFO_LIST)` [-> AGING_INFO_LIST="エイジング情報リスト" (KKW02404SFConst.java:168)] |

**Block 3** — [SET] `(Aging info bean initialization, L220)`

> Initializes the aging info bean reference to null before assigning it in the next step.

| # | Type | Code |
|---|------|------|
| 1 | SET | `X31SDataBeanAccess aging_info_bean = null` // Aging info bean reference |

**Block 4** — [EXEC] `(Aging target value retrieval, L222)`

> Retrieves the fixed global IP address identifier (`FIXIPAD`) from the data bean. This value serves as the aging target — the subject that is being aged (terminated/cancelled).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `String aging_sbt_cd = paramBean[0].sendMessageString(KKW02404SFConst.FIXIPAD, X31CWebConst.DATABEAN_GET_VALUE)` // Retrieves fixed global IP address [-> FIXIPAD="IPアドレス" (KKW02404SFConst.java:38)] |

**Block 5** — [EXEC] `(New aging bean creation, L223)`

> Creates a new entry in the aging information list by adding a new data bean. This new bean will hold the single aging record for this cancellation event.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `aging_info_bean = aging_info_list.addDataBean()` // Creates new aging record entry [-> AGING_INFO_LIST="エイジング情報リスト" (KKW02404SFConst.java:168)] |

**Block 6** — [EXEC] `(Aging type code setting, L225)`

> Sets the aging type code field (`AGING_SBT_CD`) to `"002"` on the new aging bean. The code `"002"` represents a cancellation/termination event type in this system's aging taxonomy.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `aging_info_bean.sendMessageString(KKW02404SFConst.AGING_SBT_CD, X31CWebConst.DATABEAN_SET_VALUE, AGING_SBT_CD)` // Sets aging type code |

**Block 7** — [EXEC] `(Aging target value setting, L227)`

> Sets the aging target value (`AGING_TG_VALUE`) on the new aging bean to the fixed global IP address identifier retrieved earlier. This links the aging record to the specific IP address being cancelled.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `aging_info_bean.sendMessageString(KKW02404SFConst.AGING_TG_VALUE, X31CWebConst.DATABEAN_SET_VALUE, aging_sbt_cd)` // Sets aging target value [-> AGING_TG_VALUE="エイジング対象値" (KKW02404SFConst.java:175)] |

**Block 8** — [EXEC] `(Cancellation date decomposition, L237)`

> Decomposes the operational date string (`unyo_ymd`, expected format `YYYYMMDD`) into its year, month, and day components using `substring()`. Each component is assigned to its respective cancellation date field on the primary data bean. This implements the v4.00 change (IT1-2012-0001599) where the operational date is used as the default cancellation date value.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `paramBean[0].sendMessageString(KKW02404SFConst.USE_ENDYMD_YEAR, X31CWebConst.DATABEAN_SET_VALUE, unyo_ymd.substring(0, 4))` // Sets cancellation date year [-> USE_ENDYMD_YEAR="利用終了日（年）" (KKW02404SFConst.java:57)] |
| 2 | CALL | `paramBean[0].sendMessageString(KKW02404SFConst.USE_ENDYMD_MON, X31CWebConst.DATABEAN_SET_VALUE, unyo_ymd.substring(4, 6))` // Sets cancellation date month [-> USE_ENDYMD_MON="利用終了日（月）" (KKW02404SFConst.java:62)] |
| 3 | CALL | `paramBean[0].sendMessageString(KKW02404SFConst.USE_ENDYMD_DAY, X31CWebConst.DATABEAN_SET_VALUE, unyo_ymd.substring(6, 8))` // Sets cancellation date day [-> USE_ENDYMD_DAY="利用終了日（日）" (KKW02404SFConst.java:67)] |

**Block 9** — [IF-ELSE] `(Service cancellation date normalization, IT1-2012-0000433, L242)`

> Retrieves the current service cancellation date (`USE_ENDYMD`) and checks whether it matches the sentinel "max date" value `"20991231"`. This sentinel indicates an indefinite/active subscription that has not yet had a cancellation date set. If matched, the value is cleared (set to empty string) so that the UI does not display the max date. Otherwise, the original value is preserved. This logic was added in v2.00 (IT1-2012-0000433) to prevent display of the placeholder max date.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `String svc_endymd = paramBean[0].sendMessageString(KKW02404SFConst.USE_ENDYMD, X31CWebConst.DATABEAN_GET_VALUE)` [-> USE_ENDYMD="利用終了日" (KKW02404SFConst.java:49)] |

**Block 9.1** — [IF] `(Max date sentinel check, L243)`

> Checks whether the service cancellation date equals the max date sentinel value `"20991231"` from `JKKCommonConst.MAX_YMD` [-> MAX_YMD="20991231" (JKKCommonConst.java:3924)].

| # | Type | Code |
|---|------|------|
| 1 | COND | `JKKCommonConst.MAX_YMD.equals(svc_endymd)` [-> MAX_YMD="20991231" (JKKCommonConst.java:3924)] |

**Block 9.1.1** — [ELSE] `(Sentinel true — clear the date, L245)`

> The cancellation date is the max sentinel value. Replace it with an empty string so the UI displays a blank field rather than the placeholder.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `paramBean[0].sendMessageString(KKW02404SFConst.USE_ENDYMD, X31CWebConst.DATABEAN_SET_VALUE, "")` // Clears cancellation date for max sentinel [-> USE_ENDYMD="利用終了日" (KKW02404SFConst.java:49)] |

**Block 9.1.2** — [IF] `(Sentinel false — preserve the date, L248)`

> The cancellation date is a real date value. Preserve it as-is.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `paramBean[0].sendMessageString(KKW02404SFConst.USE_ENDYMD, X31CWebConst.DATABEAN_SET_VALUE, svc_endymd)` // Preserves real cancellation date [-> USE_ENDYMD="利用終了日" (KKW02404SFConst.java:49)] |

**Block 10** — [EXEC] `(Update flag enablement, L253)`

> Sets the update-state-permissible flag (`CHG_KAHI_FLG`) to `true`, indicating that the screen data is modifiable and the user may perform update operations.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `paramBean[0].sendMessageBoolean(KKW02404SFConst.CHG_KAHI_FLG, X31CWebConst.DATABEAN_SET_VALUE, true)` // Enables screen editing [-> CHG_KAHI_FLG="更新状態可否フラグ" (KKW02404SFConst.java:234)] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `USE_YMD` | Field | Operational date — the system's current operating date in `YYYYMMDD` string format, used as the default value for the cancellation date |
| `USE_ENDYMD` | Field | Service cancellation date — the date when the customer's service contract ends; `"20991231"` is a sentinel indicating an active (non-cancelled) subscription |
| `USE_ENDYMD_YEAR` | Field | Cancellation date (year) — the year portion extracted from `USE_ENDYMD` or `USE_YMD` |
| `USE_ENDYMD_MON` | Field | Cancellation date (month) — the month portion extracted from `USE_ENDYMD` or `USE_YMD` |
| `USE_ENDYMD_DAY` | Field | Cancellation date (day) — the day portion extracted from `USE_ENDYMD` or `USE_YMD` |
| `FIXIPAD` | Field | Fixed global IP address — the IP address identifier being cancelled; also used as the aging target value |
| `AGING_INFO_LIST` | Field | Aging information list — a list of processing records (audit trail) maintained on the screen for tracking business operations |
| `AGING_SBT_CD` | Field | Aging type code — classifies the type of aging event; `"002"` represents a cancellation/termination event |
| `AGING_TG_VALUE` | Field | Aging target value — the entity being aged (the fixed global IP address identifier) |
| `CHG_KAHI_FLG` | Field | Update state permissible flag — indicates whether the screen data may be edited by the user; `true` = editing is enabled |
| `MAX_YMD` | Constant | Max date sentinel `"20991231"` — used as a placeholder for "no end date set" / active subscription |
| KKW02404SF | Module | Fixed Global IP Address Information Cancellation — the screen module for cancelling a customer's fixed global IP address service |
| DataBean | Pattern | Screen data transfer object — an in-memory object carrying field values between the UI layer and business logic layer |
| Aging (エイジング) | Business term | Processing audit trail/aging record — a tracking record used to log operational events (such as cancellations) for processing and compliance purposes |
| `X31SDataBeanAccess` | Technical | Data bean access interface providing `sendMessageString`/`sendMessageBoolean`/`getDataBeanArray`/`addDataBean` methods for reading and writing screen fields |
| JKKCommonConst | Component | Shared common constants class containing system-wide constants such as `MAX_YMD` |
| Subscription | Business term | A customer's active service contract; when in active state, the cancellation date is set to the max sentinel value |
