# Eo / Web / Webview / Kkw00844sf

## Overview

The `KKW00844SF` package is the view-layer component for the **Smart Link Premium Registration Confirmation** screen within the customer contract web application. It is responsible for displaying a confirmation page where operators can review and finalize a Smart Link Premium service registration, and for coordinating the data exchange with backend services that retrieve initial screen data and persist the registration.

In short: when an operator navigates to this screen, the module initializes the form with customer and service data, the operator confirms the details, and on submission the module calls the appropriate backend service to register the Smart Link Premium subscription.

---

## Key Classes and Interfaces

### KKW00844SFLogic — View Business Logic

**File:** `source/koptWebB/src/eo/web/webview/KKW00844SF/KKW00844SFLogic.java`

This is the central orchestrator of the module. It extends `JCCWebBusinessLogic` and handles all three user actions on the screen:

| Method | When called | What it does |
|---|---|---|
| `actionInit()` | Screen load (initial display) | Initializes the form bean, fetches the online operation date and datetime, copies customer contract context from the shared bean, sets default values for status codes, and calls `callKKSV0638()` to populate screen data from the backend service. It also displays a message confirming the action. |
| `actionBack()` | "Back" button clicked | Sets the previous screen ID in the shared form bean and returns without processing. |
| `actionFix()` | "Confirm/Fix" button clicked | Calls `callKKSV0639()` to persist the registration, sets the next screen ID/name, and displays a success message. |
| `actionFin()` | "Complete/List" button clicked | Sets the list-screen ID and returns without processing. |

Key implementation details:

- **`actionInit()`** sets up a rich set of defaults. It pulls the `svc_kei_no`, `ido_div` (change category), and `sysid` from the customer contract list carried in the shared form bean. It pre-fills operation metadata (dates, codes) including:
  - `MSKM_STAT_SKBT_CD_SHONIN` set to the "approved" status code.
  - `IDO_DIV` branching logic: if the change category equals `00031` (operation setting), the submission type (`MSKM_SBT_CD`) is set to code `000026`; otherwise it defaults to `00001`.
  - The operation service code (`OP_SVC_CD`) is hardcoded to the Smart Link Premium service code, and the operation cost code (`OP_PCRS_CD`) and plan code (`OP_PPLAN_CD`) are set to the corresponding billing codes.
  - The progress status (`PRG_STAT`) is set to `5101` (option information application in progress).

- **`callKKSV0638()`** (called during `actionInit`) is the data-fetch method. It builds a parameter map with the use-case ID and operation ID, instantiates a `KKSV0638_KKSV0638OPDBMapper`, and invokes four mapper configuration methods:
  - `setKKSV063801SC` — initial screen data retrieval
  - `setKKSV063801CC` — for internal equipment type `P0` (tablet), added in version v38.00 for "tablet 2nd unit or later security pack to premium pack upgrade" support (ANK-3360)
  - `setKKSV063802SC` — for new contract and service addition change types (ido_div `00001` / `00002`), added in v5.00 for "progress scheme different-year timestamp" support
  - `setKKSV063803SC` — discount service contract consent check, added in v6.00

  After `invokeService()` returns, it calls `getKKSV063801CC()` (unmapping) and then `spPackCheck()` (discussed below). For new contract/service addition change types, it also reads the `ido_dtm` from the service output into the form bean.

- **`callKKSV0639()`** (called during `actionFix`) is the registration/persistence method. It instantiates `KKSV0639_KKSV0639OPDBMapper` and invokes a long chain of mapper configuration methods (16 total: `setKKSV063901SC` through `setKKSV063916SC`, plus `setUpdMkmScinsprtWkCC`, `setIsSserviceOpUpdCC`, and `setSecurityPackOperateCC`). This maps all form bean fields to the input parameters of the KKSV0639 backend service. After invocation, it checks for errors via `getErrInfo()`, then sets the next screen and displays a confirmation message (`EKB2960--I`).

- **`spPackCheck()`** — a conditional business rule method (added in v6.00). It examines the output from `KKSV063803SC` and looks for a discount service contract with service code `W00000010` (eo Security Pack) whose status is neither `D` (discontinued) nor `C` (suspended). If such a contract exists, it displays an informational message (`EKBE600__I`) to alert the operator. This supports the "discount update judgment" feature introduced in v6.00.

- **`getErrInfo()`** — a utility method that processes error information returned from a service call. It iterates over an `err_info_list` array from the output map and maps each error entry to a display message. If any error has `kkoku_flg` set to `"0"`, it sets the error flag to true, causing the operation to abort (the `actionFix` returns early).

### KKW00844SFChecker — GUI Validation Checker

**File:** `source/koptWebB/src/eo/web/webview/KKW00844SF/KKW00844SFChecker.java`

This class implements `X31SGuiCheckBase`. The framework calls `checkMethod()` with a pattern ID and a parameter block before rendering the screen or on form submission.

Current implementation: the `checkMethod()` always returns `true`, meaning no GUI-level validation is currently defined for this screen. The checker infrastructure is in place (it receives the business logic class reference), but no actual validation rules have been implemented. This is the default generated template that can be extended with screen-specific validation later.

### KKW00844SFBean — Main Form Data Bean

**File:** `source/koptWebB/src/eo/web/webview/KKW00844SF/KKW00844SFBean.java`

This is the main screen-level data bean, extending `X33VViewBaseBean` and implementing `X33VListedBeanInterface` and `X31CBaseBean`. It carries all form data between the view (JSP) and the logic layer.

The bean contains three categories of fields:

1. **Simple scalar fields** — each with a triple (`_update`, `_value`, `_state`) pattern plus an optional `_enabled` boolean. The `_update` field tracks whether the value was modified on the screen, `_value` holds the current data, and `_state` carries display state (e.g., read-only, disabled). Examples:
   - `use_staymd_*` — usage start date
   - `svc_kei_no_*` — service contract number
   - `ido_div_*` — change category
   - `unyo_ymd_*` / `unyo_dtm_*` — operation date / datetime
   - `svc_kei_stat_*` — service contract status
   - `mskm_dtl_no_*` — application detail number
   - `mskm_stat_skbt_cd_shonin_*` — application status identification code (approved)
   - `mskm_sbt_cd_*` — application type code
   - `op_svc_cd_*` — operation service code
   - `op_pcrs_cd_*` / `op_pplan_cd_*` — operation cost code / plan code
   - `oya_kei_skbt_cd_*` — parent contract identification code
   - `rule0059_auto_aply_*` — service charge auto-application flag
   - `prg_memo_*` / `prg_stat_*` / `prg_tkjk_1_*` — progress memo, status, special item 1
   - `net_tab_op_if_ctl_cd_*` — net tab operation info control code
   - `ido_dtm_*` — change timestamp
   - `haiso_hmpin_stat_cd_*` — delivery return status code

2. **List fields** — two `X33VDataTypeList` collections:
   - `cust_kei_hktgi_list_list` — customer contract continuation list. Initialized to one element containing a `KKW00844SF01DBean` instance in the constructor. The helper method `getJsflist_typelist_cust_kei_hktgi_list()` converts this to a `SelectItem` list for JSF dropdown rendering.
   - `ido_rsn_list_list` — change reason list. Initialized empty; the helper `getJsflist_typelist_ido_rsn_list()` converts it to `SelectItem` entries.

The bean is referenced by 3 JSP views and 3 XML configuration files.

### KKW00844SF01DBean — Customer Contract Row Data Bean

**File:** `source/koptWebB/src/eo/web/webview/KKW00844SF/KKW00844SF01DBean.java`

This is a row-level data bean used inside the `cust_kei_hktgi_list_list` list in `KKW00844SFBean`. Each element in the customer contract list is a `KKW00844SF01DBean` instance, allowing the screen to display and edit multiple customer contract rows.

Fields (each following the `_update` / `_value` / `_state` triple pattern):

| Field group | Purpose |
|---|---|
| `sysid_*` | System ID |
| `svc_kei_no_*` | Service contract number |
| `ido_div_*` | Change category |
| `ido_rsn_cd_list` | Change reason code list (`X33VDataTypeList` of strings) |
| `ido_rsn_memo_*` | Change reason memo |
| `op_svc_kei_no_list` | Operation service contract number list |
| `tran_div_*` | Process category |
| `mskm_no_*` | Application number |
| `mskm_dtl_no_*` | Application detail number |

It also implements `X33VDataTypeBeanInterface` with the full `loadModelData()` / `storeModelData()` / `typeModelData()` / `listKoumokuIds()` / `addListDataInstance()` / `removeElementFromListData()` / `clearListDataInstance()` protocol. The `loadModelData()` method supports a key/subkey lookup pattern where the key maps a Japanese field name (like "システムID", "サービス契約番号", "変動区分") to the corresponding getter. For list-type fields (change reason code, operation service contract number), it parses an index from the key substring to access the correct list element.

The `getJsflist_ido_rsn_cd()` and `getJsflist_op_svc_kei_no()` methods convert their respective lists into `ArrayList<SelectItem>` for JSF dropdown rendering.

### KKW00844SF02DBean — Change Reason Row Data Bean

**File:** `source/koptWebB/src/eo/web/webview/KKW00844SF/KKW00844SF02DBean.java`

A simpler row-level bean representing a single change reason entry. It holds only:

| Field | Purpose |
|---|---|
| `ido_rsn_cd_*` | Change reason code |
| `ido_rsn_memo_*` | Change reason memo |

This bean is used within the `ido_rsn_list_list` list in `KKW00844SFBean`. It implements the same `X33VDataTypeBeanInterface` protocol with `loadModelData()` / `storeModelData()` / `typeModelData()` / `listKoumokuIds()`.

### KKW00844SFConst — Constants

**File:** `source/koptWebB/src/eo/web/webview/KKW00844SF/KKW00844SFConst.java`

A simple utility class with a private constructor containing all field name constants as Japanese `String` values. These constants (e.g., `USE_STAYMD` = "利用開始日", `SVC_KEI_NO` = "サービス契約番号", `IDO_DIV` = "変動区分") are used throughout the logic and bean classes as map keys when communicating with the framework's data bean access layer. They provide a single source of truth for field name strings used in `sendMessageString()` calls and mapper parameter maps.

---

## How It Works

### Screen Flow

```mermaid
flowchart TD
    A[User navigates to KKW00844SF screen] --> B[actionInit called]
    B --> C[Screen info fetched from shared bean]
    C --> D[setDataBean populates defaults]
    D --> E[callKKSV0638 fetches data from backend]
    E --> F{change type is new/addition?}
    F -->|yes| G[Fetch ido_dtm from service output]
    F -->|no| H[Continue to next step]
    G --> H
    H --> I[spPackCheck evaluates discount flag]
    I --> J[Screen rendered with data]
    J --> K{User action?}
    K -->|Back| L[actionBack: set prev screen ID]
    K -->|Fix/Confirm| M[actionFix called]
    K -->|Complete| N[actionFin: set list screen ID]
    M --> O[callKKSV0639 persists registration]
    O --> P{errors?}
    P -->|yes| Q[Display error messages, stop]
    P -->|no| R[Set next screen ID/name]
    R --> S[Display success message]
    S --> T[Screen rendered]
```

### Detailed Init Flow (actionInit)

1. The framework creates the `KKW00844SFLogic` instance and calls `actionInit()`.
2. It retrieves the shared form bean (for cross-screen info) and the service form bean (this screen's data).
3. `JCCWebCommon.getScreenInfo(this)` extracts screen metadata from the HTTP request.
4. `setDataBean()` populates the service form bean with:
   - Current operation date (`unyo_ymd`, `use_staymd`)
   - Current operation datetime (`unyo_dtm`)
   - Customer contract context (`svc_kei_no`, `ido_div`, `sysid`) from the shared bean's customer contract list
   - Default status: application approved (`MSKM_STAT_SKBT_CD_SHONIN`)
   - Default application type: `000026` for operation-setting changes, `00001` otherwise
   - Hardcoded operation codes: service = Smart Link Premium, cost = `B80`, plan = `PB8001`
   - Parent contract = service contract, service charge auto-application = yes
   - Progress status = `5101` (in-progress)
   - Progress special item 1 = "Smart Link Premium Information + registration"
   - Net tab operation control code = `1`
   - System datetime for change (`ido_dtm`)
5. `callKKSV0638()` is invoked with `FUNC_CD_2` to fetch additional screen data from the backend service KKSV0638. The mapper handles input mapping for customer contract data, internal equipment, change type, and discount consent.
6. `spPackCheck()` examines the service response for discount service contracts that would be affected.
7. If the change type is new contract or service addition, the `ido_dtm` from the service response is placed into the form bean.
8. The data bean is dumped to the log, and the method returns `true` to proceed with screen rendering.

### Detailed Fix Flow (actionFix)

1. User confirms the screen data by clicking the "Fix" button.
2. `callKKSV0639()` is invoked with `FUNC_CD_1` (registration mode).
3. The mapper configures all 16+ service input parameters from the form bean, including security pack operation data.
4. `invokeService()` sends the request to the backend.
5. The output is checked for errors via `getErrInfo()`. If any error has `kkoku_flg = "0"`, the method returns early without proceeding.
6. The next screen ID and name are set to `KKW00845` (completion screen), and a success message is displayed.

---

## Data Model

### Bean Hierarchy

```
KKW00844SFBean (main form)
├── use_staymd_*          (String: usage start date)
├── svc_kei_no_*          (String: service contract number)
├── ido_div_*             (String: change category)
├── sysid_*               (String: system ID)
├── unyo_ymd_*            (String: operation date)
├── unyo_dtm_*            (String: operation datetime)
├── svc_kei_stat_*        (String: service contract status)
├── mskm_dtl_no_*         (String: application detail number)
├── mskm_stat_skbt_cd_shonin_* (String: application status approved code)
├── mskm_sbt_cd_*         (String: application type code)
├── op_svc_cd_*           (String: operation service code)
├── op_pcrs_cd_*          (String: operation cost code)
├── op_pplan_cd_*         (String: operation plan code)
├── oya_kei_skbt_cd_*     (String: parent contract code)
├── rule0059_auto_aply_*  (String: service charge auto-application flag)
├── prg_memo_*            (String: progress memo)
├── prg_stat_*            (String: progress status)
├── prg_tkjk_1_*          (String: progress special item 1)
├── net_tab_op_if_ctl_cd_* (String: net tab operation control code)
├── ido_dtm_*             (String: change timestamp)
├── haiso_hmpin_stat_cd_* (String: delivery return status)
├── cust_kei_hktgi_list_list (X33VDataTypeList<KKW00844SF01DBean>)
│   └── KKW00844SF01DBean[0]
│       ├── sysid_*
│       ├── svc_kei_no_*
│       ├── ido_div_*
│       ├── ido_rsn_cd_list (X33VDataTypeList<String>)
│       ├── ido_rsn_memo_*
│       ├── op_svc_kei_no_list (X33VDataTypeList<String>)
│       ├── tran_div_*
│       ├── mskm_no_*
│       └── mskm_dtl_no_*
└── ido_rsn_list_list (X33VDataTypeList<KKW00844SF02DBean>)
    └── KKW00844SF02DBean[N]
        ├── ido_rsn_cd_*
        └── ido_rsn_memo_*
```

### Constant Key Names

`KKW00844SFConst` defines all field name constants as Japanese strings. The most frequently used keys include:

- `USE_STAYMD` ("利用開始日") — Usage start date
- `CUST_KEI_HKTGI_LIST` ("顧客契約引継リスト") — Customer contract continuation list key
- `IDO_RSN_LIST` ("変動理由リスト") — Change reason list key
- `SVC_KEI_NO` ("サービス契約番号") — Service contract number
- `SYSID` ("システムID") — System ID
- `IDO_DIV` ("変動区分") — Change category
- `UNYO_YMD` / `UNYO_DTM` — Operation date / datetime
- `SVC_KEI_STAT` — Service contract status
- `MSKM_DTL_NO` — Application detail number
- `MSKM_STAT_SKBT_CD_SHONIN` — Application status (approved)
- `MSKM_SBT_CD` — Application type code
- `OP_SVC_CD` — Operation service code
- `IDO_DTM` — Change timestamp

---

## Dependencies and Integration

### Backend Services

| Service | Mapper Class | When called | Purpose |
|---|---|---|---|
| **KKSV0638** — Smart Link Premium Registration Confirmation Initial Display | `KKSV0638_KKSV0638OPDBMapper` | `actionInit()` | Fetches screen data, customer contract info, security pack details |
| **KKSV0639** — Smart Link Premium Registration Confirmation | `KKSV0639_KKSV0639OPDBMapper` | `actionFix()` | Persists the registration data to the database |

The use-case IDs and operation IDs are defined in `JKKCommonConst` (`UCID_KKSV0638`, `OPID_KKSV0638OP`, `UCID_KKSV0639`, `OPID_KKSV0639OP`).

### Framework Dependencies

- Extends the X31 framework: `JCCWebBusinessLogic`, `X31SDataBeanAccess`, `X31CWebConst`, `X31SDataBeanAccessArray`
- Bean layer uses the X33V framework: `X33VViewBaseBean`, `X33VListedBeanInterface`, `X33VDataTypeList`, `X33VDataTypeBeanInterface`, `X31CBaseBean`
- JSF integration via `javax.faces.model.SelectItem` for dropdown rendering

### Cross-Module References

| Consumed by | What it uses |
|---|---|
| `KKW008440PJP.jsp` | `KKW00844SFBean` — the JSP view binds to this bean |
| `WEBGAMEN_KKW008440PJP.xml` | `KKW00844SFBean`, `KKW00844SFLogic` — screen configuration |
| `WEBGAMEN_KKW008450PJP.xml` | `KKW00844SFBean`, `KKW00844SFLogic` — completion screen config |
| `x31business_logic_KKW00844SF.xml` | `KKW00844SFLogic` — business logic wiring |

### External Constants Used

The logic class references constants from:
- `JKKCommonConst` — screen IDs, status codes, function codes, operation codes, security pack codes
- `JKKStrConst` — service code strings (e.g., `WRIB_SVC_CD_SECURITY_PACK`)
- `JPCOnlineMessageConstant` — message IDs for UI messages (`EKB0370__I`, `EKBE600__I`)
- `CommonInfoCFConst` — shared form bean keys (`NEXT_SCREEN_NAME`, `NEXT_SCREEN_ID`)
- `JKKScreenConst` — screen identifiers (`SCREEN_NAME_KKW00844`, `SCREEN_ID_KKW00845`)
- `JKCModelConstant` — function codes (`FUNC_CD_1`, `FUNC_CD_2`)
- `JPCStrConst` — string literals

---

## Version History

Key feature additions:

| Version | Date | Feature |
|---|---|---|
| v4.00 | 2012-08-07 | Initial creation |
| v4.01 | 2012-10-18 | Progress supplementary item editing support |
| v4.02 | 2013-01-11 | System date handling for different-year months/days |
| v4.03 | 2013-02-16 | Tab delivery status confirmation |
| v5.00 | 2013-06-18 | Progress scheme different-year timestamp support |
| v5.01 | 2013-10-02 | Message removal |
| v6.00 | 2013-12-22 | Discount update judgment (spPackCheck) |
| v10.00 | 2014-08-02 | US management support |
| v32.00 | 2017-04-14 | Security pack introduction |
| v38.00 | 2018-09-07 | Tablet 2nd+ unit security pack to premium pack upgrade |

---

## Notes for Developers

### Checker is a stub

`KKW00844SFChecker` currently always returns `true` from `checkMethod()`. If you need to add form validation rules for this screen (e.g., field format checks, cross-field consistency), this is where to implement them. The `X31SGuiCheckParam` parameter contains a `patternID` that can be used to branch between different validation scenarios (screen init vs. submission).

### Default value branching

In `setDataBean()`, the application type code (`MSKM_SBT_CD`) is set based on the change category (`IDO_DIV`). If the change category equals `00031` (operation setting), the code is set to `000026`; otherwise it defaults to `00001`. Be aware that this is a hardcoded mapping — if new change categories are added in the future, this logic may need to be updated.

### spPackCheck business rule

The `spPackCheck()` method checks whether the customer already has an active "eo Security Pack" discount service contract (service code `W00000010`, status not `D`/`C`). If so, it displays an informational message but does **not** block the operation. This was added to support the discount update judgment feature — the system alerts the operator but allows them to proceed.

### Hardcoded codes

Several service and cost codes are hardcoded in `setDataBean()`:
- `OP_SVC_CD` = Smart Link Premium service code
- `OP_PCRS_CD` = `B80`
- `OP_PPLAN_CD` = `PB8001`
- `OYA_KEI_SKBT_CD` = service contract type

These are drawn from `JKKCommonConst` and `JKKStrConst`. If billing or service codes change, these constant references are the single point of modification.

### Thread safety

Like most X31 framework beans, the data bean is stored in the HTTP session. The logic class instances are created per-request. There is no explicit synchronization — developers should avoid storing request-specific state in instance variables on `KKW00844SFLogic` outside of method scopes.

### Adding new fields

To add a new field to this screen:
1. Add the `_update` / `_value` / `_state` triple (and `_enabled` if applicable) to `KKW00844SFBean`
2. Add the constant to `KKW00844SFConst`
3. Set/get the field in `setDataBean()` during init and in the appropriate mapper configuration methods
4. Ensure the mapper (`KKSV0639`) is configured to include the new field in the input/output mapping
5. Update the JSP view (`KKW008440PJP.jsp`) to render the field

### Row-level beans

`KKW00844SF01DBean` and `KKW00844SF02DBean` are used for list/dynamic rows. To add a field to these:
1. Add the triple pattern fields to the appropriate bean class
2. Add `loadModelData()` / `storeModelData()` / `typeModelData()` branches for the new field
3. Add the constant to `KKW00844SFConst`
4. Register the field in `listKoumokuIds()`