# Business Logic — JKKEmgRrksNmUpdCC.getEkk0781A010() [41 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKEmgRrksNmUpdCC` |
| Layer | CC/Common Component — a shared business rule component within the order-processing (BP) module |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKEmgRrksNmUpdCC.getEkk0781A010()

This method performs a **recovery-period lookup for a service-contract line item** by calling the `EKK0781A010` CBS (Call Back Service) — the Service Contract List Inquiry (SYSID) 2 interface. Its business purpose is to determine **how many days of grace/recovery period remain** for a given service group, which is used to enforce cancellation windows in the emergency contact name/kana update flow.

The method acts as a **service-dispatch delegate**: it builds an input map with a template ID, function code, processing group code, and current operation date, then delegates all CBS interaction to `callSC()`. After receiving the response message, it applies a conditional branch based on the target service status to return either the **cancellation recovery period** (`CANCEL_CL_PSB_PRD`) when the service is in cancelled state (`CD00037_CANCEL_ZM = "920"`), or the **general recovery period** (`KAIHK_PSB_PRD`) for any other state (e.g., terminated services with `CD00037_DSL_ZM = "910"`).

This method is called from `dslYmdKaihkPsbPrdCheck()`, which computes whether a cancellation or termination date plus the recovery period exceeds the current operation date — effectively implementing a **contract change window guard**. If the method returns an empty string (no data found), the guard rejects the change; if it returns a valid period, the guard checks whether the operation date is past the recovery window and allows or blocks the update accordingly.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getEkk0781A010 handle, param, fixedText, prcGrpCd, trgtSvcKeiUcwkStat"])

    START --> INIT["Create ServiceComponentRequestInvoker scCall"]

    INIT --> BUILD["Build input map ekk0781A010In as Object[][]"]

    BUILD --> S1["Set TEMPLATEID = EKK0781A010"]

    S1 --> S2["Set FUNC_CODE = 2 (JPCModelConstant.FUNC_CD_2)"]

    S2 --> S3["Set KEY_PRC_GRP_CD = prcGrpCd"]

    S3 --> S4["Set KEY_RSV_APLY_YMD = JPCBPCommon.getOpeDate null"]

    S4 --> CALLSC["Call callSC handle, scCall, param, ekk0781A010In, fixedText, EKK0781A010CBSMsg contents"]

    CALLSC --> EXTRACT["Extract CAANMsg[] ekk0781A010Msg1List from getCAANMsgList EKK0781A010CBSMSG1LIST"]

    EXTRACT --> CHECK_NULL{"ekk0781A010Msg1List != null?"}

    CHECK_NULL -->|No| EMPTY_RETURN["Return empty string"]

    CHECK_NULL -->|Yes| GET_MSG["Get ekk0781A010Msg from ekk0781A010Msg1List[0]"]

    GET_MSG --> CHECK_STAT{"trgtSvcKeiUcwkStat == 920 (CD00037_CANCEL_ZM)?"}

    CHECK_STAT -->|Yes - Cancelled| RET_CANCEL["Return ekk0781A010Msg.getString CANCEL_CL_PSB_PRD"]

    CHECK_STAT -->|No - Other status| RET_RECOVER["Return ekk0781A010Msg.getString KAIHK_PSB_PRD"]

    RET_CANCEL --> END(["End Return recovery period"])

    RET_RECOVER --> END

    EMPTY_RETURN --> END
```

**Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|-----------------|
| `TEMPLATE_ID_EKK0781A010` | `"EKK0781A010"` | CBS template ID for Service Contract List Inquiry (SYSID) 2 |
| `JPCModelConstant.FUNC_CD_2` | `"2"` | Function code — inquiry mode (as opposed to `"1"` for update mode, `"4"` for list mode) |
| `JKKStrConst.CD00037_CANCEL_ZM` | `"920"` | Target service status: Cancelled — indicates the service was cancelled, requiring the cancellation recovery period |
| `JKKStrConst.CD00037_DSL_ZM` | `"910"` | Target service status: Terminated — indicates the service was terminated, requiring the general recovery period |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Application session handle carrying user authentication context, transaction state, and tenant information for the CBS call. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object holding screen-level input data and message templates. Passed through to `callSC` to maintain request continuity. |
| 3 | `fixedText` | `String` | A service message key (e.g., `"JKKEmgRrksNmUpdCC"`) used to correlate request/response messages. Passed to `callSC` for logging and message mapping. |
| 4 | `prcGrpCd` | `String` | Processing group code — identifies which service group (e.g., service contract line item) to query. In the caller, this is hardcoded to `"10"` (JJKStrConst.CD00133_10), corresponding to a specific service category such as FTTH or broadband. |
| 5 | `trgtSvcKeiUcwkStat` | `String` | Target service detail work status — determines which recovery period field to return. `"920"` means the service was cancelled (returns cancellation recovery period); any other value including `"910"` (terminated) returns the general recovery period. |

**Instance fields read:** None. This method is stateless and reads no instance-level fields.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callSC` (via `EKK0781A010CBSMsg`) | EKK0781A010SC | Service contract line items (inquiry) | Calls the centralized service component invoker to invoke the EKK0781A010 CBS — Service Contract List Inquiry (SYSID) 2 — which reads service contract data for the specified SYSID and processing group. |
| R | `JPCBPCommon.getOpeDate` | - | - | Retrieves the current operation date (system date for business processing) used as the reservation application date in the CBS input. |
| R | `CAANMsg.getString` | - | - | Reads the recovery period value from the CBS response message — either cancellation recovery period or general recovery period field. |
| R | `CAANMsg.getCAANMsgList` | - | - | Extracts the message list from the CBS response payload, identifying the EKK0781A010CBSMSG1LIST result set. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen: Emergency Contact Name Update (JKKEmgRrksNmUpdCC.execute) | `execute(handle, param, fixedText)` → `dslYmdKaihkPsbPrdCheck(handle, param, fixedText, trgtSvcKeiUcwkStat, ekk0161a010Map)` → `getEkk0781A010(handle, param, fixedText, prcGrpCd, trgtSvcKeiUcwkStat)` | `callSC [R] EKK0781A010SC`, `getOpeDate [R] -`, `getString [R] CANCEL_CL_PSB_PRD / KAIHK_PSB_PRD` |

**Call chain explanation:** The primary caller is `dslYmdKaihkPsbPrdCheck()`, a private validation method within the same class. It is invoked during the "Emergency Contact Name/Kana Update Main Processing" flow, where for each service contract line item in cancelled or terminated state, the system checks whether the recovery period has elapsed before allowing the emergency contact update. `dslYmdKaihkPsbPrdCheck()` computes the cancellation/termination date and compares it against the recovery period obtained from `getEkk0781A010()`.

## 6. Per-Branch Detail Blocks

**Block 1** — [INITIALIZATION] (L389)

> Creates the service component request invoker and builds the input parameter map for the CBS call.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ServiceComponentRequestInvoker scCall = new ServiceComponentRequestInvoker()` | [→ CONSTANT=""] Instantiate the CBS request invoker for making service component calls. |
| 2 | SET | `Object[][] ekk0781A010In = { ... }` | Build the 2D input map array for CBS parameters. |
| 3 | SET | `ekk0781A010In[0] = {EKK0781A010CBSMsg.TEMPLATEID, TEMPLATE_ID_EKK0781A010}` | [→ CONSTANT_NAME="EKK0781A010"] Set the CBS template ID for Service Contract List Inquiry (SYSID) 2. |
| 4 | SET | `ekk0781A010In[1] = {EKK0781A010CBSMsg.FUNC_CODE, JPCModelConstant.FUNC_CD_2}` | [→ FUNC_CD_2="2"] Set function code to 2 (inquiry mode, as opposed to update mode "1"). |
| 5 | SET | `ekk0781A010In[2] = {EKK0781A010CBSMsg.KEY_PRC_GRP_CD, prcGrpCd}` | Pass the processing group code (typically "10" for FTTH/broadband service group). |
| 6 | SET | `ekk0781A010In[3] = {EKK0781A010CBSMsg.KEY_RSV_APLY_YMD, JPCBPCommon.getOpeDate(null)}` | [→ getOpeDate] Set the reservation application date to the current operation date. |
| 7 | CALL | `callSC(handle, scCall, param, ekk0781A010In, fixedText, new EKK0781A010CBSMsg().getContents())` | Invoke the CBS — Service Contract List Inquiry (SYSID) 2 — with the constructed input map. Returns a CAANMsg wrapper. |
| 8 | SET | `CAANMsg[] ekk0781A010Msg1List = callSC(...).getCAANMsgList(EKK0781A010CBSMsg.EKK0781A010CBSMSG1LIST)` | Extract the message list for EKK0781A010CBSMSG1LIST from the CBS response. |

**Block 2** — [IF] `(null != ekk0781A010Msg1List)` (L402)

> Checks whether the CBS returned any data rows. If no data is found, the method returns an empty string, which signals to the caller that the recovery period lookup failed and the contract change should be blocked.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `CAANMsg ekk0781A010Msg = new CAANMsg()` | [→ ""] Declare a reference for the single message row. |
| 2 | SET | `ekk0781A010Msg = ekk0781A010Msg1List[0]` | [→ 0] Get the first (and likely only) message from the CBS result list. |

**Block 2.1** — [IF] `(JKKStrConst.CD00037_CANCEL_ZM.equals(trgtSvcKeiUcwkStat))` (L405)

> **[CD00037_CANCEL_ZM = "920" (Cancelled)]** Checks whether the target service is in cancelled state. If cancelled, the cancellation recovery period is the relevant value because a cancelled service may be reinstated within a specific window.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return ekk0781A010Msg.getString(EKK0781A010CBSMsg1List.CANCEL_CL_PSB_PRD)` | Return the cancellation recovery period (number of days within which a cancelled service can be reinstated) from the CBS response. |

**Block 2.2** — [ELSE] (L408)

> **[Other status — includes CD00037_DSL_ZM = "910" (Terminated)]** For any other service status (most commonly terminated services), the general recovery period applies. This period determines how long after termination a service remains recoverable.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return ekk0781A010Msg.getString(EKK0781A010CBSMsg1List.KAIHK_PSB_PRD)` | Return the general recovery period (number of days within which a terminated service can be reinstated) from the CBS response. |

**Block 3** — [DEFAULT RETURN] (L414)

> If the CBS returned no data rows (null or empty list), return an empty string. The caller interprets this as "recovery period not found" and blocks the contract change.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return ""` | Return empty string — no recovery period data available, which will cause the caller to reject the contract change. |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `getEkk0781A010` | Method | Service Contract List Inquiry (SYSID) 2 — recovery period lookup method |
| `prcGrpCd` | Field | Processing Group Code — identifies the service category/group (e.g., "10" for FTTH/broadband) |
| `trgtSvcKeiUcwkStat` | Field | Target Service Detail Work Status — the status of the service contract line item ("910"=Terminated, "920"=Cancelled, etc.) |
| `CANCEL_CL_PSB_PRD` | Field | Cancellation Possible Period (days) — recovery period for cancelled services; the window within which a cancelled contract can be reinstated |
| `KAIHK_PSB_PRD` | Field | Recovery Possible Period (days) — general recovery period for terminated services; the number of days after termination during which the service can be reinstated |
| `EKK0781A010` | SC Code | Service Contract List Inquiry (SYSID) 2 — CBS that queries service contract data by SYSID and processing group |
| `EKK0781A010CBSMSG1LIST` | Field | CBS response message list name for EKK0781A010 results |
| `TEMPLATE_ID_EKK0781A010` | Constant | CBS template identifier = "EKK0781A010" |
| `FUNC_CD_2` | Constant | Function code "2" — inquiry mode for CBS calls |
| `CD00037_CANCEL_ZM` | Constant | Service status = "920" — Cancelled state |
| `CD00037_DSL_ZM` | Constant | Service status = "910" — Terminated state |
| `CD00037_STAT_STP` | Constant | Service status = "220" — Stopped state |
| `CD00133_10` | Constant | Service group code = "10" — FTTH/broadband service category |
| DSL_ZM | Japanese acronym | 解除済み — Terminated/Canceled (service completed) |
| CANCEL_ZM | Japanese acronym | キャンセル済み — Cancelled (service contract cancellation in progress) |
| KAIHK | Japanese acronym | 回復 — Recovery (reinstatement of a service) |
| PSB | Japanese acronym | 可能 — Possible/available (indicating a capability or valid window) |
| PRD | Abbreviation | Period (days) |
| SYSID | Abbreviation | System ID — customer/master identifier used to look up service contracts |
| CBS | Abbreviation | Call Back Service — a back-end service component invoked via the `callSC` infrastructure |
| SC | Abbreviation | Service Component — a service-layer module that handles specific business operations |
| CAANMsg | Class | Common Application ANswer Message — the response message container for CBS calls |
| JPCBPCommon | Class | Common BP utility class providing operation date retrieval and shared business constants |
| `dslYmdKaihkPsbPrdCheck` | Method | DSL Recovery Possible Period Check — validates whether the cancellation/termination date plus recovery period has elapsed |
| `execute` | Method | Emergency Contact Name/Kana Update main processing — the screen entry point that orchestrates the full update flow |
| SessionHandle | Type | Application session handle — carries authentication, transaction, and tenant context |
| IRequestParameterReadWrite | Type | Request parameter interface — holds screen input data and message containers |
