# Business Logic — KKW03204SFLogic.actionUpd_cfm() [83 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW03204SF.KKW03204SFLogic` |
| Layer | Controller (Web Presentation / Screen Logic) |
| Module | `KKW03204SF` (Package: `eo.web.webview.KKW03204SF`) |

## 1. Role

### KKW03204SFLogic.actionUpd_cfm()

This method is the business core of the **"Update Confirmation" (変更確認) button press** on the **050 Number Issuance/Change Screen** (050番号発行変更). It processes user-submitted data for a contract change operation, validates the input, executes the underlying service, and determines the next screen destination. Specifically, it performs three sequential phases: (1) **DataBean configuration** — composes the usage end date (利用終了日) from separate year/month/day fields and stores it back into the service form DataBean, then calls `setDataDsl()` and `setMappedKKSV0136()` to prepare mapping data; (2) **Service invocation** — delegates to `doService("KKSV0136", "KKSV0136OP")` to execute the actual business logic for the 050 number change confirmation service; (3) **Navigation setup** — on success, sets the next screen ID and name (`KKW03205`, "050番号発行変更確認") in the common form bean and displays a confirmation message; on failure, resolves and displays appropriate error/substituted messages via `getMsgRep()`. The method implements the **delegation + routing pattern**, centralizing the confirmation workflow and shielding callers from multi-step service orchestration.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["actionUpd_cfm()"])
    START --> INIT_VARS["Initialize variables: result, msgInfo, commoninfoBean, bean, paramBean, msgResult"]

    INIT_VARS --> COMPOSE_DATE["Compose usd_endymd from USE_ENDYMD_YEAR, USE_ENDYMD_MON, USE_ENDYMD_DAY"]
    COMPOSE_DATE --> SET_DATES["SET use_endymd and dsp_endymd in bean"]
    SET_DATES --> SET_DSL["setDataDsl"]
    SET_DSL --> SET_MAPPED["setMappedKKSV0136 with FUNC_CD_2"]
    SET_MAPPED --> DO_SERVICE["doService KKSV0136 KKSV0136OP"]
    DO_SERVICE --> CHECK_ERROR{"setErrorMessageInfo error check?"}

    CHECK_ERROR -->|true| ERROR_RETURN["Return false"]
    CHECK_ERROR -->|false| STORE["storeDataBeanDslsrv paramBean outputMap"]
    STORE --> GET_STR_MSG["GET err_msg_id from bean"]
    GET_STR_MSG --> CHECK_STR_MSG{"strMsg null or empty?"}

    CHECK_STR_MSG -->|true| SET_NEXT_SCREEN["SET nextScreenId and nextScreenName"]
    SET_NEXT_SCREEN --> SET_MSG_INFO["JCCWebCommon.setMessageInfo EKB0370__I"]
    SET_MSG_INFO --> DUMP_DATABEAN["JSYwebLog println databean dump"]
    DUMP_DATABEAN --> SUCCESS_RETURN["Return true"]

    CHECK_STR_MSG -->|false| GET_MSG_REP["getMsgRep trans_div strMsg"]
    GET_MSG_REP --> CHECK_STR{"str result null?"}
    CHECK_STR -->|true| MSG_ID_ONLY["JCCWebCommon.setMessageInfo with strMsg only"]
    CHECK_STR -->|false| MSG_WITH_SUBST["JCCWebCommon.setMessageInfo with strMsg and substitutions"]

    MSG_ID_ONLY --> DUMP_DATABEAN
    MSG_WITH_SUBST --> DUMP_DATABEAN
    ERROR_RETURN --> DUMP_DATABEAN
```

**Processing flow description:**

1. **Variable Initialization** — Declares local variables: `result` (return flag, default `true`), `msgInfo` array (3-element message info buffer), retrieves the common form bean (`X31SDataBeanAccess`) and the service form bean (`X31SDataBeanAccess`).

2. **Usage End Date Composition** — Reads the year, month, and day values from the DataBean using keys `USE_ENDYMD_YEAR` ("利用終了日（年）"), `USE_ENDYMD_MON` ("利用終了日（月）"), and `USE_ENDYMD_DAY` ("利用終了日（日）"), concatenates them into a single YYYYMMDD string (`usd_endymd`), and stores it back into the DataBean under keys `USE_ENDYMD` ("利用終了日") and `DSP_ENDYMD` ("表示用利用終了日").

3. **DataBean Setup & Mapping** — Calls `setDataDsl()` to set DSL-related fields in the DataBean, then calls `setMappedKKSV0136(FUNC_CD_2)` to perform upper-level mapping (service item-to-DataBean item mapping) with function code "2".

4. **Service Execution** — Invokes `doService("KKSV0136", "KKSV0136OP")` to execute the backend service for the 050 number change confirmation operation.

5. **Error Check (OM-2015-0000564)** — Checks for errors from SC `KKSV013601SC` using `setErrorMessageInfo()`. If an error is detected, returns `false` immediately.

6. **DataBean Store** — Calls `storeDataBeanDslsrv(paramBean, outputMap)` to store the service results back into the DataBean.

7. **Error Message Retrieval** — Retrieves the error message ID from the DataBean using key `ERR_MSG_ID` ("エラーメッセージID").

8. **Conditional Branch — Success Path** (when `strMsg` is null or empty):
   - Sets the next screen ID (`KKW03205`) and screen name ("050番号発行変更確認") in the common form bean.
   - Sets `msgInfo[0]` to `MSGSTRING[0]` (predefined message string constant).
   - Calls `JCCWebCommon.setMessageInfo(this, EKB0370__I, msgInfo)` to display the transition destination screen message.

9. **Conditional Branch — Error Path** (when `strMsg` has a value):
   - Calls `getMsgRep(trans_div, strMsg)` to resolve message substitutions.
   - If the resolved result `str` is null, displays message with ID only via `JCCWebCommon.setMessageInfo(this, strMsg)`.
   - If `str` is non-null, displays message with text substitution via `JCCWebCommon.setMessageInfo(this, strMsg, str)`.

10. **DataBean Logging** — Dumps the DataBean state to the log via `JSYwebLog.println(JSYwebLog.DataBean_Dump, ...)`.

11. **Return** — Returns `result` (`true`).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | `(none)` | - | This method takes no external parameters. All input data comes from the session-scoped DataBean populated by the previous screen. |

### Instance Fields / External State Read

| Field | Type | Business Description |
|-------|------|---------------------|
| `trans_div` | `String` | Operation transport division — indicates the type of operation (DSL, Cancellation/Recovery, Reservation Cancellation). Used for message resolution routing. |
| `outputMap` | `HashMap<String, Object>` | Service execution output map — holds results returned from `doService()`, including error flags from `KKSV013601SC`. |
| `MSGSTRING` | `String[]` | Predefined message string array — holds predefined message text for different operation types. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `KKW03204SFLogic.setDataDsl` | KKW03204SFLogic | - | Internal method: sets DSL-related fields in the DataBean |
| - | `KKW03204SFLogic.setMappedKKSV0136` | KKW03204SFLogic | - | Internal method: performs upper-level mapping for KKSV0136 service (function code 2, check-only mode) |
| C/R | `KKW03204SFLogic.doService` | KKSV013601SC | KKSV0136 | Calls the backend service for 050 number change confirmation — reads contract data, validates, and writes confirmation results |
| - | `KKW03204SFLogic.storeDataBeanDslsrv` | KKW03204SFLogic | - | Internal method: stores service results from outputMap back into the DataBean |
| R | `KKW03204SFLogic.getMsgRep` | KKW03204SFLogic | - | Internal method: resolves message substitutions based on operation type |
| - | `JKKWebCommon.setMessageInfo` | JCCWebCommon | - | Displays confirmation/error messages on the screen |

### Detail: `doService("KKSV0136", "KKSV0136OP")`

This is the primary service call. It invokes the **KKSV0136** screen service with operation code **KKSV0136OP**, which corresponds to the backend component **KKSV013601SC**. This service:
- **Reads** contract data and 050 number issuance/change records from the database
- **Validates** the submission data against business rules (date constraints, status checks)
- **Writes** confirmation/record-keeping results back to relevant tables

### Detail: `setMappedKKSV0136(FUNC_CD_2)`

When called with function code `"2"` (check mode), this method performs upper-level mapping — it maps service item data to DataBean fields so the screen can display pre-service-confirmation data. The mapper `KKSV0136_KKSV0136OPDBMapper` is instantiated and its `setOpsvckeiKaihkCC` method is called to perform the mapping.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKA16401SF | `apiControl()` -> `this.actionUpd_cfm()` | `KKSV0136 doService [C/R] KKSV013601SC (050 number change service)` |
| 2 | (Standalone) | Invoked directly from screen action handler for the "Update Confirmation" button on screen KKW03204 | `KKSV0136 doService [C/R] KKSV013601SC` |

**Notes:**
- `KKA16401SFLogic.apiControl()` is the OneStop API controller that orchestrates the entire 050 number issuance/change contract flow. It calls `actionUpd_cfm()` after validation checks (OneStop-specific checks, initial DataBean overwrite) to process the "Update Confirmation" button press.
- The method navigates to screen `KKW03205` (050 Number Issuance/Change Confirmation) on success, which is defined in `JKKScreenConst.SCREEN_ID_KKW03205` = `"KKW03205"` with screen name `"050番号発行変更確認"`.

## 6. Per-Branch Detail Blocks

### Block 1 — [VARIABLE DECLARATION] (L260)

> Initializes local variables for the method execution.

| # | Type | Code |
|---|------|------|
| 1 | SET | `boolean result = true;` // Return flag, default success |
| 2 | SET | `String[] msgInfo = new String[1];` // Message display buffer |
| 3 | SET | `X31SDataBeanAccess commoninfoBean = super.getCommonInfoBean();` // Gets common form bean |
| 4 | SET | `X31SDataBeanAccess bean = super.getServiceFormBean();` // Gets service form bean |
| 5 | SET | `X31SDataBeanAccess[] paramBean = {bean};` // Wraps bean as array for service calls |
| 6 | SET | `X31CMessageResult msgResult = null;` // Service call return value holder |

### Block 2 — [DATA BEAN CONFIGURATION] (L270–277)

> Composes the usage end date (利用終了日) from separate year/month/day components and stores the composite date string back into the DataBean.

| # | Type | Code |
|---|------|------|
| 1 | SET | `usd_endymd = bean.sendMessageString(USE_ENDYMD_YEAR, GET_VALUE)` // Reads year, USE_ENDYMD_YEAR="利用終了日（年）" |
| 2 | EXEC | `+ bean.sendMessageString(USE_ENDYMD_MON, GET_VALUE)` // + month, USE_ENDYMD_MON="利用終了日（月）" |
| 3 | EXEC | `+ bean.sendMessageString(USE_ENDYMD_DAY, GET_VALUE)` // + day, USE_ENDYMD_DAY="利用終了日（日）" |
| 4 | SET | `bean.sendMessageString(USE_ENDYMD, SET_VALUE, usd_endymd)` // Sets composite date, USE_ENDYMD="利用終了日" |
| 5 | SET | `bean.sendMessageString(DSP_ENDYMD, SET_VALUE, usd_endymd)` // Sets display date, DSP_ENDYMD="表示用利用終了日" |

### Block 3 — [CALL: setDataDsl()] (L279)

> Sets DSL (Data Service Line) related fields in the DataBean.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setDataDsl();` // Internal method: sets DSL data bean fields |

### Block 4 — [CALL: setMappedKKSV0136()] (L282)

> Performs upper-level mapping for the KKSV0136 service item-to-DataBean mapping. Called with function code 2 (check-only mode).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setMappedKKSV0136(FUNC_CD_2)` // FUNC_CD_2="2" (check mode) |

### Block 5 — [CALL: doService()] (L285)

> Executes the backend service for the 050 number change confirmation operation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgResult = doService("KKSV0136", "KKSV0136OP")` // Screen service call |

### Block 6 — [IF] (setErrorMessageInfo error check) (L290)

> Checks for errors from SC KKSV013601SC. This block was added in change ticket OM-2015-0000564 (2015/12/04).

| # | Type | Code |
|---|------|------|
| 1 | IF | `setErrorMessageInfo(outputMap, "KKSV013601SC")` // Checks chk_kbn == "1" for error condition |
| 2 | RETURN | `return false;` // Error detected, abort processing |

**Block 6.1 — [ELSE] (implicit: no error from service)** (L300)

> Processing continues when no error is found in the service output.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `storeDataBeanDslsrv(paramBean, outputMap);` // Stores service results into DataBean |

### Block 7 — [ERROR MESSAGE RETRIEVAL] (L302)

> Retrieves the error message ID from the DataBean.

| # | Type | Code |
|---|------|------|
| 1 | SET | `strMsg = bean.sendMessageString(ERR_MSG_ID, GET_VALUE)` // ERR_MSG_ID="エラーメッセージID" |

### Block 8 — [IF] (strMsg == null OR empty) (L304)

> **Success path**: No error message was set by the service. Navigate to the confirmation screen.

| # | Type | Code |
|---|------|------|
| 1 | IF | `strMsg == null || "".equals(strMsg)` // No error message indicates success |
| 2 | SET | `commoninfoBean.sendMessageString(NEXT_SCREEN_ID, SET_VALUE, SCREEN_ID_KKW03205)` // NEXT_SCREEN_ID="nextScreenId", SCREEN_ID_KKW03205="KKW03205" |
| 3 | SET | `commoninfoBean.sendMessageString(NEXT_SCREEN_NAME, SET_VALUE, SCREEN_NAME_KKW03205)` // SCREEN_NAME_KKW03205="050番号発行変更確認" |
| 4 | SET | `msgInfo[0] = MSGSTRING[0]` // Predefined success message text |
| 5 | EXEC | `JCCWebCommon.setMessageInfo(this, EKB0370__I, msgInfo)` // EKB0370__I: confirmation screen transition message |
| 6 | GOTO | (falls through to Block 11) |

### Block 9 — [ELSE] (strMsg has value = error case) (L317)

> Error message path: resolve and display appropriate error message.

| # | Type | Code |
|---|------|------|
| 1 | SET | `str = getMsgRep(trans_div, strMsg)` // Resolves message substitutions based on operation type |

#### Block 9.1 — [IF] (str result is null) (L319)

> Message ID only — no text substitution needed.

| # | Type | Code |
|---|------|------|
| 1 | IF | `str == null` // No substitution text available |
| 2 | EXEC | `JCCWebCommon.setMessageInfo(this, strMsg)` // Display message with ID only |
| 3 | GOTO | (falls through to Block 11) |

#### Block 9.2 — [ELSE] (str result is non-null) (L322)

> Message with text substitution — format placeholders in the message text.

| # | Type | Code |
|---|------|------|
| 1 | ELSE | `str != null` // Substitution text is available |
| 2 | EXEC | `JCCWebCommon.setMessageInfo(this, strMsg, str)` // Display message with substituted text |
| 3 | GOTO | (falls through to Block 11) |

### Block 10 — [LOGGING] (L328)

> Dumps the DataBean state to the log for debugging.

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

### Block 11 — [RETURN] (L330)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return result;` // Always returns true; error handling uses early returns |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `actionUpd_cfm` | Method | "Update Confirmation" action — processes the user's confirmation button press on the data change screen |
| `KKW03204SF` | Module | 050 Number Issuance/Change screen module — handles requests for issuing or changing a K-Opticom 050 number (virtual number service) |
| `KKW03205` | Screen ID | 050 Number Issuance/Change Confirmation screen — displays confirmed changes before final submission |
| `KKSV0136` | Screen/Service | Backend screen service for 050 number change confirmation |
| `KKSV013601SC` | SC Code | Service Component for KKSV0136 operation — executes the core business logic for 050 number contract change |
| `trans_div` | Field | Transport division / operation type code — distinguishes between DSL (01), Recovery/Restoration (04), and Reservation Cancellation (03) operations |
| `usd_endymd` | Variable | Usage End Date (YYYYMMDD composite) — composed from year, month, and day fields; represents when the service subscription ends |
| `USE_ENDYMD_YEAR` | Constant Key | "利用終了日（年）" (Usage End Date Year) — DataBean key for the year portion of the usage end date |
| `USE_ENDYMD_MON` | Constant Key | "利用終了日（月）" (Usage End Date Month) — DataBean key for the month portion |
| `USE_ENDYMD_DAY` | Constant Key | "利用終了日（日）" (Usage End Date Day) — DataBean key for the day portion |
| `USE_ENDYMD` | Constant Key | "利用終了日" (Usage End Date) — composite DataBean key for the full YYYYMMDD date |
| `DSP_ENDYMD` | Constant Key | "表示用利用終了日" (Display Usage End Date) — DataBean key for the date shown on screen |
| `ERR_MSG_ID` | Constant Key | "エラーメッセージID" (Error Message ID) — DataBean key storing error message identifiers |
| `FUNC_CD_2` | Constant | `"2"` — Function code for check-only mode (validation without data modification) |
| `NEXT_SCREEN_ID` | Constant | "nextScreenId" — Common form bean key for the next screen's ID |
| `NEXT_SCREEN_NAME` | Constant | "nextScreenName" — Common form bean key for the next screen's display name |
| `EKB0370__I` | Constant | Confirmation screen transition message code — displayed when navigating to the confirmation screen |
| `commoninfoBean` | Field | Common form DataBean — shared bean carrying data across screens (e.g., next screen navigation info) |
| `bean` / `paramBean` | Field | Service form DataBean — holds user input data for the current screen |
| `outputMap` | Field | Service execution output map — holds results from the backend service call, including error flags |
| `MSGSTRING` | Field | Predefined message string array — holds pre-formatted messages for different operation types |
| `doService` | Method | Service invocation method — calls the backend screen service with screen ID and operation code |
| `setMappedKKSV0136` | Method | Upper-level mapping method — maps service data to DataBean fields for screen display |
| `setDataDsl` | Method | DSL DataBean setup method — configures DSL-specific fields in the DataBean |
| `storeDataBeanDslsrv` | Method | DataBean service result storage — stores backend service results back into the DataBean |
| `getMsgRep` | Method | Message replacement resolver — resolves message templates with substitution values based on operation type |
| `JCCWebCommon.setMessageInfo` | Method | Screen message display utility — sets messages for display on the web screen |
| `setErrorMessageInfo` | Method | Error message setter — checks service output map for error flags (chk_kbn == "1") |
| OneStop | Business term | K-Opticom's OneStop unified API platform — enables third-party systems to integrate K-Opticom services |
| API | Acronym | Application Programming Interface — in this context, the OneStop API controller |
| DataBean | Technical term | Java object holding screen form data — used for passing data between presentation and business layers |
| SC | Acronym | Service Component — backend component implementing specific business operations |
| 050番号 | Business term | 050 Number — K-Opticom's virtual telephone number service (Japan's 050 prefix for VoIP numbers) |
| 発行変更 | Business term | Issuance/Change — the operation of applying for or modifying a 050 number assignment |
| 変更確認 | Business term | Update Confirmation — the intermediate screen showing changes before final confirmation |
| 利用終了日 | Business term | Usage End Date — the date when the customer's service subscription ends |
