# Business Logic — JKKCancelSvcWribCC.editInEKK1391C040() [104 LOC]

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

## 1. Role

### JKKCancelSvcWribCC.editInEKK1391C040()

This method performs **upstream CBS message mapping for the Data Extraction Item Settings Completion** screen (`EKK1391C040`). It is a **response builder / data mapper** that transforms extracted work data from the caller's `workBeanListMap3` HashMap into a properly structured `CAANMsg` template destined for the CBS layer. The business context is the **service cancellation workflow**: when a user completes the data extraction item settings step of a service cancellation, this method serializes the relevant fields into the CBS response message. It maps six domain-specific fields — data extraction item settings number, completion type code, completion end date, move division, and completion opportunity code — each with safe null-handling. It also determines the correct "update datetime before" (`upd_dtm_bf`) value: if the service contract with the most recent update timestamp has never been modified (i.e., `maxDtm` is empty), it passes through the existing `upd_dtm_bf` from work data; otherwise it overwrites it with the computed max datetime. The method implements a **builder pattern** (creating and populating a `CAANMsg` template) and follows a **delegation pattern** by calling `getDtmMax` for cross-contract timestamp resolution. Its role in the larger system is a **shared CBS-response mapper** within the cancel service writing component, called by `cancelSvcWrib` during the cancel service workflow submission.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editInEKK1391C040()"])

    START --> CreateTemplate["Create CAANMsg template (EKK1391C040CBSMsg)"]
    CreateTemplate --> SetTemplateID["Set template ID = EKK1391C040"]
    SetTemplateID --> SetFuncCode["Set func_code"]
    SetFuncCode --> SetOperator["Set operator ID from param"]
    SetOperator --> SetOpeDate["Set operate date from param"]
    SetOpeDate --> SetOpeTime["Set operate datetime from param"]
    SetOpeTime --> GetWorkMap["Get workMap from param.getMappingWorkArea()"]
    GetWorkMap --> NullCheckWork{"workMap == null?"}
    NullCheckWork -->|Yes| InitWorkMap["Init workMap = new HashMap(); param.setMappingWorkArea()"]
    NullCheckWork -->|No| CheckDchskmstNo
    InitWorkMap --> CheckDchskmstNo{"workBeanListMap3 has dchskmst_no?"}
    CheckDchskmstNo -->|No| SetNullDchskmstNo["template.setNull(DCHSKMST_NO)"]
    CheckDchskmstNo -->|Yes| SetDchskmstNo["template.set(DCHSKMST_NO, dchskmst_no)"]
    SetNullDchskmstNo --> CheckFinSbtCd{"workBeanListMap3 has dchskmst_fin_sbt_cd?"}
    SetDchskmstNo --> CheckFinSbtCd
    CheckFinSbtCd -->|No| SetNullFinSbtCd["template.setNull(DCHSKMST_FIN_SBT_CD)"]
    CheckFinSbtCd -->|Yes| SetFinSbtCd["template.set(DCHSKMST_FIN_SBT_CD, dchskmst_fin_sbt_cd)"]
    SetNullFinSbtCd --> CheckEndYmd{"workBeanListMap3 has dchskmst_end_ymd?"}
    SetFinSbtCd --> CheckEndYmd
    CheckEndYmd -->|No| SetNullEndYmd["template.setNull(DCHSKMST_END_YMD)"]
    CheckEndYmd -->|Yes| SetEndYmd["template.set(DCHSKMST_END_YMD, dchskmst_end_ymd)"]
    SetNullEndYmd --> CheckIdoDiv{"workBeanListMap3 has ido_div?"}
    SetEndYmd --> CheckIdoDiv
    CheckIdoDiv -->|No| SetNullIdoDiv["template.setNull(IDO_DIV)"]
    CheckIdoDiv -->|Yes| SetIdoDiv["template.set(IDO_DIV, ido_div)"]
    SetNullIdoDiv --> CheckFinOpty{"workBeanListMap3 has dchskmst_fin_opty_cd?"}
    SetIdoDiv --> CheckFinOpty
    CheckFinOpty -->|No| SetNullFinOpty["template.setNull(DCHSKMST_FIN_OPTY_CD)"]
    CheckFinOpty -->|Yes| SetFinOpty["template.set(DCHSKMST_FIN_OPTY_CD, dchskmst_fin_opty_cd)"]
    SetNullFinOpty --> CallGetDtmMax["CALL getDtmMax(param, 2, listNo, hanyoSvcCdList)"]
    SetFinOpty --> CallGetDtmMax
    CallGetDtmMax --> CheckMaxDtm{"maxDtm is empty?"}
    CheckMaxDtm -->|Yes| CheckUpdTmBf{"workBeanListMap3 has upd_dtm_bf?"}
    CheckMaxDtm -->|No| SetUpdTmMax["template.set(UPD_DTM_BF, maxDtm)"]
    CheckUpdTmBf -->|No| SetNullUpdTmBf["template.setNull(UPD_DTM_BF)"]
    CheckUpdTmBf -->|Yes| SetUpdTmBf["template.set(UPD_DTM_BF, upd_dtm_bf)"]
    SetNullUpdTmBf --> END_RETURN(["Return template"])
    SetUpdTmBf --> END_RETURN
    SetUpdTmMax --> END_RETURN
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Request parameter holder carrying operator metadata (operator ID, operate date, operate time) and the mapping work area. It bridges the screen layer with the CBS response message. |
| 2 | `workBeanListMap3` | `HashMap` | Work data map extracted from the previous screen step. Contains six keys: `dchskmst_no` (data extraction item settings number), `dchskmst_fin_sbt_cd` (completion type code), `dchskmst_end_ymd` (completion end date), `ido_div` (move division), `dchskmst_fin_opty_cd` (completion opportunity code), and `upd_dtm_bf` (update datetime before). Values may be `null` or empty string to indicate missing/unchecked fields. |
| 3 | `func_code` | `String` | Function code identifying which screen/business function invoked this mapper. Set directly into the CBS response template for audit/traceability. |
| 4 | `listNo` | `String` | List number identifying the specific line/item within the service cancellation list. Used by `getDtmMax` to scope the timestamp search to the correct contract line. |
| 5 | `hanyoSvcCdList` | `ArrayList` | List of service codes for services with partial cancellation or service-level modifications (`hanyo` = partial/half). Each entry is a HashMap containing `svc_kei_no` (service contract number) and `upd_dtm_bf` (previous update datetime). Used to determine the maximum update timestamp across related contracts. |

**External state / instance fields read:** None. This method is stateless and reads only its parameters and calls the private instance method `getDtmMax`.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKCancelSvcWribCC.getDtmMax` | (private method) | `svc_kei_no` / `upd_dtm_bf` fields | Calls `getDtmMax(param, 2, listNo, hanyoSvcCdList)` to find the service contract with the latest update datetime among partial-cancellation services. The `kbn=2` parameter selects the partial cancellation path. |
| - | `JKKBpCommon.getLastDtmBySvcKeiNo` (called within `getDtmMax`) | — | Service contract records (by `svc_kei_no`) | Within `getDtmMax`, calls `JKKBpCommon.getLastDtmBySvcKeiNo` to fetch the actual update datetime for a given service contract number. |

**Note:** This method is a **pure mapper** — it does not directly perform any CRUD operations itself. All database/entity access is delegated to `getDtmMax`, which in turn calls `JKKBpCommon.getLastDtmBySvcKeiNo` to look up the latest update datetime for service contracts. The called `setNull` methods referenced in pre-computed evidence originate from OTHER methods in `JKKCancelSvcWribCC`, not from `editInEKK1391C040`.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKCancelSvcWribCC.getDtmMax` | — | Service contract data (svc_kei_no, upd_dtm_bf) | Resolves the maximum update datetime across service contracts in the partial cancellation list to correctly populate `upd_dtm_bf` in the CBS response. |
| R | `JKKBpCommon.getLastDtmBySvcKeiNo` | — | Service contract records | Fetches the last update datetime for a specific service contract number; used internally by `getDtmMax` to compare timestamps. |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `getDtmMax` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKCancelSvcWribCC.cancelSvcWrib` | `cancelSvcWrib` -> `editInEKK1391C040` | `getDtmMax [R] svc_kei_no / upd_dtm_bf` |

**Caller Details:**
- `JKKCancelSvcWribCC.cancelSvcWrib()` — This is a CBS method in the same class that orchestrates cancel service writing. It calls `editInEKK1391C040` to map the data extraction item settings completion response message during the service cancellation workflow.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialize CBS template `(L394)`

> Creates the CAANMsg response template and populates metadata fields.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template = new CAANMsg(EKK1391C040CBSMsg.class.getName())` // Create CBS response template |
| 2 | SET | `template.set(EKK1391C040CBSMsg.TEMPLATEID, "EKK1391C040")` // Template ID [-> "EKK1391C040"] |
| 3 | SET | `template.set(EKK1391C040CBSMsg.FUNC_CODE, func_code)` // Function code from caller |
| 4 | SET | `operatorId = param.getControlMapData(SCControlMapKeys.OPERATOR_ID)` // Operator executing the action |
| 5 | SET | `template.set(JCMConstants.OPERATOR_ID_KEY, operatorId)` // Write operator ID to template |
| 6 | SET | `operateDate = param.getControlMapData(SCControlMapKeys.OPE_DATE)` // Operating date from control data |
| 7 | SET | `template.set(JCMConstants.OPERATE_DATE_KEY, operateDate)` // Write operate date to template |
| 8 | SET | `operateDateTime = param.getControlMapData(SCControlMapKeys.OPE_TIME)` // Operating time from control data |
| 9 | SET | `template.set(JCMConstants.OPERATE_DATETIME_KEY, operateDateTime)` // Write operate datetime to template |

---

**Block 2** — [SET] Get work mapping area `(L418)`

> Retrieves the mapping work area from the request parameter. If null, initializes a new HashMap.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap = param.getMappingWorkArea()` // Get existing work area map |
| 2 | IF [null check] `workMap == null` `(L419)` | |

**Block 2.1** — [IF-ELSE] Work map null check `[workMap == null]` `(L419)`

> If the work map is null, initialize a new HashMap and store it in the parameter.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap = new HashMap()` // Create empty work map |
| 2 | EXEC | `param.setMappingWorkArea(workMap)` // Store in param |

---

**Block 3** — [IF-ELSE] Map `dchskmst_no` (data extraction item settings number) `(L428)`

> Maps the data extraction item settings number. Japanese comment: データ抽出項目設定番号 → データ抽出項目設定番号 (Data extraction item settings number → Data extraction item settings number).

| # | Type | Code |
|---|------|------|
| 1 | IF [null/empty check] `(L428)` | `workBeanListMap3 == null OR workBeanListMap3.get("dchskmst_no") == null OR "".equals(workBeanListMap3.get("dchskmst_no"))` |

**Block 3.1** — [IF] `dchskmst_no` is null or empty `[dchskmst_no is missing]` `(L429)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.setNull(EKK1391C040CBSMsg.DCHSKMST_NO)` // Set null for data extraction item settings number |

**Block 3.2** — [ELSE] `dchskmst_no` has a value `[dchskmst_no has value]` `(L432)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1391C040CBSMsg.DCHSKMST_NO, (String)workBeanListMap3.get("dchskmst_no"))` // Set data extraction item settings number |

---

**Block 4** — [IF-ELSE] Map `dchskmst_fin_sbt_cd` (completion type code) `(L438)`

> Maps the data extraction item settings completion type code. Japanese comment: データ抽出項目設定完了種類コード → データ抽出項目設定完了種類コード (Data extraction item settings completion type code → Data extraction item settings completion type code).

| # | Type | Code |
|---|------|------|
| 1 | IF [null/empty check] `(L438)` | `workBeanListMap3 == null OR workBeanListMap3.get("dchskmst_fin_sbt_cd") == null OR "".equals(workBeanListMap3.get("dchskmst_fin_sbt_cd"))` |

**Block 4.1** — [IF] `dchskmst_fin_sbt_cd` is null or empty `[completion type code is missing]` `(L439)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.setNull(EKK1391C040CBSMsg.DCHSKMST_FIN_SBT_CD)` // Set null for completion type code |

**Block 4.2** — [ELSE] `dchskmst_fin_sbt_cd` has a value `[completion type code has value]` `(L442)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1391C040CBSMsg.DCHSKMST_FIN_SBT_CD, (String)workBeanListMap3.get("dchskmst_fin_sbt_cd"))` // Set completion type code |

---

**Block 5** — [IF-ELSE] Map `dchskmst_end_ymd` (completion end date) `(L448)`

> Maps the data extraction item settings completion end date. Japanese comment: データ抽出項目設定終了年月日 → データ抽出項目設定終了年月日 (Data extraction item settings completion end date → Data extraction item settings completion end date).

| # | Type | Code |
|---|------|------|
| 1 | IF [null/empty check] `(L448)` | `workBeanListMap3 == null OR workBeanListMap3.get("dchskmst_end_ymd") == null OR "".equals(workBeanListMap3.get("dchskmst_end_ymd"))` |

**Block 5.1** — [IF] `dchskmst_end_ymd` is null or empty `[completion end date is missing]` `(L449)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.setNull(EKK1391C040CBSMsg.DCHSKMST_END_YMD)` // Set null for completion end date |

**Block 5.2** — [ELSE] `dchskmst_end_ymd` has a value `[completion end date has value]` `(L452)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1391C040CBSMsg.DCHSKMST_END_YMD, (String)workBeanListMap3.get("dchskmst_end_ymd"))` // Set completion end date |

---

**Block 6** — [IF-ELSE] Map `ido_div` (move division) `(L456)`

> Maps the move division flag. Japanese comment: 異動区分 → 異動区分 (Move division → Move division). Move division indicates the type of service contract transfer/move.

| # | Type | Code |
|---|------|------|
| 1 | IF [null/empty check] `(L456)` | `workBeanListMap3 == null OR workBeanListMap3.get("ido_div") == null OR "".equals(workBeanListMap3.get("ido_div"))` |

**Block 6.1** — [IF] `ido_div` is null or empty `[move division is missing]` `(L457)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.setNull(EKK1391C040CBSMsg.IDO_DIV)` // Set null for move division |

**Block 6.2** — [ELSE] `ido_div` has a value `[move division has value]` `(L460)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1391C040CBSMsg.IDO_DIV, (String)workBeanListMap3.get("ido_div"))` // Set move division |

---

**Block 7** — [IF-ELSE] Map `dchskmst_fin_opty_cd` (completion opportunity code) `(L463)`

> Maps the data extraction item settings completion opportunity code. Japanese comment: データ抽出項目設定完了契約コード → データ抽出項目設定完了契約コード (Data extraction item settings completion opportunity code → Data extraction item settings completion opportunity code).

| # | Type | Code |
|---|------|------|
| 1 | IF [null/empty check] `(L463)` | `workBeanListMap3 == null OR workBeanListMap3.get("dchskmst_fin_opty_cd") == null OR "".equals(workBeanListMap3.get("dchskmst_fin_opty_cd"))` |

**Block 7.1** — [IF] `dchskmst_fin_opty_cd` is null or empty `[completion opportunity code is missing]` `(L464)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.setNull(EKK1391C040CBSMsg.DCHSKMST_FIN_OPTY_CD)` // Set null for completion opportunity code |

**Block 7.2** — [ELSE] `dchskmst_fin_opty_cd` has a value `[completion opportunity code has value]` `(L467)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1391C040CBSMsg.DCHSKMST_FIN_OPTY_CD, (String)workBeanListMap3.get("dchskmst_fin_opty_cd"))` // Set completion opportunity code |

---

**Block 8** — [CALL] Get max update datetime `[IT1-2012-0000811]` `(L475)`

> Japanese comment: 最終更新日が最大のサービス契約番号を取得 (Get the service contract number with the latest update date). Bug fix ticket IT1-2012-0000811 (データ抽出項目設定もサービスの排斥制御に含むように変更) — changed to include data extraction item settings in service exclusion control.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `maxDtm = getDtmMax(param, 2, listNo, hanyoSvcCdList)` // kbn=2 selects partial cancellation path |

---

**Block 9** — [IF-ELSE] Map `upd_dtm_bf` (update datetime before) `(L478)`

> Japanese comment: 更新年月日时分秒(更新前) → 更新年月日时分秒(更新前) (Update datetime before → Update datetime before). The logic depends on whether `getDtmMax` found a newer timestamp.

| # | Type | Code |
|---|------|------|
| 1 | IF [check maxDtm] `(L478)` | `"".equals(maxDtm)` — maxDtm is empty |

**Block 9.1** — [IF] `maxDtm` is empty `[no newer contract found, use existing value]` `(L478)`

> No newer update was found among related contracts, so pass through the existing `upd_dtm_bf` from work data.

| # | Type | Code |
|---|------|------|
| 1 | IF [null/empty check] `(L481)` | `workBeanListMap3 == null OR workBeanListMap3.get("upd_dtm_bf") == null OR "".equals(workBeanListMap3.get("upd_dtm_bf"))` |

**Block 9.1.1** — [IF] `upd_dtm_bf` is null or empty `[upd_dtm_bf is missing]` `(L482)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.setNull(EKK1391C040CBSMsg.UPD_DTM_BF)` // Set null for update datetime before |

**Block 9.1.2** — [ELSE] `upd_dtm_bf` has a value `[upd_dtm_bf has value]` `(L485)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1391C040CBSMsg.UPD_DTM_BF, (String)workBeanListMap3.get("upd_dtm_bf"))` // Pass through existing update datetime before |

**Block 9.2** — [ELSE] `maxDtm` is NOT empty `[newer contract found, override with maxDtm]` `(L489)`

> `getDtmMax` found a service contract with a newer update datetime. Override the `upd_dtm_bf` with this max value to enforce concurrency control.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(EKK1391C040CBSMsg.UPD_DTM_BF, maxDtm)` // Override with maximum update datetime from related contracts |

---

**Block 10** — [RETURN] Return template `(L494)`

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return template` // Return populated CBS response message |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `dchskmst_no` | Field | Data extraction item settings number — internal sequence/identifier for the data extraction item settings record in the service cancellation workflow |
| `dchskmst_fin_sbt_cd` | Field | Data extraction item settings completion type code — classification of how the data extraction was completed (e.g., normal completion, abnormal termination) |
| `dchskmst_end_ymd` | Field | Data extraction item settings completion end date — the date when the data extraction item settings process concluded (year/month/day format) |
| `ido_div` | Field | Move division — indicates the type of service contract transfer/move operation being performed in the cancellation workflow |
| `dchskmst_fin_opty_cd` | Field | Data extraction item settings completion opportunity code — identifies the business opportunity/channel through which the data extraction was completed |
| `upd_dtm_bf` | Field | Update datetime before (before update) — the timestamp of the service contract record prior to the current update; used for optimistic concurrency control |
| `svc_kei_no` | Field | Service contract number — unique identifier for a service contract line in the telecom service management system |
| `hanyoSvcCdList` | Field | Partial/cancellation service code list — list of service codes for services undergoing partial cancellation or modification; `hanyo` (部分) means "partial" |
| `listNo` | Field | List number — identifies the specific line/item within the service cancellation list being processed |
| `func_code` | Field | Function code — identifies the screen or business function that initiated the request |
| `maxDtm` | Field | Maximum datetime — the latest update timestamp found across related service contracts, used for concurrency control |
| `kbn` | Field | Classification (区分) — discriminant parameter for `getDtmMax`; value `2` selects the partial cancellation path |
| `CAANMsg` | Class | Canonical message wrapper — Fujitsu's generic message class used for CBS request/response data exchange |
| `EKK1391C040` | Business term | Data extraction item settings completion screen — the CBS screen/module for confirming data extraction item settings during service cancellation |
| `JKKCancelSvcWribCC` | Class | JKK Cancel Service Writing Common Component — custom component handling CBS response message mapping for service cancellation workflows |
| `IRequestParameterReadWrite` | Interface | Request parameter read/write interface — contract for accessing screen input data and control metadata |
| `getDtmMax` | Method | Get maximum datetime — private method that iterates through service contracts to find the one with the most recent update timestamp |
| IT1-2012-0000811 | Ticket ID | Change request ticket — updated logic to include data extraction item settings in service exclusion control (排斥制御) |
| 排斥制御 (Haigai Seigyo) | Business term | Exclusion control — mechanism to prevent conflicting updates to the same service contract by comparing update timestamps |
| CBS | Acronym | Component-Based System — Fujitsu's application server framework for enterprise business systems |
| CC | Acronym | Common Component — shared reusable business logic component |
