# Business Logic — KKW02501SFLogic.setChgFlags() [163 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW02501SF.KKW02501SFLogic` |
| Layer | Service / Logic (Web-layer business logic class within the Service/CC/Common Component tier) |
| Module | `KKW02501SF` (Package: `eo.web.webview.KKW02501SF`) |

## 1. Role

### KKW02501SFLogic.setChgFlags()

This method performs the **change flag determination and configuration processing** for email information updates (Eメール情報の変更) within K-Opticom's contract management system. Its primary business purpose is to prepare the `DataBean` for submission to the update service by analyzing what fields the user intends to change and setting appropriate flags that distinguish between three distinct change scenarios. The method operates as a **data preparation transformer** — it does not persist any data itself; rather, it synthesizes user-provided inputs into structured change indicators that downstream service components consume.

The method handles four distinct configurable service domains: **mail address change** (メールアドレス変更), **mail alias management** (メールエイリアス), **mail box capacity adjustment** (メールBOX容量), and **antivirus check toggle** (ウィルスチェック). For each domain, it evaluates whether the user's requested value differs from the pre-change baseline, then classifies the change as one of three types: no change (変更なし, flag `"0"`), new registration or change (登録ありまたは変更有変更, flag `"1"`), or continuation change / already-existing modification (継続変更 — already present, or no-change change, flag `"2"`). The classification logic also checks whether a Sub-Option Service (サブオプションサービス) contract number (`sbop_svc_no`) already exists — if it does, the change is a continuation of an existing service (continuation change); if it does not, the change constitutes a new registration.

The method is invoked exclusively by `KKW02501SFLogic.setChgesrv()`, which serves as the entry point for preparing email update payloads. It acts as a shared data preparation utility within the E-Mail Update module, ensuring consistency in how change types are determined before the sub-option service contract list is created. This method implements the **routing/dispatch pattern** — reading from the input `DataBean`, computing derived values (such as the full changed mail address by concatenating account + domain), and writing classification flags back into the `DataBean` for downstream consumption.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setChgFlags paramBean"])
    START --> GET_MAIL["Get changed mail account and domain"]
    GET_MAIL --> MLAD_GET["Get original mail address mlad_bf"]
    MLAD_GET --> SET_CHG_MLAD["Set CHGAF_MLAD<br/>Set CHGAF_MLAD_ACCOUNT_O"]
    SET_CHG_MLAD --> CAPA_SELECT["setListSelectData: MAIL_CAPA_INFO"]
    CAPA_SELECT --> UM_CHECK{MLAD_CHG_UM_FLG?}
    UM_CHECK -->|true| GET_CAPA["Get capacity from CAPA"]
    UM_CHECK -->|false| GET_DEF_CAPA["Get capacity from CHGAF_CAPA_CD"]
    GET_CAPA --> SET_CAPA["Set CHGAF_CAPA"]
    GET_DEF_CAPA --> SET_CAPA
    SET_CAPA --> CALC_ADD_CAPA["Calculate additional capacity"]
    CALC_ADD_CAPA --> SET_ADD_CAPA["Set ADD_CAPA"]
    SET_ADD_CAPA --> VIRUS_SELECT["setListSelectData: VIRUS_CHK_INFO"]
    VIRUS_SELECT --> MLAD_CHG{Mail address changed?}
    MLAD_CHG -->|no| SET_NOCHG_MLAD["Set MLAD_CHG_FLG = 0"]
    MLAD_CHG -->|yes| SET_CHG1_MLAD["Set MLAD_CHG_FLG = 1"]
    SET_NOCHG_MLAD --> ALIAS_NOCHANGE{Mail address changed?}
    SET_CHG1_MLAD --> ALIAS_CANCEL["Set ALIAS_CHG_FLG = 0<br/>Cancel alias"]
    ALIAS_NOCHANGE --> ALIAS_COMPARE{alias same?}
    ALIAS_COMPARE -->|same| SET_NOCHG_ALIAS["Set ALIAS_CHG_FLG = 0"]
    ALIAS_COMPARE -->|diff| GET_SBOP_ALIAS["Get sbop_svc_no_alias"]
    GET_SBOP_ALIAS --> SBOP_EMPTY{sbop_svc empty?}
    SBOP_EMPTY -->|yes| SET_CHG1_ALIAS["Set ALIAS_CHG_FLG = 1<br/>New registration"]
    SBOP_EMPTY -->|no| SET_CHG2_ALIAS["Set ALIAS_CHG_FLG = 2<br/>Continuation change"]
    ALIAS_CANCEL --> CAPA_CHECK{Capacity changed?}
    SET_NOCHG_ALIAS --> CAPA_CHECK2{Capacity changed?}
    SET_CHG1_ALIAS --> CAPA_CHECK3{Capacity changed?}
    SET_CHG2_ALIAS --> CAPA_CHECK4{Capacity changed?}
    CAPA_CHECK -->|no| SET_NOCHG_CAPA["Set CAPA_CHG_FLG = 0"]
    CAPA_CHECK2 -->|no| SET_NOCHG_CAPA2["Set CAPA_CHG_FLG = 0"]
    CAPA_CHECK3 -->|no| SET_NOCHG_CAPA3["Set CAPA_CHG_FLG = 0"]
    CAPA_CHECK4 -->|no| SET_NOCHG_CAPA4["Set CAPA_CHG_FLG = 0"]
    CAPA_CHECK -->|yes| GET_SBOP_CAPA["Get sbop_svc_no_capa"]
    CAPA_CHECK2 -->|yes| GET_SBOP_CAPA2["Get sbop_svc_no_capa"]
    CAPA_CHECK3 -->|yes| GET_SBOP_CAPA3["Get sbop_svc_no_capa"]
    CAPA_CHECK4 -->|yes| GET_SBOP_CAPA4["Get sbop_svc_no_capa"]
    GET_SBOP_CAPA --> CAPA_SBOP_EMPTY{sbop_capa empty?}
    GET_SBOP_CAPA2 --> CAPA_SBOP_EMPTY2{sbop_capa empty?}
    GET_SBOP_CAPA3 --> CAPA_SBOP_EMPTY3{sbop_capa empty?}
    GET_SBOP_CAPA4 --> CAPA_SBOP_EMPTY4{sbop_capa empty?}
    CAPA_SBOP_EMPTY -->|yes| SET_CHG1_CAPA["Set CAPA_CHG_FLG = 1<br/>New registration"]
    CAPA_SBOP_EMPTY -->|no| SET_CHG2_CAPA["Set CAPA_CHG_FLG = 2<br/>Continuation change"]
    CAPA_SBOP_EMPTY2 -->|yes| SET_CHG1_CAPA2["Set CAPA_CHG_FLG = 1"]
    CAPA_SBOP_EMPTY2 -->|no| SET_CHG2_CAPA2["Set CAPA_CHG_FLG = 2"]
    CAPA_SBOP_EMPTY3 -->|yes| SET_CHG1_CAPA3["Set CAPA_CHG_FLG = 1"]
    CAPA_SBOP_EMPTY3 -->|no| SET_CHG2_CAPA3["Set CAPA_CHG_FLG = 2"]
    CAPA_SBOP_EMPTY4 -->|yes| SET_CHG1_CAPA4["Set CAPA_CHG_FLG = 1"]
    CAPA_SBOP_EMPTY4 -->|no| SET_CHG2_CAPA4["Set CAPA_CHG_FLG = 2"]
    SET_NOCHG_CAPA --> VIRUS_CHECK{Virus chk changed?}
    SET_NOCHG_CAPA2 --> VIRUS_CHECK5{Virus chk changed?}
    SET_NOCHG_CAPA3 --> VIRUS_CHECK6{Virus chk changed?}
    SET_NOCHG_CAPA4 --> VIRUS_CHECK7{Virus chk changed?}
    SET_CHG1_CAPA --> VIRUS_CHECK
    SET_CHG2_CAPA --> VIRUS_CHECK
    SET_CHG1_CAPA2 --> VIRUS_CHECK5
    SET_CHG2_CAPA2 --> VIRUS_CHECK5
    SET_CHG1_CAPA3 --> VIRUS_CHECK6
    SET_CHG2_CAPA3 --> VIRUS_CHECK6
    SET_CHG1_CAPA4 --> VIRUS_CHECK7
    SET_CHG2_CAPA4 --> VIRUS_CHECK7
    VIRUS_CHECK -->|no| SET_NOCHG_VIRUS["Set VIRUS_CHK_CHG_FLG = 0"]
    VIRUS_CHECK5 -->|no| SET_NOCHG_VIRUS5["Set VIRUS_CHK_CHG_FLG = 0"]
    VIRUS_CHECK6 -->|no| SET_NOCHG_VIRUS6["Set VIRUS_CHK_CHG_FLG = 0"]
    VIRUS_CHECK7 -->|no| SET_NOCHG_VIRUS7["Set VIRUS_CHK_CHG_FLG = 0"]
    VIRUS_CHECK -->|yes| ON_CHECK{vchk_cd = ON?}
    VIRUS_CHECK5 -->|yes| ON_CHECK5{vchk_cd = ON?}
    VIRUS_CHECK6 -->|yes| ON_CHECK6{vchk_cd = ON?}
    VIRUS_CHECK7 -->|yes| ON_CHECK7{vchk_cd = ON?}
    SET_NOCHG_VIRUS --> END(["Return"])
    SET_NOCHG_VIRUS5 --> END5(["Return"])
    SET_NOCHG_VIRUS6 --> END6(["Return"])
    SET_NOCHG_VIRUS7 --> END7(["Return"])
    ON_CHECK -->|yes| SET_VIRUS_ON["Set VIRUS_CHK_CHG_FLG = 1<br/>CHGAF_VIRUS_CHK = 2. 有"]
    ON_CHECK -->|no| SET_VIRUS_OFF["Set VIRUS_CHK_CHG_FLG = 2<br/>CHGAF_VIRUS_CHK = 1. 無"]
    ON_CHECK5 -->|yes| SET_VIRUS_ON5["Set VIRUS_CHK_CHG_FLG = 1<br/>CHGAF_VIRUS_CHK = 2. 有"]
    ON_CHECK5 -->|no| SET_VIRUS_OFF5["Set VIRUS_CHK_CHG_FLG = 2<br/>CHGAF_VIRUS_CHK = 1. 無"]
    ON_CHECK6 -->|yes| SET_VIRUS_ON6["Set VIRUS_CHK_CHG_FLG = 1<br/>CHGAF_VIRUS_CHK = 2. 有"]
    ON_CHECK6 -->|no| SET_VIRUS_OFF6["Set VIRUS_CHK_CHG_FLG = 2<br/>CHGAF_VIRUS_CHK = 1. 無"]
    ON_CHECK7 -->|yes| SET_VIRUS_ON7["Set VIRUS_CHK_CHG_FLG = 1<br/>CHGAF_VIRUS_CHK = 2. 有"]
    ON_CHECK7 -->|no| SET_VIRUS_OFF7["Set VIRUS_CHK_CHG_FLG = 2<br/>CHGAF_VIRUS_CHK = 1. 無"]
    SET_VIRUS_ON --> END
    SET_VIRUS_OFF --> END
    SET_VIRUS_ON5 --> END5
    SET_VIRUS_OFF5 --> END5
    SET_VIRUS_ON6 --> END6
    SET_VIRUS_OFF6 --> END6
    SET_VIRUS_ON7 --> END7
    SET_VIRUS_OFF7 --> END7
```

**Processing flow description:**
1. **Mail Address Assembly** — Retrieves the changed account part and domain from the `DataBean`, concatenates them to form the full changed email address, and stores the original mail address for later comparison.
2. **Capacity Source Selection** — Checks the `MLAD_CHG_UM_FLG` flag. If true (user is changing mail address via an "inherit" flow), reads the capacity from the `CAPA` field directly; otherwise reads from the `CHGAF_CAPA_CD` dropdown.
3. **Additional Capacity Calculation** — Computes the difference between the new capacity and the default capacity. If the new value is less than default, the additional capacity is set to `"0"`.
4. **Mail Address Change Flag Determination** — Compares the original and changed mail addresses. If unchanged or the account part is empty, sets no-change flag; otherwise sets the "change" flag.
5. **Mail Alias Change Flag Determination** — If the mail address was NOT changed, compares original and changed alias values. If they differ, checks whether a Sub-Option Service contract number exists to determine if this is a new registration (flag `"1"`) or a continuation change (flag `"2"`). If the mail address WAS changed, the alias is automatically cancelled (flag `"0"`).
6. **Mail Capacity Change Flag Determination** — Compares original and new capacity. If they differ, checks the Sub-Option Service contract number to classify as new registration or continuation change.
7. **Antivirus Check Change Flag Determination** — Compares the original and changed virus check values. If changed, also sets the human-readable label (`"2. 有"` for ON, `"1. 無"` for OFF).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `paramBean` | `X31SDataBeanAccess[]` | Array of DataBean access objects carrying the email change form data. Index `[0]` is used exclusively. Contains user-modified values for mail address components (account, domain, alias), capacity settings (code and MB value), antivirus check toggle, and pre-change baseline values for comparison. This is the primary data carrier between the presentation layer and the update service. |

**Instance fields / external state read:**

| Source | Field/Constant | Business Description |
|--------|---------------|---------------------|
| `CHG_TYPE_NOCHG` | `"0"` | Change state flag indicating no modification to the field |
| `CHG_TYPE1` | `"1"` | Change state flag indicating new registration or an active change |
| `CHG_TYPE2` | `"2"` | Change state flag indicating continuation of an existing change (already-present Sub-Option Service contract) |
| `CD00002_ON` | `"1"` | On/yes flag value used for boolean checks (e.g., antivirus enabled) |
| `KKW02501SFConst.CHGAF_MLAD_ACCOUNT_O` | Constant key | Field key for the changed account part (post-change) |
| `KKW02501SFConst.MLAD_DOMAIN` | Constant key | Field key for the domain component of the mail address |
| `KKW02501SFConst.MLAD` | Constant key | Field key for the original mail address (pre-change) |
| `KKW02501SFConst.CHGAF_MLAD` | Constant key | Field key to store the assembled changed mail address |
| `KKW02501SFConst.MAIL_CAPA_INFO` | Constant key | Source data list key for mail capacity dropdown options |
| `KKW02501SFConst.CHGAF_CAPA_CD` | Constant key | Field key for the capacity code (dropdown value) |
| `KKW02501SFConst.CHGAF_CAPA_O` | Constant key | Field key for the capacity code for display |
| `KKW02501SFConst.MLAD_CHG_UM_FLG` | Constant key | Flag indicating whether mail address change uses the "inherit" flow (new from v6.00/v6.01) |
| `KKW02501SFConst.CAPA` | Constant key | Field key for the raw capacity MB value |
| `KKW02501SFConst.CHGAF_CAPA` | Constant key | Field key for the capacity value for display |
| `KKW02501SFConst.CAPA_DEFAULT` | Constant key | Field key for the default capacity value |
| `KKW02501SFConst.ADD_CAPA` | Constant key | Field key for the computed additional capacity |
| `KKW02501SFConst.VIRUS_CHK_INFO` | Constant key | Source data list key for virus check dropdown options |
| `KKW02501SFConst.CHGAF_VIRUS_CHK_CD` | Constant key | Field key for the virus check code (post-change) |
| `KKW02501SFConst.CHGAF_VIRUS_CHK` | Constant key | Field key for the virus check display text |
| `KKW02501SFConst.CHGBF_VIRUS_CHK_FLG` | Constant key | Field key for the original virus check flag (pre-change) |
| `KKW02501SFConst.MLAD_CHG_FLG` | Constant key | Field key to store the mail address change flag result |
| `KKW02501SFConst.ALIAS` | Constant key | Field key for the original alias (pre-change) |
| `KKW02501SFConst.CHGAF_ALIAS_O` | Constant key | Field key for the changed alias (post-change) |
| `KKW02501SFConst.ALIAS_CHG_FLG` | Constant key | Field key to store the alias change flag result |
| `KKW02501SFConst.SBOP_SVC_KEI_NO_D01` | Constant key | Field key for the Sub-Option Service contract number for alias (code D01) |
| `KKW02501SFConst.CAPA_CHG_FLG` | Constant key | Field key to store the capacity change flag result |
| `KKW02501SFConst.SBOP_SVC_KEI_NO_D02` | Constant key | Field key for the Sub-Option Service contract number for capacity (code D02) |
| `KKW02501SFConst.VIRUS_CHK_CHG_FLG` | Constant key | Field key to store the virus check change flag result |
| `X31CWebConst.DATABEAN_GET_VALUE` | Constant | Parameter value for reading from DataBean |
| `X31CWebConst.DATABEAN_SET_VALUE` | Constant | Parameter value for writing to DataBean |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `OneStopDataBeanAccess.sendMessageString` | — | — | Reads/writes DataBean fields for mail address components, capacity, virus check, alias, and Sub-Option Service contract numbers. This is a DataBean access method, not a database operation. |
| - | `OneStopDataBeanAccess.sendMessageBoolean` | — | — | Reads the `MLAD_CHG_UM_FLG` boolean flag from the DataBean to determine capacity source. |
| - | `KKW02501SFLogic.setListSelectData` | KKW02501SFLogic | — | Populates dropdown select lists in the DataBean — once for mail capacity (`MAIL_CAPA_INFO` → `CHGAF_CAPA_CD` / `CHGAF_CAPA_O`) and once for virus check (`VIRUS_CHK_INFO` → `CHGAF_VIRUS_CHK_CD` / `CHGAF_VIRUS_CHK`). This is a UI data preparation utility, not a database operation. |

**Classification Note:** This method performs **no direct database operations** (no C/R/U/D against entity tables). It is a pure data transformation and flag-classification method. All interactions go through the `DataBean` access API (`sendMessageString`/`sendMessageBoolean`), and two invocations of the local helper `setListSelectData()` for dropdown population.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Logic:KKW02501SFLogic.setChgesrv | `KKW02501SFLogic.setChgesrv` -> `KKW02501SFLogic.setChgFlags` | `sendMessageString [R/W] DataBean (no DB)` |

**Notes:**
- The only direct caller is `KKW02501SFLogic.setChgesrv()`, which is the email update service entry method within the same class.
- No screen or batch entry points were found within 8 hops — this is a sub-method in the logic chain.
- Terminal operations from this method are exclusively `sendMessageString` calls (no-change, change-type-1, change-type-2 classifications) and `sendMessageBoolean` reads — all operating on the in-memory `DataBean` without any database persistence.

## 6. Per-Branch Detail Blocks

### Block 1 — [SET/EXEC] Initialize changed mail address (L1389)

> Sets the changed mail address by concatenating the account part and domain, and retrieves the original mail address for later comparison. This is the foundational data preparation step.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `chgAccount = paramBean[0].sendMessageString(CHGAF_MLAD_ACCOUNT_O, DATABEAN_GET_VALUE)` | Get the changed account part from the DataBean |
| 2 | EXEC | `domain = paramBean[0].sendMessageString(MLAD_DOMAIN, DATABEAN_GET_VALUE)` | Get the domain component from the DataBean |
| 3 | SET | `chgMailAddress = chgAccount + domain` | Assemble full changed email address (account + domain) [-> "user@example.co.jp" pattern] |
| 4 | EXEC | `mlad_bf = paramBean[0].sendMessageString(MLAD, DATABEAN_GET_VALUE)` | Get original mail address (pre-change baseline) for comparison [-> "2. 無" pattern] |

**Note:** Legacy code (ST2-2012-0000410) for handling optional mail accounts was disabled — commented out. The current logic always concatenates account + domain unconditionally.

### Block 2 — [SET/EXEC] Store changed mail address and populate capacity dropdown (L1410–1418)

> Writes the computed changed mail address and account values back into the DataBean, and populates the capacity dropdown list for display.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(CHGAF_MLAD, DATABEAN_SET_VALUE, chgMailAddress)` | Store assembled changed mail address |
| 2 | EXEC | `paramBean[0].sendMessageString(CHGAF_MLAD_ACCOUNT_O, DATABEAN_SET_VALUE, chgAccount)` | Store changed account for display |
| 3 | CALL | `setListSelectData(paramBean, MAIL_CAPA_INFO, CHGAF_CAPA_CD, CHGAF_CAPA_O)` | Populate capacity dropdown from MAIL_CAPA_INFO source data [-> "Eメール情報" label pattern] |

### Block 3 — [IF/ELSE] Capacity source selection (IT1-2013-0001664) (L1425–1436)

> Determines which field holds the capacity value based on whether the user selected "inherit" for the mail address. When the `MLAD_CHG_UM_FLG` is true, the capacity comes directly from the `CAPA` field (the "inherit" flow where the existing capacity is carried forward). Otherwise, it reads from the selected `CHGAF_CAPA_CD` dropdown value.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mail_capa = null` [-> null] |
| 2 | EXEC | `paramBean[0].sendMessageBoolean(MLAD_CHG_UM_FLG, DATABEAN_GET_VALUE)` | Check if using the "inherit" flow |

**Block 3.1** — [ELSE-IF] `MLAD_CHG_UM_FLG = "true"` [IT1-2013-0001664] (L1427)

> The user selected "inherit" — read the capacity directly from the CAPA field (the original/existing capacity is being carried forward).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `mail_capa = paramBean[0].sendMessageString(CAPA, DATABEAN_GET_VALUE)` | Get capacity MB value from the CAPA field |

**Block 3.2** — [ELSE] `MLAD_CHG_UM_FLG = "false"` (L1429)

> The user is NOT using the "inherit" flow — read the capacity from the selected dropdown code (`CHGAF_CAPA_CD`), which represents the user's choice.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `mail_capa = paramBean[0].sendMessageString(CHGAF_CAPA_CD, DATABEAN_GET_VALUE)` | Get capacity code from the selected dropdown |

### Block 4 — [SET/EXEC] Store resolved capacity (L1436)

> Writes the resolved capacity value (from either source) back to the DataBean for display purposes.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(CHGAF_CAPA, DATABEAN_SET_VALUE, mail_capa)` | Store resolved capacity for display |

### Block 5 — [SET/IF/ELSE] Calculate additional capacity (L1439–1450)

> Computes how much capacity has been added above the default. The additional capacity is the difference between the new capacity and the default capacity. If the new value is less than or equal to default, the additional capacity is zero. This supports billing calculation — users are only charged for capacity above the default.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `mail_capa_bf = paramBean[0].sendMessageString(CAPA, DATABEAN_GET_VALUE)` | Get original capacity (pre-change) |
| 2 | EXEC | `mail_capa_default = paramBean[0].sendMessageString(CAPA_DEFAULT, DATABEAN_GET_VALUE)` | Get default capacity value |
| 3 | SET | `mail_capa_new_val = Integer.parseInt(mail_capa)` | Parse the new capacity as integer |
| 4 | SET | `mail_capa_default_val = Integer.parseInt(mail_capa_default)` | Parse the default capacity as integer |
| 5 | SET | `mail_add_capa = null` | Initialize additional capacity |

**Block 5.1** — [IF] `mail_capa_new_val >= mail_capa_default_val` (L1443)

> The new capacity meets or exceeds the default — the additional capacity is the difference. This represents the billable extra capacity.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mail_add_capa = String.valueOf(mail_capa_new_val - mail_capa_default_val)` | Compute the surplus capacity as string |

**Block 5.2** — [ELSE] `mail_capa_new_val < mail_capa_default_val` (L1446)

> The new capacity is below the default — additional capacity is clamped to zero. The user gets the default capacity at no extra charge.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mail_add_capa = String.valueOf("0")` | Additional capacity is zero |

### Block 6 — [SET/EXEC] Store additional capacity (L1450)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(ADD_CAPA, DATABEAN_SET_VALUE, mail_add_capa)` | Store computed additional capacity |

### Block 7 — [EXEC] Populate virus check dropdown (L1453)

> Populates the virus check options for display in the form dropdown.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setListSelectData(paramBean, VIRUS_CHK_INFO, CHGAF_VIRUS_CHK_CD, CHGAF_VIRUS_CHK)` | Populate virus check dropdown from VIRUS_CHK_INFO source data [-> "Eメール情報" label pattern] |

### Block 8 — [IF/ELSE] Mail address change flag determination (L1456–1466)

> Determines whether the mail address was changed. If the original and changed addresses are equal, or if the account part is empty, no change is recorded. Otherwise, a change flag of type 1 (new registration or change with change) is set.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `mlad_bf.equals(chgMailAddress)` | Compare original vs changed mail address |
| 2 | EXEC | `"".equals(chgAccount)` | Check if the account part is empty |

**Block 8.1** — [IF] `mlad_bf == chgMailAddress || chgAccount is empty` (L1456)

> The mail address is unchanged (or the account part is empty, meaning no valid change was entered). Set the no-change flag.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(MLAD_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE_NOCHG)` | Set MLAD_CHG_FLG to "0" — no change [-> "0" pattern] |

**Block 8.2** — [ELSE] (L1462)

> The mail address was changed. Set the change flag to type 1.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(MLAD_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE1)` | Set MLAD_CHG_FLG to "1" — change with change [-> "1" pattern] |

### Block 9 — [IF/ELSE] Mail alias change flag determination (IT1-2013-0001584) (L1470–1520)

> Determines the alias change state. The logic depends on whether the mail address was changed. If the mail address was NOT changed, the alias is analyzed separately. If the mail address WAS changed, the alias is automatically cancelled (a mail address change implies the alias should be cancelled).

**Block 9.1** — [IF] `mlad_bf == chgMailAddress || chgAccount is empty` (L1470)

> The mail address was NOT changed. Analyze the alias independently. This branch handles three sub-scenarios: (a) alias is the same (no-change), (b) alias changed and no existing Sub-Option Service contract (new registration), (c) alias changed and existing Sub-Option Service contract (continuation change).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `alias_bf = paramBean[0].sendMessageString(ALIAS, DATABEAN_GET_VALUE)` | Get original alias |
| 2 | EXEC | `chgafAlias = paramBean[0].sendMessageString(CHGAF_ALIAS_O, DATABEAN_GET_VALUE)` | Get changed alias |

**Block 9.1.1** — [IF] `alias_bf == chgafAlias` [OM-2016-0001005] (L1476)

> The original and changed aliases are the same. The OM-2016-0001005 fix removed the empty-string check on `chgafAlias` — now only the equality check is performed. (Previously, an empty `chgafAlias` would also result in no-change; the fix ensures that a deliberately empty alias is treated as a change, not as "no change".) Set the no-change flag.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(ALIAS_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE_NOCHG)` | Set ALIAS_CHG_FLG to "0" — no change |

**Block 9.1.2** — [ELSE] `alias_bf != chgafAlias` (L1480)

> The alias was changed. Check whether a Sub-Option Service contract number already exists to classify the change type. Per the Japanese comment: サブオプションサービス契約番号（エイリアス用）が存在すれば変更、しない場合は新規登録 (If a Sub-Option Service contract number for alias exists, this is a change; otherwise, it is a new registration).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `sbop_svc_no_alias = paramBean[0].sendMessageString(SBOP_SVC_KEI_NO_D01, DATABEAN_GET_VALUE)` | Get Sub-Option Service contract number for alias (code D01) |

**Block 9.1.2.1** — [IF] `sbop_svc_no_alias is empty` (L1487)

> No existing Sub-Option Service contract. This is a new alias registration.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(ALIAS_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE1)` | Set ALIAS_CHG_FLG to "1" — new registration |

**Block 9.1.2.2** — [ELSE] `sbop_svc_no_alias` is not empty (L1491)

> A Sub-Option Service contract number already exists. This is a continuation change (the alias was previously registered as a sub-option service and is now being modified).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(ALIAS_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE2)` | Set ALIAS_CHG_FLG to "2" — continuation change |

**Block 9.2** — [ELSE] `mlad_bf != chgMailAddress || chgAccount is not empty` (L1497)

> The mail address WAS changed. The Japanese comment states メールアドレスの変更がある場合はエイリアスは解約・キャンセルする (When the mail address is changed, cancel the alias). Set the no-change flag (which in this context signals that the alias should be cancelled).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(ALIAS_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE_NOCHG)` | Set ALIAS_CHG_FLG to "0" — cancel alias (triggered by mail address change) |

### Block 10 — [IF/ELSE] Mail capacity change flag determination (L1503–1522)

> Determines the capacity change state. If the original and new capacities are the same, or if the capacity is empty, no change is recorded. Otherwise, check the Sub-Option Service contract number to classify as new registration or continuation change.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `mail_capa_bf.equals(mail_capa)` | Compare original vs new capacity |
| 2 | EXEC | `"".equals(mail_capa)` | Check if the new capacity is empty |

**Block 10.1** — [IF] `mail_capa_bf == mail_capa || mail_capa is empty` (L1503)

> The capacity was unchanged. Set the no-change flag.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(CAPA_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE_NOCHG)` | Set CAPA_CHG_FLG to "0" — no change |

**Block 10.2** — [ELSE] `mail_capa_bf != mail_capa && mail_capa is not empty` (L1509)

> The capacity was changed. Check the Sub-Option Service contract number for classification. Per the Japanese comment: サブオプションサービス契約番号（容量用）が存在すれば変更、しない場合は新規登録 (If a Sub-Option Service contract number for capacity exists, this is a change; otherwise, it is a new registration).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `sbop_svc_no_capa = paramBean[0].sendMessageString(SBOP_SVC_KEI_NO_D02, DATABEAN_GET_VALUE)` | Get Sub-Option Service contract number for capacity (code D02) |

**Block 10.2.1** — [IF] `sbop_svc_no_capa is empty` (L1513)

> No existing Sub-Option Service contract. This is a new capacity registration.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(CAPA_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE1)` | Set CAPA_CHG_FLG to "1" — new registration |

**Block 10.2.2** — [ELSE] `sbop_svc_no_capa` is not empty (L1517)

> A Sub-Option Service contract number already exists. This is a continuation change (the capacity was previously registered as a sub-option service and is now being modified).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(CAPA_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE2)` | Set CAPA_CHG_FLG to "2" — continuation change |

### Block 11 — [IF/ELSE] Virus check change flag determination (ANK-0364) (L1525–1547)

> Determines whether the virus check setting was changed. If unchanged or the value is empty, set the no-change flag. If changed, also set the human-readable display label (`"2. 有"` for enabled, `"1. 無"` for disabled) and classify the change type based on the specific value being set.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `vchk_cd = paramBean[0].sendMessageString(CHGAF_VIRUS_CHK_CD, DATABEAN_GET_VALUE)` | Get changed virus check code |
| 2 | EXEC | `vchk_cd_bf = paramBean[0].sendMessageString(CHGBF_VIRUS_CHK_FLG, DATABEAN_GET_VALUE)` | Get original virus check flag |

**Block 11.1** — [IF] `vchk_cd_bf == vchk_cd || vchk_cd is empty` (L1528)

> The virus check setting was unchanged. Set the no-change flag.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(VIRUS_CHK_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE_NOCHG)` | Set VIRUS_CHK_CHG_FLG to "0" — no change |

**Block 11.2** — [ELSE] `vchk_cd_bf != vchk_cd && vchk_cd is not empty` (L1532)

> The virus check setting was changed. The Japanese comment states: 変更後ウィルスチェック内容で「有」に変更か「無」に変更かを設定 (Set whether the post-change virus check was changed to "ON" or "OFF").

**Block 11.2.1** — [IF] `vchk_cd == CD00002_ON` [CD00002_ON = "1"] (L1535)

> The virus check was changed to "ON" (有). Set the change flag to type 1 (change with change) and set the display label to "2. 有".

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(VIRUS_CHK_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE1)` | Set VIRUS_CHK_CHG_FLG to "1" — change to ON |
| 2 | EXEC | `paramBean[0].sendMessageString(CHGAF_VIRUS_CHK, DATABEAN_SET_VALUE, "2. 有")` | Set display label to "2. 有" (Enabled) |

**Block 11.2.2** — [ELSE] `vchk_cd != CD00002_ON` (L1541)

> The virus check was changed to "OFF" (無). Set the change flag to type 2 (continuation change) and set the display label to "1. 無". Note: The code unconditionally uses CHG_TYPE2 for "OFF" changes — this appears intentional, treating the removal of antivirus as a continuation-style change.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `paramBean[0].sendMessageString(VIRUS_CHK_CHG_FLG, DATABEAN_SET_VALUE, CHG_TYPE2)` | Set VIRUS_CHK_CHG_FLG to "2" — change to OFF |
| 2 | EXEC | `paramBean[0].sendMessageString(CHGAF_VIRUS_CHK, DATABEAN_SET_VALUE, "1. 無")` | Set display label to "1. 無" (Disabled) |

### Block 12 — [RETURN] (L1549)

> The method completes with a void return. All change flags have been written into the DataBean for downstream consumption by `setChgesrv()` and the sub-option service contract list creation.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return;` (implicit) — void method, no return value |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `chgMailAddress` | Variable | Changed mail address — the full email address after user modification (account + domain concatenation) |
| `mlad_bf` | Variable | Mail address before (pre-change baseline) — the original email address stored in the DataBean for comparison |
| `chgAccount` | Variable | Changed account part — the local-part (before @) of the email address as modified by the user |
| `mail_capa` | Variable | Resolved mail capacity — the capacity MB value after determining the correct source field (inherit flow vs. dropdown selection) |
| `mail_capa_bf` | Variable | Mail capacity before — the original capacity value (pre-change) for comparison |
| `mail_capa_default_val` | Variable | Default capacity — the baseline capacity allocated to the account by default |
| `mail_add_capa` | Variable | Additional capacity — the billable surplus capacity computed as `new_capa - default_capa`; clamped to "0" if the new value is below default |
| `vchk_cd` | Variable | Virus check code — the post-change antivirus check setting code |
| `vchk_cd_bf` | Variable | Virus check code before — the original antivirus setting for comparison |
| `alias_bf` | Variable | Alias before — the original mail alias (pre-change) |
| `chgafAlias` | Variable | Changed alias — the new alias value as entered by the user |
| `sbop_svc_no_alias` | Variable | Sub-Option Service contract number for alias — the contract identifier (D01) used to determine if alias change is a new registration or continuation |
| `sbop_svc_no_capa` | Variable | Sub-Option Service contract number for capacity — the contract identifier (D02) used to determine if capacity change is a new registration or continuation |
| `MLAD_CHG_UM_FLG` | Field | Mail address change "inherit" flag — when true, indicates the user selected to inherit their existing capacity during mail address change (introduced in v6.00/v6.01, IT1-2013-0001655/IT1-2013-0001664) |
| `CHG_TYPE_NOCHG` | Constant | Change state "0" — no modification to the field; the value matches the pre-change baseline |
| `CHG_TYPE1` | Constant | Change state "1" — new registration or an active change with change; used for new Sub-Option Service contracts and for mail address changes, alias new registrations, and virus check ON changes |
| `CHG_TYPE2` | Constant | Change state "2" — continuation change (the Sub-Option Service contract already exists and is being modified); also used for virus check OFF changes |
| `CD00002_ON` | Constant | "1" — the boolean true/on value for flags and toggles (e.g., antivirus check enabled) |
| `CD00002_OFF` | Constant | "0" — the boolean false/off value for flags and toggles |
| `SBOP_SVC_CD_ALIAS` | Constant | "D01" — Sub-Option Service code for mail alias (エイリアス用) |
| `SBOP_SVC_CD_MAIL_CAPA` | Constant | "D02" — Sub-Option Service code for mail box capacity (メールBOX容量用) |
| `SBOP_SVC_CD_VCHK` | Constant | "D03" — Sub-Option Service code for virus check (ウィルスチェック用) |
| `SBOP_SVC_KEI_NO_D01` | Field | Sub-Option Service contract number (for alias) — when non-empty, indicates an existing alias sub-option service contract |
| `SBOP_SVC_KEI_NO_D02` | Field | Sub-Option Service contract number (for capacity) — when non-empty, indicates an existing capacity sub-option service contract |
| `CHGAF_MLAD_ACCOUNT_O` | Constant key | DataBean field key for the changed account part (output) |
| `CHGAF_MLAD` | Constant key | DataBean field key for the changed full mail address (output) |
| `MLAD_DOMAIN` | Constant key | DataBean field key for the domain component |
| `MLAD` | Constant key | DataBean field key for the original mail address |
| `MLAD_CHG_FLG` | Constant key | DataBean field key for the mail address change flag result |
| `ALIAS_CHG_FLG` | Constant key | DataBean field key for the alias change flag result |
| `CAPA_CHG_FLG` | Constant key | DataBean field key for the capacity change flag result |
| `VIRUS_CHK_CHG_FLG` | Constant key | DataBean field key for the virus check change flag result |
| `CHGAF_CAPA_CD` | Constant key | DataBean field key for the capacity code (dropdown selection) |
| `CHGAF_CAPA` | Constant key | DataBean field key for the capacity value for display |
| `CHGAF_VIRUS_CHK_CD` | Constant key | DataBean field key for the virus check code (post-change) |
| `CHGAF_VIRUS_CHK` | Constant key | DataBean field key for the virus check display text (e.g., "1. 無" or "2. 有") |
| `CHGBF_VIRUS_CHK_FLG` | Constant key | DataBean field key for the virus check flag before change |
| `ADD_CAPA` | Constant key | DataBean field key for the computed additional capacity |
| `CAPA_DEFAULT` | Constant key | DataBean field key for the default capacity value |
| `CAPA` | Constant key | DataBean field key for the capacity MB value |
| `SBOP_SVC_KEI_NO_D01` | Constant key | DataBean field key for the Sub-Option Service contract number (alias, D01) |
| `SBOP_SVC_KEI_NO_D02` | Constant key | DataBean field key for the Sub-Option Service contract number (capacity, D02) |
| MAIL_CAPA_INFO | Constant key | Source data list key for the mail capacity dropdown select options |
| VIRUS_CHK_INFO | Constant key | Source data list key for the virus check dropdown select options |
| setListSelectData | Method | Helper method that populates a dropdown select list in the DataBean from a source info list. Signature: `setListSelectData(paramBean, srcListKey, setBeanKey, setBeanKey2)` |
| Sub-Option Service (サブオプションサービス) | Business term | Optional add-on services that customers can subscribe to for email features (alias, capacity, virus check). Each has a unique contract number in the system. |
| DataBean | Technical term | X31 framework data transfer object used to pass data between the presentation layer and business logic. Accessed via `sendMessageString`/`sendMessageBoolean` for typed get/set operations. |
| CHGAF (変更後) | Japanese abbreviation | Post-change — the value after user modification |
| BF (変更前) | Japanese abbreviation | Before — the pre-change original value |
| ウィルスチェック | Japanese term | Virus check — the antivirus scanning service toggle for email |
| 有 / 無 | Japanese terms | "有" (yu) = ON/enabled; "無" (mu) = OFF/disabled — used for the virus check display labels |
| 変更なし | Japanese term | No change — the state where the user's selection matches the original value |
| 登録ありまたは変更有変更 | Japanese term | New registration or change with change — CHG_TYPE1 |
| 継続変更 | Japanese term | Continuation change — CHG_TYPE2, used when a Sub-Option Service contract already exists |
| エイリアス解約 | Japanese term | Alias cancellation — when a mail address change automatically triggers cancellation of the associated alias |
| 引き継ぐ | Japanese term | Inherit — the user's choice to carry forward their existing settings during a change operation |
| Eメール情報 | Japanese term | E-Mail Information — the label for the email information section in dropdown source data lists |
| X31SDataBeanAccess | Technical type | The X31 framework class providing typed access methods (sendMessageString, sendMessageBoolean) to read and write DataBean fields |
| X31CWebConst.DATABEAN_GET_VALUE | Constant | Parameter value used as the "command" to retrieve a value from the DataBean |
| X31CWebConst.DATABEAN_SET_VALUE | Constant | Parameter value used as the "command" to set a value in the DataBean |
