# Business Logic — JBSbatKKEoTVChgeFix.insertKktkSvcKeiBcasDslInfo() [540 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKEoTVChgeFix` |
| Layer | Service (Batch Processing) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKEoTVChgeFix.insertKktkSvcKeiBcasDslInfo()

This method performs the **B-CAS subscription cancellation registration** into the Device Provision Service Contract table (KK_T_KKTK_SVC_KEI) when a customer exchanges their STB (Set-Top Box) to a 4K STB, or conversely when exchanging from a 4K STB back to an STB (which triggers a work-cancellation workflow). It is a batch-level service method that maps B-CAS provider information into a comprehensive 171-field row for the `KK_T_KKTK_SVC_KEI` table. The method implements a **data aggregation and mapping pattern** -- it receives a `JBSbatCommonDBInterface` containing source B-CAS contract data, determines the appropriate service cancellation reason code based on the STB exchange direction, and then systematically copies all relevant fields (149 B-CAS fields plus 22 fixed/derived values) into a flat `Object[]` array. The resulting array is passed to `executeKK_T_KKTK_SVC_KEI_PKINSERT` for primary-key-based INSERT/UPSERT into the database. This method serves as a critical data bridge between the B-CAS provider information layer and the device provisioning service contract layer within the eo customer management system, and is specifically invoked during STB exchange batch processing flows.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["insertKktkSvcKeiBcasDslInfo"])
    START --> GET_SYSDATE["Get systemDateTimeStamp"]
    GET_SYSDATE --> PARAM_CHECK{"changeStbPettern equals 0?"}
    PARAM_CHECK -- Yes --> SVC_NORMAL["svcDlreCd = 01 Normal Cancellation"]
    PARAM_CHECK -- No --> SVC_CANCEL["svcDlreCd = 03 Cancellation Work Cancel"]
    SVC_NORMAL --> INIT_ARRAY["Init setParam array 171 elements"]
    SVC_CANCEL --> INIT_ARRAY
    INIT_ARRAY --> SET_DATA["Fill idx 0-170 from bCasInfo fields"]
    SET_DATA --> SET_FIXED["Set fixed values:
sysDate at idx 1,155
status 910 at idx 2
rsvAplyCd FIX 2 at idx 100
planEndYmd = rsvAplyYmd month end at idx 105
planEndYmd = rsvAplyYmd at idx 103
svcEndYmd = rsvAplyYmd at idx 124
svcEndPrd = month end at idx 125
svcDlreYmd = rsvAplyYmd at idx 126
svcDlreCd from branch at idx 127
svcDlreMemo blank at idx 128
mk_flg YK 0 at idx 161
regDttm sysDate at idx 155
regUserId batchUserId at idx 156
updDttm sysDate at idx 157
updUserId batchUserId at idx 158
delDttm blank at idx 159
delUserId blank at idx 160
empty strings idx 162-167"]
    SET_FIXED --> EXEC_INSERT["CALL executeKK_T_KKTK_SVC_KEI_PKINSERT"]
    EXEC_INSERT --> END(["Return"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `changeStbPettern` | `String` | STB exchange direction indicator. `"0"` means normal STB-to-4KSTB swap (standard cancellation). Any other value means 4KSTB-to-STB swap (work cancellation workflow). Determines the `svcDlreCd` (service cancellation reason code). |
| 2 | `bCasInfo` | `JBSbatCommonDBInterface` | B-CAS provider information object containing the source contract data. Holds 149+ fields covering device info, customer address, service contract details, billing plans, delivery information, installation data, CAS card details, router cancellation data, and more. This is the primary data source from which fields are extracted and mapped. |
| 3 | `paramRsvAplyYmd` | `String` | Reservation application year-month-date (YYYYMMDD format). Used as the effective date for plan end, service end, service cancellation, and reservation application date fields. Derived month-end dates are computed from this value. |

**Instance fields referenced:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `batchUserId` | `String` | The batch operation user ID used for audit trail (registration user, update user). Inherited from the parent class. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `JBSbatKKEoTVChgeFix.executeKK_T_KKTK_SVC_KEI_PKINSERT` | (Internal batch SC) | `KK_T_KKTK_SVC_KEI` | Inserts/UPSERTs the assembled 171-field service contract row into the Device Provision Service Contract table using primary key-based logic |
| R | `bCasInfo.getString(JBSbatKK_T_KKTK_SVC_KEI.KKTK_SVC_KEI_NO)` | - | In-memory B-CAS data | Reads the device provision service contract number from B-CAS information |
| R | `bCasInfo.getString(JBSbatKK_T_KKTK_SVC_KEI.KKTK_SVC_CD)` | - | In-memory B-CAS data | Reads the device provision service code from B-CAS information |
| R | `bCasInfo.getString(JBSbatKK_T_KKTK_SVC_KEI.PCRS_CD)` | - | In-memory B-CAS data | Reads the cost code from B-CAS information |
| R | `bCasInfo.getString(JBSbatKK_T_KKTK_SVC_KEI.PPLAN_CD)` | - | In-memory B-CAS data | Reads the plan code from B-CAS information |
| R | `JBSbatDateUtil.getSystemDateTimeStamp` | - | - | Gets the current system date-time stamp for audit timestamps |
| R | `JBSbatDateUtil.getEndOfMonth(rsvAplyYmd.substring(0, 6))` | - | - | Gets the last day of the month for computing plan end and service end dates |
| - | `JBSbatStringUtil.Rtrim` | - | - | Trims trailing whitespace from all string values extracted from bCasInfo |

**Table:** `KK_T_KKTK_SVC_KEI` (Device Provision Service Contract Table)

The single terminal CRUD operation is a **Create** (via `executeKK_T_KKTK_SVC_KEI_PKINSERT`) on the `KK_T_KKTK_SVC_KEI` entity table. All other data access is a **Read** from the in-memory `bCasInfo` parameter (which carries data from a prior database query) and utility calls for date/time operations.

## 5. Dependency Trace

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKEoTVChgeFix.createKokanAfSTBInfoKjCl() | `createKokanAfSTBInfoKjCl()` -> `insertKktkSvcKeiBcasDslInfo(CHANGE_KIKI_STB_TO_4KSTB, bCasInfo, super.opeDate)` | `executeKK_T_KKTK_SVC_KEI_PKINSERT [C] KK_T_KKTK_SVC_KEI` |
| 2 | Batch: JBSbatKKEoTVChgeFix.createKokanBfSTBInfo() | `createKokanBfSTBInfo()` -> `insertKktkSvcKeiBcasDslInfo(...)` | `executeKK_T_KKTK_SVC_KEI_PKINSERT [C] KK_T_KKTK_SVC_KEI` |

**Terminal operations from this method:**

| # | Operation | Type | Description |
|---|-----------|------|-------------|
| 1 | `executeKK_T_KKTK_SVC_KEI_PKINSERT(setParam)` | C (Create) | Inserts/UPSERTs the assembled row into `KK_T_KKTK_SVC_KEI` |
| 2 | `JBSbatStringUtil.Rtrim(...)` (x149) | - | String utility: trims trailing whitespace from bCasInfo fields |
| 3 | `bCasInfo.getString(...)` (x149) | R (Read) | Reads individual fields from B-CAS information interface |
| 4 | `JBSbatDateUtil.getSystemDateTimeStamp()` | R (Read) | Gets current system date-time stamp |
| 5 | `JBSbatDateUtil.getEndOfMonth(...)` (x2) | R (Read) | Computes last day of month for plan/service end date derivation |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] (Acquire system date-time stamp) (L12655)

> Retrieves the current system date-time stamp as the audit timestamp for all registration/update operations.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sysDate = JBSbatDateUtil.getSystemDateTimeStamp()` // Get system date-time stamp |
| 2 | SET | `rsvAplyYmd = paramRsvAplyYmd` // Pass-through: reservation application date |

**Block 2** — [IF/ELSE] (Determine service cancellation reason code based on STB exchange direction) (L12660)

> Determines the cancellation reason code based on whether the exchange is a standard STB-to-4KSTB swap or a reverse 4KSTB-to-STB swap.
> [CHANGE_KIKI_STB_TO_4KSTB = "0"]

**Block 2.1** — [IF branch] (STB to 4KSTB -- Normal Cancellation) (L12666)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcDlreCd = JBSbatKKConst.SVC_DLRE_CD_NORMAL` // [-> "01" Normal Cancellation] |

**Block 2.2** — [ELSE branch] (4KSTB to STB -- Work Cancellation) (L12670)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcDlreCd = JBSbatKKConst.SVC_DLRE_CD_CANCEL` // [-> "03" Cancellation - Work Cancellation] |

**Block 3** — [SET] (Initialize 171-element parameter array) (L12675)

> Creates a flat `Object[]` with 171 elements that will hold all fields for the device provision service contract record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setParam = new Object[171]` // New registered data container |

**Block 4** — [SET loop] (Fill idx 0-170 with B-CAS fields and fixed values) (L12678–L13188)

> Systematically copies 149 fields from the `bCasInfo` B-CAS data interface and fills 22 fields with fixed/derived values. Every field value is trimmed via `JBSbatStringUtil.Rtrim()` to remove trailing whitespace. The mapping covers:
>
> - **idx 0**: Device provision service contract number (KKTK_SVC_KEI_NO)
> - **idx 1**: System date-time stamp (reg_dttm)
> - **idx 2**: Service status = "910" (CD00056_KKTK_SVC_KEI_STAT_910) -- Device provision service contract status: Cancellation complete [-> "910"]
> - **idx 3-139**: Various service contract, billing, delivery, installation, and device fields from B-CAS info
> - **idx 140**: eoTV device installation approval status code
> - **idx 141-146**: Device installation approval date, home device transfer code, CAS card usage permission date, additional device info code, inspection cancellation completion code
> - **idx 147-148**: Router cancellation reservation transfer status/result codes
> - **idx 149**: Delivery method code
> - **idx 150**: Device transfer destination transfer executor ID code
> - **idx 151**: Returned device existence flag
> - **idx 152**: Delivery request specified date
> - **idx 153**: Departure completion process complete flag
> - **idx 154**: Service start delivery status identification code
> - **idx 155**: Registration date-time stamp (sysDate) -- same as idx 1
> - **idx 156**: Registration user ID (batchUserId)
> - **idx 157**: Update date-time stamp (sysDate)
> - **idx 158**: Update user ID (batchUserId)
> - **idx 159**: Delete date-time stamp = "" (blank)
> - **idx 160**: Delete user ID = "" (blank)
> - **idx 161**: Invalid flag = "0" (MK_FLG_YK) [-> "0" Valid -- i.e., record is valid/active]
> - **idx 162-167**: Empty strings for registration/update/delete operation month and process IDs
> - **idx 168-170**: Guarantee/refund period start date calculation reference year-month-date, flag, and identification code
>
> **Derived date fields:**
> - **idx 98 (rsvAplyYmd)**: Reservation application date -- taken directly from paramRsvAplyYmd
> - **idx 100 (RSV_APLY_CD)**: Reservation application code = "2" (FIX / 予約確定 -- reservation confirmed)
> - **idx 103 (plan_end_ymd)**: Plan end date -- same as reservation application date
> - **idx 105 (plan_end_prd_ymd)**: Plan end period -- last day of the same month as reservation application date (computed as `rsvAplyYmd.substring(0, 6) + getEndOfMonth(...)`)
> - **idx 124 (svc_end_ymd)**: Service end date -- same as reservation application date
> - **idx 125 (svc_end_prd_ymd)**: Service end period -- last day of the same month
> - **idx 126 (svc_dlre_ymd)**: Service cancellation date -- same as reservation application date
> - **idx 127 (svc_dlre_cd)**: Service cancellation reason code -- from Block 2.1 or 2.2
> - **idx 128 (svc_dlre_memo)**: Service cancellation reason memo = "" (blank)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `setParam[0] = Rtrim(bCasInfo.getString(KKTK_SVC_KEI_NO))` | Device provision service contract number |
| 2 | SET | `setParam[1] = sysDate` | Registration date-time stamp |
| 3 | SET | `setParam[2] = CD00056_KKTK_SVC_KEI_STAT_910` | [-> "910"] Device provision service contract status: Cancellation complete |
| 4 | SET | `setParam[3] = Rtrim(bCasInfo.getString(KKTK_SVC_CD))` | Device provision service code |
| 5 | SET | `setParam[4] = Rtrim(bCasInfo.getString(PCRS_CD))` | Cost code |
| 6 | SET | `setParam[5] = Rtrim(bCasInfo.getString(PPLAN_CD))` | Plan code |
| 7 | SET | `setParam[6] = Rtrim(bCasInfo.getString(TK_HOSHIKI_KEI_NO))` | Provider method contract number |
| 8 | SET | `setParam[7] = Rtrim(bCasInfo.getString(KKTK_SBT_CD))` | Device provision type code |
| 9 | SET | `setParam[8] = Rtrim(bCasInfo.getString(HAMBAI_SBT_CD))` | Sales type code |
| 10 | SET | `setParam[9] = Rtrim(bCasInfo.getString(SVC_USE_STA_KIBO_YMD))` | Service usage start desired date |
| 11 | SET | `setParam[10] = Rtrim(bCasInfo.getString(RSV_TSTA_KIBO_YMD))` | Reservation application start desired date |
| 12 | SET | `setParam[11] = Rtrim(bCasInfo.getString(KIBO_MAKER_CD))` | Desired maker code |
| 13 | SET | `setParam[12] = Rtrim(bCasInfo.getString(KIKI_SHITEI_SBT_CD))` | Device specification type code |
| 14 | SET | `setParam[13] = Rtrim(bCasInfo.getString(TAKNKIKI_SBT_CD))` | Home device type code |
| 15 | SET | `setParam[14] = Rtrim(bCasInfo.getString(TAKNKIKI_MODEL_CD))` | Home device model code |
| 16 | SET | `setParam[15] = Rtrim(bCasInfo.getString(KIKI_SEIZO_NO))` | Device serial number |
| 17 | SET | `setParam[16] = Rtrim(bCasInfo.getString(HUZOKUHIN_SBT_CD))` | Accessory type code |
| 18 | SET | `setParam[17] = Rtrim(bCasInfo.getString(HUZOKUHIN_MODEL_CD))` | Accessory model code |
| 19 | SET | `setParam[18] = Rtrim(bCasInfo.getString(TAKNKIKI_SETHIN_MODEL_CD))` | Home device set model code |
| 20 | SET | `setParam[19] = Rtrim(bCasInfo.getString(KIKI_CHG_NO))` | Device exchange number |
| 21 | SET | `setParam[20] = Rtrim(bCasInfo.getString(KIKI_CHG_RSN_CD))` | Device exchange reason code |
| 22 | SET | `setParam[21] = Rtrim(bCasInfo.getString(TSUSHIN_KIKI_SET_CD))` | Communication device set code |
| 23 | SET | `setParam[22] = Rtrim(bCasInfo.getString(HDD_CAPA_CD))` | HDD capacity code |
| 24 | SET | `setParam[23] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_PLACE_NO))` | Device installation destination location number |
| 25 | SET | `setParam[24] = Rtrim(bCasInfo.getString(OYA_KEI_SKBT_CD))` | Parent contract identification code |
| 26 | SET | `setParam[25] = Rtrim(bCasInfo.getString(SVC_KEI_NO))` | Service contract number |
| 27 | SET | `setParam[26] = Rtrim(bCasInfo.getString(SVC_KEI_UCWK_NO))` | Service contract detail work number |
| 28 | SET | `setParam[27] = Rtrim(bCasInfo.getString(SVC_KEI_KAISEN_UCWK_NO))` | Service contract line detail work number |
| 29 | SET | `setParam[28] = Rtrim(bCasInfo.getString(OP_SVC_KEI_NO))` | Optional service contract number |
| 30 | SET | `setParam[29] = Rtrim(bCasInfo.getString(SYSID))` | SYSID |
| 31 | SET | `setParam[30] = Rtrim(bCasInfo.getString(MSKM_DTL_NO))` | Application detail number |
| 32 | SET | `setParam[31] = Rtrim(bCasInfo.getString(LINK_STB_FLG))` | Link STB flag |
| 33 | SET | `setParam[32] = Rtrim(bCasInfo.getString(KIKI_HKAT_SHITEI_SOKO_CD))` | Device withdrawal destination warehouse code |
| 34 | SET | `setParam[33] = Rtrim(bCasInfo.getString(KIKI_HKAT_SHITEI_SKDN_CD))` | Device withdrawal destination shelf code |
| 35 | SET | `setParam[34] = Rtrim(bCasInfo.getString(KIKI_STI_JI_KRIPLACE_SKCD))` | Device specification time management site identification code |
| 36 | SET | `setParam[35] = Rtrim(bCasInfo.getString(KIKI_STI_JI_KOCOMP_CD))` | Device specification time contractor company code |
| 37 | SET | `setParam[36] = Rtrim(bCasInfo.getString(KIKI_STI_JI_KOCOMP_SLF_CD))` | Device specification time contractor company shelf code |
| 38 | SET | `setParam[37] = Rtrim(bCasInfo.getString(KIKI_STI_JI_YTKSKOF_CD))` | Device specification time advance office code |
| 39 | SET | `setParam[38] = Rtrim(bCasInfo.getString(KIKI_STI_JI_YTKSKOF_SLF_CD))` | Device specification time advance office shelf code |
| 40 | SET | `setParam[39] = Rtrim(bCasInfo.getString(KKTK_SVC_KEI_HKHASYMD))` | Device provision service contract occurrence date |
| 41 | SET | `setParam[40] = Rtrim(bCasInfo.getString(KIKI_SORYO_UM))` | Device freight existence flag |
| 42 | SET | `setParam[41] = Rtrim(bCasInfo.getString(KIKI_SORYO_SAKSEI_YMD))` | Device freight creation date |
| 43 | SET | `setParam[42] = Rtrim(bCasInfo.getString(KIKI_SOHUS_NM))` | Device delivery destination name |
| 44 | SET | `setParam[43] = Rtrim(bCasInfo.getString(KIKI_SOHUS_KANA))` | Device delivery destination katakana name |
| 45 | SET | `setParam[44] = Rtrim(bCasInfo.getString(KIKI_SOHUS_AD_CD))` | Device delivery destination address code |
| 46 | SET | `setParam[45] = Rtrim(bCasInfo.getString(KIKI_SOHUS_PCD))` | Device delivery destination postal code |
| 47 | SET | `setParam[46] = Rtrim(bCasInfo.getString(KIKI_SOHUS_STATE_NM))` | Device delivery destination prefecture name |
| 48 | SET | `setParam[47] = Rtrim(bCasInfo.getString(KIKI_SOHUS_CITY_NM))` | Device delivery destination city/town/village name |
| 49 | SET | `setParam[48] = Rtrim(bCasInfo.getString(KIKI_SOHUS_OAZTSU_NM))` | Device delivery destination district street name |
| 50 | SET | `setParam[49] = Rtrim(bCasInfo.getString(KIKI_SOHUS_AZCHO_NM))` | Device delivery destination block name |
| 51 | SET | `setParam[50] = Rtrim(bCasInfo.getString(KIKI_SOHUS_BNCHIGO))` | Device delivery destination lot number |
| 52 | SET | `setParam[51] = Rtrim(bCasInfo.getString(KIKI_SOHUS_ADRTTM))` | Device delivery destination address note/building name |
| 53 | SET | `setParam[52] = Rtrim(bCasInfo.getString(KIKI_SOHUS_ADRRM))` | Device delivery destination address note/room number |
| 54 | SET | `setParam[53] = Rtrim(bCasInfo.getString(KIKI_SHS_AD_MAN_INPUT_FLG))` | Device delivery destination address manual entry flag |
| 55 | SET | `setParam[54] = Rtrim(bCasInfo.getString(KIKI_SOHUS_TELNO))` | Device delivery destination phone number |
| 56 | SET | `setParam[55] = Rtrim(bCasInfo.getString(MANSION_BUKKEN_NO))` | Mansion property number |
| 57 | SET | `setParam[56] = Rtrim(bCasInfo.getString(KIKI_SOHUS_KSH_AD_SAI_FLG))` | Device delivery destination contract address difference flag |
| 58 | SET | `setParam[57] = Rtrim(bCasInfo.getString(KIKI_SHS_KBT_SHITEI_FLG))` | Device delivery destination individual designation flag |
| 59 | SET | `setParam[58] = Rtrim(bCasInfo.getString(KIKI_SHS_HSK_CD_1))` | Device delivery destination supplementary code 1 |
| 60 | SET | `setParam[59] = Rtrim(bCasInfo.getString(KIKI_SHS_HSK_CD_2))` | Device delivery destination supplementary code 2 |
| 61 | SET | `setParam[60] = Rtrim(bCasInfo.getString(KIKI_SHS_HSK_MEMO))` | Device delivery destination supplementary memo |
| 62 | SET | `setParam[61] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_NM))` | Device installation destination name |
| 63 | SET | `setParam[62] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_KANA))` | Device installation destination katakana name |
| 64 | SET | `setParam[63] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_AD_CD))` | Device installation destination address code |
| 65 | SET | `setParam[64] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_PCD))` | Device installation destination postal code |
| 66 | SET | `setParam[65] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_STATE_NM))` | Device installation destination prefecture name |
| 67 | SET | `setParam[66] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_CITY_NM))` | Device installation destination city/town/village name |
| 68 | SET | `setParam[67] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_OAZTSU_NM))` | Device installation destination district street name |
| 69 | SET | `setParam[68] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_AZCHO_NM))` | Device installation destination block name |
| 70 | SET | `setParam[69] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_BNCHIGO))` | Device installation destination lot number |
| 71 | SET | `setParam[70] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_ADRTTM))` | Device installation destination address note/building name |
| 72 | SET | `setParam[71] = Rtrim(bCasInfo.getString(KIKI_STC_SAKI_ADRRM))` | Device installation destination address note/room number |
| 73 | SET | `setParam[72] = Rtrim(bCasInfo.getString(KIKI_STC_SK_KSH_AD_SAI_FLG))` | Device installation destination contract address difference flag |
| 74 | SET | `setParam[73] = Rtrim(bCasInfo.getString(KIKI_STC_SK_TELNO))` | Device installation destination phone number |
| 75 | SET | `setParam[74] = Rtrim(bCasInfo.getString(KIKI_STS_KKK_SEIRI_CHU_FLG))` | Device installation destination district organization flag |
| 76 | SET | `setParam[75] = Rtrim(bCasInfo.getString(AD_MI_FIX_FLG))` | Address unconfirmed flag |
| 77 | SET | `setParam[76] = Rtrim(bCasInfo.getString(AUTO_ADD_CD))` | Automatic registration code |
| 78 | SET | `setParam[77] = Rtrim(bCasInfo.getString(AD_MI_FIX_RLS_YMD))` | Address unconfirmed resolution date |
| 79 | SET | `setParam[78] = Rtrim(bCasInfo.getString(CHRG_STA_YMD_HOSEI_UM))` | Billing start date correction existence flag |
| 80 | SET | `setParam[79] = Rtrim(bCasInfo.getString(KIKI_STS_HSK_CD_1))` | Device installation destination supplementary code 1 |
| 81 | SET | `setParam[80] = Rtrim(bCasInfo.getString(KIKI_STS_HSK_CD_2))` | Device installation destination supplementary code 2 |
| 82 | SET | `setParam[81] = Rtrim(bCasInfo.getString(KIKI_STS_HSK_MEMO))` | Device installation destination supplementary memo |
| 83 | SET | `setParam[82] = Rtrim(bCasInfo.getString(KKTK_SVC_KEI_KZKWRK_REQYMD))` | Device provision service contract follow-up work request date |
| 84 | SET | `setParam[83] = Rtrim(bCasInfo.getString(SHOSA_YMD))` | Inspection date |
| 85 | SET | `setParam[84] = Rtrim(bCasInfo.getString(SHOSA_CL_YMD))` | Inspection cancellation date |
| 86 | SET | `setParam[85] = Rtrim(bCasInfo.getString(HAISO_DIV))` | Delivery division |
| 87 | SET | `setParam[86] = Rtrim(bCasInfo.getString(HAISO_KIGEN_YMD))` | Delivery deadline date |
| 88 | SET | `setParam[87] = Rtrim(bCasInfo.getString(HAISO_ARIV_SHITEI_YMD))` | Delivery arrival specified date |
| 89 | SET | `setParam[88] = Rtrim(bCasInfo.getString(FTRIAL_KANYU_YMD))` | Free trial entry date |
| 90 | SET | `setParam[89] = Rtrim(bCasInfo.getString(FTRIAL_PRD_ENDYMD))` | Free trial period end date |
| 91 | SET | `setParam[90] = Rtrim(bCasInfo.getString(HONKANYU_YMD))` | Actual entry date |
| 92 | SET | `setParam[91] = Rtrim(bCasInfo.getString(HONKANYU_IKO_KIGEN_YMD))` | Actual entry transfer deadline date |
| 93 | SET | `setParam[92] = Rtrim(bCasInfo.getString(KEI_CNC_YMD))` | Contract conclusion date |
| 94 | SET | `setParam[93] = Rtrim(bCasInfo.getString(JCCC_KANYU_BUNSHO_YMD))` | JCCC application document date |
| 95 | SET | `setParam[94] = Rtrim(bCasInfo.getString(HOSHO_CD))` | Guarantee code |
| 96 | SET | `setParam[95] = Rtrim(bCasInfo.getString(KKTK_SVKEI_HOKI))` | Device provision service contract supplement |
| 97 | SET | `setParam[96] = Rtrim(bCasInfo.getString(HOSHO_STAYMD))` | Guarantee start date |
| 98 | SET | `setParam[97] = Rtrim(bCasInfo.getString(HOSHO_END_YMD))` | Guarantee end date |
| 99 | SET | `setParam[98] = rsvAplyYmd` | Reservation application date |
| 100 | SET | `setParam[99] = Rtrim(bCasInfo.getString(RSV_CL_YMD))` | Reservation cancellation date |
| 101 | SET | `setParam[100] = RSV_APLY_CD_FIX` | [-> "2"] Reservation application code: Fixed/Confirmed |
| 102 | SET | `setParam[101] = Rtrim(bCasInfo.getString(KIKI_CHG_YMD))` | Device exchange date |
| 103 | SET | `setParam[102] = Rtrim(bCasInfo.getString(PLAN_STAYMD))` | Plan start date |
| 104 | SET | `setParam[103] = rsvAplyYmd` | Plan end date -- same as reservation application date |
| 105 | SET | `setParam[104] = Rtrim(bCasInfo.getString(PLAN_CHRG_STAYMD))` | Plan billing start date |
| 106 | SET | `setParam[105] = rsvAplyYmd.substring(0, 6) + getEndOfMonth(...)` | Plan end period -- last day of the month of reservation application date |
| 107 | SET | `setParam[106] = Rtrim(bCasInfo.getString(PLAN_END_SBT_CD))` | Plan end type code |
| 108 | SET | `setParam[107] = Rtrim(bCasInfo.getString(SVC_CANCEL_YMD))` | Service cancellation date |
| 109 | SET | `setParam[108] = Rtrim(bCasInfo.getString(SVC_CANCEL_RSN_CD))` | Service cancellation reason code |
| 110 | SET | `setParam[109] = Rtrim(bCasInfo.getString(SVC_STA_KISAN_YMD))` | Service start billing date |
| 111 | SET | `setParam[110] = Rtrim(bCasInfo.getString(SVC_STA_YMD))` | Service start date |
| 112 | SET | `setParam[111] = Rtrim(bCasInfo.getString(SVC_CHRG_STAYMD))` | Service billing start date |
| 113 | SET | `setParam[112] = Rtrim(bCasInfo.getString(SVC_STP_YMD))` | Service stop date |
| 114 | SET | `setParam[113] = Rtrim(bCasInfo.getString(SVCTK_CHU_USE_FAIL_SBT_CD))` | Service in-progress unusable type code |
| 115 | SET | `setParam[114] = Rtrim(bCasInfo.getString(SVC_STP_RSN_CD))` | Service stop reason code |
| 116 | SET | `setParam[115] = Rtrim(bCasInfo.getString(SVC_STP_RLS_YMD))` | Service stop release date |
| 117 | SET | `setParam[116] = Rtrim(bCasInfo.getString(SVC_STP_RLS_RSN_CD))` | Service stop release reason code |
| 118 | SET | `setParam[117] = Rtrim(bCasInfo.getString(PAUSE_STP_CD))` | Pause stop code |
| 119 | SET | `setParam[118] = Rtrim(bCasInfo.getString(SVC_PAUSE_YMD))` | Service pause date |
| 120 | SET | `setParam[119] = Rtrim(bCasInfo.getString(SVC_PAUSE_RSN_CD))` | Service pause reason code |
| 121 | SET | `setParam[120] = Rtrim(bCasInfo.getString(SVC_PAUSE_RSN_MEMO))` | Service pause reason memo |
| 122 | SET | `setParam[121] = Rtrim(bCasInfo.getString(SVC_PAUSE_RLS_YMD))` | Service pause release date |
| 123 | SET | `setParam[122] = Rtrim(bCasInfo.getString(SVC_PAUSE_RLS_RSN_CD))` | Service pause release reason code |
| 124 | SET | `setParam[123] = Rtrim(bCasInfo.getString(SVC_PAUSE_RLS_RSN_MEMO))` | Service pause release reason memo |
| 125 | SET | `setParam[124] = rsvAplyYmd` | Service end date -- same as reservation application date |
| 126 | SET | `setParam[125] = rsvAplyYmd.substring(0, 6) + getEndOfMonth(...)` | Service end period -- last day of the month of reservation application date |
| 127 | SET | `setParam[126] = rsvAplyYmd` | Service cancellation date -- same as reservation application date |
| 128 | SET | `setParam[127] = svcDlreCd` | Service cancellation reason code (from Block 2) |
| 129 | SET | `setParam[128] = ""` | Service cancellation reason memo -- blank |
| 130 | SET | `setParam[129] = Rtrim(bCasInfo.getString(ZANCHI_FLG))` | Retention flag |
| 131 | SET | `setParam[130] = Rtrim(bCasInfo.getString(SVC_DSL_TTDKI_FIN_FLG))` | Service cancellation procedure completion flag |
| 132 | SET | `setParam[131] = Rtrim(bCasInfo.getString(KAIHK_YMD))` | Recovery date |
| 133 | SET | `setParam[132] = Rtrim(bCasInfo.getString(SVC_CANCEL_CL_YMD))` | Service cancellation withdrawal date |
| 134 | SET | `setParam[133] = Rtrim(bCasInfo.getString(SVC_DSL_CL_YMD))` | Service cancellation withdrawal date |
| 135 | SET | `setParam[134] = Rtrim(bCasInfo.getString(SKEKKA_SEND_CD))` | Review result transmission code |
| 136 | SET | `setParam[135] = Rtrim(bCasInfo.getString(SVC_PAUSE_CHRG_STA_YMD))` | Service pause billing start date |
| 137 | SET | `setParam[136] = Rtrim(bCasInfo.getString(PNLTY_HASSEI_CD))` | Penalty occurrence code |
| 138 | SET | `setParam[137] = Rtrim(bCasInfo.getString(KIKI_NINSHO_ID))` | Device authentication ID |
| 139 | SET | `setParam[138] = Rtrim(bCasInfo.getString(KIKI_NINSHO_ID_PWD))` | Device authentication ID password |
| 140 | SET | `setParam[139] = Rtrim(bCasInfo.getString(IDO_DIV))` | Transfer division |
| 141 | SET | `setParam[140] = Rtrim(bCasInfo.getString(KKST_JSEKI_UK_YMD))` | Device installation actual payment date |
| 142 | SET | `setParam[141] = Rtrim(bCasInfo.getString(EO_TV_KKST_SNN_STAT_CD))` | eoTV device installation approval status code |
| 143 | SET | `setParam[142] = Rtrim(bCasInfo.getString(KKST_SNN_YMD))` | Device installation approval date |
| 144 | SET | `setParam[143] = Rtrim(bCasInfo.getString(TAKNKIKI_IDO_CD))` | Home device transfer code |
| 145 | SET | `setParam[144] = Rtrim(bCasInfo.getString(CAS_CARD_USE_KYODAK_YMD))` | CAS card usage permission date |
| 146 | SET | `setParam[145] = Rtrim(bCasInfo.getString(KIKI_HUKA_INFO_CD))` | Device additional information code |
| 147 | SET | `setParam[146] = Rtrim(bCasInfo.getString(SHOSA_DSL_FIN_CD))` | Inspection cancellation completion code |
| 148 | SET | `setParam[147] = Rtrim(bCasInfo.getString(ROUTER_DSL_RSV_TRN_STAT_CD))` | Router cancellation reservation transfer status code |
| 149 | SET | `setParam[148] = Rtrim(bCasInfo.getString(ROUTER_DSL_RSV_TRN_RSLT_CD))` | Router cancellation reservation transfer result code |
| 150 | SET | `setParam[149] = Rtrim(bCasInfo.getString(HAISO_WAY_CD))` | Delivery method code |
| 151 | SET | `setParam[150] = Rtrim(bCasInfo.getString(KIKI_ITENS_MV_JSSIS_SKCD))` | Device transfer destination transfer executor identification code |
| 152 | SET | `setParam[151] = Rtrim(bCasInfo.getString(KAISHU_KIKI_UM))` | Returned device existence flag |
| 153 | SET | `setParam[152] = Rtrim(bCasInfo.getString(HAISO_REQ_SHITEI_YMD))` | Delivery request specified date |
| 154 | SET | `setParam[153] = Rtrim(bCasInfo.getString(SHKA_FIN_JI_SYRZM_FLG))` | Departure completion process complete flag |
| 155 | SET | `setParam[154] = Rtrim(bCasInfo.getString(SVC_STA_JI_HIS_JOKYO_SKCD))` | Service start delivery status identification code |
| 156 | SET | `setParam[155] = sysDate` | Registration date-time stamp |
| 157 | SET | `setParam[156] = batchUserId` | Registration user ID |
| 158 | SET | `setParam[157] = sysDate` | Update date-time stamp |
| 159 | SET | `setParam[158] = batchUserId` | Update user ID |
| 160 | SET | `setParam[159] = ""` | Delete date-time stamp -- blank |
| 161 | SET | `setParam[160] = ""` | Delete user ID -- blank |
| 162 | SET | `setParam[161] = MK_FLG_YK` | [-> "0"] Invalid flag: Valid (active) |
| 163 | SET | `setParam[162] = ""` | Registration operation month -- blank |
| 164 | SET | `setParam[163] = ""` | Registration process ID -- blank |
| 165 | SET | `setParam[164] = ""` | Update operation month -- blank |
| 166 | SET | `setParam[165] = ""` | Update process ID -- blank |
| 167 | SET | `setParam[166] = ""` | Delete operation month -- blank |
| 168 | SET | `setParam[167] = ""` | Delete process ID -- blank |
| 169 | SET | `setParam[168] = Rtrim(bCasInfo.getString(HCPRD_STAD_SNSTSTD_YMD))` | Guarantee/refund period start date calculation reference YMD |
| 170 | SET | `setParam[169] = Rtrim(bCasInfo.getString(HCPRD_STAD_SNSTSTD_YMD_IKF))` | Guarantee/refund period start date calculation reference YMD transfer flag |
| 171 | SET | `setParam[170] = Rtrim(bCasInfo.getString(HCPRD_STAD_SNSTSTD_YMD_SCD))` | Guarantee/refund period start date calculation reference YMD identification code |

**Block 5** — [CALL] (Execute INSERT/UPSERT into KK_T_KKTK_SVC_KEI) (L13193)

> Invokes the primary-key-based insert/UPSERT method to persist the fully assembled 171-field record into the device provision service contract table.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `executeKK_T_KKTK_SVC_KEI_PKINSERT(setParam)` | Insert B-CAS cancellation service contract data into KK_T_KKTK_SVC_KEI |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `KK_T_KKTK_SVC_KEI` | Table | Device Provision Service Contract -- the core table storing all device-related service contract information for customers |
| `changeStbPettern` | Field | STB exchange direction parameter -- determines whether the exchange is a normal STB-to-4KSTB swap or a reverse 4KSTB-to-STB swap |
| `bCasInfo` | Field | B-CAS provider information -- the source data interface carrying all B-CAS smart card and subscription data |
| `paramRsvAplyYmd` | Field | Reservation application year-month-date (YYYYMMDD) -- the effective date when the reservation becomes active |
| `svcDlreCd` | Field | Service cancellation reason code -- determines the type of cancellation (normal vs. work cancellation) |
| `SVC_DLRE_CD_NORMAL` | Constant | Service cancellation reason code "01" -- Normal Cancellation (standard STB-to-4KSTB swap) |
| `SVC_DLRE_CD_CANCEL` | Constant | Service cancellation reason code "03" -- Cancellation due to work cancellation (4KSTB-to-STB reverse swap) |
| `CD00056_KKTK_SVC_KEI_STAT_910` | Constant | Device provision service contract status code "910" -- Cancellation complete |
| `RSV_APLY_CD_FIX` | Constant | Reservation application code "2" -- Reservation confirmed/fixed |
| `MK_FLG_YK` | Constant | Invalid flag code "0" -- Record is valid (active); "1" would mean invalid |
| `CHANGE_KIKI_STB_TO_4KSTB` | Constant | Exchange direction code "0" -- Indicates STB to 4KSTB exchange |
| `KKTK_SVC_KEI_NO` | Field | Device provision service contract number -- unique contract identifier |
| `KKTK_SVC_CD` | Field | Device provision service code -- identifies the type of device provision service |
| `SVC_KEI_NO` | Field | Service contract number -- the main service contract identifier |
| `SVC_KEI_UCWK_NO` | Field | Service contract detail work number -- internal tracking ID for service contract line items |
| `SVC_KEI_KAISEN_UCWK_NO` | Field | Service contract line detail work number |
| `OP_SVC_KEI_NO` | Field | Optional service contract number |
| `HAMBAI_SBT_CD` | Field | Sales type code |
| `KKTK_SBT_CD` | Field | Device provision type code |
| `PCRS_CD` | Field | Cost code |
| `PPLAN_CD` | Field | Plan code |
| `KIKI_CHG_YMD` | Field | Device exchange date |
| `KIKI_SEIZO_NO` | Field | Device serial number (manufacturing number) |
| `KIBO_MAKER_CD` | Field | Desired maker code |
| `SHOSA_YMD` | Field | Inspection date |
| `SHOSA_CL_YMD` | Field | Inspection cancellation date |
| `SHOSA_DSL_FIN_CD` | Field | Inspection cancellation completion code |
| `PLAN_STAYMD` | Field | Plan start date |
| `PLAN_CHRG_STAYMD` | Field | Plan billing start date |
| `PLAN_END_SBT_CD` | Field | Plan end type code |
| `SVC_USE_STA_KIBO_YMD` | Field | Service usage start desired date |
| `RSV_TSTA_KIBO_YMD` | Field | Reservation application start desired date |
| `RSV_CL_YMD` | Field | Reservation cancellation date |
| `RSV_APLY_CD` | Field | Reservation application code |
| `KEI_CNC_YMD` | Field | Contract conclusion date |
| `HAISO_DIV` | Field | Delivery division |
| `HAISO_KIGEN_YMD` | Field | Delivery deadline date |
| `HAISO_ARIV_SHITEI_YMD` | Field | Delivery arrival specified date |
| `FTRIAL_KANYU_YMD` | Field | Free trial entry date |
| `FTRIAL_PRD_ENDYMD` | Field | Free trial period end date |
| `HONKANYU_YMD` | Field | Actual entry date |
| `HONKANYU_IKO_KIGEN_YMD` | Field | Actual entry transfer deadline date |
| `JCCC_KANYU_BUNSHO_YMD` | Field | JCCC (Joint Countermeasures Center for Commercial Broadcasting) application document date |
| `HOSHO_CD` | Field | Guarantee code |
| `HOSHO_STAYMD` | Field | Guarantee start date |
| `HOSHO_END_YMD` | Field | Guarantee end date |
| `SVC_CANCEL_YMD` | Field | Service cancellation date |
| `SVC_CANCEL_RSN_CD` | Field | Service cancellation reason code |
| `SVC_STA_YMD` | Field | Service start date |
| `SVC_STP_YMD` | Field | Service stop date |
| `SVC_STP_RSN_CD` | Field | Service stop reason code |
| `SVC_STP_RLS_YMD` | Field | Service stop release date |
| `SVC_PAUSE_YMD` | Field | Service pause date |
| `SVC_PAUSE_RSN_CD` | Field | Service pause reason code |
| `SVC_PAUSE_RLN_RSN_MEMO` | Field | Service pause reason memo |
| `SVC_PAUSE_RLS_YMD` | Field | Service pause release date |
| `SVC_PAUSE_RLS_RSN_CD` | Field | Service pause release reason code |
| `SVC_PAUSE_RLS_RSN_MEMO` | Field | Service pause release reason memo |
| `SVC_END_YM` | Field | Service end date |
| `SVC_DSL_TTDKI_FIN_FLG` | Field | Service cancellation procedure completion flag |
| `ZANCHI_FLG` | Field | Retention flag |
| `ROUTER_DSL_RSV_TRN_STAT_CD` | Field | Router cancellation reservation transfer status code |
| `ROUTER_DSL_RSV_TRN_RSLT_CD` | Field | Router cancellation reservation transfer result code |
| `KIKI_NINSHO_ID` | Field | Device authentication ID |
| `KIKI_NINSHO_ID_PWD` | Field | Device authentication ID password |
| `KIKI_SORYO_UM` | Field | Device freight existence flag |
| `KIKI_SOHUS_*` | Fields | Device delivery destination address fields (name, katakana, address code, postal code, prefecture, city, district, block, lot number, building name, room number, manual entry flag, phone number, contract address difference flag) |
| `KIKI_STC_SAKI_*` | Fields | Device installation destination fields (name, katakana, address code, postal code, prefecture, city, district, block, lot number, building name, room number, contract address difference flag, phone number) |
| `CAS_CARD_USE_KYODAK_YMD` | Field | CAS card usage permission date |
| `TAKNKIKI_SBT_CD` | Field | Home device type code |
| `TAKNKIKI_MODEL_CD` | Field | Home device model code |
| `TAKNKIKI_SETHIN_MODEL_CD` | Field | Home device set model code |
| `TAKNKIKI_IDO_CD` | Field | Home device transfer code |
| `KIKI_SHITEI_SBT_CD` | Field | Device specification type code |
| `KIKI_CHG_RSN_CD` | Field | Device exchange reason code |
| `KIKI_HUKA_INFO_CD` | Field | Device additional information code |
| `HCPRD_STAD_SNSTSTD_YMD` | Field | Guarantee/refund period start date calculation reference YMD |
| `HCPRD_STAD_SNSTSTD_YMD_IKF` | Field | Guarantee/refund period start date calculation reference YMD transfer flag |
| `HCPRD_STAD_SNSTSTD_YMD_SCD` | Field | Guarantee/refund period start date calculation reference YMD identification code |
| B-CAS | Business term | B-CAS -- Broadcast Content Protection for Digital Broadcasting, the conditional access system used for digital TV subscription services in Japan |
| STB | Acronym | Set-Top Box -- the hardware device that decodes digital broadcast signals for TV display |
| 4K STB | Business term | 4K Set-Top Box -- a next-generation STB supporting 4K Ultra HD resolution |
| eo | Business term | eo -- KDDI's brand for fixed-line telecommunications services (internet, TV, phone) in Japan |
| Device Provision Service | Business term | A service model where the provider (eo) provides STB/4K STB hardware to customers as part of a service contract, rather than requiring customers to purchase the equipment outright |
| Service Cancellation (解約) | Business term | The process of terminating a service contract and its associated B-CAS subscription |
| Reservation Application (予約適用) | Business term | A reservation system in which service changes take effect on a specified future date rather than immediately |
| Primary Key INSERT (PKINSERT) | Technical term | An insert strategy that uses primary key matching to determine whether to insert a new record or update an existing one |
| batchUserId | Field | The user ID of the batch processing operation, used for audit trail (registration user, update user) |
