# Business Logic — KKW02519SFLogic.kksv0370Execute() [61 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW02519SF.KKW02519SFLogic` |
| Layer | Service Logic (Controller layer — webview logic class) |
| Module | `KKW02519SF` (Package: `eo.web.webview.KKW02519SF`) |

## 1. Role

### KKW02519SFLogic.kksv0370Execute()

This method is the central execution entry point for the **Telephone Option Service Contract Update/Cancellation** business process (電話オプションサービス契約更新解約サービス実行). It orchestrates the complete lifecycle of updating or canceling telephone option service subscriptions — including advanced special item display setup, parameter mapping to the business process (BP) layer, service invocation, and post-execution error/confirmation handling. The method follows a **delegation/routing pattern**, preparing data, invoking a shared BP execution engine (`invokeService`), and interpreting the result to determine success or failure flow. It is called by two screen-specific entry points within the same logic class (`actionFix` for confirmation/registration and `actionUpdCfm` for update confirmation), making it the primary shared business logic hub for the KKSV0370 option service screen. The method also handles single-item/simple-related check errors returned by the underlying service by displaying message information and short-circuiting the flow to return `false`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["kksv0370Execute start"])
    CHECK_NULL["Check svcFormBean, funcCd null"]
    GET_PRG["CALL getPrgTkjkSvcNm(svcFormBean)"]
    SET_PRG["SET strPrgTkjk1 = getPrgTkjkSvcNm + 情報 + 解約"]
    SET_FORM["EXEC svcFormBean.sendMessageString(PRG_TKJK_1, SET_VALUE, strPrgTkjk1)"]
    CREATE_PARAM["SET paramMap = new HashMap<br/>SET inputMap = new HashMap<br/>SET outputMap = new HashMap"]
    SET_UCID["SET paramMap UCID_KKSV0370"]
    SET_OPID["SET paramMap OPID_KKSV0370OP"]
    CREATE_MAPPER["SET mapper = new KKSV0370_KKSV0370OPDBMapper"]
    SET_01CC["CALL mapper.setKKSV037001CC<br/>Option service contract cancellation CC"]
    SET_02CC["CALL mapper.setKKSV037002CC<br/>Service order CC"]
    SET_01SC["CALL mapper.setKKSV037001SC<br/>Order issue condition list FUNC_CD_2"]
    INVOKE["CALL invokeService<br/>Telephone option service contract update/cancellation"]
    CHECK_ERR["IF setErrorMessageInfo(outputMap) true"]
    RETURN_ERR["RETURN false"]
    GET_OUT["CALL mapper.getKKSV037001CC<br/>Downstream mapping"]
    GET_MSG["CALL sendMessageString RTN_MSG_ID GET_VALUE"]
    CHECK_MSG["IF rtnMsgId not null and not empty"]
    SET_MSG_INFO["CALL JCCWebCommon.setMessageInfo<br/>Single item simple related check error"]
    RETURN_MSG["RETURN false"]
    RETURN_OK["RETURN true"]
    END(["kksv0370Execute end"])

    START --> CHECK_NULL
    CHECK_NULL --> GET_PRG
    GET_PRG --> SET_PRG
    SET_PRG --> SET_FORM
    SET_FORM --> CREATE_PARAM
    CREATE_PARAM --> SET_UCID
    SET_UCID --> SET_OPID
    SET_OPID --> CREATE_MAPPER
    CREATE_MAPPER --> SET_01CC
    SET_01CC --> SET_02CC
    SET_02CC --> SET_01SC
    SET_01SC --> INVOKE
    INVOKE --> CHECK_ERR
    CHECK_ERR -- true --> RETURN_ERR
    CHECK_ERR -- false --> GET_OUT
    GET_OUT --> GET_MSG
    GET_MSG --> CHECK_MSG
    CHECK_MSG -- true --> SET_MSG_INFO
    SET_MSG_INFO --> RETURN_MSG
    CHECK_MSG -- false --> RETURN_OK
    RETURN_ERR --> END
    RETURN_MSG --> END
    RETURN_OK --> END
```

**Block descriptions:**

1. **Progressive special item preparation** — Constructs a display string by combining the option service name (via `getPrgTkjkSvcNm`), the suffix "情報" (information), and the action type "解約" (cancellation), then stores it in the form bean under the `PRG_TKJK_1` key for screen display.

2. **Parameter map initialization** — Creates the three HashMap instances (`paramMap`, `inputMap`, `outputMap`) and configures the telegram metadata (UCID and Operation ID) for routing.

3. **DataBean-to-BP mapping** — Instantiates `KKSV0370_KKSV0370OPDBMapper` and calls three mapping methods to transform the form bean data into BP-level input parameters: `setKKSV037001CC` (option service contract/cancellation common data), `setKKSV037002CC` (service order data), and `setKKSV037001SC` (order issue condition list, always with `FUNC_CD_2`).

4. **Service invocation** — Delegates to `invokeService` to execute the actual telephone option service contract update/cancellation business process.

5. **Error and confirmation handling** — Checks for error messages after invocation. If errors exist, returns `false`. Otherwise, maps output back to the form bean, checks for a return message ID indicating a simple/single-item validation error, and either displays that error (returning `false`) or returns `true` for success.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `svcFormBean` | `X31SDataBeanAccess` | The screen form data bean carrying all user-entered and display data for the telephone option service contract update/cancellation screen. Contains service contract numbers, option service numbers, update timestamps, discontinuation reasons, progress special items, and return message IDs. |
| 2 | `funcCd` | `String` | Function code indicating the specific operation mode — typically "1" for option service contract/cancellation or "2" for order-related operations. Determines how the data mapper and service interpret the input parameters. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `this` (logic instance) | `KKW02519SFLogic` | Passed as context to `JCCWebCommon.setMessageInfo` and `setErrorMessageInfo` |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `KKW02519SFLogic.getPrgTkjkSvcNm` | - | - | Reads option service name from `svcFormBean` (data bean array, option service code key) |
| - | `KKW02519SFLogic.setErrorMessageInfo` | - | - | Checks `outputMap` for error message conditions set by the BP |
| R | `KKSV0370_KKSV0370OPDBMapper.getKKSV037001CC` | - | - | Downstream mapping: extracts output data from BP result back into form bean |
| - | `KKSV0370_KKSV0370OPDBMapper.setKKSV037001CC` | - | - | Upstream mapping: extracts form bean fields into input map for option service CC |
| - | `KKSV0370_KKSV0370OPDBMapper.setKKSV037001SC` | - | - | Upstream mapping: sets order issue condition list parameters (with `FUNC_CD_2`) |
| - | `KKSV0370_KKSV0370OPDBMapper.setKKSV037002CC` | - | - | Upstream mapping: extracts form bean fields into input map for service order CC |
| - | `JCCBatCommon.invokeService` | - | - | Invokes the BP (business process) that performs the actual telephone option service contract update/cancellation service logic |
| - | `JCCWebCommon.setMessageInfo` | - | - | Displays confirmation/warning message for single-item/simple-related check errors returned by the service CC |
| - | `OneStopDataBeanAccess.sendMessageString` | - | - | Reads/writes form bean field values during progress item preparation and return message retrieval |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0370 (actionFix path) | `KKW02519SFLogic.actionFix` -> `kksv0370Execute` | `setErrorMessageInfo [-]`, `sendMessageString [-]`, `getKKSV037001CC [R]`, `setMessageInfo [-]`, `invokeService [-]`, `setKKSV037001SC [-]`, `setKKSV037001CC [-]`, `setKKSV037002CC [-]` |
| 2 | Screen:KKSV0370 (actionUpdCfm path) | `KKW02519SFLogic.actionUpdCfm` -> `kksv0370Execute` | `setErrorMessageInfo [-]`, `sendMessageString [-]`, `getKKSV037001CC [R]`, `setMessageInfo [-]`, `invokeService [-]`, `setKKSV037001SC [-]`, `setKKSV037001CC [-]`, `setKKSV037002CC [-]` |

**Note:** The method is not directly invoked by any screen or batch entry point. It is called internally from two action methods within the same `KKW02519SFLogic` class, which are themselves triggered by the KKSV0370 web screen for telephone option service contract update/cancellation.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Progressive special item construction (L749-763)

> Sets the progressive special item 1 (進展特記事項1) string for screen display. Combines the option service name with the suffix "情報" (information) and action type "解約" (cancellation). The original commented-out code previously extracted the service name from a separate data bean array, but was changed to use `getPrgTkjkSvcNm()` for dynamic resolution. The comment indicates "進捗特記事項1を設定" (Set progressive special item 1) and references the 2013 modification "サブオプションの場合、サブオプションの名称を進捗補足に表示" (For sub-options, display sub-option name in progress supplement).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `strPrgTkjk1 = getPrgTkjkSvcNm(svcFormBean) + PRG_TKJK_1_JYOHO + PRG_TKJK_1_DSL` // "情報" + "解約" [-> CONSTANT: PRG_TKJK_1_JYOHO="情報", PRG_TKJK_1_DSL="解約"] |
| 2 | EXEC | `svcFormBean.sendMessageString(KKW02519SFConst.PRG_TKJK_1, X31CWebConst.DATABEAN_SET_VALUE, strPrgTkjk1)` // Store progressive special item 1 into form bean [-> CONSTANT: PRG_TKJK_1="進展特記事項1"] |

**Block 2** — [SET] Parameter map initialization (L765-771)

> Creates the service parameter containers and configures the routing metadata for the BP invocation.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `X31SDataBeanAccess[] paramBean = {svcFormBean}` // Wrap form bean into array for mapper methods |
| 2 | SET | `paramMap = new HashMap<String, Object>()` // Parameter map generation [-> Comment: パラメータマップ生成] |
| 3 | SET | `inputMap = new HashMap<String, Object>()` // Input map generation [-> Comment: インプットマップ生成] |
| 4 | SET | `outputMap = new HashMap<String, Object>()` // Output map generation [-> Comment: アウトプットマップ生成] |
| 5 | SET | `paramMap.put(X31CWebConst.TELEGRAM_INFO_USECASE_ID, JKKCommonConst.UCID_KKSV0370)` // Set use case ID [-> CONSTANT: UCID_KKSV0370="KKSV0370"] |
| 6 | SET | `paramMap.put(X31CWebConst.TELEGRAM_INFO_OPERATION_ID, JKKCommonConst.OPID_KKSV0370OP)` // Set operation ID [-> CONSTANT: OPID_KKSV0370OP="KKSV0370OP"] |

**Block 3** — [SET] DataBean-to-BP mapping setup (L773-780)

> Instantiates the mapper and calls three mapping methods to populate the input map with form bean data for the option service contract/cancellation CC, service order CC, and order issue condition list SC.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapper = new KKSV0370_KKSV0370OPDBMapper()` // Mapper instantiation |
| 2 | CALL | `inputMap = mapper.setKKSV037001CC(paramBean, inputMap, funcCd)` // Option service contract/cancellation CC mapping [-> Comment: オプションサービス契約解約CC] |
| 3 | CALL | `inputMap = mapper.setKKSV037002CC(paramBean, inputMap, funcCd)` // Service order CC mapping [-> Comment: サービスオーダCC] |
| 4 | CALL | `inputMap = mapper.setKKSV037001SC(paramBean, inputMap, JPCModelConstant.FUNC_CD_2)` // Order issue condition list [-> CONSTANT: FUNC_CD_2="2", Comment: オーダ発行条件一覧照会] |

**Block 4** — [CALL] Service invocation (L782-783)

> Invokes the underlying business process that performs the actual telephone option service contract update/cancellation. This is the core business operation that reads/writes the relevant telecom service contract data.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `invokeService(paramMap, inputMap, outputMap)` // Telephone option service contract update/cancellation service execution [-> Comment: 電話オプションサービス契約更新解約サービス実行] |

**Block 5** — [IF] Error message check after service invocation (L785-792)

> Checks if the service returned error conditions. If errors exist, returns `false` to abort the flow.

**Block 5.1** — [IF condition] `setErrorMessageInfo(outputMap)` [CONSTANT: none] (L786)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setErrorMessageInfo(outputMap)` // Check if error messages exist in output map |

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return false` // Error condition — abort processing |

**Block 5.2** — [ELSE-IF false path] Proceed to output mapping (L791)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `mapper.getKKSV037001CC(paramBean, outputMap)` // Downstream mapping: extract output data back to form bean [-> Comment: 取得情報の下りマッピング] |

**Block 6** — [SET/IF] Return message ID check (L793-805)

> After the service returns, retrieves the return message ID from the form bean. If it is not null and not empty, it indicates a single-item/simple-related check error from the option service contract/cancellation CC. In that case, displays the error message and returns `false`. Otherwise, returns `true` indicating successful processing.

**Block 6.1** — [SET] Retrieve return message ID (L793)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `rtnMsgId = svcFormBean.sendMessageString(KKW02519SFConst.RTN_MSG_ID, X31CWebConst.DATABEAN_GET_VALUE)` // Get return message ID [-> CONSTANT: RTN_MSG_ID="返却メッセージID"] |

**Block 6.2** — [IF condition] `null != rtnMsgId && !"".equals(rtnMsgId)` [CONSTANT: none] (L794)

| # | Type | Code |
|---|------|------|
| 1 | SET | `JCCWebCommon.setMessageInfo(this, rtnMsgId)` // Display option service contract/cancellation CC single item/simple related check error [-> Comment: オプションサービス契約解約CCで単項目・単関連エラー] |

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return false` // Single-item or simple-related check error occurred |

**Block 6.3** — [ELSE-IF false path] Success (L804)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true` // Processing completed successfully |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `PRG_TKJK_1` | Field/Constant | Progressive special item 1 (進展特記事項1) — display field on screen showing the option service name plus action type for user confirmation |
| `PRG_TKJK_1_JYOHO` | Constant | "情報" (information) — suffix appended to the service name in the progressive special item display |
| `PRG_TKJK_1_DSL` | Constant | "解約" (cancellation) — action type suffix indicating this is a cancellation operation (as opposed to 登録 registration or 変更 change) |
| `RTN_MSG_ID` | Field/Constant | Return message ID (返却メッセージID) — message identifier returned by the service CC, used for single-item and simple-related validation error display |
| `UCID_KKSV0370` | Constant | "KKSV0370" — Use Case ID for routing the service request to the correct business process |
| `OPID_KKSV0370OP` | Constant | "KKSV0370OP" — Operation ID for the option service update/cancellation operation |
| `FUNC_CD_2` | Constant | "2" — Function code used to specify order issue condition inquiry mode (オーダ発行条件一覧照会) in the SC mapping |
| `invokeService` | Method | Core service invocation method that delegates to the BP (Business Process) layer for actual data processing |
| `KKSV037001CC` | Mapping constant | Option service contract/cancellation common data mapping — maps form bean fields (SYSID, SVC_KEI_NO, OP_SVC_KEI_NO, SBOP_SVC_KEI_NO, UPD_DTM_BF, IDO_DIV, SVC_ENDYMD, SVC_CHRG_ENDYMD, PRG_TKJK_1, IDO_RSN_CD/MEMO list) to BP input parameters |
| `KKSV037002CC` | Mapping constant | Service order common data mapping — maps form bean fields for service order processing |
| `KKSV037001SC` | Mapping constant | Order issue condition list SC — retrieves order issue condition data (オーダ発行条件一覧照会) |
| `KKSV0370` | Screen code | Telephone option service contract update/cancellation screen — the web screen that triggers this logic |
| `KKW02519SF` | Module code | Telephone option service contract update module — the web module containing this logic class |
| Option service | Domain term | Telephone option service (電話オプションサービス) — value-added telecom services (e.g., call forwarding, international phone stop, usage notification) offered as add-ons to base internet/phone contracts |
| Sub-option | Domain term | Sub-option service (サブオプションサービス) — nested/secondary option services layered under a primary option service |
| Discontinuation reason | Domain term | 異動理由 — the reason code and memo for why a service contract is being updated or cancelled |
| Single-item/simple-related check | Domain term | 単項目・単関連エラー — validation error type returned by the service CC when a single field or simple related-field check fails (as opposed to complex business rule violations) |
| Progress special item | Domain term | 進展特記事項 — progressive/special notes field displayed on screen during service processing to show the current state of the option service operation |

---