# Business Logic — KKW12601SFLogic.actionFix() [89 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW12601SF.KKW12601SFLogic` |
| Layer | Controller (Web-tier Logic / Screen Handler) |
| Module | `KKW12601SF` (Package: `eo.web.webview.KKW12601SF`) |

## 1. Role

### KKW12601SFLogic.actionFix()

This method implements the **determination processing** (確定処理) for the "Welcome Letter List Confirmation" screen in the K-Opticom customer onboarding system. It performs the core business operation of bulk-changing welcome letter issuance records: it takes the user-selected rows from a confirmation list, maps the form data into the service layer, and invokes the `KKSV0142` (Welcome Letter Issuance Bulk Change) service to apply updates. The method also handles the special case where a send batch is actively running — if the service returns error flag "1" (indicating a transmission batch conflict), it displays a warning and bypasses the post-processing data updates. On successful completion, it configures the shared form bean for navigation to the "Welcome Letter List Update Completion" screen (KKW12606), sets a success message, and processes the updated data list by applying flags for letter dispatch division (KOPT routing), send exclusion status, and re-issuance detection. The method follows a **delegation + routing pattern**: it delegates data mapping to a DB mapper, delegates business logic to an AP service, then handles presentation-side state updates locally.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["actionFix()"])
    START --> GET_BEAN["Get service form bean (X31SDataBeanAccess)"]
    GET_BEAN --> CREATE_MAPPER["Create KKSV0142_KKSV0142OPDBMapper"]
    CREATE_MAPPER --> CREATE_INPUT["Create inputMap HashMap"]
    CREATE_INPUT --> MAP_INPUT["mapper.setKanuoresoIktTrkCC(paramBean, inputMap, FUNC_CD_1)"]
    MAP_INPUT --> MAP_SC["mapper.setKKSV014201SC(paramBean, inputMap, FUNC_CD_1)"]
    MAP_SC --> INVOKE_SVC["invokeService(KKSV0142, KKSV0142OP)"]
    INVOKE_SVC --> CHECK_RESULT["getKKSV0142Result(outputMap)"]
    CHECK_RESULT --> CHECK_RSLT{"rslt equals 1?"}
    CHECK_RSLT -->|Yes - Batch Running| BATCH_MSG["setMessageInfo(EKB0930_NW): Send batch in progress message"]
    CHECK_RSLT -->|No - Success| GET_COMMON["Get common info bean (X31SDataBeanAccess)"]
    BATCH_MSG --> LOG_DUMP["JSYwebLog DataBean dump"]
    GET_COMMON --> SET_NEXT_SCREEN["Set NEXT_SCREEN_ID = KKW12606"]
    SET_NEXT_SCREEN --> SET_NEXT_NAME["Set NEXT_SCREEN_NAME = 'Welcome Letter List Update Completion'"]
    SET_NEXT_NAME --> SET_MSG["setMessageInfo(EKB4390__I): Welcome letter list update message"]
    SET_MSG --> GET_DATA_ARRAY["Get KANUORESO_LIST_UPD DataBeanArray"]
    GET_DATA_ARRAY --> LOOP_START{"i < datalistUpd.getCount()?"}
    LOOP_START -->|Yes| GET_LETTER["Get LETTER_HASSO_SHIWAKE_DIV_02"]
    GET_LETTER --> CHECK_KOPT{"letter == LETTER_SHIWAKE_KOPT = '1'?"}
    CHECK_KOPT -->|Yes| SET_HIKINUKI["Set HIKINUKI_02 = true (Exclusion flag)"]
    CHECK_KOPT -->|No| CHECK_JGI
    SET_HIKINUKI --> CHECK_JGI
    CHECK_JGI --> GET_JGI["Get SEND_JGI_FLG_02"]
    GET_JGI --> CHECK_JGI_VAL{"send_jgi == SEND_JGI_JGI = '2'?"}
    CHECK_JGI_VAL -->|Yes - Exclusion| SET_SEND_JGI["Set SEND_JGI_02 = true (Send exclusion flag)"]
    CHECK_JGI_VAL -->|No| CHECK_DTM
    SET_SEND_JGI --> CHECK_DTM
    CHECK_DTM --> GET_DTM["Get SEND_DTM_02"]
    GET_DTM --> CHECK_DTM_EMPTY{"send_dtm not null and not empty?"}
    CHECK_DTM_EMPTY -->|Yes - Re-issue| SET_RE_HAKO["Set RE_HAKO_02 = true (Re-issuance flag)"]
    CHECK_DTM_EMPTY -->|No| INCR_I
    SET_RE_HAKO --> INCR_I
    INCR_I --> LOOP_NEXT{"i++ < count?"}
    LOOP_NEXT -->|Yes| GET_LETTER
    LOOP_NEXT -->|No| LOG_ACTION
    LOG_ACTION --> LOG_DUMP["JSYwebLog DataBean dump"]
    LOG_DUMP --> RETURN(["return true"])
    RETURN --> END(["End"])
```

**Key constant resolutions:**
- `LETTER_SHIWAKE_KOPT` = "1" — Letter dispatch division: "Send to KOPT" (internal routing designation)
- `SEND_JGI_JGI` = "2" — Send exclusion flag: "Exclusion" (marked for send exclusion)
- `SCREEN_ID_KKW12606` = "KKW12606" — Target screen for navigation after successful processing
- `SCREEN_NAME_KKW12606` = "Welcome Letter List Update Completion" — Display name of target screen
- `JPCModelConstant.FUNC_CD_1` — Function code 1 (standard operation mode)

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It reads all required data from the request-scoped form bean via `super.getServiceFormBean()` and shared state from the common info bean. |
| - | `super.getServiceFormBean()` | `X31SDataBeanAccess` | The screen's form bean containing user-selected rows from the welcome letter confirmation list, including data such as service contract numbers, order content codes, dispatch division flags, and send exclusion flags. |
| - | `inputMap` | `HashMap<String, Object>` | Instance field used to collect mapped input data before service invocation. Populated by mapper calls. |
| - | `outputMap` | `HashMap<String, Object>` | Instance field populated by `invokeService()` containing AP server processing results, including the error flag from the service response. |
| - | `bean` (local) | `X31SDataBeanAccess[]` | Array wrapper around the service form bean, passed to the mapper for data mapping. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `KKSV0142_KKSV0142OPDBMapper.setKanuoresoIktTrkCC` | (Mapper) | - | Maps welcome letter issuance bulk change tracking data from form beans into the input map for service invocation |
| - | `KKSV0142_KKSV0142OPDBMapper.setKKSV014201SC` | (Mapper) | - | Maps welcome letter issuance registration data (SC-level input fields) from form beans into the input map |
| C/U | `KKSV0142` / `KKSV0142OP` (invokeService) | KKSV014201SC | Welcome letter issuance records (bulk update) | Invokes the AP service for welcome letter issuance bulk change. Performs check and register/update operations on welcome letter records. The service returns an error flag indicating success (0) or a send batch conflict (1). |
| - | `KKW12601SFLogic.getKKSV0142Result` | (Internal) | - | Extracts the error flag from the AP service output map under the key "KanuoresoIktTrkCC" |
| - | `JCCWebCommon.setMessageInfo(this, JPCOnlineMessageConstant.EKB0930_NW, msgInfo)` | (Message) | - | Sets a warning message for "Send batch in progress: Update" when the service returns error flag 1 |
| - | `JCCWebCommon.setMessageInfo(this, JPCOnlineMessageConstant.EKB4390__I, msgInfo)` | (Message) | - | Sets an informational message for "Welcome letter list update" on successful completion |
| - | `JKKAddSupportCC.setMessageInfo` | (Message) | - | Sets navigation messages for the common info bean (screen transition metadata) |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW12601 (KKW12601SFLogic) | `KKW12601SFLogic.actionFix` (direct screen entry point) | `invokeService [C/U] KKSV014201SC (Welcome Letter Issuance Records)` |
| 2 | Screen:KKW12602 (KKW12602SFLogic) | `KKW12602SFLogic.actionFix` (related screen, separate logic) | `invokeService [C/U] KKSV014201SC (Welcome Letter Issuance Records)` |

**Notes:** The `actionFix()` method is a screen-level entry point called directly from the KKW12601SF screen (Welcome Letter List Confirmation). The action is typically triggered by a form submission button (e.g., a "Determine" / "Confirm" button). The KKSV0142OP service performs a check-then-register/update operation on welcome letter issuance records.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] (Retrieve and prepare form bean data) (L1259)

> Obtains the service form bean and creates an input map for service invocation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `boolean result = true` // Initialize return value |
| 2 | EXEC | `X31SDataBeanAccess bean = super.getServiceFormBean()` // Get service form bean [--> DataBean Access] |
| 3 | SET | `X31SDataBeanAccess[] paramBean = {bean}` // Wrap bean in array |
| 4 | SET | `KKSV0142_KKSV0142OPDBMapper mapper = new KKSV0142_KKSV0142OPDBMapper()` // Create mapper instance |
| 5 | SET | `inputMap = new HashMap<String, Object>()` // Create input map [--> Map for service invocation] |

**Block 2** — [EXEC] (Map form data to service input) (L1270)

> Maps the welcome letter list data into service-level input structures via two mapper methods.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `mapper.setKanuoresoIktTrkCC(paramBean, inputMap, JPCModelConstant.FUNC_CD_1)` // Map tracking data [--> FUNC_CD_1 = standard mode] |
| 2 | CALL | `mapper.setKKSV014201SC(paramBean, inputMap, JPCModelConstant.FUNC_CD_1)` // Map SC-level registration data [--> Welcome letter issuance SC] |

**Block 3** — [EXEC] (Invoke AP service) (L1274)

> Calls the welcome letter issuance bulk change service.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `X31CMessageResult msgResult = invokeService("KKSV0142", "KKSV0142OP")` // Invoke AP service [--> KKSV014201SC] |
| 2 | SET | `String rslt = getKKSV0142Result(outputMap)` // Extract error flag from output [--> err_flg from KanuoresoIktTrkCC map] |

**Block 4** — [IF] `(rslt.equals("1"))` — Send batch is running (L1278)

> The AP service detected a send batch conflict. Display a warning and skip post-processing data updates.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String[] msgInfo = {"送信バッチが実行中", "更新"}` // Message: "Send batch in progress" + "Update" |
| 2 | CALL | `JCCWebCommon.setMessageInfo(this, JPCOnlineMessageConstant.EKB0930_NW, msgInfo)` // Display warning message |

**Block 5** — [ELSE] `(rslt does not equal "1")` — Processing succeeded (L1284)

> The service completed successfully. Navigate to the completion screen and update the data list flags.

**Block 5.1** — [SET] (Configure screen navigation) (L1287)

> Sets the next screen ID and name in the shared form bean for navigation to KKW12606.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `X31SDataBeanAccess commoninfoBean = super.getCommonInfoBean()` // Get shared form bean |
| 2 | EXEC | `commoninfoBean.sendMessageString(CommonInfoCFConst.NEXT_SCREEN_ID, X31CWebConst.DATABEAN_SET_VALUE, JKKScreenConst.SCREEN_ID_KKW12606)` // Set next screen ID [--> NEXT_SCREEN_ID = "KKW12606"] |
| 3 | EXEC | `commoninfoBean.sendMessageString(CommonInfoCFConst.NEXT_SCREEN_NAME, X31CWebConst.DATABEAN_SET_VALUE, JKKScreenConst.SCREEN_NAME_KKW12606)` // Set next screen name [--> NEXT_SCREEN_NAME = "Welcome Letter List Update Completion"] |

**Block 5.2** — [SET] (Display success message) (L1293)

| # | Type | Code |
|---|------|------|
| 1 | SET | `String[] msgInfo = {"加入御礼書一覧更新"}` // Message: "Welcome letter list update" |
| 2 | CALL | `JCCWebCommon.setMessageInfo(this, JPCOnlineMessageConstant.EKB4390__I, msgInfo)` // Display success message |

**Block 5.3** — [FOR] `(i < datalistUpd.getCount())` — Process updated data rows (L1297)

> Iterates over the updated welcome letter list data array and sets derived flags on each row.

| # | Type | Code |
|---|------|------|
| 1 | SET | `X31SDataBeanAccessArray datalistUpd = bean.getDataBeanArray(KKW12601SFConst.KANUORESO_LIST_UPD)` // Get updated list [--> KANUORESO_LIST_UPD = "Welcome letter update info"] |
| 2 | SET | `int i = 0` // Loop counter |
| 3 | EXEC | Loop condition: `i < datalistUpd.getCount()` |

**Block 5.3.1** — [FOR BODY] — Process individual row (L1299)

**Block 5.3.1.1** — [SET] (Letter dispatch division check) (L1302)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `X31SDataBeanAccess dataBeanUpd = datalistUpd.getDataBean(i)` // Get row DataBean |
| 2 | SET | `String letter = dataBeanUpd.sendMessageString(KKW12601SFConst.LETTER_HASSO_SHIWAKE_DIV_02, X31CWebConst.DATABEAN_GET_VALUE)` // Get letter dispatch division [--> LETTER_HASSO_SHIWAKE_DIV_02 = "Letter dispatch division"] |

**Block 5.3.1.2** — [IF] `(LETTER_SHIWAKE_KOPT.equals(letter))` — Dispatch to KOPT (L1306)

> The letter is designated for KOPT internal routing. Set the exclusion flag.

| # | Type | Code |
|---|------|------|
| 1 | SET | `LETTER_SHIWAKE_KOPT` = "1" [from JKKCommonConst.LETTER_SHIWAKE_KOPT] |
| 2 | EXEC | `dataBeanUpd.sendMessageBoolean(KKW12601SFConst.HIKINUKI_02, X31CWebConst.DATABEAN_SET_VALUE, true)` // Set HIKINUKI_02 = true [--> "Exclusion"] |

**Block 5.3.1.3** — [SET] (Send exclusion flag check) (L1311)

| # | Type | Code |
|---|------|------|
| 1 | SET | `String send_jgi = dataBeanUpd.sendMessageString(KKW12601SFConst.SEND_JGI_FLG_02, X31CWebConst.DATABEAN_GET_VALUE)` // Get send exclusion flag [--> SEND_JGI_FLG_02 = "Send exclusion flag"] |

**Block 5.3.1.4** — [IF] `(SEND_JGI_JGI.equals(send_jgi))` — Exclusion marked (L1316)

> The send exclusion flag is set to "Exclusion". Set the corresponding boolean flag.

| # | Type | Code |
|---|------|------|
| 1 | SET | `SEND_JGI_JGI` = "2" [from JKKCommonConst.SEND_JGI_JGI] |
| 2 | EXEC | `dataBeanUpd.sendMessageBoolean(KKW12601SFConst.SEND_JGI_02, X31CWebConst.DATABEAN_SET_VALUE, true)` // Set SEND_JGI_02 = true [--> "Send exclusion"] |

**Block 5.3.1.5** — [SET] (Re-issuance detection) (L1324)

> If the send timestamp is already set, this record is a re-issue (re-print/copy).

| # | Type | Code |
|---|------|------|
| 1 | SET | `String send_dtm = dataBeanUpd.sendMessageString(KKW12601SFConst.SEND_DTM_02, X31CWebConst.DATABEAN_GET_VALUE)` // Get send timestamp [--> SEND_DTM_02 = "Send datetime"] |
| 2 | IF | `send_dtm != null && !"".equals(send_dtm)` // Not null and not empty |
| 3 | EXEC | `dataBeanUpd.sendMessageBoolean(KKW12601SFConst.RE_HAKO_02, X31CWebConst.DATABEAN_SET_VALUE, true)` // Set RE_HAKO_02 = true [--> "Re-issuance"] |

**Block 6** — [EXEC] (Log DataBean state) (L1333)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JSYwebLog.println(JSYwebLog.DataBean_Dump, getClass(), dumpDatabean(), null, null, null)` // Dump DataBean for debug logging |

**Block 7** — [RETURN] (L1335)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return result` // Always returns true |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KANUORESO` | Field | Welcome Letter — the confirmation letter sent to new customers upon subscription |
| `KANUORESO_HAKKO_NO` | Field | Welcome Letter Issuance Number — unique identifier for each welcome letter issuance |
| `KANUORESO_LIST_UPD` | Field | Welcome Letter Update Info — array of updated welcome letter records after bulk processing |
| `KANUORESO_CHOICE` | Field | Welcome Letter Selection Row — user-selected row in the confirmation list |
| `LETTER_HASSO_SHIWAKE_DIV_02` | Field | Letter Dispatch Division — classifies where the welcome letter is dispatched to (e.g., standard address, KOPT internal) |
| `LETTER_SHIWAKE_KOPT` | Constant | Letter Dispatch Division: "Send to KOPT" — value "1", indicates internal routing to K-Opticom |
| `LETTER_SHIWAKE_TUJYO` | Constant | Letter Dispatch Division: "Standard Address" — value "2", indicates dispatch to the customer's registered address |
| `SEND_JGI_FLG` / `SEND_JGI_FLG_02` | Field | Send Exclusion Flag — whether the welcome letter should be excluded from dispatch |
| `SEND_JGI_JGI` | Constant | Send Exclusion: "Exclusion" — value "2", the record is marked as excluded from sending |
| `SEND_JGI_02` | Field | Send Exclusion — boolean flag (true = excluded from send) |
| `SEND_DTM_02` | Field | Send DateTime — timestamp of when the welcome letter was last sent |
| `RE_HAKO_02` | Field | Re-issuance — boolean flag indicating this is a re-print/copy of a previously sent letter |
| `HIKINUKI_02` | Field | Exclusion — boolean flag for letter dispatch division exclusion |
| `KKSV0142` | Service | Welcome Letter Issuance Bulk Change Service — AP service for bulk update of welcome letter records |
| `KKSV014201SC` | SC Code | Welcome Letter Issuance Registration — service component that handles individual record registration/update |
| `KKW12601SF` | Screen | Welcome Letter List Confirmation Screen — the source screen where this action is invoked |
| `KKW12606` | Screen | Welcome Letter List Update Completion Screen — the destination screen after successful processing |
| `KKW12602SF` | Screen | Welcome Letter List Print Screen — related screen with its own `actionFix` method |
| `FUNC_CD_1` | Constant | Function Code 1 — standard operation mode identifier |
| `JPCOnlineMessageConstant.EKB0930_NW` | Constant | Warning message key — "Send batch in progress" notification |
| `JPCOnlineMessageConstant.EKB4390__I` | Constant | Information message key — "Welcome letter list update" notification |
| `X31SDataBeanAccess` | Class | Shared form bean access — data transfer object for screen-level form data |
| `X31SDataBeanAccessArray` | Class | Array wrapper for DataBean — collection of DataBean objects for list operations |
| `X31CMessageResult` | Class | Message result container — holds AP service response messages |
| AP Server | Term | Application Server — the backend tier that processes business logic via service invocation |
| KOPT | Acronym | K-Opticom — the ISP company (internal routing designation) |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband service (in context: welcome letter for FTTH subscriptions) |
