---

# Business Logic — KKW12601SFLogic.actionSend() [69 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW12601SF.KKW12601SFLogic` |
| Layer | Controller (Web business logic, extends JCCWebBusinessLogic) |
| Module | `KKW12601SF` (Package: `eo.web.webview.KKW12601SF`) |

## 1. Role

### KKW12601SFLogic.actionSend()

This method performs the **Yamato delivery (ヤマト送信) processing** for sending a "Welcome Letter" (加入御礼書) to customers via the Yamato shipping service. It is the primary action method invoked when a user selects the "Send Welcome Letter via Yamato" job in the Welcome Letter list screen (KKW12601SF).

The method retrieves the current service form DataBean, performs up-mapping of screen input parameters into an AP-facing request map through the `KKSV0144_KKSV0144OPDBMapper`, invokes the business service `KKSV0144` / `KKSV0144OP` (which is the "Billing Yamato Delivery" process), and then performs down-mapping to extract results.

It implements a **conditional routing/dispatch pattern** based on error flags returned from the backend service. Specifically, it checks for batch execution error conditions: if a sending batch is already running (`err_flg = "1"`), if a withdrawal batch is running (`err_flg = "2"`), or if no unsent data exists — each branch displays an appropriate message to the user. On successful completion, it displays a confirmation message that the Welcome Letter was sent via Yamato.

The method is a **screen entry point** called directly from the KKW12601SF screen (via `KKSV0144_KKSV0144OPDBMapper`) to orchestrate the entire send workflow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["actionSend()"])
    RESULT["result = true"]
    GET_BEAN["Get service form bean"]
    PARAM_BEAN["Create paramBean array"]
    MAPPER["Create KKSV0144_KKSV0144OPDBMapper"]
    INPUT_MAP["inputMap = new HashMap"]
    SET_01["setKKSV014401SC - common info mapping"]
    SET_02["setKKSV014402SC - billing list mapping"]
    SET_03["setKKSV014403SC - delayed processing mapping"]
    INVOKE["invokeService KKSV0144 KKSV0144OP"]
    GET_ERR["getErrFlg outputMap KKW12601SFConst.SEARCH_ERR_FLG_ZERO"]
    DIAL1{"err_flg == \"1\"?"}
    MSG_BATCH1["msgInfo = 送信バッチが実行中の, 実行"]
    SET_MSG1["JCCWebCommon.setMessageInfo EKB0930_NW"]
    DIAL2{"err_flg == \"2\"?"}
    MSG_BATCH2["msgInfo = 抽出自バッチが実行中の, 実行"]
    SET_MSG2["JCCWebCommon.setMessageInfo EKB0930_NW"]
    DOWN_MAP["getKKSV014402SC - down-mapping"]
    GET_SEND_FLG["sendMessageString SEND_TRGT_FLG"]
    GET_ERR_FLG2["sendMessageString SEARCH_ERR_FLG_ZERO"]
    DIAL3{"send_trgt_flg == search_err_flg_zero?"}
    MSG_EMPTY["msgInfo = 未送信データが存在しない, 送信の実行"]
    SET_MSG3["JCCWebCommon.setMessageInfo EKB0930_NW"]
    MSG_SUCCESS["msgInfo = 加入御礼書ヤマト送信"]
    SET_MSG4["JCCWebCommon.setMessageInfo EKB7950__I"]
    LOG_DUMP["JSYwebLog.println dumpDatabean"]
    RETURN["return result"]

    START --> RESULT
    RESULT --> GET_BEAN
    GET_BEAN --> PARAM_BEAN
    PARAM_BEAN --> MAPPER
    MAPPER --> INPUT_MAP
    INPUT_MAP --> SET_01
    SET_01 --> SET_02
    SET_02 --> SET_03
    SET_03 --> INVOKE
    INVOKE --> GET_ERR
    GET_ERR --> DIAL1
    DIAL1 -- "1" --> MSG_BATCH1
    MSG_BATCH1 --> SET_MSG1
    SET_MSG1 --> LOG_DUMP
    DIAL1 -- other --> DIAL2
    DIAL2 -- "2" --> MSG_BATCH2
    MSG_BATCH2 --> SET_MSG2
    SET_MSG2 --> LOG_DUMP
    DIAL2 -- else --> DOWN_MAP
    DOWN_MAP --> GET_SEND_FLG
    GET_SEND_FLG --> GET_ERR_FLG2
    GET_ERR_FLG2 --> DIAL3
    DIAL3 -- true --> MSG_EMPTY
    MSG_EMPTY --> SET_MSG3
    SET_MSG3 --> LOG_DUMP
    DIAL3 -- false --> MSG_SUCCESS
    MSG_SUCCESS --> SET_MSG4
    SET_MSG4 --> LOG_DUMP
    LOG_DUMP --> RETURN
```

**Processing flow:**

1. Initialize result to `true`.
2. Retrieve the service form DataBean from the session.
3. Create the up-mapper and configure three sub-SC maps (common info, billing list, delayed processing).
4. Invoke the backend service `KKSV0144` / `KKSV0144OP`.
5. Check error flag: if `err_flg == "1"`, display "sending batch is running" error.
6. Check error flag: if `err_flg == "2"`, display "withdrawal batch is running" error.
7. Otherwise, down-map results, check for unsent data condition, and display either a "no unsent data" warning or a "Welcome Letter sent" success message.
8. Dump DataBean to log and return.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no parameters. It operates on instance fields (`inputMap`, `outputMap`) and the session-scoped DataBean obtained via `super.getServiceFormBean()`. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `inputMap` | `HashMap<String, Object>` | Request map holding business data to pass to the AP server |
| `outputMap` | `HashMap<String, Object>` | Response map holding business data returned from the AP server |
| `seniFromFin` | `boolean` | Flag indicating navigation from the completion screen (not actively used in this method) |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `KKSV0144_KKSV0144OPDBMapper.setKKSV014401SC` | - | - | Calls `setKKSV014401SC` — up-maps common info and request job ID (`EO2050410J0`) for delayed processing |
| - | `KKSV0144_KKSV0144OPDBMapper.setKKSV014402SC` | - | - | Calls `setKKSV014402SC` — up-maps billing list parameters (page number, max search count, send exclusion flag, unsent flag) |
| - | `KKSV0144_KKSV0144OPDBMapper.setKKSV014403SC` | - | - | Calls `setKKSV014403SC` — up-maps delayed processing request subtype code (added in v4.03) |
| - | `KKW12601SFLogic.invokeService` | - | - | Invokes the backend service `KKSV0144` / `KKSV0144OP` to execute the billing Yamato delivery processing |
| - | `KKSV0144_KKSV0144OPDBMapper.getKKSV014402SC` | - | - | Calls `getKKSV014402SC` — down-maps search error flag from the service result into the DataBean |
| - | `KKW12601SFLogic.getErrFlg` | R | - | Reads error flag from `outputMap` for the `KKSV014403SC` key |
| R | `X31SDataBeanAccess.sendMessageString` | - | - | Reads `SEND_TRGT_FLG` (送信対象有無フラグ) and `SEARCH_ERR_FLG_ZERO` (検索エラーフラグ(0件)) from the DataBean |
| - | `JCCWebCommon.setMessageInfo` | - | - | Displays error/success messages to the user via message constants `EKB0930_NW` (warnings) or `EKB7950__I` (information) |
| - | `KKW12601SFLogic.dumpDatabean` | - | - | Dumps the DataBean contents to the JSYwebLog for debugging |

**SC Code notes:**
- `KKSV0144` is the screen code; `KKSV0144OP` is the service name invoked via `invokeService`.
- `REQ_JOB_ID_KKSV0144 = "EO2050410J0"` is the delayed processing request ID for Yamato sending.
- The actual SC codes and DB tables are defined in the backend service components (`KKSV0144OP`), which are external to this method's scope.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0144 | `KKSV0144_KKSV0144OPDBMapper` -> `KKW12601SFLogic.actionSend` | `KKSV0144OP [call] EO2050410J0` |
| 2 | Screen:KKSV0143 | `KKSV0143_KKSV0143OPDBMapper` -> `KKW12601SFLogic.actionSend` (shared logic) | `KKSV0144OP [call] EO2050410J0` |
| 3 | Screen:KKSV0145 | `KKSV0145_KKSV0145OPDBMapper` -> `KKW12601SFLogic.actionSend` (shared logic) | `KKSV0144OP [call] EO2050410J0` |

**Notes:**
- `KKSV0143`, `KKSV0144`, and `KKSV0145` all reference `KKW12601SFLogic.REQ_JOB_ID_KKSV0144` and related constants in their mapper classes, indicating they are all Welcome Letter-related screens that share the same logic layer.
- `KKSV0144` is the primary screen for the "Billing Yamato Sending" operation — this is the main entry point for `actionSend`.
- `KKSV0143` handles "Delayed Processing" (ダイレイド処理), and `KKSV0145` handles "Yamato Receiving" (ヤマト受信).

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(Initialization)` (L1103)

> Initialize result variable and retrieve the service form DataBean.

| # | Type | Code |
|---|------|------|
| 1 | SET | `boolean result = true` |
| 2 | CALL | `X31SDataBeanAccess bean = super.getServiceFormBean()` // Get service form bean from session |
| 3 | SET | `X31SDataBeanAccess[] paramBean = {bean}` // Wrap in array |

---

**Block 2** — [SET] `(Up-mapping setup - Service item - DataBean mapping)` (L1110)

> The comment states: "Up-mapping processing (service item - DataBean item mapping). Function code = no input files (check & register)."

| # | Type | Code |
|---|------|------|
| 1 | SET | `KKSV0144_KKSV0144OPDBMapper mapper = new KKSV0144_KKSV0144OPDBMapper()` |
| 2 | SET | `inputMap = new HashMap<String, Object>()` |
| 3 | EXEC | `mapper.setKKSV014401SC(paramBean, inputMap, JPCModelConstant.FUNC_CD_3)` // Common info mapping |
| 4 | EXEC | `mapper.setKKSV014402SC(paramBean, inputMap, JPCModelConstant.FUNC_CD_1)` // Billing list mapping |
| 5 | EXEC | `mapper.setKKSV014403SC(paramBean, inputMap, JPCModelConstant.FUNC_CD_2)` // Delayed processing mapping (ST2-2013-0000313 ADD) |

---

**Block 3** — [CALL] `(Service invocation)` (L1115)

> Invoke the backend service for billing Yamato delivery processing.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `X31CMessageResult msgResult = invokeService("KKSV0144", "KKSV0144OP")` // v4.03 ST2-2013-0000313 |

---

**Block 4** — [IF/ELSE-IF/ELSE] `(Error flag check - v4.03 ST2-2013-0000313 MOD)` (L1118)

> Check the error flag returned from the backend service for batch execution status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String err_flg = getErrFlg(outputMap, "KKSV014403SC")` |

**Block 4.1** — [IF] `(IF) [err_flg.equals("1")]` (L1120)

> A sending batch is currently running. Display error to user.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String[] msgInfo = {"送信バッチが実行中の", "実行"}` // For message display: "Sending batch is running", "Running" |
| 2 | CALL | `JCCWebCommon.setMessageInfo(this, JPCOnlineMessageConstant.EKB0930_NW, msgInfo)` // Display warning message |

**Block 4.2** — [ELSE-IF] `(ELSE-IF) [err_flg.equals("2")]` (L1127)

> A withdrawal (unsend) batch is currently running. Display error to user.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String[] msgInfo = {"抽出自バッチが実行中の", "実行"}` // For message display: "Withdrawal batch is running", "Running" |
| 2 | CALL | `JCCWebCommon.setMessageInfo(this, JPCOnlineMessageConstant.EKB0930_NW, msgInfo)` // Display warning message |

**Block 4.3** — [ELSE] `(ELSE - Normal processing path)` (L1134)

> No batch errors. Perform down-mapping and check if there is unsent data.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `mapper.getKKSV014402SC(paramBean, outputMap)` // Down-mapping from service result |
| 2 | SET | `String send_trgt_flg = paramBean[0].sendMessageString(KKW12601SFConst.SEND_TRGT_FLG, X31CWebConst.DATABEAN_GET_VALUE)` // Read "送信対象有無フラグ" (Send target existence flag) |
| 3 | SET | `String search_err_flg_zero = paramBean[0].sendMessageString(KKW12601SFConst.SEARCH_ERR_FLG_ZERO, X31CWebConst.DATABEAN_GET_VALUE)` // Read "検索エラーフラグ(0件)" (Search error flag for 0 results) |

**Block 4.3.1** — [IF] `(IF) [send_trgt_flg.equals(search_err_flg_zero)]` (L1140)

> The send target flag equals the search error flag — meaning there is no unsent data to send.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String[] msgInfo = {"未送信データが存在しない", "送信の実行"}` // "No unsent data exists", "Send execution" |
| 2 | CALL | `JCCWebCommon.setMessageInfo(this, JPCOnlineMessageConstant.EKB0930_NW, msgInfo)` // Display warning |

**Block 4.3.2** — [ELSE] `(ELSE - successful send)` (L1146)

> Unsent data exists and was successfully processed. Display success message.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String[] msgInfo = {"加入御礼書ヤマト送信"}` // "Welcome Letter Yamato sending" |
| 2 | CALL | `JCCWebCommon.setMessageInfo(this, JPCOnlineMessageConstant.EKB7950__I, msgInfo)` // Display info message |

---

**Block 5** — [CALL] `(DataBean logging)` (L1155)

> Log the DataBean contents for debugging/audit purposes.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JSYwebLog.println(JSYwebLog.DataBean_Dump, getClass(), dumpDatabean(), null, null, null)` |

**Block 6** — [RETURN] `(Return)` (L1157)

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `actionSend` | Method | Yamato send processing — sends a Welcome Letter (加入御礼書) to a customer via Yamato logistics |
| `KKW12601SF` | Module | Welcome Letter List Confirmation — screen module for managing and operating on customer welcome letters |
| 加入御礼書 (Kanuru O-reisho) | Domain term | Welcome Letter — a formal notification letter sent to a customer after service registration |
| ヤマト送信 (Yamato Sentin) | Domain term | Yamato delivery sending — dispatching documents via Yamato Transport logistics service |
| `KKSV0144` | Screen code | Billing Yamato Sending screen — the operational screen for sending Welcome Letters |
| `KKSV0144OP` | Service name | Billing operation service — backend service handling Yamato delivery processing |
| `REQ_JOB_ID_KKSV0144` | Constant | Delayed processing request ID = `"EO2050410J0"` — identifies the Yamato send job in the delayed processing system |
| `SEND_TRGT_FLG` | Field | Send target existence flag — indicates whether there is data to send |
| `SEARCH_ERR_FLG_ZERO` | Field | Search error flag (0 results) — indicates whether the search returned zero records |
| `err_flg` | Field | Error flag returned from backend service — `"1"` = sending batch running, `"2"` = withdrawal batch running |
| `SEND_JGI_INFO` | Constant | Send exclusion information — identifies records excluded from sending |
| `MI_SEND` | Constant | Uns sent — records that have not been sent yet |
| `FUNC_CD_1` | Constant | Function code 1 — used for billing list mapping |
| `FUNC_CD_2` | Constant | Function code 2 — used for delayed processing mapping |
| `FUNC_CD_3` | Constant | Function code 3 — used for common info mapping |
| `EKB0930_NW` | Message constant | Warning message code — used for error/warning notifications (e.g., batch already running, no data to send) |
| `EKB7950__I` | Message constant | Information message code — used for success notifications (e.g., Welcome Letter sent) |
| `inputMap` | Instance field | Request map holding business data to pass to the AP server |
| `outputMap` | Instance field | Response map holding business data returned from the AP server |
| `KKSV014401SC` | Sub-SC code | Common info sub-service component — handles common data mapping |
| `KKSV014402SC` | Sub-SC code | Billing list sub-service component — handles billing list data mapping |
| `KKSV014403SC` | Sub-SC code | Delayed processing sub-service component — handles delayed processing data mapping (added in v4.03) |
| `KKSV0143` | Screen code | Delayed processing screen |
| `KKSV0145` | Screen code | Yamato receiving screen |
| 送信バッチ (Sovin batch) | Domain term | Sending batch — the background batch process that dispatches documents via Yamato |
| 抽出自バッチ (Kishutsu-j batch) | Domain term | Withdrawal (unsend) batch — the background batch process that cancels/skips certain documents from dispatch |
| 未送信データ (Misoushin data) | Domain term | Unsent data — records that have not yet been dispatched via Yamato |
| `sendMessageString` | DataBean method | Reads or writes string values to/from the DataBean |
| `JPCModelConstant.FUNC_CD_*` | Constant class | Common function code constants shared across modules |
| `JPCOnlineMessageConstant.EKB0930_NW` | Constant class | Online notification message constants — warnings/errors |
| `JPCOnlineMessageConstant.EKB7950__I` | Constant class | Online notification message constants — information/success |
| `JCCWebCommon.setMessageInfo` | Utility method | Sets a message to be displayed on the web screen |

---
