# Business Logic — KKW03204SFLogic.getMsgRep() [42 LOC]

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

## 1. Role

### KKW03204SFLogic.getMsgRep()

`getMsgRep` is a private utility method that retrieves **replacement message text** for user-facing display based on a transaction division and a message template ID. Its Japanese Javadoc states: "Replacement message acquisition processing — retrieves the replacement string corresponding to the return message ID" (置換メッセージ取得処理 / 返却メッセージIDに対応する置換文字列を取得する). This method serves as a **message routing/dispatch mechanism** within the service contract cancellation screen (`KKW03204SF`), which handles termination and recovery of telecom services.

The method branches on the **transaction division (`trandiv`)**, which specifies the operation type: **cancellation (解約)** for division `"04"` and **recovery (回復)** for division `"05"`. For each transaction division, it matches against specific message IDs defined in `JPCOnlineMessageConstant` to return human-readable, localized replacement text arrays. The returned `String[]` arrays are used by callers to populate error and information messages on the screen via `JCCWebCommon.setMessageInfo`, where the first element serves as the message body and subsequent elements are format placeholders for dynamic values.

If no matching message template is found (i.e., the message ID is not recognized for the given transaction division), the method returns `null`, signaling to the caller that a fallback display method should be used (e.g., displaying the message ID directly or a default message). This makes `getMsgRep` a **conditional message formatter** — a design pattern commonly used in enterprise screen logic to decouple message content from display code.

The method is exclusively called within `KKW03204SFLogic` itself, specifically from `actionFix()` (the save/update cancellation screen handler) and `actionUpd_cfm()` (the update confirmation screen handler). This makes it a **shared screen utility** rather than a cross-screen or cross-module service.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getMsgRep"])
    START --> CHECK_TRANDIV{Check trandiv}

    CHECK_TRANDIV -->|DSL| DSL_BRANCH["DSL Branch"]
    CHECK_TRANDIV -->|Recovery| KAIHK_BRANCH["Recovery Branch"]
    CHECK_TRANDIV -->|Other| FALL_THROUGH["Fall Through"]

    DSL_BRANCH --> CHECK_EKB5440_1{EKB5440-JW}
    CHECK_EKB5440_1 -->|Yes| MSG_SUSPEND["Return Suspended Msg"]
    CHECK_EKB5440_1 -->|No| CHECK_EKB0270{EKB0270-NW}

    CHECK_EKB0270 -->|Yes| MSG_FUTURE["Return Future Msg"]
    CHECK_EKB0270 -->|No| CHECK_EKB0690{EKB0690-NW}

    CHECK_EKB0690 -->|Yes| MSG_PAST["Return Past Msg"]
    CHECK_EKB0690 -->|No| DSL_FALL["DSL End"]

    KAIHK_BRANCH --> CHECK_EKB5440_2{EKB5440-JW}
    CHECK_EKB5440_2 -->|Yes| MSG_RECOVERY["Return Recovery Msg"]
    CHECK_EKB5440_2 -->|No| KAIHK_FALL["Recovery End"]

    MSG_SUSPEND --> END_RET["Return String array"]
    MSG_FUTURE --> END_RET
    MSG_PAST --> END_RET
    MSG_RECOVERY --> END_RET
    DSL_FALL --> END_RET
    KAIHK_FALL --> END_RET
    FALL_THROUGH --> END_NULL["Return null"]
    END_RET --> END_NODE(["End"])
    END_NULL --> END_NODE
```

### Business description of the flow:

1. **Transaction division dispatch**: The method checks the `trandiv` parameter against two operation types — **cancellation (`OP_TRAN_DIV_DSL = "04"`)** and **recovery (`OP_TRAN_DIV_KAIHK = "05"`)**.

2. **DSL/Cancellation branch** (trandiv = `"04"`): Three message-specific checks:
   - **`EKB5440-JW`**: Suspended service — returned when a service is currently suspended and the user attempts to set a future cancellation date. Returns the replacement text `["休止中", "未来日の解約は"]` (Suspended / Future date cancellations are...).
   - **`EKB0270-NW`**: Future date — returned when the user attempts to set a cancellation date beyond the allowed operational window (current operational date + 60 days). Returns `["利用終止日", "運用日+60日", "日付"]` (Service termination date / 60 days from operational date / date).
   - **`EKB0690-NW`**: Past date — returned when the user attempts to set a cancellation date that falls in the past. Returns `["利用終止日", "過去"]` (Service termination date / Past).

3. **Recovery branch** (trandiv = `"05"`): One message-specific check:
   - **`EKB5440-JW`**: Recovery period expired — returned when the recovery window has passed and recovery is no longer possible. Returns `["回復可能期間外", "回復は"]` (Outside recovery period / Recovery is...).

4. **No-match / fallback**: If none of the message IDs match the current transaction division, the method returns `null`, allowing the caller to use a fallback display method.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `trandiv` | `String` | **Transaction division code** — specifies the type of business operation being performed. This is the same `trans_div` instance field used by the calling methods (`actionFix`, `actionUpd_cfm`), which captures the operation classification (e.g., `"04"` for cancellation/解約, `"05"` for recovery/回復). The method's behavior changes entirely based on this value. |
| 2 | `rtn_msg_id` | `String` | **Return message ID** — a template message identifier (e.g., `EKB5440-JW`, `EKB0270-NW`, `EKB0690-NW`) used to look up the appropriate replacement text. These message IDs correspond to specific validation error scenarios in the service cancellation screen. |

### Instance fields read:
| Field | Type | Business Description |
|-------|------|---------------------|
| `trans_div` (inferred from caller context) | `String` | The transaction division set by the calling action method before invoking `getMsgRep`. Stored as an instance field of `KKW03204SFLogic`. |

## 4. CRUD Operations / Called Services

This method is a **pure presentation-level utility**. It performs no database operations, no service component calls, and no entity mutations. All operations are local — string comparisons, array allocations, and returns.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| (N/A) | *(none)* | — | — | No CRUD or service calls. This method only performs in-memory message text routing based on `trandiv` and `rtn_msg_id`. |

The method does **not** interact with any SC Code, CBS, or database tables. It serves purely as a **message formatting utility** for the view layer.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 2 methods.
Terminal operations from this method: —

Both callers are **screen logic action methods** within the same class (`KKW03204SFLogic`). The module `KKW03204SF` is part of the service contract cancellation screen flow.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW03204 — `actionFix()` | `KKW03204SFLogic.actionFix()` → `getMsgRep(trans_div, strMsg)` | `setErrorMessageInfo [E] KKSV013601SC` (error flag check) |
| 2 | Screen:KKW03204 — `actionUpd_cfm()` | `KKW03204SFLogic.actionUpd_cfm()` → `getMsgRep(trans_div, strMsg)` | `setErrorMessageInfo [E] KKSV016301SC` (error flag check) |

### Caller context:
- **`actionFix()` (line ~324)**: The cancellation save action handler. After processing service termination data via `KKSV0136` service (`doService("KKSV0136", "KKSV0136OP")`), it checks for errors. If an error message ID is set (`ERR_MSG_ID`), it calls `getMsgRep` to retrieve replacement text for display.
- **`actionUpd_cfm()` (line ~442)**: The cancellation update confirmation action handler. After processing via `KKSV0163` service (`doService("KKSV0163", "KKSV0163OP")`), it similarly checks for errors and delegates message formatting to `getMsgRep` when needed.

Both callers use the same pattern: if `getMsgRep` returns a non-null `String[]`, the caller invokes `JCCWebCommon.setMessageInfo(this, strMsg, str)` with the replacement text. If it returns `null`, the caller falls back to `JCCWebCommon.setMessageInfo(this, strMsg)` displaying only the message ID.

## 6. Per-Branch Detail Blocks

### Block 1 — IF (Transaction Division Check) `(JPKKCommonConst.OP_TRAN_DIV_DSL.equals(trandiv))` `[OP_TRAN_DIV_DSL="04" (Cancellation/解約)]` (L1040)

> If the transaction division is cancellation (解約), enter the cancellation message branch. This handles error message replacements specific to service cancellation operations.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (JKKCommonConst.OP_TRAN_DIV_DSL.equals(trandiv))` `[OP_TRAN_DIV_DSL="04"]` |
| 2 | SET | `String[] str = new String[2]` |
| 3 | SET | `str[0] = "休止中"` (Suspended / Currently suspended) |
| 4 | SET | `str[1] = "未来日の解約は"` (Future date cancellations are...) |
| 5 | RETURN | `return str;` |

### Block 1.1 — IF (DSL: EKB5440-JW) `JPCOnlineMessageConstant.EKB5440_JW.equals(rtn_msg_id)` (L1044)

> When the message ID is `EKB5440-JW` in the cancellation context, the user has a suspended service and has attempted to specify a future cancellation date. Returns a two-element replacement array for the suspension message.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (JPCOnlineMessageConstant.EKB5440_JW.equals(rtn_msg_id))` `[EKB5440-JW]` |
| 2 | SET | `str[0] = "休止中"` (Suspended) |
| 3 | SET | `str[1] = "未来日の解約は"` (Future date cancellations are...) |
| 4 | RETURN | `return str;` |

### Block 1.2 — IF (DSL: EKB0270-NW) `JPCOnlineMessageConstant.EKB0270_NW.equals(rtn_msg_id)` (L1052)

> When the message ID is `EKB0270-NW`, the user specified a cancellation date beyond the allowed future window. Returns a three-element replacement array for the future date error message, which includes a dynamic value placeholder.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (JPCOnlineMessageConstant.EKB0270_NW.equals(rtn_msg_id))` `[EKB0270-NW]` |
| 2 | SET | `str[0] = "利用終止日"` (Service termination date) |
| 3 | SET | `str[1] = "運用日+60日"` (60 days from operational date) |
| 4 | SET | `str[2] = "日付"` (Date) |
| 5 | RETURN | `return str;` |

### Block 1.3 — IF (DSL: EKB0690-NW) `JPCOnlineMessageConstant.EKB0690_NW.equals(rtn_msg_id)` (L1060)

> When the message ID is `EKB0690-NW`, the user specified a cancellation date in the past. Returns a two-element replacement array for the past date error message.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (JPCOnlineMessageConstant.EKB0690_NW.equals(rtn_msg_id))` `[EKB0690-NW]` |
| 2 | SET | `str[0] = "利用終止日"` (Service termination date) |
| 3 | SET | `str[1] = "過去"` (Past) |
| 4 | RETURN | `return str;` |

### Block 2 — ELSE IF (Transaction Division Check) `(JKKCommonConst.OP_TRAN_DIV_KAIHK.equals(trandiv))` `[OP_TRAN_DIV_KAIHK="05" (Recovery/回復)]` (L1068)

> If the transaction division is recovery (回復), enter the recovery message branch. This handles error message replacements specific to service recovery operations.

| # | Type | Code |
|---|------|------|
| 1 | IF | `else if (JKKCommonConst.OP_TRAN_DIV_KAIHK.equals(trandiv))` `[OP_TRAN_DIV_KAIHK="05"]` |
| 2 | IF | `if (JPCOnlineMessageConstant.EKB5440_JW.equals(rtn_msg_id))` `[EKB5440-JW]` |
| 3 | SET | `str[0] = "回復可能期間外"` (Outside recovery period) |
| 4 | SET | `str[1] = "回復は"` (Recovery is...) |
| 5 | RETURN | `return str;` |

### Block 2.1 — ELSE IF (Recovery: EKB5440-JW) (L1072)

> When the message ID is `EKB5440-JW` in the recovery context, the user is attempting to recover a service outside the allowed recovery period. Returns a two-element replacement array for the recovery period expiration message.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (JPCOnlineMessageConstant.EKB5440_JW.equals(rtn_msg_id))` `[EKB5440-JW]` |
| 2 | SET | `str[0] = "回復可能期間外"` (Outside recovery period) |
| 3 | SET | `str[1] = "回復は"` (Recovery is...) |
| 4 | RETURN | `return str;` |

### Block 3 — ELSE (Fallback) (L1076)

> If none of the conditions above match (i.e., the transaction division is not cancellation or recovery, or the message ID is not recognized), return `null`. The caller will use a fallback display method.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `trandiv` | Field | Transaction division code — classifies the type of operation (cancellation, recovery, etc.) being performed on a service contract |
| `rtn_msg_id` | Field | Return message ID — a template identifier (e.g., `EKB5440-JW`) used to select the appropriate user-facing error message text |
| `OP_TRAN_DIV_DSL` | Constant | Operation transaction division = DSL — value `"04"`, represents cancellation (解約) of a service contract |
| `OP_TRAN_DIV_KAIHK` | Constant | Operation transaction division = Kaihaku (Recovery) — value `"05"`, represents recovery (回復) of a previously suspended or cancelled service |
| `EKB5440-JW` | Message ID | Suspension-related error — used in both cancellation and recovery contexts. In cancellation, indicates "suspended + future date"; in recovery, indicates "outside recovery period" |
| `EKB0270-NW` | Message ID | Future date error — indicates a date specified is beyond the allowed window (operational date + 60 days) |
| `EKB0690-NW` | Message ID | Past date error — indicates a date specified falls in the past |
| 休止中 | Japanese term | Currently suspended — a service is in a suspended (paused) state |
| 解約 | Japanese term | Cancellation / Contract termination — the act of ending a service contract |
| 回復 | Japanese term | Recovery / Restoration — the act of restoring a previously suspended or cancelled service |
| 未来日 | Japanese term | Future date — a date in the future beyond a specific threshold |
| 運用日 | Japanese term | Operational date — the current business processing date used as a reference point for date validations |
| 利用終止日 | Japanese term | Service termination date — the effective date when a service contract ends |
| 過去 | Japanese term | Past — a date that falls before the current date |
| 回復可能期間外 | Japanese term | Outside recovery period — the window during which a service can be recovered has expired |
| 回復は | Japanese term | Recovery is... — incomplete sentence fragment used as a message prefix requiring a dynamic value suffix |
| 未来日の解約は | Japanese term | Future date cancellations are... — incomplete sentence fragment used as a message prefix |
| JPCOnlineMessageConstant | Class | Central message constant definition class containing all error and information message ID constants |
| JKKCommonConst | Class | Common constant definition class containing operation type classification constants |
| `setMappedKKSV0136` | Method | Service mapping method for `KKSV0136` — sets up data mapping for the service cancellation screen |
| `setMappedKKSV0163` | Method | Service mapping method for `KKSV0163` — sets up data mapping for the service cancellation recovery screen |
| KKSV0136 | Service Code | Service component for service cancellation (解約) processing |
| KKSV0163 | Service Code | Service component for service cancellation recovery (回復) processing |
