# Business Logic — JBSBatKKKkOpDlRvAdd.insertOpSvcKei() [211 LOC]

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

## 1. Role

### JBSBatKKKkOpDlRvAdd.insertOpSvcKei()

This method performs the **discontinuation suspension processing** (v22.00.00) of an **Operation Service Contract** (op_svc_kei — オプションサービス契約) for a **machine-provided service** (機器提供サービス) in a telecom wholesale batch system. It retrieves the existing operation service contract record from the `KK_T_OP_SVC_KEI` table by its composite primary key (`op_svc_kei_no` + `gene_add_dtm`), runs Rule 0066 to determine the authoritative service charge start date, and then constructs a comprehensive 79-field parameter set that represents the terminal state of the service contract after discontinuation suspension. The method uses the **builder pattern**: it populates a flat `String[79]` array with all relevant contract fields — pulling values from the fetched database record, instance fields (`opeDate`), and method parameters — before delegating to `executeKK_T_OP_SVC_KEI_PKINSERT()` which performs an insert-by-primary-key into the same table. This effectively **archives or snapshots** the complete operation service contract record at the point of discontinuation suspension, ensuring the database contains a full historical state. The processing is date-driven: v22.00.00 changed the source of end-related dates from the instance field `this.opeDate` to the parameter `idoRsvAplyYmd` (異動予約適用日 — migration reservation application date), enabling deferred processing where the reservation date, not the execution date, determines the effective date.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["insertOpSvcKei params"])
    
    START --> Q1["Query KK_T_OP_SVC_KEI by PK
op_svc_kei_no + gene_add_dtm"]
    Q1 --> RULE["callRule0066001
Get service charge start date"]
    RULE --> ARRAY["Create setParam array[79]"]
    ARRAY --> SET1["Set fields 0-65 from opSvKeiKeyMap
and constant values"]
    SET1 --> RULE_CHECK{"ruleDate equals SPACE?"}
    RULE_CHECK -->|"Yes
callRule0066001 returned
empty date"| SET2["Set field 28 = field 48
Set field 36 = field 48
(use service end date)"]
    RULE_CHECK -->|"No
callRule0066001 returned
ruleDate"| SET3["Set field 28 = ruleDate
Set field 36 = ruleDate
(use rule-derived date)"]
    SET2 --> EXEC["executeKK_T_OP_SVC_KEI_PKINSERT(setParam)"]
    SET3 --> EXEC
    EXEC --> END(("Return / Next"))
```

**CRITICAL — Constant Resolution:**
- `JBSbatKKConst.SVC_KEI_STAT_DLS_ZM = "910"` — Service detail status: Service discontinuation suspension completed (サービス契約内容ステータス: サービス停止中止完了). In v22.00.00, replaced the literal `OP_SVC_KEI_STAT_910` with this constant reference.
- `JKKBatConst.RSV_APLY_CD_RSV_FIX = "2"` — Reservation application code: Reservation fixed (予約適用コード: 予約決定). The contract reservation status is set to "fixed" at the point of discontinuation suspension.
- `JBSbatKKConst.CD00879_SVC_DLRE_CD_01 = "01"` — Service dissolution reason code 01 (サービス解約理由コード: 01). Hardcoded as the reason for service cancellation during discontinuation suspension.
- `JBSbatKKConst.CD01359_FIN_FLG_1 = "1"` — Service dissolution procedure completion flag: completed (サービス解約手順完了フラグ: 完了). Marks the dissolution procedure as finished.
- `JKKBatConst.SPACE = ""` — Empty string constant used as default/null value placeholder (e.g., for `KAIHK_YMD` — recovery date).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `op_svc_kei_no` | `String` | Operation service contract number — the unique identifier of the operation service contract line item to process. Used as the primary key to look up the record in `KK_T_OP_SVC_KEI`. |
| 2 | `gene_add_dtm` | `String` | Generation registration datetime — the timestamp when this contract version was created (世代登録年月日時分秒). Part of the composite primary key for versioned contract records. |
| 3 | `ido_div` | `String` | Migration distinction — classification code indicating the type of migration/operation being performed (異動区分). Set into `setParam[63]` to record the operation type in the inserted record. |
| 4 | `sysDate` | `String` | System date — used as the `GENE_ADD_DTM` field (setParam[1]) in the output, replacing the original generation datetime with the system date. |
| 5 | `idoRsvAplyYmd` | `String` | Migration reservation application date — the effective date for reservation-related fields (予約適用日). In v22.00.00, replaced `this.opeDate` as the source for: plan end date (field 29), service end date (field 48), service charge end date (field 50), and service dissolution date (field 51). This enables deferred/batch-processed contracts where the reservation date, not execution date, determines effective dates. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `this.opeDate` | `String` | Operation date — instance field used for `RSV_APLY_YMD` (field 23: reservation application date). Still partially in use but superseded by `idoRsvAplyYmd` for most date fields. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `db_KK_T_OP_SVC_KEI.selectByPrimaryKeys` | — | `KK_T_OP_SVC_KEI` | Reads the existing operation service contract record by primary key (`op_svc_kei_no`, `gene_add_dtm`) to populate `opSvKeiKeyMap` |
| C | `callRule0066001` | — | — | Executes Rule 0066 (sokan/rule engine) to determine the authoritative service charge start date. Returns a date string or empty. Internal method that invokes `JCCBatCommon.createSokanRuleEngine(RULE0066001)` |
| C | `executeKK_T_OP_SVC_KEI_PKINSERT(setParam)` | — | `KK_T_OP_SVC_KEI` | Inserts a new operation service contract record using the populated 79-field parameter array. Internally maps each `setParam[i]` to a field name and calls `db_KK_T_OP_SVC_KEI.insertByPrimaryKeys(setMap)` |
| R | `opSvKeiKeyMap.getString(...)` | — | — | Reads individual field values from the retrieved contract record. Called 40+ times for fields spanning contract identity, dates, status codes, cancellation data, pause data, and audit fields |

### Detailed per-call analysis:

| # | CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|---|------|----------|---------|-------------|----------------------|
| 1 | R | `db_KK_T_OP_SVC_KEI.selectByPrimaryKeys` | — | `KK_T_OP_SVC_KEI` | Query: Selects the operation service contract record by composite PK (`op_svc_kei_no`, `gene_add_dtm`). Returns `JBSbatCommonDBInterface` containing the full row. |
| 2 | C | `callRule0066001` | — | — | Rule execution: Invokes Rule 0066 via `JCCBatCommon.createSokanRuleEngine` to determine the authoritative service charge start date. Parameters: `SVC_CD` = `JKKBatConst.SVC_CD_NET` (01 = internet service), `UP_OPTY` = `UPD_OPTY_ZERO` (0 = cancellation), `DSLJI_CHRG` = `DSLJI_CHRG_FLG_HIKAKIN` (0 = no charge). Returns either a date string or empty. |
| 3 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.OP_SVC_KEI_NO)` | — | `KK_T_OP_SVC_KEI` | Read: Operation service contract number (field 0). |
| 4 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.OP_SVC_CD)` | — | `KK_T_OP_SVC_KEI` | Read: Operation service code (field 3). |
| 5 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.PCRS_CD)` | — | `KK_T_OP_SVC_KEI` | Read: Price course code (field 4). |
| 6 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.PPLAN_CD)` | — | `KK_T_OP_SVC_KEI` | Read: Price plan code (field 5). |
| 7 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.OYA_KEI_SKBT_CD)` | — | `KK_T_OP_SVC_KEI` | Read: Parent contract identification code (field 6). |
| 8 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_KEI_NO)` | — | `KK_T_OP_SVC_KEI` | Read: Service contract number (field 7). |
| 9 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_KEI_UCWK_NO)` | — | `KK_T_OP_SVC_KEI` | Read: Service contract detail number (field 8). |
| 10 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.HOJIN_SVC_KEI_UK_NO)` | — | `KK_T_OP_SVC_KEI` | Read: Legal entity service contract reception number (field 9). |
| 11 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SYSID)` | — | `KK_T_OP_SVC_KEI` | Read: SYSID (field 10). |
| 12 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.MSKM_DTL_NO)` | — | `KK_T_OP_SVC_KEI` | Read: Application detail number (field 11). |
| 13 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.FTRIAL_KANYU_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Trial insertion date (field 12). |
| 14 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.FTRIAL_PRD_ENDYMD)` | — | `KK_T_OP_SVC_KEI` | Read: Trial period end date (field 13). |
| 15 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.HONKANYU_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Full insertion date (field 14). |
| 16 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.HONKANYU_IKO_KIGEN_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Full insertion relocation deadline date (field 15). |
| 17 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_USE_STA_KIBO_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Service usage start desired date (field 16). |
| 18 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.RSV_TSTA_KIBO_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Reservation application start desired date (field 17). |
| 19 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.OP_SVC_KEI_KZKWRK_REQYMD)` | — | `KK_T_OP_SVC_KEI` | Read: Operation service contract follow-up work request date (field 18). |
| 20 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SHOSA_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Inspection date (field 19). |
| 21 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SHOSA_CL_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Inspection cancellation date (field 20). |
| 22 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SKEKKA_SEND_CD)` | — | `KK_T_OP_SVC_KEI` | Read: Review result notification code (field 21). |
| 23 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.KEI_CNC_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Contract conclusion date (field 22). |
| 24 | SET | `this.opeDate` | — | — | Set: Reservation application date (field 23) from instance field. |
| 25 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.RSV_CL_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Reservation cancellation date (field 24). |
| 26 | SET | `JKKBatConst.RSV_APLY_CD_RSV_FIX = "2"` | — | — | Set: Reservation application code = "2" (reservation fixed). |
| 27 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.PLAN_STAYMD)` | — | `KK_T_OP_SVC_KEI` | Read: Plan start date (field 26). |
| 28 | R/conditional | `idoRsvAplyYmd` or `callRule0066001` | — | — | Set: Plan end date (field 27) and plan charge start date (field 28). If ruleDate is empty, uses service end date; otherwise uses rule-derived date. |
| 29 | R/conditional | `idoRsvAplyYmd` or `callRule0066001` | — | — | Set: Plan charge end date (field 29). Uses `idoRsvAplyYmd - 1 day` or rule date - 1 day. |
| 30 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.PLAN_END_SBT_CD)` | — | `KK_T_OP_SVC_KEI` | Read: Plan end type code (field 30). |
| 31 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_CANCEL_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Service cancellation date (field 31). |
| 32 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_CANCEL_RSN_CD)` | — | `KK_T_OP_SVC_KEI` | Read: Service cancellation reason code (field 32). |
| 33 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STAYMD)` | — | `KK_T_OP_SVC_KEI` | Read: Service start date (field 33). |
| 34 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STA_HMS)` | — | `KK_T_OP_SVC_KEI` | Read: Service start time (field 34). |
| 35 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.DSP_SVCTK_STAYMD)` | — | `KK_T_OP_SVC_KEI` | Read: Display service provision start date (field 35). |
| 36 | R/conditional | `idoRsvAplyYmd` or `callRule0066001` | — | — | Set: Service charge start date (field 36). Same conditional logic as fields 28/36. |
| 37 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STP_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Service stop date (field 37). |
| 38 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STP_RSN_CD)` | — | `KK_T_OP_SVC_KEI` | Read: Service stop reason code (field 38). |
| 39 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STP_RLS_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Service stop release date (field 39). |
| 40 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_STP_RLS_RSN_CD)` | — | `KK_T_OP_SVC_KEI` | Read: Service stop release reason code (field 40). |
| 41 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.PAUSE_STP_CD)` | — | `KK_T_OP_SVC_KEI` | Read: Suspension interruption code (field 41). |
| 42-47 | R | Various | — | `KK_T_OP_SVC_KEI` | Read: Service pause date/reason code/memo and pause release date/reason code/memo (fields 42–47). |
| 48 | R/conditional | `idoRsvAplyYmd` | — | — | Set: Service end date (field 48). v22.00.00: uses `idoRsvAplyYmd` instead of `this.opeDate`. |
| 49 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_END_HMS)` | — | `KK_T_OP_SVC_KEI` | Read: Service end time (field 49). |
| 50 | R/conditional | `idoRsvAplyYmd` | — | — | Set: Service charge end date (field 50). Uses `idoRsvAplyYmd - 1 day`. |
| 51 | R/conditional | `idoRsvAplyYmd` | — | — | Set: Service dissolution date (field 51). v22.00.00: uses `idoRsvAplyYmd`. |
| 52 | SET | `JBSbatKKConst.CD00879_SVC_DLRE_CD_01 = "01"` | — | — | Set: Service dissolution reason code = "01" (v22.00.00 constant). |
| 53 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_DLRE_MEMO)` | — | `KK_T_OP_SVC_KEI` | Read: Service dissolution memo (field 53). |
| 54 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.DSL_TNT_USER_ID)` | — | `KK_T_OP_SVC_KEI` | Read: Dissolution responsible user ID (field 54). |
| 55 | SET | `JBSbatKKConst.CD01359_FIN_FLG_1 = "1"` | — | — | Set: Service dissolution procedure completion flag = "1" (completed). |
| 56 | SET | `JKKBatConst.SPACE = ""` | — | — | Set: Recovery date = empty string (v7.00.04: commented out original db read). |
| 57 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_CANCEL_CL_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Service cancellation cancellation date (field 57). |
| 58 | R | `opSvKeiKeyMap.getString(JBSbatKK_T_OP_SVC_KEI.SVC_DSL_CL_YMD)` | — | `KK_T_OP_SVC_KEI` | Read: Service dissolution cancellation date (field 58). |
| 59-65 | R | Various | — | `KK_T_OP_SVC_KEI` | Read: Billing start date correction flag, pause billing start date, contract continuation date, penalty occurrence code, distinction code, inspection dissolution completion code, service provision service deletion processing date-time (fields 59–65). |
| 66-68 | R | — | — | `KK_T_OP_SVC_KEI` | Read: Registration date-time, registration operator account, update date-time, update operator account (commented out — fields 66–69 not set). |
| 69-72 | R | Various | — | `KK_T_OP_SVC_KEI` | Read: Deletion date-time, deletion operator account, invalid flag (fields 70–72). Fields 73–76 commented out. |
| 73-74 | R | Various | — | `KK_T_OP_SVC_KEI` | Read: Deletion operation date, deletion process ID (fields 77–78). |
| 75 | C | `executeKK_T_OP_SVC_KEI_PKINSERT` | — | `KK_T_OP_SVC_KEI` | Create: Inserts the fully-populated 79-field record into `KK_T_OP_SVC_KEI` via `db_KK_T_OP_SVC_KEI.insertByPrimaryKeys()`. |

## 5. Dependency Trace

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

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSBatKKKkOpDlRvAdd` | `JBSBatKKKkOpDlRvAdd.execute()` → `insertOpSvcKei(op_svc_kei_no, gene_add_dtm, ido_div, sysDate, idoRsvAplyYmd)` | `executeKK_T_OP_SVC_KEI_PKINSERT [C] KK_T_OP_SVC_KEI`, `db_KK_T_OP_SVC_KEI.selectByPrimaryKeys [R] KK_T_OP_SVC_KEI`, `callRule0066001 [C] —` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(Initialization and Database Query)` (L2782)

> Creates the database query interface and fetches the operation service contract record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `whereMap = new JBSbatCommonDBInterface()` |
| 2 | EXEC | `whereMap.setValue(JBSbatKK_T_OP_SVC_KEI.OP_SVC_KEI_NO, op_svc_kei_no)` // Set contract number as query key |
| 3 | EXEC | `whereMap.setValue(JBSbatKK_T_OP_SVC_KEI.GENE_ADD_DTM, gene_add_dtm)` // Set generation datetime as query key |
| 4 | CALL | `opSvKeiKeyMap = db_KK_T_OP_SVC_KEI.selectByPrimaryKeys(whereMap)` // R: Read contract record from KK_T_OP_SVC_KEI |

**Block 2** — [CALL] `(Rule 0066 Execution)` (L2789)

> Invokes Rule 0066 to determine the authoritative service charge start date. The rule engine is configured with: `SVC_CD = "01"` (internet service), `UP_OPTY = "0"` (cancellation), `DSLJI_CHRG = "0"` (no charge). The returned date is either an actual date string or empty (SPACE).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `ruleDate = callRule0066001(opSvKeiKeyMap)` // C: Rule 0066 execution — determines authoritative service charge start date |

**Block 3** — [SET] `(Array Allocation)` (L2791)

> Allocates the 79-element output parameter array that will be passed to the insert method.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setParam = new String[79]` |

**Block 4** — [SET] `(Fields 0-78: Field Population)` (L2794–L2950)

> Populates the 79-element array with field values from the fetched record, constants, and parameters. The Japanese comments (inline with `//`) indicate each field's business meaning.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setParam[0] = opSvKeiKeyMap.getString(OP_SVC_KEI_NO)` // Operation service contract number |
| 2 | SET | `setParam[1] = sysDate` // Generation registration datetime (system date) |
| 3 | SET | `setParam[2] = JBSbatKKConst.SVC_KEI_STAT_DLS_ZM = "910"` // Service detail status: discontinuation suspension completed [-> v22.00.00 change] |
| 4 | SET | `setParam[3] = opSvKeiKeyMap.getString(OP_SVC_CD)` // Operation service code |
| 5 | SET | `setParam[4] = opSvKeiKeyMap.getString(PCRS_CD)` // Price course code |
| 6 | SET | `setParam[5] = opSvKeiKeyMap.getString(PPLAN_CD)` // Price plan code |
| 7 | SET | `setParam[6] = opSvKeiKeyMap.getString(OYA_KEI_SKBT_CD)` // Parent contract identification code |
| 8 | SET | `setParam[7] = opSvKeiKeyMap.getString(SVC_KEI_NO)` // Service contract number |
| 9 | SET | `setParam[8] = opSvKeiKeyMap.getString(SVC_KEI_UCWK_NO)` // Service contract detail number |
| 10 | SET | `setParam[9] = opSvKeiKeyMap.getString(HOJIN_SVC_KEI_UK_NO)` // Legal entity service contract reception number |
| 11 | SET | `setParam[10] = opSvKeiKeyMap.getString(SYSID)` // SYSID |
| 12 | SET | `setParam[11] = opSvKeiKeyMap.getString(MSKM_DTL_NO)` // Application detail number |
| 13 | SET | `setParam[12] = opSvKeiKeyMap.getString(FTRIAL_KANYU_YMD)` // Trial insertion date |
| 14 | SET | `setParam[13] = opSvKeiKeyMap.getString(FTRIAL_PRD_ENDYMD)` // Trial period end date |
| 15 | SET | `setParam[14] = opSvKeiKeyMap.getString(HONKANYU_YMD)` // Full insertion date |
| 16 | SET | `setParam[15] = opSvKeiKeyMap.getString(HONKANYU_IKO_KIGEN_YMD)` // Full insertion relocation deadline date |
| 17 | SET | `setParam[16] = opSvKeiKeyMap.getString(SVC_USE_STA_KIBO_YMD)` // Service usage start desired date |
| 18 | SET | `setParam[17] = opSvKeiKeyMap.getString(RSV_TSTA_KIBO_YMD)` // Reservation application start desired date |
| 19 | SET | `setParam[18] = opSvKeiKeyMap.getString(OP_SVC_KEI_KZKWRK_REQYMD)` // Follow-up work request date |
| 20 | SET | `setParam[19] = opSvKeiKeyMap.getString(SHOSA_YMD)` // Inspection date |
| 21 | SET | `setParam[20] = opSvKeiKeyMap.getString(SHOSA_CL_YMD)` // Inspection cancellation date |
| 22 | SET | `setParam[21] = opSvKeiKeyMap.getString(SKEKKA_SEND_CD)` // Review result notification code |
| 23 | SET | `setParam[22] = opSvKeiKeyMap.getString(KEI_CNC_YMD)` // Contract conclusion date |
| 24 | SET | `setParam[23] = this.opeDate` // Reservation application date [instance field] |
| 25 | SET | `setParam[24] = opSvKeiKeyMap.getString(RSV_CL_YMD)` // Reservation cancellation date |
| 26 | SET | `setParam[25] = JKKBatConst.RSV_APLY_CD_RSV_FIX = "2"` // Reservation application code: fixed [-> RSV_FIX="2"] |
| 27 | SET | `setParam[26] = opSvKeiKeyMap.getString(PLAN_STAYMD)` // Plan start date |
| 28 | SET | `setParam[27] = idoRsvAplyYmd` // Plan end date [v22.00.00: replaced this.opeDate] |
| 29 | SET | `setParam[29] = JBSbatDateUtil.adjustDate(idoRsvAplyYmd, -1)` // Plan charge end date [idoRsvAplyYmd - 1 day] |
| 30 | SET | `setParam[30] = opSvKeiKeyMap.getString(PLAN_END_SBT_CD)` // Plan end type code |
| 31 | SET | `setParam[31] = opSvKeiKeyMap.getString(SVC_CANCEL_YMD)` // Service cancellation date |
| 32 | SET | `setParam[32] = opSvKeiKeyMap.getString(SVC_CANCEL_RSN_CD)` // Service cancellation reason code |
| 33 | SET | `setParam[33] = opSvKeiKeyMap.getString(SVC_STAYMD)` // Service start date |
| 34 | SET | `setParam[34] = opSvKeiKeyMap.getString(SVC_STA_HMS)` // Service start time |
| 35 | SET | `setParam[35] = opSvKeiKeyMap.getString(DSP_SVCTK_STAYMD)` // Display service provision start date |
| 36 | SET | `setParam[37] = opSvKeiKeyMap.getString(SVC_STP_YMD)` // Service stop date |
| 37 | SET | `setParam[38] = opSvKeiKeyMap.getString(SVC_STP_RSN_CD)` // Service stop reason code |
| 38 | SET | `setParam[39] = opSvKeiKeyMap.getString(SVC_STP_RLS_YMD)` // Service stop release date |
| 39 | SET | `setParam[40] = opSvKeiKeyMap.getString(SVC_STP_RLS_RSN_CD)` // Service stop release reason code |
| 40 | SET | `setParam[41] = opSvKeiKeyMap.getString(PAUSE_STP_CD)` // Suspension interruption code |
| 41 | SET | `setParam[42] = opSvKeiKeyMap.getString(SVC_PAUSE_YMD)` // Service pause date |
| 42 | SET | `setParam[43] = opSvKeiKeyMap.getString(SVC_PAUSE_RSN_CD)` // Service pause reason code |
| 43 | SET | `setParam[44] = opSvKeiKeyMap.getString(SVC_PAUSE_RSN_MEMO)` // Service pause reason memo |
| 44 | SET | `setParam[45] = opSvKeiKeyMap.getString(SVC_PAUSE_RLS_YMD)` // Service pause release date |
| 45 | SET | `setParam[46] = opSvKeiKeyMap.getString(SVC_PAUSE_RLS_RSN_CD)` // Service pause release reason code |
| 46 | SET | `setParam[47] = opSvKeiKeyMap.getString(SVC_PAUSE_RLS_RSN_MEMO)` // Service pause release reason memo |
| 47 | SET | `setParam[48] = idoRsvAplyYmd` // Service end date [v22.00.00: replaced this.opeDate] |
| 48 | SET | `setParam[49] = opSvKeiKeyMap.getString(SVC_END_HMS)` // Service end time |
| 49 | SET | `setParam[50] = JBSbatDateUtil.adjustDate(idoRsvAplyYmd, -1)` // Service charge end date [idoRsvAplyYmd - 1 day] |
| 50 | SET | `setParam[51] = idoRsvAplyYmd` // Service dissolution date [v22.00.00: replaced this.opeDate] |
| 51 | SET | `setParam[52] = JBSbatKKConst.CD00879_SVC_DLRE_CD_01 = "01"` // Service dissolution reason code [-> CD00879="01"] |
| 52 | SET | `setParam[53] = opSvKeiKeyMap.getString(SVC_DLRE_MEMO)` // Service dissolution memo |
| 53 | SET | `setParam[54] = opSvKeiKeyMap.getString(DSL_TNT_USER_ID)` // Dissolution responsible user ID |
| 54 | SET | `setParam[55] = JBSbatKKConst.CD01359_FIN_FLG_1 = "1"` // Service dissolution procedure completion flag [-> FIN_FLG_1="1"] |
| 55 | SET | `setParam[56] = JKKBatConst.SPACE = ""` // Recovery date (v7.00.04: set to empty instead of db read) |
| 56 | SET | `setParam[57] = opSvKeiKeyMap.getString(SVC_CANCEL_CL_YMD)` // Service cancellation cancellation date |
| 57 | SET | `setParam[58] = opSvKeiKeyMap.getString(SVC_DSL_CL_YMD)` // Service dissolution cancellation date |
| 58 | SET | `setParam[59] = opSvKeiKeyMap.getString(CHRG_STA_YMD_HOSEI_UM)` // Billing start date correction flag |
| 59 | SET | `setParam[60] = opSvKeiKeyMap.getString(SVC_PAUSE_CHRG_STA_YMD)` // Service pause billing start date |
| 60 | SET | `setParam[61] = opSvKeiKeyMap.getString(OP_SVC_KEI_HKHASYMD)` // Operation service contract continuation occurrence date |
| 61 | SET | `setParam[62] = opSvKeiKeyMap.getString(PNLTY_HASSEI_CD)` // Penalty occurrence code |
| 62 | SET | `setParam[63] = ido_div` // Migration distinction [parameter] |
| 63 | SET | `setParam[64] = opSvKeiKeyMap.getString(SHOSA_DSL_FIN_CD)` // Inspection dissolution completion code |
| 64 | SET | `setParam[65] = opSvKeiKeyMap.getString(SVCTK_BUT_DEL_TRN_JSSI_DTM)` // Service provision service deletion processing datetime |
| 65 | SET | `setParam[70] = opSvKeiKeyMap.getString(DEL_DTM)` // Deletion datetime |
| 66 | SET | `setParam[71] = opSvKeiKeyMap.getString(DEL_OPEACNT)` // Deletion operator account |
| 67 | SET | `setParam[72] = opSvKeiKeyMap.getString(MK_FLG)` // Invalid flag |
| 68 | SET | `setParam[77] = opSvKeiKeyMap.getString(DEL_UNYO_YMD)` // Deletion operation date |
| 69 | SET | `setParam[78] = opSvKeiKeyMap.getString(DEL_TRN_ID)` // Deletion process ID |

Note: Fields 66–69, 73–76 are commented out (registration datetime, registration operator account, update datetime, update operator account, registration operation date, registration process ID, update operation date, update process ID).

**Block 5** — [IF/ELSE] `(ruleDate equals SPACE?)` (L2952)

> Conditional logic to determine plan charge start date (field 28) and service charge start date (field 36). If the rule engine returned an empty date (SPACE), use the service end date (field 48) as the charge start date. Otherwise, use the rule-derived date. This reflects the Rule 0066 outcome: when the rule cannot determine a charge start date, the system falls back to using the service end date.

| # | Type | Code |
|---|------|------|
| 1 | IF | `JKKBatConst.SPACE.equals(ruleDate)` [condition: ruleDate is empty] |

**Block 5.1** — [IF branch: ruleDate is empty] `(Use service end date for charges)` (L2953)

> When Rule 0066 returns empty, plan charges and service charges start from the service end date.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setParam[28] = setParam[48]` // Plan charge start date = service end date |
| 2 | SET | `setParam[36] = setParam[48]` // Service charge start date = service end date |

**Block 5.2** — [ELSE branch: ruleDate is not empty] `(Use rule-derived date for charges)` (L2957)

> When Rule 0066 returns a valid date, that date becomes the authoritative charge start date for both plan and service charges.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setParam[28] = ruleDate` // Plan charge start date = rule-derived date |
| 2 | SET | `setParam[36] = ruleDate` // Service charge start date = rule-derived date |

**Block 6** — [CALL] `(Record Insertion)` (L2988)

> Final step: inserts the fully-populated 79-field operation service contract record into the database via `executeKK_T_OP_SVC_KEI_PKINSERT()`, which internally creates a `JBSbatCommonDBInterface`, maps all 79 fields by name, and executes `db_KK_T_OP_SVC_KEI.insertByPrimaryKeys(setMap)`.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_OP_SVC_KEI_PKINSERT(setParam)` // C: Insert complete operation service contract record into KK_T_OP_SVC_KEI |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `op_svc_kei_no` | Field | Operation service contract number — unique identifier for an optional service contract line item in the telecom system |
| `gene_add_dtm` | Field | Generation registration datetime — version-tracking timestamp for contract records (世代登録年月日時分秒) |
| `ido_div` | Field | Migration distinction — classification code for the type of migration/operation being performed (異動区分) |
| `idoRsvAplyYmd` | Field | Migration reservation application date — effective date for deferred processing (異動予約適用日) |
| `opSvKeiKeyMap` | Field | Operation service contract key map — JBSbatCommonDBInterface holding the fetched contract record |
| `setParam` | Field | 79-element parameter array — flat data structure mapping all fields for the PK insert |
| `KK_T_OP_SVC_KEI` | Table | Operation service contract table — stores optional service contract line items (機器提供オプションサービス契約) |
| `SVC_KEI_STAT_DLS_ZM` | Constant | Service detail status: discontinuation suspension completed = "910" (サービス契約内容ステータス: サービス停止中止完了) |
| `RSV_APLY_CD_RSV_FIX` | Constant | Reservation application code: reservation fixed = "2" (予約適用コード: 予約決定) |
| `CD00879_SVC_DLRE_CD_01` | Constant | Service dissolution reason code = "01" (サービス解約理由コード: 01) |
| `CD01359_FIN_FLG_1` | Constant | Service dissolution procedure completion flag: completed = "1" (サービス解約手順完了フラグ: 完了) |
| `SPACE` | Constant | Empty string — used as null placeholder for optional fields (空白) |
| Rule 0066 | Rule | Sokan (sokan) rule engine rule for determining service charge start date during cancellation. Parameters: SVC_CD="01" (internet), UP_OPTY="0" (cancellation), DSLJI_CHRG="0" (no charge) |
| JCCBatCommon | Class | Batch common component class providing rule engine creation (`createSokanRuleEngine`) and check result retrieval (`getCheckResultArray`) |
| JBSbatBusinessService | Parent Class | Base class for all batch business services (JBSBatKKKkOpDlRvAdd extends this) |
| `insertByPrimaryKeys` | Method | Database insert operation using primary key columns |
| `selectByPrimaryKeys` | Method | Database select operation using primary key columns |
| `SVC_CD_NET` | Constant | Service code for internet service = "01" (インターネットサービス) |
| `UPD_OPTY_ZERO` | Constant | Update opportunity: 0 = cancellation (解約時) |
| `DSLJI_CHRG_FLG_HIKAKIN` | Constant | Cancellation charge flag: 0 = no charge (非課金) |
| `OP_SVC_CD` | Field | Operation service code — identifies the type of optional service |
| `PCRS_CD` | Field | Price course code — pricing course classification |
| `PPLAN_CD` | Field | Price plan code — pricing plan classification |
| `OYA_KEI_SKBT_CD` | Field | Parent contract identification code — identifies the parent service contract |
| `SVC_KEI_NO` | Field | Service contract number — the main service contract this operation service belongs to |
| `SVC_KEI_UCWK_NO` | Field | Service contract detail number — internal tracking ID for service contract items |
| `HOJIN_SVC_KEI_UK_NO` | Field | Legal entity service contract reception number — for business/corporate contracts (法人サービス契約受付番号) |
| `MSKM_DTL_NO` | Field | Application detail number — associated application detail record |
| `FTRIAL_KANYU_YMD` | Field | Trial insertion date — when trial service was registered (試用加入年月日) |
| `FTRIAL_PRD_ENDYMD` | Field | Trial period end date — when trial service ends (試用期間終了年月日) |
| `HONKANYU_YMD` | Field | Full insertion date — when full service was registered (本加入年月日) |
| `HONKANYU_IKO_KIGEN_YMD` | Field | Full insertion relocation deadline date (本加入移行期限年月日) |
| `SVC_USE_STA_KIBO_YMD` | Field | Service usage start desired date (サービス利用開始希望年月日) |
| `RSV_TSTA_KIBO_YMD` | Field | Reservation application start desired date (予約適用開始希望年月日) |
| `OP_SVC_KEI_KZKWRK_REQYMD` | Field | Operation service contract follow-up work request date (オプションサービス契約後続業務依頼年月日) |
| `SHOSA_YMD` | Field | Inspection date (照会年月日) |
| `SHOSA_CL_YMD` | Field | Inspection cancellation date (照会取消年月日) |
| `SKEKKA_SEND_CD` | Field | Review result notification code (審査結果送信コード) |
| `KEI_CNC_YMD` | Field | Contract conclusion date (契約締結年月日) |
| `RSV_APLY_YMD` | Field | Reservation application date (予約適用年月日) |
| `RSV_CL_YMD` | Field | Reservation cancellation date (予約取消年月日) |
| `PLAN_STAYMD` | Field | Plan start date (プラン開始年月日) |
| `PLAN_ENDYMD` | Field | Plan end date (プラン終了年月日) |
| `PLAN_CHRG_STAYMD` | Field | Plan charge start date (プラン課金開始年月日) |
| `PLAN_CHRG_ENDYMD` | Field | Plan charge end date (プラン課金終了年月日) |
| `PLAN_END_SBT_CD` | Field | Plan end type code (プラン終了種別コード) |
| `SVC_CANCEL_YMD` | Field | Service cancellation date (サービス取消年月日) |
| `SVC_CANCEL_RSN_CD` | Field | Service cancellation reason code (サービス取消理由コード) |
| `SVC_STAYMD` | Field | Service start date (サービス開始年月日) |
| `SVC_STA_HMS` | Field | Service start time (サービス開始时分秒) |
| `DSP_SVCTK_STAYMD` | Field | Display service provision start date (表示用サービス提供開始年月日) |
| `SVC_CHRG_STAYMD` | Field | Service charge 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_STP_RLS_RSN_CD` | Field | Service stop release reason code (サービス停止解除理由コード) |
| `PAUSE_STP_CD` | Field | Suspension interruption code (休止中断コード) |
| `SVC_PAUSE_YMD` | Field | Service pause date (サービス休止年月日) |
| `SVC_PAUSE_RSN_CD` | Field | Service pause reason code (サービス休止理由コード) |
| `SVC_PAUSE_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_ENDYMD` | Field | Service end date (サービス終了年月日) |
| `SVC_END_HMS` | Field | Service end time (サービス終了时分秒) |
| `SVC_CHRG_ENDYMD` | Field | Service charge end date (サービス課金終了年月日) |
| `SVC_DSL_YMD` | Field | Service dissolution date (サービス解約年月日) |
| `SVC_DLRE_CD` | Field | Service dissolution reason code (サービス解約理由コード) |
| `SVC_DLRE_MEMO` | Field | Service dissolution memo (サービス解約理由メモ) |
| `DSL_TNT_USER_ID` | Field | Dissolution responsible user ID (解約担当ユーザーID) |
| `SVC_DSL_TTDKI_FIN_FLG` | Field | Service dissolution procedure completion flag (サービス解約手順完了フラグ) |
| `KAIHK_YMD` | Field | Recovery date (回復年月日) — set to empty in v7.00.04 |
| `SVC_CANCEL_CL_YMD` | Field | Service cancellation cancellation date (サービス取消取消年月日) |
| `SVC_DSL_CL_YMD` | Field | Service dissolution cancellation date (サービス解約取消年月日) |
| `CHRG_STA_YMD_HOSEI_UM` | Field | Billing start date correction flag (課金開始年月日補正有無) |
| `SVC_PAUSE_CHRG_STA_YMD` | Field | Service pause billing start date (サービス休止課金開始年月日) |
| `OP_SVC_KEI_HKHASYMD` | Field | Operation service contract continuation occurrence date (オプションサービス契約発生年月日) |
| `PNLTY_HASSEI_CD` | Field | Penalty occurrence code (違約金発生コード) |
| `SHOSA_DSL_FIN_CD` | Field | Inspection dissolution completion code (照会解約完了コード) |
| `SVCTK_BUT_DEL_TRN_JSSI_DTM` | Field | Service provision service deletion processing datetime (サービス提供物消去処理実行年月日時分秒) |
| `DEL_DTM` | Field | Deletion datetime (削除年月日時分秒) |
| `DEL_OPEACNT` | Field | Deletion operator account (削除オペレータアカウント) |
| `MK_FLG` | Field | Invalid/marked flag (無効フラグ) |
| `DEL_UNYO_YMD` | Field | Deletion operation date (削除運用年月日) |
| `DEL_TRN_ID` | Field | Deletion process ID (削除処理ID) |
| `opeDate` | Instance Field | Operation date — instance field used for certain date fields (部分 v22.00.00 replaced by idoRsvAplyYmd) |
| v22.00.00 | Version | Version change marker — replaced hardcoded literals with constants and changed date source from `this.opeDate` to `idoRsvAplyYmd` |
| v7.00.04 | Version | Version change marker — commented out `KAIHK_YMD` db read and set to empty SPACE |
