# Business Logic — JBSbatKKEoTVChgeFix.insertOpSvcKei() [280 LOC]

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

## 1. Role

### JBSbatKKEoTVChgeFix.insertOpSvcKei()

This method performs **Option Service Contract Registration** (オプションサービス契約登録処理) — a batch processing step that creates a new row in the Option Service Contract table (`KK_T_OP_SVC_KEI`) at the time of work completion (工事完了). It is specifically invoked during the partial STB removal (解除 — cancellation) workflow, where an Option Service Contract line item is re-registered to reflect that a set-top-box is being removed from a customer's service bundle.

The method operates in a **pure Create mode** — it does not read, update, or delete any records. Instead, it constructs a 79-field parameter array (`Object[] setParam`) by pulling current values from the `dbInfo` interface (which holds the Option Service Contract current-state record), injecting fixed business constants (e.g., status = "910" Cancellation Complete, penalty code = "0" No Penalty), and computing derived date values (e.g., plan end date = work completion date's month-end).

The method implements a **data assembly + delegation pattern**: it gathers all contract lifecycle data from the input map, applies transformation logic (e.g., appending month-end to dates, setting cancellation disposition), and delegates the actual database insert to `executeKK_T_OP_SVC_KEI_PKINSERT()`. After the main contract row is inserted, it further delegates sub-type registration to `JKKBatCommon.createSubTypeKK0351()`.

Its **role in the larger system** is as a sub-step within the construction-finishing workflow (工事完了ワーク). It is called by `createOpSvcKeiDslInfoKjFin()`, which iterates over a list of Option Service Contract detail records that require partial STB removal, queries each PK, and invokes `insertOpSvcKei()` to re-register the contract line with updated cancellation state.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["insertOpSvcKei(dbInfo, kojiakJssiYmd, strIdoDiv, strMskmDtlNo)"])

    START --> LOG1["Debug Log: Print idoDiv and mskmDtlNo"]
    LOG1 --> SYS_DATE["Get System DateTimeStamp (sysDate)"]
    SYS_DATE --> CREATE_ARRAY["Create Object[] setParam[79]"]
    CREATE_ARRAY --> READ1["Read OP_SVC_KEI_NO from dbInfo"]
    READ1 --> SET0["setParam[0] = opSvcKeiNo"]
    SET0 --> SET1["setParam[1] = sysDate"]
    SET1 --> SET2["setParam[2] = SVC_KEI_STAT_DLS_ZM (status 910 = Cancellation Complete)"]
    SET2 --> READ_SERV["Read OP_SVC_CD, PCS_CD, PPLAN_CD, OYA_KEI_SKBT_CD from dbInfo"]
    READ_SERV --> SET3456["setParam[3..6] = Service Price Plan Parent contract codes"]
    SET3456 --> SET789["setParam[7..10] = SVC_KEI_NO SVC_KEI_UCWK_NO HOJIN_SVC_KEI_UK_NO SYSID"]
    SET789 --> SET10_17["setParam[11..17] = mskmDtlNo trial dates activation dates service use start reservation start"]
    SET10_17 --> SET18_23["setParam[18..23] = post work req inspection dates contract end date operation date"]
    SET18_23 --> SET24_29["setParam[24..29] = rsv cancel date rsv fix code plan start end dates"]
    SET24_29 --> SET30["setParam[30] = PLAN_END_SBT_CD_MSDDSL (plan end type 2 = Plan Change)"]
    SET30 --> SET31_47["setParam[31..47] = service cancel pause resume fields"]
    SET31_47 --> SET48_51["setParam[48..51] = kojiakJssiYmd (service end termination dates)"]
    SET48_51 --> SET52["setParam[52] = SVC_DLRE_CD_NORMAL (normal cancellation 01)"]
    SET52 --> SET53_58["setParam[53..58] = cancellation memo user ID recovery date empty cancel dates"]
    SET53_58 --> SET59_62["setParam[59..62] = billing correction pause billing contract occurrence penalty code 0"]
    SET59_62 --> SET63_71["setParam[63..71] = idoDiv inspection completion service delivery registration update delete audit fields"]
    SET63_71 --> SET72["setParam[72] = MK_FLG_YK (valid flag 0 = Valid)"]
    SET72 --> SET73_78["setParam[73..78] = empty operation dates and process IDs"]
    SET73_78 --> EXEC_INSERT["executeKK_T_OP_SVC_KEI_PKInsert setParam"]
    EXEC_INSERT --> CREATE_SUBTYPE["JKKBatCommon.createSubTypeKK0351 commonItem opSvcKeiNo geneAddDtm sysDate"]
    CREATE_SUBTYPE --> END_NODE(["Return Next"])
```

**Processing Summary:**

1. **Debug logging** — prints the migration division (異動区分) and application detail number (申込明細番号) for traceability.
2. **System datetime acquisition** — captures the current system timestamp for audit fields (registration datetime, generation datetime).
3. **Parameter array construction** — builds a 79-element `Object[]` where each slot maps to a column in the `KK_T_OP_SVC_KEI` table.
4. **Current-state field extraction** — reads 38 fields from the `dbInfo` interface (the Option Service Contract current record) via `dbInfo.getString(columnName)`, applying right-trim (`JBSbatStringUtil.Rtrim`) for string fields.
5. **Fixed constant injection** — sets 14 fields to hardcoded business constants (resolved from `JBSbatKKConst`):
   - `SVC_KEI_STAT_DLS_ZM` = `"910"` — Cancellation Complete
   - `RSV_APLY_CD_FIX` = `"2"` — Reservation confirmed
   - `PLAN_END_SBT_CD_MSDDSL` = `"2"` — Plan Change
   - `SVC_DLRE_CD_NORMAL` = `"01"` — Normal Cancellation
   - `CD01375_PNLTY_HASSEI_CD_0` = `"0"` — No Penalty
   - `MK_FLG_YK` = `"0"` — Valid
6. **Derived date computation** — computes two date fields as the month-end of the work completion date (工事実施年月日):
   - `PLAN_CHRG_ENDYMD` = `kojiakJssiYmd.substring(0,6) + getEndOfMonth(...)` (Plan billing end date)
   - `SVC_CHRG_ENDYMD` = `kojiakJssiYmd.substring(0,6) + getEndOfMonth(...)` (Service billing end date)
7. **Audit field population** — sets registration/update datetime to `sysDate`, registration/update operator to `batchUserId` (from inherited class), and delete fields to empty strings.
8. **Contract insert** — delegates to `executeKK_T_OP_SVC_KEI_PKInsert()` which maps the array into a `JBSbatCommonDBInterface` and inserts the row into `KK_T_OP_SVC_KEI`.
9. **Sub-type registration** — delegates to `JKKBatCommon.createSubTypeKK0351()` to register the sub-type record associated with the Option Service Contract.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `dbInfo` | `JBSbatCommonDBInterface` | The Option Service Contract current-state record — a key-value map containing the full set of field values from the `KK_T_OP_SVC_KEI` table for the specific contract line being re-registered. This is the primary data source from which 38 out of 79 fields are pulled. |
| 2 | `kojiakJssiYmd` | `String` | Work completion implementation date (工事実施年月日) — a YYYYMMDD-formatted string representing the date when the physical installation/construction work was completed. Used as the effective date for service end date, termination date, plan end date, and billing end date fields. |
| 3 | `strIdoDiv` | `String` | Migration division code (異動区分) — a code indicating the type of contract change being performed (e.g., addition, cancellation, change). Here it maps to the `IDO_DIV` field in the Option Service Contract record, reflecting that this is a partial STB removal/cancellation migration. |
| 4 | `strMskmDtlNo` | `String` | Application detail number (申込明細番号) — uniquely identifies the application detail line item associated with this contract registration. In this context, it represents the reservation-expected application detail number that triggered the partial STB removal workflow. |

**Inherited instance fields read by the method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `batchUserId` | `String` | The batch job user ID — used as the registration and update operator account for audit trail purposes. Inherited from the parent class `JBSbatBusinessService`. |
| `commonItem` | `JBSbatCommonItem` | Batch common parameters — passed to `createSubTypeKK0351()` for sub-type registration, containing shared batch context. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `dbInfo.getString(columnName)` | - | `KK_T_OP_SVC_KEI` (current record) | Reads 38 field values from the Option Service Contract current-state record passed as `dbInfo`. Fields include service codes, contract dates, cancellation info, pause/resume info, and audit fields. |
| C | `JBSbatDateUtil.getSystemDateTimeStamp()` | - | - | Acquires the current system datetime stamp for generation datetime and registration datetime fields. |
| R | `JBSbatDateUtil.getEndOfMonth(String yyyymm)` | - | - | Computes the last day of the month for a given YYYYMM string, used to derive plan billing end date and service billing end date. |
| C | `executeKK_T_OP_SVC_KEI_PKINSERT(Object[] setParam)` | EOP_SVC_KEI_C010 | `KK_T_OP_SVC_KEI` | Inserts a new Option Service Contract record into the database. Maps the 79-element parameter array into column values (OP_SVC_KEI_NO, GENE_ADD_DTM, OP_SVC_KEI_STAT, etc.) and performs the INSERT operation. |
| C | `JKKBatCommon.createSubTypeKK0351(JBSbatCommonItem, String, String, String)` | EOP_SVC_KEI_C020 | `KK_T_OP_SVC_KEI_SUB` (sub-type table) | Registers sub-type records linked to the newly created Option Service Contract (identified by `opSvcKeiNo`). Receives the work completion date's generation datetime and system datetime. |
| - | `JBSbatStringUtil.Rtrim(String)` | - | - | Applies right-trim to all string fields extracted from `dbInfo` to remove trailing whitespace. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `createOpSvcKeiDslInfoKjFin` | `JBSbatKKEoTVChgeFix.createOpSvcKeiDslInfoKjFin` -> iterates `opSvcKeiDslInfoList` -> `searchPKOpSvcKei(info)` -> `insertOpSvcKei(dbInfo, kojiakJssiYmd, idoDiv, mskmDtlNo)` | `executeKK_T_OP_SVC_KEI_PKINSERT [C] KK_T_OP_SVC_KEI`, `createSubTypeKK0351 [C] KK_T_OP_SVC_KEI_SUB` |

**Notes:** The pre-computed caller list identified one direct caller: `createOpSvcKeiDslInfoKjFin()`. No screen/batch entry points were found within 8 hops. The terminal operations from this method are limited to: `executeKK_T_OP_SVC_KEI_PKINSERT` (Create on `KK_T_OP_SVC_KEI`) and `createSubTypeKK0351` (Create on sub-type table).

## 6. Per-Branch Detail Blocks

### Block 1 — SETUP (L7592)

> Debug logging and system state acquisition at method entry.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printDebugLog("異動区分---->" + strIdoDiv)` // Debug Log: Print migration division (異動区分) |
| 2 | EXEC | `super.logPrint.printDebugLog("申込明細番号---->" + strMskmDtlNo)` // Debug Log: Print application detail number (申込明細番号) |
| 3 | SET | `sysDate = JBSbatDateUtil.getSystemDateTimeStamp()` // Get current system datetime stamp [-> YYYYMMDDHH24MISS format] |
| 4 | SET | `setParam = new Object[79]` // Create 79-element parameter array |

### Block 2 — FIELD EXTRACTION & PARAMETER ASSEMBLY (L7597–L7870)

> Constructs the 79-field parameter array for the Option Service Contract insert. No conditional branches — each setParam index is assigned exactly once in sequence.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `opSvcKeiNo = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.OP_SVC_KEI_NO))` | Read Option Service Contract number (オプションサービス契約番号) |
| 2 | SET | `setParam[0] = opSvcKeiNo` | Option Service Contract number |
| 3 | SET | `setParam[1] = sysDate` | Generation registration datetime (世代登録年月日时分秒) |
| 4 | SET | `setParam[2] = JBSbatKKConst.SVC_KEI_STAT_DLS_ZM` [-> `"910"` (Cancellation Complete / 解約済)] | Option Service Contract status — set to Cancellation Complete (changed from old constant in v20.00.00) |
| 5 | SET | `setParam[3] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.OP_SVC_CD))` | Option Service Code (オプションサービスコード) |
| 6 | SET | `setParam[4] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.PCRS_CD))` | Price Cost Code (料金コストコード) |
| 7 | SET | `setParam[5] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.PPLAN_CD))` | Price Plan Code (料金プランコード) |
| 8 | SET | `setParam[6] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.OYA_KEI_SKBT_CD))` | Parent Contract Identification Code (親契約識別コード) |
| 9 | SET | `setParam[7] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_KEI_NO))` | Service Contract Number (サービス契約番号) |
| 10 | SET | `setParam[8] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_KEI_UCWK_NO))` | Service Contract Internal Number (サービス契約内訳番号) |
| 11 | SET | `setParam[9] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.HOJIN_SVC_KEI_UK_NO))` | Corporate Service Contract Reception Number (法人サービス契約受付番号) |
| 12 | SET | `setParam[10] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SYSID))` | SYSID |
| 13 | SET | `setParam[11] = strMskmDtlNo` | Reservation-expected Application Detail Number (予約予定.申込明細番号) |
| 14 | SET | `setParam[12] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.FTRIAL_KANYU_YMD))` | Trial Insertion Date (試用加入年月日) |
| 15 | SET | `setParam[13] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.FTRIAL_PRD_ENDYMD))` | Trial Period End Date (試用期間終了年月日) |
| 16 | SET | `setParam[14] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.HONKANYU_YMD))` | Actual Insertion Date (本加入年月日) |
| 17 | SET | `setParam[15] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.HONKANYU_IKO_KIGEN_YMD))` | Actual Insertion Transfer Deadline Date (本加入移行期限年月日) |
| 18 | SET | `setParam[16] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_USE_STA_KIBO_YMD))` | Service Use Start Desired Date (サービス利用開始希望年月日) |
| 19 | SET | `setParam[17] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.RSV_TSTA_KIBO_YMD))` | Reservation Application Start Desired Date (予約適用開始希望年月日) |
| 20 | SET | `setParam[18] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.OP_SVC_KEI_KZKWRK_REQYMD))` | Option Service Contract Post Work Request Date (オプションサービス契約後続業務依頼年月日) |
| 21 | SET | `setParam[19] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SHOSA_YMD))` | Inspection Date (照査年月日) |
| 22 | SET | `setParam[20] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SHOSA_CL_YMD))` | Inspection Cancellation Date (照査取消年月日) |
| 23 | SET | `setParam[21] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SKEKKA_SEND_CD))` | Review Result Transmission Code (審査結果送信コード) |
| 24 | SET | `setParam[22] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.KEI_CNC_YMD))` | Contract Conclusion Date (契約締結年月日) |
| 25 | SET | `setParam[23] = super.opeDate` | Reservation Application Date -> Operation Date (予約適用年月日->運用日) |
| 26 | SET | `setParam[24] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.RSV_CL_YMD))` | Reservation Cancellation Date (予約取消年月日) |
| 27 | SET | `setParam[25] = JBSbatKKConst.RSV_APLY_CD_FIX` [-> `"2"` (Reservation Confirmed / 予約確定)] | Reservation Application Code -> "2" (Reservation Confirmed, changed from old constant in v20.00.00) |
| 28 | SET | `setParam[26] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.PLAN_STAYMD))` | Plan Start Date (プラン開始年月日) |
| 29 | SET | `setParam[27] = kojiakJssiYmd` | Plan End Date -> Work Completion Date (プラン終了年月日->工事案件実施年月日) |
| 30 | SET | `setParam[28] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.PLAN_CHRG_STAYMD))` | Plan Billing Start Date (プラン課金開始年月日) |
| 31 | SET | `setParam[29] = kojiakJssiYmd.substring(0, 6) + JBSbatDateUtil.getEndOfMonth(kojiakJssiYmd.substring(0, 6))` | Plan Billing End Date -> Month-end of Work Completion Date (プラン課金終了年月日->工事案件実施年月日の同月末日) |
| 32 | SET | `setParam[30] = JBSbatKKConst.PLAN_END_SBT_CD_MSDDSL` [-> `"2"` (Plan Change / プラン変更)] | Plan End Type Code -> "2" Plan Change (changed from old constant "1" in v20.00.00) |
| 33 | SET | `setParam[31] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_CANCEL_YMD))` | Service Cancel Date (サービスキャンセル年月日) |
| 34 | SET | `setParam[32] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_CANCEL_RSN_CD))` | Service Cancel Reason Code (サービスキャンセル理由コード) |
| 35 | SET | `setParam[33] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STAYMD))` | Service Start Date (サービス開始年月日) |
| 36 | SET | `setParam[34] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STA_HMS))` | Service Start Time (サービス開始时分秒) |
| 37 | SET | `setParam[35] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.DSP_SVCTK_STAYMD))` | Display Service Provision Start Date (表示用サービス提供開始年月日) |
| 38 | SET | `setParam[36] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_CHRG_STAYMD))` | Service Billing Start Date (サービス課金開始年月日) |
| 39 | SET | `setParam[37] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STP_YMD))` | Service Suspension Date (サービス停止年月日) |
| 40 | SET | `setParam[38] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STP_RSN_CD))` | Service Suspension Reason Code (サービス停止理由コード) |
| 41 | SET | `setParam[39] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STP_RLS_YMD))` | Service Suspension Release Date (サービス停止解除年月日) |
| 42 | SET | `setParam[40] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STP_RLS_RSN_CD))` | Service Suspension Release Reason Code (サービス停止解除理由コード) |
| 43 | SET | `setParam[41] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.PAUSE_STP_CD))` | Suspension Interruption Code (休止中断コード) |
| 44 | SET | `setParam[42] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_PAUSE_YMD))` | Service Suspension Date (サービス休止年月日) |
| 45 | SET | `setParam[43] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_PAUSE_RSN_CD))` | Service Suspension Reason Code (サービス休止理由コード) |
| 46 | SET | `setParam[44] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_PAUSE_RSN_MEMO))` | Service Suspension Reason Memo (サービス休止理由メモ) |
| 47 | SET | `setParam[45] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_PAUSE_RLS_YMD))` | Service Suspension Release Date (サービス休止解除年月日) |
| 48 | SET | `setParam[46] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_PAUSE_RLS_RSN_CD))` | Service Suspension Release Reason Code (サービス休止解除理由コード) |
| 49 | SET | `setParam[47] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_PAUSE_RLS_RSN_MEMO))` | Service Suspension Release Reason Memo (サービス休止解除理由メモ) |
| 50 | SET | `setParam[48] = kojiakJssiYmd` | Service End Date -> Work Completion Date (サービス終了年月日->工事案件実施年月日) |
| 51 | SET | `setParam[49] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_END_HMS))` | Service End Time (サービス終了时分秒) |
| 52 | SET | `setParam[50] = kojiakJssiYmd.substring(0, 6) + JBSbatDateUtil.getEndOfMonth(kojiakJssiYmd.substring(0, 6))` | Service Billing End Date -> Month-end of Work Completion Date (サービス課金終了年月日->工事案件実施年月日の同月末日) |
| 53 | SET | `setParam[51] = kojiakJssiYmd` | Service Cancellation Date -> Work Completion Date (サービス解約年月日->工事案件実施年月日) |
| 54 | SET | `setParam[52] = JBSbatKKConst.SVC_DLRE_CD_NORMAL` [-> `"01"` (Normal Cancellation / 通常解約)] | Service Cancellation Reason Code -> "01: Normal Cancellation" (changed from old constant in v20.00.00) |
| 55 | SET | `setParam[53] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_DLRE_MEMO))` | Service Cancellation Reason Memo (サービス解約理由メモ) |
| 56 | SET | `setParam[54] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.DSL_TNT_USER_ID))` | Cancellation Responsible User ID (解約担当者ユーザーID) |
| 57 | SET | `setParam[55] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_DSL_TTDKI_FIN_FLG))` | Service Cancellation Handled Completion Flag (サービス解約手続完了フラグ) |
| 58 | SET | `setParam[56] = ""` | Recovery Date (回復年月日) — OM-2014-0000400: set to empty string |
| 59 | SET | `setParam[57] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_CANCEL_CL_YMD))` | Service Cancel Withdrawal Date (サービスキャンセル取消年月日) |
| 60 | SET | `setParam[58] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_DSL_CL_YMD))` | Service Cancellation Withdrawal Date (サービス解約取消年月日) |
| 61 | SET | `setParam[59] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.CHRG_STA_YMD_HOSEI_UM))` | Billing Start Date Correction Presence/Absence (課金開始年月日補正有无) |
| 62 | SET | `setParam[60] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVC_PAUSE_CHRG_STA_YMD))` | Service Pause Billing Start Date (サービス休止課金開始年月日) |
| 63 | SET | `setParam[61] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.OP_SVC_KEI_HKHASYMD))` | Option Service Contract Occurrence Date (オプションサービス契約発生年月日) |
| 64 | SET | `setParam[62] = JBSbatKKConst.CD01375_PNLTY_HASSEI_CD_0` [-> `"0"` (No Penalty / 違約金なし)] | Penalty Occurrence Code -> "0" (No Penalty, changed from old constant in v20.00.00) |
| 65 | SET | `setParam[63] = strIdoDiv` | Migration Division -> Reservation-expected Migration Division (異動区分->予約予定.異動区分) |
| 66 | SET | `setParam[64] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SHOSA_DSL_FIN_CD))` | Inspection Cancellation Completion Code (照査解約完了コード) |
| 67 | SET | `setParam[65] = JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.SVCTK_BUT_DEL_TRN_JSSI_DTM))` | Service Provision Disposal Processing Implementation DateTime (サービス提供物消去処理実施年月日时分秒) |
| 68 | SET | `setParam[66] = sysDate` | Registration DateTime (登録年月日时分秒) |
| 69 | SET | `setParam[67] = batchUserId` | Registration Operator Account (登録オペレーターアカウント) |
| 70 | SET | `setParam[68] = sysDate` | Update DateTime (更新年月日时分秒) |
| 71 | SET | `setParam[69] = batchUserId` | Update Operator Account (更新オペレーターアカウント) |
| 72 | SET | `setParam[70] = ""` | Delete DateTime (削除年月日时分秒) — empty (record is not deleted) |
| 73 | SET | `setParam[71] = ""` | Delete Operator Account (削除オペレーターアカウント) — empty |
| 74 | SET | `setParam[72] = JBSbatKKConst.MK_FLG_YK` [-> `"0"` (Valid / 有効)] | Invalid Flag -> "0" = Valid (changed from old constant in v20.00.00) |
| 75 | SET | `setParam[73] = ""` | Registration Operation Date (登録運用年月日) — empty |
| 76 | SET | `setParam[74] = ""` | Registration Process ID (登録処理ID) — empty |
| 77 | SET | `setParam[75] = ""` | Update Operation Date (更新運用年月日) — empty |
| 78 | SET | `setParam[76] = ""` | Update Process ID (更新処理ID) — empty |
| 79 | SET | `setParam[77] = ""` | Delete Operation Date (削除運用年月日) — empty |
| 80 | SET | `setParam[78] = ""` | Delete Process ID (削除処理ID) — empty |

### Block 3 — MAIN CONTRACT INSERT (L7870)

> Delegates the Option Service Contract row insert to the PK insert handler.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `executeKK_T_OP_SVC_KEI_PKInsert(setParam)` | Inserts the constructed Option Service Contract record into `KK_T_OP_SVC_KEI` table. Maps each setParam element to a database column via `JBSbatCommonDBInterface.setValue()`. |

### Block 4 — SUB-TYPE REGISTRATION (L7873)

> Registers the sub-type records associated with the newly created Option Service Contract.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `JKKBatCommon.createSubTypeKK0351(commonItem, opSvcKeiNo, JBSbatStringUtil.Rtrim(dbInfo.getString(JBSbatKK_T_OP_SVC_KEI.GENE_ADD_DTM)), sysDate)` | Register sub-type records (サブクラスの登録) linked to the Option Service Contract number. Passes the generation datetime (GENE_ADD_DTM) from dbInfo as the source timestamp. |
| 2 | RETURN | `return` | Method completes. No return value (void). |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `insertOpSvcKei` | Method | Option Service Contract Registration — creates a new Option Service Contract record at work completion |
| `OP_SVC_KEI_NO` | Field | Option Service Contract Number — unique identifier for the Option Service Contract line item |
| `OP_SVC_KEI_STAT` | Field | Option Service Contract Status — lifecycle state (e.g., "910" = Cancellation Complete) |
| `OP_SVC_CD` | Field | Option Service Code — identifies the specific Option Service product (e.g., eo Multi Router, Phone Adapter) |
| `GENE_ADD_DTM` | Field | Generation Registration DateTime — when the record version was created |
| `OP_SVC_KEI_DSL_INFO` | Field | Option Service Contract Cancellation Detail Info — data for contracts undergoing partial STB removal |
| `SVC_KEI_STAT_DLS_ZM` | Constant | Status Code "910" — Cancellation Complete (解約済). Used to mark the contract as fully cancelled. |
| `RSV_APLY_CD_FIX` | Constant | Reservation Application Code "2" — Reservation Confirmed (予約確定) |
| `PLAN_END_SBT_CD_MSDDSL` | Constant | Plan End Type Code "2" — Plan Change (プラン変更). Replaced "1" in v20.00.00. |
| `SVC_DLRE_CD_NORMAL` | Constant | Service Cancellation Reason Code "01" — Normal Cancellation (通常解約) |
| `CD01375_PNLTY_HASSEI_CD_0` | Constant | Penalty Occurrence Code "0" — No Penalty (違約金なし) |
| `MK_FLG_YK` | Constant | Valid/Invalid Flag "0" — Valid (有効). The record is active. |
| `SVC_KEI_NO` | Field | Service Contract Number — the parent service contract this Option Service belongs to |
| `SVC_KEI_UCWK_NO` | Field | Service Contract Internal Number — internal breakdown number for service contract details |
| `HOJIN_SVC_KEI_UK_NO` | Field | Corporate Service Contract Reception Number — for法人 (corporate/business) customers |
| `MSKM_DTL_NO` | Field | Application Detail Number — identifies the application detail line |
| `IDO_DIV` | Field | Migration Division — code indicating the type of contract change (addition, cancellation, etc.) |
| `kojiakJssiYmd` | Parameter | Work Completion Implementation Date (工事実施年月日) — YYYYMMDD date when physical work was completed |
| `strIdoDiv` | Parameter | Migration Division Code (異動区分) — type of contract migration being performed |
| `strMskmDtlNo` | Parameter | Application Detail Number (申込明細番号) — ID of the application detail triggering this registration |
| `dbInfo` | Parameter | Option Service Contract Current Record — key-value map of the current contract state from `KK_T_OP_SVC_KEI` |
| `KK_T_OP_SVC_KEI` | Table | Option Service Contract table — main table storing Option Service Contract lifecycle data |
| `KK_T_OP_SVC_KEI_SUB` | Table | Option Service Contract Sub-type table — stores sub-type breakdown records linked to the main contract |
| `createSubTypeKK0351` | Method | Sub-type registration handler for Option Service Contract (code 0351) |
| `executeKK_T_OP_SVC_KEI_PKInsert` | Method | Performs the actual INSERT into `KK_T_OP_SVC_KEI` from a parameter array |
| STB | Acronym | Set-Top Box — hardware device for TV/service delivery. Partial removal indicates a customer is having some STBs removed. |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband service. The Option Service product family. |
| 工事完了 | Business term | Work Completion — the state when physical installation/construction work has been finished by the technician |
| 解約済 | Business term | Cancellation Complete — the final contract state indicating all cancellation processing has finished |
| 工事案件実施年月日 | Business term | Work Project Implementation Date — the actual date the installation/construction work was performed |
| 異動区分 | Business term | Migration Division — a code classifying what type of contract change is occurring (addition, cancellation, transfer, etc.) |
| 申込明細番号 | Business term | Application Detail Number — unique identifier for a line item within a customer application |
| 違約金 | Business term | Penalty / Liquidated Damages — fees charged when a contract is cancelled before the agreed term. Code "0" means no penalty applies. |
| batchUserId | Field | Batch Job User ID — the system user account under which the batch process runs, used for audit trail |
