---

# Business Logic — WribSvcKeiMover.transform() [80 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.WribSvcKeiMover` |
| Layer | CC/Common Component — shared utility within the custom/common package |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### WribSvcKeiMover.transform()

This method is a **data transformation and routing utility** that maps incoming telecom service contract messages (`CAANMsg`) into a standardized `HashMap<String, String>` output structure. It handles **two business operations**: **withdrawal service** (keiKind="1") and **reduction service** (keiKind≠"1"), where withdrawal represents a customer cancelling their entire service contract line, and reduction represents modifying or downgrading an existing contract. The method implements a **conditional dispatch pattern** — branching on the contract type code to apply slightly different data mappings. For withdrawal service, it applies a **date adjustment rule** (v5.00.24): when the start date is a sentinel value "20991231" (representing an open-ended/unset date), it computes the actual start date as the day after the end date. For reduction service, it applies an additional **special handling rule** (LT-2013-0000101): when the service contract code is "DT0000002" (Net Phone TV Three-Point Contract — a bundled internet/phone/TV package), it clears both the start and end dates since such bundled contracts do not have fixed service period dates. The method was refactored in v5.00.20 to consolidate data extraction from a single service interface (`EKK0451B011CBSMsg1List`) instead of multiple interfaces, removing the previous `DchskmstMover` class. It serves as a **shared transformation utility** called by numerous screens, batches, and CBS routing components across the system.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["transform(CAANMsg in)"])
    END_NODE(["Return out"])

    START --> CREATE_OUT["Create HashMap<String, String> out"]
    CREATE_OUT --> GET_KEIKIND["Extract keiKind from WRIB_DCHS_HAMBET_CD"]
    GET_KEIKIND --> COND_KEIKIND{"keiKind equals 1?"}

    COND_KEIKIND -->|Yes| BRANCH_WITHDRAWAL["Withdrawal Service Processing"]
    COND_KEIKIND -->|No| BRANCH_REDUCTION["Reduction Service Processing"]

    BRANCH_WITHDRAWAL --> GET_SYMD["Extract sYmd from SVC_CHRG_DCHSKMST_STAYMD"]
    GET_SYMD --> GET_EYMD["Extract eYmd from SVC_CHRG_DCHSKMST_ENDYMD"]
    GET_EYMD --> COND_SYMD{"sYmd equals 20991231?"}

    COND_SYMD -->|Yes| COND_EYMD{"eYmd not null and not 20991231?"}
    COND_SYMD -->|No| PUT_COMMON_W["Put common fields into out"]

    COND_EYMD -->|Yes| CALC_SYMD["sYmd = JPCDateUtil.addDay(eYmd, 1)"]
    COND_EYMD -->|No| PUT_COMMON_W
    CALC_SYMD --> PUT_COMMON_W

    PUT_COMMON_W --> PUT_STAYMD_W["Set staymd to sYmd"]
    PUT_STAYMD_W --> PUT_REST_W["Put remaining fields into out"]
    PUT_REST_W --> END_NODE

    BRANCH_REDUCTION --> PUT_COMMON_R["Put common fields into out"]
    PUT_COMMON_R --> PUT_STAYMD_R["Set staymd from input"]
    PUT_STAYMD_R --> PUT_REST_R["Put remaining fields into out"]
    PUT_REST_R --> CHECK_TGHANSOKU{"WRISVC_DCHSKM_CD equals DT0000002?"}

    CHECK_TGHANSOKU -->|Yes| CLEAR_DATES["Clear staymd and endymd to empty strings"]
    CHECK_TGHANSOKU -->|No| END_NODE
    CLEAR_DATES --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `in` | `CAANMsg` | An incoming message container carrying telecom service contract withdrawal or reduction data. It contains fields extracted from the CBS message definition `EKK0451B011CBSMsg1List`, including service contract number, status, type codes, campaign information, date ranges, and service category codes. The `WRIB_DCHS_HAMBET_CD` field (contract type/binding code) determines the processing branch — "1" means withdrawal (complete cancellation), while any other value means reduction (downgrade/modification). |

**Instance fields / external state:** None — this method is purely functional with no reliance on instance fields or static mutable state. It reads from the input `CAANMsg` and invokes utility methods (`JPCDateUtil.addDay`, `JKKWribSvcKeiOperateCC.KeiKind.getKeiKind()`).

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `in.getString` (EKK0451B011CBSMsg1List.WRIB_DCHS_HAMBET_CD) | - | - | Reads contract type code from input message to determine withdrawal vs. reduction |
| R | `in.getString` (EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_STAYMD) | - | - | Reads service charge period start date from input message |
| R | `in.getString` (EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_ENDYMD) | - | - | Reads service charge period end date from input message |
| R | `in.getString` (EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_NO) | - | - | Reads withdrawal/reduction service contract number |
| R | `in.getString` (EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_STAT) | - | - | Reads withdrawal/reduction service status code |
| R | `in.getString` (EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_STAT_NM) | - | - | Reads withdrawal/reduction service status name |
| R | `in.getString` (EKK0451B011CBSMsg1List.WRIB_DCHS_TYPE_CD) | - | - | Reads withdrawal service type code |
| R | `in.getString` (EKK0451B011CBSMsg1List.WRIB_DCHS_TYPE_CD_NM) | - | - | Reads withdrawal service type code name |
| R | `in.getString` (EKK0451B011CBSMsg1List.DSP_CAMPAIGN_DCHSKM_CD) | - | - | Reads campaign code associated with the withdrawal/reduction service |
| R | `in.getString` (EKK0451B011CBSMsg1List.WRISVC_DCHSKM_NM) | - | - | Reads withdrawal/reduction service name |
| R | `in.getString` (EKK0451B011CBSMsg1List.MSKM_YMD) | - | - | Reads service activation date (start date) |
| R | `in.getString` (EKK0451B011CBSMsg1List.WRISVC_DCHSKM_CD) | - | - | Reads withdrawal/reduction service code (used to identify "DT0000002" bundled contracts) |
| R | `in.getString` (EKK0451B011CBSMsg1List.APLY_JUN_NM) | - | - | Reads application order name |
| C | `JKKWribSvcKeiOperateCC.KeiKind.WRIB.getKeiKind()` | - | - | Returns the constant "1" indicating withdrawal service kind |
| C | `JKKWribSvcKeiOperateCC.KeiKind.HNSOKU.getKeiKind()` | - | - | Returns the constant indicating reduction service kind |
| C | `JPCDateUtil.addDay(eYmd, 1)` | - | - | Utility to compute the next day from a given date string (used for date adjustment in withdrawal processing v5.00.24) |

**Note:** This method does not perform any database reads, creates, updates, or deletes. It is a pure data transformation (mapping) method that reads from the `CAANMsg` input container and writes to a `HashMap<String, String>` output. All data originates from upstream CBS interfaces (`EKK0451B011CBSMsg1List`). The only business logic is the date adjustment rule for withdrawal services and the bundled-contract date clearing rule for reduction services.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JKKBatKKCashPostBase | `JKKBatKKCashPostBase.execute()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 2 | Utility: Items | `Items.map()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 3 | CBS: JECNA0040001TPMA | `JECNA0040001TPMA.invoke()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 4 | CBS: JECNA0040002TPMA | `JECNA0040002TPMA.invoke()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 5 | CBS: JECNA0150001TPMA | `JECNA0150001TPMA.callPost()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 6 | CBS: JECNA0160001TPMA | `JECNA0160001TPMA.callPost()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 7 | CBS: JKKejbKKA0010002SecProc | `JKKejbKKA0010002SecProc.searchCredit()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 8 | CBS: JKKejbKKA001SecProc | `JKKejbKKA001SecProc.shokaiOsrIrai()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 9 | CBS: JKKejbKKA0110001SecProc | `JKKejbKKA0110001SecProc.execute()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 10 | CBS: JCKCtrlCisInfoImpl | `JCKCtrlCisInfoImpl.call_CIS()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 11 | CBS: JCKCtrlCisInfoStubImpl | `JCKCtrlCisInfoStubImpl.call_CIS()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 12 | CBS: JCRCtrlTnInfoImpl | `JCRCtrlTnInfoImpl.ctrlTnInfo_CRA0001()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 13 | CBS: JKKCtrlMvnoSvcKeiInfoImpl | `JKKCtrlMvnoSvcKeiInfoImpl.ctrlMvnoInfo_KKA0003()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 14 | CBS: JZMCtrlCisInfoImpl | `JZMCtrlCisInfoImpl.ctrlCisInfo_ZMA0001()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |
| 15 | CBS: JZMCtrlTrankInfoImpl | `JZMCtrlTrankInfoImpl.call_TRANK()` -> `WribSvcKeiMover.transform` | `in.getString [R] EKK0451B011CBS` |

## 6. Per-Branch Detail Blocks

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

Initialize the output HashMap for mapping transformed data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `out = new HashMap<String, String>(DEFAULT_HASH_SIZE)` // Create output map with default capacity |

---

**Block 2** — [IF] (`"1".equals(keiKind)` — WRIB_DCHS_HAMBET_CD equals "1") (L17052) `[CD00002_ARI="1"]`

Withdrawal service processing branch. When the contract type/binding code is "1", this branch handles complete cancellation (withdrawal) of a service contract line. It applies a date adjustment rule from v5.00.24.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `keiKind = in.getString(EKK0451B011CBSMsg1List.WRIB_DCHS_HAMBET_CD)` // Read contract type code from input |
| 2 | SET | `sYmd = in.getString(EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_STAYMD)` // Read service charge period start date [v5.00.24] |
| 3 | SET | `eYmd = in.getString(EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_ENDYMD)` // Read service charge period end date [v5.00.24] |

**Block 2.1** — [IF-IF NESTED] (`"20991231".equals(sYmd)` AND `eYmd` valid) (L17059)

Date adjustment rule (v5.00.24): When the start date is the sentinel value "20991231" (representing an unset/open-ended date), and the end date is also not "20991231", compute the actual start date as one day after the end date.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"20991231".equals(sYmd)` // Check if start date is sentinel value (unset/open-ended) |
| 2 | IF | `!isNullBlank(eYmd) && !"20991231".equals(eYmd)` // Check if end date is valid and not sentinel |
| 3 | SET | `sYmd = JPCDateUtil.addDay(eYmd, 1)` // Compute start date as day after end date [-> addDay utility] |

**Block 2.2** — [PROCESSING: Put common fields] (L17063)

Populate the output map with shared withdrawal service fields from the CBS message.

| # | Type | Code |
|---|------|------|
| 1 | SET | `out.put("no", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_NO))` // Service contract number |
| 2 | SET | `out.put("kei_kind", JKKWribSvcKeiOperateCC.KeiKind.WRIB.getKeiKind())` // [-> KeiKind.WRIB = "1"] |
| 3 | SET | `out.put("stat", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_STAT))` // Service status code |
| 4 | SET | `out.put("stat_nm", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_STAT_NM))` // Service status name |
| 5 | SET | `out.put("type_cd", in.getString(EKK0451B011CBSMsg1List.WRIB_DCHS_TYPE_CD))` // Withdrawal service type code |
| 6 | SET | `out.put("type_cd_nm", in.getString(EKK0451B011CBSMsg1List.WRIB_DCHS_TYPE_CD_NM))` // Withdrawal service type code name |
| 7 | SET | `out.put("campaign_cd", in.getString(EKK0451B011CBSMsg1List.DSP_CAMPAIGN_DCHSKM_CD))` // Campaign code |
| 8 | SET | `out.put("campaign_nm", in.getString(EKK0451B011CBSMsg1List.WRISVC_DCHSKM_NM))` // Campaign/service name |
| 9 | SET | `out.put("mskm_ymd", in.getString(EKK0451B011CBSMsg1List.MSKM_YMD))` // Service activation date |
| 10 | SET | `out.put("staymd", sYmd)` // [v5.00.24] Adjusted start date (may be computed in Block 2.1) |
| 11 | SET | `out.put("endymd", in.getString(EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_ENDYMD))` // Service end date |
| 12 | SET | `out.put("wrib_svc_cd", in.getString(EKK0451B011CBSMsg1List.WRISVC_DCHSKM_CD))` // Withdrawal/reduction service code |
| 13 | SET | `out.put("aply_jun_nm", in.getString(EKK0451B011CBSMsg1List.APLY_JUN_NM))` // Application order name |

---

**Block 3** — [ELSE] (`"1"` does not equal keiKind) (L17079)

Reduction service processing branch. When the contract type/binding code is not "1", this branch handles modification/downgrade (reduction) of a service contract line. It uses the raw start date from input and applies a special handling rule for bundled contracts (LT-2013-0000101).

| # | Type | Code |
|---|------|------|
| 1 | SET | `out.put("no", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_NO))` // Service contract number |
| 2 | SET | `out.put("kei_kind", JKKWribSvcKeiOperateCC.KeiKind.HNSOKU.getKeiKind())` // [-> KeiKind.HNSOKU = reduction type] |
| 3 | SET | `out.put("stat", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_STAT))` // Service status code |
| 4 | SET | `out.put("stat_nm", in.getString(EKK0451B011CBSMsg1List.WRIBSVK_DCHSKMST_STAT_NM))` // Service status name |
| 5 | SET | `out.put("type_cd", in.getString(EKK0451B011CBSMsg1List.WRIB_DCHS_TYPE_CD))` // Withdrawal service type code |
| 6 | SET | `out.put("type_cd_nm", in.getString(EKK0451B011CBSMsg1List.WRIB_DCHS_TYPE_CD_NM))` // Withdrawal service type code name |
| 7 | SET | `out.put("campaign_cd", in.getString(EKK0451B011CBSMsg1List.DSP_CAMPAIGN_DCHSKM_CD))` // Campaign code |
| 8 | SET | `out.put("campaign_nm", in.getString(EKK0451B011CBSMsg1List.WRISVC_DCHSKM_NM))` // Campaign/service name |
| 9 | SET | `out.put("mskm_ymd", in.getString(EKK0451B011CBSMsg1List.MSKM_YMD))` // Service activation date |
| 10 | SET | `out.put("staymd", in.getString(EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_STAYMD))` // Service start date from input |
| 11 | SET | `out.put("endymd", in.getString(EKK0451B011CBSMsg1List.SVC_CHRG_DCHSKMST_ENDYMD))` // Service end date |
| 12 | SET | `out.put("wrib_svc_cd", in.getString(EKK0451B011CBSMsg1List.WRISVC_DCHSKM_CD))` // Service code |
| 13 | SET | `out.put("aply_jun_nm", in.getString(EKK0451B011CBSMsg1List.APLY_JUN_NM))` // Application order name |

**Block 3.1** — [IF] (`TgHansoku.equals(WRISVC_DCHSKM_CD)`) (L17094) `[DT0000002 = Net Phone TV Three-Point Contract]`

Special handling for bundled net/phone/TV contracts (LT-2013-0000101). When the service contract code equals "DT0000002" (Net Phone TV Three-Point Contract — a bundled internet, phone, and TV package), clear both the start date (staymd) and end date (endymd) to empty strings since bundled contracts do not have fixed service period dates.

| # | Type | Code |
|---|------|------|
| 1 | SET | `TgHansoku = "DT0000002"` // Local constant: Net Phone TV Three-Point Contract bundled service |
| 2 | IF | `TgHansoku.equals(in.getString(EKK0451B011CBSMsg1List.WRISVC_DCHSKM_CD))` // Check if bundled contract |
| 3 | SET | `out.put("staymd", "")` // Clear start date — not applicable for bundled contracts |
| 4 | SET | `out.put("endymd", "")` // Clear end date — not applicable for bundled contracts |

---

**Block 4** — [RETURN] (L17114)

Return the transformed HashMap to the caller.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return out` // Return transformed data to caller |

---

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `WRIB_DCHS_HAMBET_CD` | Field | Contract type/binding code — determines whether the service is withdrawal (cancellation, "1") or reduction (modification, other values) |
| `WRIBSVK_DCHSKMST_NO` | Field | Withdrawal/Reduction Service Contract Number — unique identifier for the contract modification line item |
| `WRIBSVK_DCHSKMST_STAT` | Field | Withdrawal/Reduction Service Status Code — current processing status of the contract modification |
| `WRIBSVK_DCHSKMST_STAT_NM` | Field | Withdrawal/Reduction Service Status Name — human-readable description of the current status |
| `WRIB_DCHS_TYPE_CD` | Field | Withdrawal Service Type Code — classifies the type of withdrawal/modification action |
| `WRIB_DCHS_TYPE_CD_NM` | Field | Withdrawal Service Type Code Name — human-readable description of the type |
| `DSP_CAMPAIGN_DCHSKM_CD` | Field | Display Campaign Code for Withdrawal/Reduction — promotional or campaign identifier associated with the modification |
| `WRISVC_DCHSKM_NM` | Field | Withdrawal/Reduction Service Name — name of the service being modified |
| `MSKM_YMD` | Field | Service Activation Date — the date when the service becomes effective (from "mskm" = 開始, "start") |
| `SVC_CHRG_DCHSKMST_STAYMD` | Field | Service Charge Period Start Date — the date the billing period begins for the modified service |
| `SVC_CHRG_DCHSKMST_ENDYMD` | Field | Service Charge Period End Date — the date the billing period ends for the modified service |
| `WRISVC_DCHSKM_CD` | Field | Withdrawal/Reduction Service Code — identifies the specific service category (e.g., "DT0000002" for bundled contract) |
| `APLY_JUN_NM` | Field | Application Order Name — the display name for the application order number |
| `KeiKind.WRIB` | Constant | Contract kind for withdrawal — value "1", representing complete cancellation of a service contract line |
| `KeiKind.HNSOKU` | Constant | Contract kind for reduction — represents modification/downgrade of an existing service contract line |
| "20991231" | Sentinel | Open-ended/unset date sentinel — used to indicate a date field has not been set; when encountered as start date, it triggers date computation logic |
| "DT0000002" | Constant | Net Phone TV Three-Point Contract — a bundled service package combining internet (net), telephone, and television services |
| WRIB | Acronym | Withdrawal — service contract cancellation operation |
| DCHS | Acronym | Deduction/Reduction — service contract modification or downgrade operation |
| DCHSKMST | Acronym | Deduction Service Master — the master record for deduction (reduction) service contract modifications |
| v5.00.20 | Version | Refactoring version that consolidated data extraction to a single CBS interface |
| v5.00.24 | Version | Version that added the start date adjustment rule when start date is the sentinel "20991231" |
| LT-2013-0000101 | Ticket | Change request ticket — added special handling for bundled net/phone/TV contracts to clear date fields |
| CAANMsg | Type | Message container class — carries telecom billing/contract data fields in key-value format |
