# Business Logic — JKKTvSvcKeiCancelCC.execMskm() [49 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKTvSvcKeiCancelCC` |
| Layer | CC/Common Component |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKTvSvcKeiCancelCC.execMskm()

The `execMskm` method orchestrates the service-detail registration and follow-up request workflow during a TV contract cancellation process. Specifically, it performs two sequential Service Component (CBS) calls: first, it invokes the **Order Content Approval Registration** (EKK0011D020CBS) to create a new service detail record and obtain a generated service detail number (`MSKM_DTL_NO`); second, it invokes the **Service Detail Inquiry / Post-Process Request** (EKK0021C060CBS) to submit a follow-up business request using that newly allocated detail number.

This method implements a **sequential delegation pattern** — it constructs two separate CBS input messages, populates them with contextual data extracted from the shared request map (`ccMsg`), delegates to `callSC` for each one, and returns the response from the first CBS call (which carries the full service registration details, including `MSKM_NO` and `MSKM_DTL_NO`). These return values are consumed by the caller (`cancel()`) to drive subsequent cancellation logic.

The method serves as a **shared utility within the cancellation common component**, meaning it is reusable across different cancellation scenarios that reach the "confirmation completed" (確認済) state. It has no screen-level entry point — it is always invoked indirectly from `cancel()` when the current service detail status (`curSvcKeiStat`) equals `"020"`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execMskm handle, scCall, param, dataMapKey"])
    START --> GET["ccMsg = param.getData dataMapKey"]
    GET --> FUNC["funcCode = ccMsg.get func_code"]
    FUNC --> IN1["Build EKK0011D020IN message"]
    IN1 --> SET1["Set TEMPLATE_ID_EKK0011D020"]
    SET1 --> SET2["Set FUNC_CODE funcCode"]
    SET2 --> SET3["Set SYSID from ccMsg"]
    SET3 --> SET4["Set MSKM_SBT_CD to 00020"]
    SET4 --> SET5["Set MSKM_UK_DTM to getOpeDateTimeStamp"]
    SET5 --> SET6["Set MSKM_UK_TNT_USER_ID from control map"]
    SET6 --> SET7["Set MSKM_YMD to getOpeDate"]
    SET7 --> SET8["Set CONSMBSN_MSKM_STAT_SKBT_CD to 04"]
    SET8 --> MSG1["Create ekk0011d020msglist array"]
    MSG1 --> COND1{manssbsys_rnki_yo_kijiran == null or empty?}
    COND1 -- Yes --> NULL["SetNull MANSSBSYS_RNKI_YO_KIJIRAN"]
    COND1 -- No --> VALUE["Set MANSSBSYS_RNKI_YO_KIJIRAN value"]
    NULL --> MSGSET["Set EKK0011D020CBSMSG1LIST"]
    VALUE --> MSGSET
    MSGSET --> CALL1["callSC EKK0011D020CBS"]
    CALL1 --> EXTRACT["Extract mskmDtlNo from response"]
    EXTRACT --> IN2["Build EKK0021C060IN message"]
    IN2 --> S1["Set TEMPLATE_ID_EKK0021C060"]
    S1 --> S2["Set FUNC_CODE funcCode"]
    S2 --> S3["Set MSKM_DTL_NO"]
    S3 --> S4["Set KZKWRK_REQYMD to getOpeDate"]
    S4 --> S5["Set UPD_DTM_BF from mskmInfo"]
    S5 --> S6["Set IDO_DIV from ccMsg"]
    S6 --> CALL2["callSC EKK0021C060CBS"]
    CALL2 --> RETURN(["Return mskmInfo"])

    START --> GET
```

**Processing flow summary:**

1. **Data extraction**: Retrieves the shared `ccMsg` HashMap from `param.getData(dataMapKey)` and extracts `funcCode`.
2. **First CBS build (EKK0011D020 — Order Content Approval Registration)**: Constructs the CBS input message with template ID, function code, system ID, sub-detail code (`00020` = service registration), operation datetime (via `JPCBPCommon.getOpeDateTimeStamp`), operator ID (from control map), operation date (via `JPCBPCommon.getOpeDate`), and cancellation detail status (`04`).
3. **Conditional branch**: If `manssbsys_rnki_yo_kijiran` (service system request target flag) is null or empty, sets the field as `null`; otherwise, sets its value. This field determines whether a request notice is sent to the service system.
4. **First CBS execution**: Calls `callSC` with the built message.
5. **Detail number extraction**: Extracts `MSKM_DTL_NO` (service detail number) from the CBS response list for use in the second CBS call.
6. **Second CBS build (EKK0021C060 — Service Detail Inquiry / Post-Process Request)**: Constructs the CBS input message with template ID, function code, the extracted detail number, request operation date, the update datetime from the first CBS response, and the movement/division indicator.
7. **Second CBS execution**: Calls `callSC` with the built message.
8. **Return**: Returns the `mskmInfo` response from the first CBS call, which contains the assigned `MSKM_NO` and `MSKM_DTL_NO`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle — provides the database connection and transaction context for CBS invocations. Used internally by `callSC` to route service component calls. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service Component invocation context object — carries routing, logging, and metadata needed to execute CBS (service component) calls. Passed to `callSC` for actual execution. |
| 3 | `param` | `IRequestParameterReadWrite` | Request parameter interface — holds the request-scoped data map from which `ccMsg` is extracted via `getData(dataMapKey)`. Also provides `getControlMapData` for retrieving the operator ID. |
| 4 | `dataMapKey` | `String` | The key used to retrieve the shared `ccMsg` HashMap from `param`. Typically corresponds to the screen's fixed text configuration, allowing the same data to be shared across multiple CBS calls within a screen. |

**Related instance fields / external state:**

| Field | Source | Business Description |
|-------|--------|---------------------|
| `TEMPLATE_ID_EKK0011D020` | Instance field (String constant) | Template ID for EKK0011D020CBS — identifies the message template for Order Content Approval Registration. |
| `TEMPLATE_ID_EKK0021C060` | Instance field (String constant) | Template ID for EKK0021C060CBS — identifies the message template for Service Detail Inquiry / Post-Process Request. |
| `MSKM_SBT_CD` | Instance field (constant = `"00020"`) | Service sub-detail code — `00020` identifies this as a new service detail registration (new entry). Other values (e.g., `00010`) represent different sub-detail types. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callSC` (EKK0011D020CBS) | EKK0011D020CBS | KK_T_MSKM (Service Detail Master) | Invokes Order Content Approval Registration CBS — creates/registers a new service detail record and returns assigned detail number. |
| R | `callSC` (EKK0021C060CBS) | EKK0021C060CBS | KK_T_MSKM (Service Detail Master) | Invokes Service Detail Inquiry / Post-Process Request CBS — performs inquiry and triggers follow-up business processing for the registered detail. |

**How to classify:**
- Both `callSC` invocations are **Read** (R) operations because they execute CBS service components that perform database operations internally. The `callSC` method itself reads from the service component layer — the actual CRUD semantics are determined by the CBS being called.
- **EKK0011D020CBS** (申込内容承認登録 / Order Content Approval Registration) performs a **Create** operation on the service detail master table (`KK_T_MSKM`), registering a new service detail record with status `04` (contract cancellation registration). It also performs reads to validate input data and assign the next service detail number.
- **EKK0021C060CBS** (申込明細照査・後続業務依頼 / Service Detail Inquiry and Post-Process Request) performs a **Read** operation — it inquires about the registered service detail and initiates follow-up business processing (e.g., provisioning, equipment assignment, or line configuration tasks).

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS:JKKTvSvcKeiCancelCC.cancel | `JKKTvSvcKeiCancelCC.cancel` -> `execMskm` | `callSC [C/R] KK_T_MSKM (EKK0011D020CBS)`, `callSC [R] KK_T_MSKM (EKK0021C060CBS)` |

**Caller context details:**
- `execMskm` is called from `JKKTvSvcKeiCancelCC.cancel()` (line 188) when the current service detail status (`curSvcKeiStat`) equals `"020"` (確認済 / confirmation completed). This condition means the service detail has already been confirmed and needs to go through the approval registration process before cancellation can proceed.
- The return value `mskmInfo` is used to extract `MSKM_NO` and `MSKM_DTL_NO`, which are passed to the `svcCancel` method for the actual cancellation processing.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(condition: none)` (L758)

Extracts the shared data map and function code from the request parameter.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMsg = (HashMap)param.getData(dataMapKey)` // Retrieves the shared request map [-> dataMapKey is the screen config key] |
| 2 | SET | `funcCode = (String)ccMsg.get("func_code")` // Extracts function code [-> identifies the business function context] |

**Block 2** — [SET x7] `(condition: none)` (L762–770)

Builds the EKK0011D020CBS (Order Content Approval Registration) input message. Sets the template ID, function code, system ID, sub-detail code, operation datetime, operator ID, operation date, and cancellation status.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ekk0011d020IN = new CAANMsg(EKK0011D020CBSMsg.class.getName())` | Creates the CBS input message object [-> EKK0011D020CBS] |
| 2 | SET | `ekk0011d020IN.set(EKK0011D020CBSMsg.TEMPLATEID, TEMPLATE_ID_EKK0011D020)` | Sets template ID [-> "EKK0011D020"] |
| 3 | SET | `ekk0011d020IN.set(EKK0011D020CBSMsg.FUNC_CODE, funcCode)` | Sets function code [-> from ccMsg] |
| 4 | SET | `ekk0011d020IN.set(EKK0011D020CBSMsg.SYSID, ccMsg.get("sysid"))` | Sets system ID [-> from ccMsg] |
| 5 | SET | `ekk0011d020IN.set(EKK0011D020CBSMsg.MSKM_SBT_CD, "00020")` | Sets service sub-detail code [-> "00020" = New Registration (新規登録)] |
| 6 | SET | `ekk0011d020IN.set(EKK0011D020CBSMsg.MSKM_UK_DTM, JPCBPCommon.getOpeDateTimeStamp(null))` | Sets update datetime [-> current operation timestamp] |
| 7 | SET | `ekk0011d020IN.set(EKK0011D020CBSMsg.MSKM_UK_TNT_USER_ID, param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` | Sets operator ID [-> from control map] |
| 8 | SET | `ekk0011d020IN.set(EKK0011D020CBSMsg.MSKM_YMD, JPCBPCommon.getOpeDate(null))` | Sets operation date [-> current operation date] |
| 9 | SET | `ekk0011d020IN.set(EKK0011D020CBSMsg.CONSMBSN_MSKM_STAT_SKBT_CD, "04")` | Sets cancellation detail status [-> "04" = Contract Cancellation Registration (契約取消登録)] |

**Block 3** — [SET x1, IF/ELSE] `(condition: manssbsys_rnki_yo_kijiran)` (L772–777)

Creates the child message list and conditionally sets the service system request target flag. If the flag is null or empty, sets the field as null (meaning no request notice is sent); otherwise, passes the value through.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0011d020msglist = new CAANMsg[]{new CAANMsg(EKK0011D020CBSMsg1List.class.getName())}` [-> creates message list with one child element] |
| 2 | IF | `ccMsg.get("manssbsys_rnki_yo_kijiran") == null || "".equals(...)` [-> "manssbsys_rnki_yo_kijiran" = Service System Request Target Flag (サービスシステム依頼用表示欄)] |

**Block 3.1** — [nested IF: true branch] `(manssbsys_rnki_yo_kijiran is null or empty)` (L773)

When the service system request target flag is absent, set the field as null to indicate no request notice should be sent.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0011d020msglist[0].setNull(EKK0011D020CBSMsg1List.MANSSBSYS_RNKI_YO_KIJIRAN)` [-> nullifies the field, suppressing the request notice] |

**Block 3.2** — [nested IF: false branch] `(manssbsys_rnki_yo_kijiran has a value)` (L775)

When the service system request target flag has a value, pass it through to the CBS message.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0011d020msglist[0].set(EKK0011D020CBSMsg1List.MANSSBSYS_RNKI_YO_KIJIRAN, ccMsg.get("manssbsys_rnki_yo_kijiran"))` [-> propagates the flag value] |

**Block 4** — [SET x1] `(condition: none)` (L778)

Attaches the child message list to the main CBS input message.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0011d020IN.set(EKK0011D020CBSMsg.EKK0011D020CBSMSG1LIST, ekk0011d020msglist)` [-> attaches the child list to the parent message] |

**Block 5** — [CALL x1] `(condition: none)` (L780)

Invokes the EKK0011D020CBS service component to register the service detail. The response contains the assigned `MSKM_NO` (service registration number) and `MSKM_DTL_NO` (service detail number).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `mskmInfo = callSC(handle, scCall, param, dataMapKey, ekk0011d020IN)` [-> executes EKK0011D020CBS] | Order Content Approval Registration — creates service detail record |

**Block 6** — [SET x1] `(condition: none)` (L782)

Extracts the service detail number from the first CBS response for use in the second CBS call.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `mskmDtlNo = mskmInfo.getCAANMsgList(...)[0].getString(EKK0011D020CBSMsg1List.MSKM_DTL_NO)` [-> extracts allocated service detail number] |

**Block 7** — [SET x6] `(condition: none)` (L785–790)

Builds the EKK0021C060CBS (Service Detail Inquiry / Post-Process Request) input message. This CBS performs the inquiry on the just-registered detail and triggers follow-up business processing.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ekk0021c060IN = new CAANMsg(EKK0021C060CBSMsg.class.getName())` [-> creates CBS input message] |
| 2 | SET | `ekk0021c060IN.set(EKK0021C060CBSMsg.TEMPLATEID, TEMPLATE_ID_EKK0021C060)` [-> "EKK0021C060"] | Template ID for follow-up request |
| 3 | SET | `ekk0021c060IN.set(EKK0021C060CBSMsg.FUNC_CODE, funcCode)` | Reuses the same function code |
| 4 | SET | `ekk0021c060IN.set(EKK0021C060CBSMsg.MSKM_DTL_NO, mskmDtlNo)` | Sets the allocated service detail number from the first CBS response |
| 5 | SET | `ekk0021c060IN.set(EKK0021C060CBSMsg.KZKWRK_REQYMD, JPCBPCommon.getOpeDate(null))` | Sets follow-up work request date [-> current operation date] |
| 6 | SET | `ekk0021c060IN.set(EKK0021C060CBSMsg.UPD_DTM_BF, mskmInfo.getString(EKK0011D020CBSMsg.UPD_DTM))` | Sets the update datetime from the first CBS response [-> timestamp of the registration] |
| 7 | SET | `ekk0021c060IN.set(EKK0021C060CBSMsg.IDO_DIV, ccMsg.get("ido_div"))` | Sets movement/division indicator [-> from ccMsg; specifies the type of movement/change] |

**Block 8** — [CALL x1] `(condition: none)` (L791)

Invokes the EKK0021C060CBS service component to perform the service detail inquiry and trigger follow-up processing. This CBS may internally update the service detail status and initiate provisioning tasks.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `callSC(handle, scCall, param, dataMapKey, ekk0021c060IN)` [-> executes EKK0021C060CBS] | Service Detail Inquiry / Post-Process Request — triggers follow-up business processing |

**Block 9** — [RETURN x1] `(condition: none)` (L793)

Returns the response from the first CBS call. The caller (`cancel()`) uses this to extract `MSKM_NO` and `MSKM_DTL_NO` for subsequent cancellation processing.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return mskmInfo` | Returns the full registration response containing service registration number and detail number |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `execMskm` | Method | Short for "exec MSKM" — executes the service detail (申込明細) registration and follow-up request workflow. |
| `MSKM` | Acronym | 申込明細 — Service Detail / Order Detail. The individual line item within a service contract order. |
| `MSKM_NO` | Field | 申込番号 — Service Registration Number. The primary key identifying a service detail registration record. |
| `MSKM_DTL_NO` | Field | 申込明細番号 — Service Detail Number. The unique number assigned to a registered service detail line item. |
| `MSKM_SBT_CD` | Field | 申込明細サブコード — Service Detail Sub-detail Code. Classifies the type of service detail action (`00020` = New Registration). |
| `MSKM_UK_DTM` | Field | 申込明細更新日時 — Service Detail Update Date/Time. Timestamp of the last update to the service detail. |
| `MSKM_UK_TNT_USER_ID` | Field | 申込明細更新担当ユーザID — Service Detail Updating Operator ID. The operator who performed the update. |
| `MSKM_YMD` | Field | 申込年月日 — Service Detail Date. The operation date for the service detail registration. |
| `CONSMBSN_MSKM_STAT_SKBT_CD` | Field | 契約取消申込明細ステータスSKBTコード — Contract Cancellation Service Detail Status SKBT Code. `04` = Contract Cancellation Registration (契約取消登録). |
| `MANSSBSYS_RNKI_YO_KIJIRAN` | Field | 満了サービスシステム依頼用表示欄 — Service System Request Target Flag. Indicates whether a request notice should be sent to the external service system. |
| `IDO_DIV` | Field | 異動区分 — Movement/Change Division Code. Specifies the type of movement or change (e.g., address change, registration change) associated with the service detail. |
| `func_code` | Field | 機能コード — Function Code. Identifies the business function context for the CBS call. |
| `sysid` | Field | システムID — System ID. Identifies the source system making the request. |
| `MSKM_DTL_STAT_CANCEL` | Constant | `920` — Service Detail Status: Cancellation. Indicates a cancelled service detail state. |
| EKK0011D020CBS | CBS | 申込内容承認登録 — Order Content Approval Registration. CBS that registers order content and generates service detail numbers. |
| EKK0021C060CBS | CBS | 申込明細照査・後続業務依頼 — Service Detail Inquiry / Post-Process Request. CBS that inquires about a service detail and triggers follow-up processing. |
| KK_T_MSKM | DB Table | 申込明細マスタ — Service Detail Master Table. The core database table storing service detail registration records. |
| `callSC` | Method | Service Component call wrapper — generic method for executing CBS service components with proper session management. |
| JPCBPCommon | Utility Class | Common utility for CBP (Customer Business Platform) operations — provides `getOpeDate` and `getOpeDateTimeStamp` for obtaining current operation timestamps. |
| `curSvcKeiStat` | Variable | 現在サービス詳細ステータス — Current Service Detail Status. The status of the service detail being cancelled (`020` = 確認済 / Confirmed). |
| cancel() | Method | Main cancellation orchestrator — the caller method that triggers `execMskm` and coordinates the full cancellation workflow. |
| `svcCancel` | Method | Service cancellation processor — executes the actual cancellation logic using the `MSKM_NO` and `MSKM_DTL_NO` obtained from `execMskm`. |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service. Part of the TV cancellation service domain. |
| CBS | Acronym | Component Business Service — Fujitsu's service component architecture for executing business logic. |
| CAANMsg | Type | Common Application ANd message — the message container class used throughout the system for CBS input/output. |
