# Business Logic — JBSbatKKMiStcKikiCncl.insertSOD() [237 LOC]

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

## 1. Role

### JBSbatKKMiStcKikiCncl.insertSOD()

The `insertSOD` method performs **Service Order Data (SOD) registration** for a changing (modified) service contract in the K-Opticom customer base system. SOD records act as internal trigger documents that propagate service changes through downstream billing, provisioning, and customer information systems. This method is the core batch-side entry point for registering a service change order when equipment is being provided as part of a service contract modification.

The method handles **two service type categories** based on the `isTknrt` flag: (1) **Multi-functional Router (Takino-Router / 多機能ルーター)** — which requires additional lookups for service contract withdrawal details and equipment operation service contracts, and (2) **Router Info (ルーター情報)** — a simpler path that only requires standard service contract data. This branching pattern implements a **routing/dispatch design**: the method routes parameter construction to different service-order profiles depending on the equipment type, then delegates both paths to the same two insert operations.

As a shared batch utility, `insertSOD` is called from `hampinUpdateAndDelete()` during batch processing — specifically as part of the hapie point contract correction update-and-delete workflow (はぴeポイント契約補正情報一括更新 削除補正). It acts as a **data transformer and registrar**, gathering all necessary context from multiple database tables (service contracts, service contract line items, service contract withdrawal details, equipment operation service contracts) and materializing two order records: an order issuance condition record (T_KK_ODR_HAKKO_JOKEN) and an order information work record (T_KK_ODR_INF_SKSI_WK).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["insertSOD params"])
    START --> GET_SYS_DATE["GET sysDate = JCCBatCommon.getSysDateTimeStamp()"]
    GET_SYS_DATE --> INIT_MAPS["INIT maps: svcKeiMap_089, svcKeiUcwkMap_07, svkeiKaienUwMap, kkopSvcKeiMap_018"]
    INIT_MAPS --> SELECT_SVC_UCWK["EXEC executeKK_T_SVC_KEI_UCWK_KK_SELECT_007"]
    SELECT_SVC_UCWK --> NEXT_UCWK["NEXT svcKeiUcwkMap_07 = db.selectNext()"]
    NEXT_UCWK --> LOOP_UCWK{"svcKeiUcwkMap_07 != null"}
    LOOP_UCWK -->|true| CHECK_STAT["GET svcKeiUcwkStat from row"]
    CHECK_STAT --> NOT_TERM_CNCL{"svcKeiUcwkStat != 910 AND != 920"}
    NOT_TERM_CNCL -->|true| SET_UCWK_INFO["SET svcKeiUcwkNo and geneAddDtmUcwk"]
    SET_UCWK_INFO --> BREAK_UCWK["BREAK loop"]
    NOT_TERM_CNCL -->|false| NEXT_UCWK2["NEXT svcKeiUcwkMap_07 = db.selectNext()"]
    NEXT_UCWK2 --> LOOP_UCWK
    BREAK_UCWK --> SELECT_SVC_KEI["EXEC executeKK_T_SVC_KEI_KK_SELECT_089"]
    SELECT_SVC_KEI --> NEXT_SVC["NEXT svcKeiMap_089 = db.selectNext()"]
    NEXT_SVC --> GET_SEQ1["GET seqOdrHakkoJokenNo from SEQ_ODR_HAKKO_JOKEN_NO"]
    GET_SEQ1 --> CHECK_IS_TKNRT{"isTknrt"}
    CHECK_IS_TKNRT -->|true| SET_TKNRT["SET ordSbtCd=2 TEL, svcOrdCd=26 TAKINORT, ordNaiyoCd=404"]
    SET_TKNRT --> SELECT_KAISEN["EXEC executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_007"]
    SELECT_KAISEN --> NEXT_KAISEN["NEXT svkeiKaienUwMap = db.selectNext()"]
    NEXT_KAISEN --> KAISEN_NULL{"svkeiKaienUwMap != null"}
    KAISEN_NULL -->|true| SET_KAISEN_DTM["SET geneAddDtmKsUcwk from map"]
    KAISEN_NULL -->|false| SELECT_KKOP["EXEC executeKK_T_KKOP_SVC_KEI_KK_SELECT_018"]
    SET_KAISEN_DTM --> SELECT_KKOP
    SELECT_KKOP --> NEXT_KKOP["NEXT kkopSvcKeiMap_018 = db.selectNext()"]
    NEXT_KKOP --> LOOP_KKOP{"kkopSvcKeiMap_018 != null"}
    LOOP_KKOP -->|true| CHECK_KKOP_CD{"KKOP_SVC_CD == G01"}
    CHECK_KKOP_CD -->|true| SET_KKOP_INFO["SET kkopSvcKeiNo and geneAddDtmKkop"]
    SET_KKOP_INFO --> NEXT_KKOP2["NEXT kkopSvcKeiMap_018 = db.selectNext()"]
    NEXT_KKOP2 --> LOOP_KKOP
    CHECK_KKOP_CD -->|false| NEXT_KKOP2
    LOOP_KKOP -->|false| EXEC_INSERT["EXEC executeKK_T_ODR_HAKKO_JOKEN_PKINSERT"]
    CHECK_IS_TKNRT -->|false| SET_ROUTER["SET ordSbtCd=1 NET, svcOrdCd=0A ROUTER_INFO, ordNaiyoCd=163"]
    SET_ROUTER --> EXEC_INSERT
    EXEC_INSERT --> GET_SEQ2["GET seqOdrInfSksiWkNo from SEQ_ODR_INF_SKSI_WK_NO"]
    GET_SEQ2 --> EXEC_INSERT2["EXEC executeKK_T_ODR_INF_SKSI_WK_PKINSERT"]
    EXEC_INSERT2 --> END_NODE(["Return"])
```

**Constant resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `JBSbatKKConst.SVC_KEI_STAT_DLS_ZM` | `"910"` | Service contract status: Dissolved/Cancelled (解約済み) |
| `JBSbatKKConst.SVC_KEI_STAT_CNCL_ZM` | `"920"` | Service contract status: Cancelled (キャンセル) |
| `JBSbatKKConst.ORDER_SBT_CD_TEL` | `"2"` | Order subtype: Telephone (電話) |
| `JBSbatKKConst.SVC_ORDER_CD_TAKINORT` | `"26"` | Service order code: Multi-functional Router (多機能ルーター) |
| `JBSbatKKConst.ORDER_NAIYO_CD_TAKINORT_CHG` | `"404"` | Order content code: Multi-functional router settings/changes (router function, connection info change) |
| `JBSbatKKConst.KK2801_KKOP_SVC_CD_G01` | `"G01"` | Equipment operation service code: eo光 Multi-functional Router — router function (eo光多機能ルーター ルーター機能) |
| `JBSbatKKConst.ORDER_SBT_CD_NET` | `"1"` | Order subtype: Network (ネット) |
| `JBSbatKKConst.SVC_ORDER_CD_ROUTER_INFO` | `"0A"` | Service order code: Router connection information (ルーター向け接続情報) |
| `JBSbatKKConst.ORDER_NAIYO_CD_ROUTER_INFO_CHG` | `"163"` | Order content code: Router connection info changes (ルーター向け接続情報・変更) |
| `JBSbatKKConst.YOKYU_SBT_CD_CHG` | `"04"` | Request subtype: Change (変更) |
| `JBSbatKKConst.ORDER_HAKKO_JOKEN_CD_SOKUJI_HAKKO` | `"01"` | Order issuance condition: Immediate issuance (即時発行) |
| `JBSbatKKConst.MK_FLG_YK` | `"0"` | Invalid flag: Valid (有効) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `kktkSvcKei` | `JBSbatCommonDBInterface` | Equipment provision service contract — the service contract record for the equipment being provided (機器提供サービス契約). Used to extract fields such as `SVC_KEI_KAISEN_UCWK_NO` (service contract withdrawal details number), `TAKNKIKI_MODEL_CD` (home equipment model code), `KIKI_SEIZO_NO` (equipment serial number), and `GENE_ADD_DTM` (generation registration datetime). |
| 2 | `kktkSvcKeiNo` | `String` | Equipment provision service contract number — the unique identifier of the equipment provision service contract. Used as a WHERE parameter for querying the equipment operation service contract table (KK_T_KKOP_SVC_KEI). |
| 3 | `svcKeiNo` | `String` | Service contract number — the primary key for identifying the service contract. Used in WHERE clauses to query service contract details (KK_T_SVC_KEI), service contract line items (KK_T_SVC_KEI_UCWK), and service contract withdrawal details (KK_T_SVKEI_KAISEN_UW). |
| 4 | `isTknrt` | `boolean` | Multi-functional router flag — determines which service type branch to process. `true` indicates the change involves a multi-functional router (多機能ルーター / Takino-Router), requiring additional lookups for router-specific data. `false` indicates a standard router information change (ルーター情報). |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `opeDate` | `String` | Operation date — used as a WHERE clause filter in all database queries to ensure only records active on the processing date are returned. |
| `batchUserId` | `String` | Batch user ID — used as a creator/updater ID in both INSERT operations for audit trail purposes. |
| `commonItem` | `Object` | Common item reference — passed to `getFormatedNextSeq()` for sequence generation, likely holding system-wide configuration. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCBatCommon.getSysDateTimeStamp` | - | - | Gets the current system timestamp for audit trail fields (GENE_ADD_DTM, GENE_UPDATE_DTM). |
| R | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_007` | (implied SC) | KK_T_SVC_KEI_UCWK | Queries service contract line items by service contract number and operation date. Used to find a valid (non-cancelled, non-dissolved) line item. |
| R | `db_KK_T_SVC_KEI_UCWK_007.selectNext` | - | KK_T_SVC_KEI_UCWK | Iterates through result set to find first non-terminated line item record. |
| R | `JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_UCWK_STAT` | - | KK_T_SVC_KEI_UCWK | Reads service contract line item status field to filter out dissolved (910) and cancelled (920) records. |
| R | `JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_UCWK_NO` | - | KK_T_SVC_KEI_UCWK | Reads service contract line item number for the SOD record. |
| R | `JBSbatKK_T_SVC_KEI_UCWK.GENE_ADD_DTM` | - | KK_T_SVC_KEI_UCWK | Reads generation registration datetime of the line item. |
| R | `executeKK_T_SVC_KEI_KK_SELECT_089` | (implied SC) | KK_T_SVC_KEI | Queries service contract details by service contract number and operation date. |
| R | `db_KK_T_SVC_KEI_089.selectNext` | - | KK_T_SVC_KEI | Gets the service contract main record. |
| R | `JBSbatKK_T_SVC_KEI.GENE_ADD_DTM` | - | KK_T_SVC_KEI | Reads generation registration datetime of the service contract for the work record. |
| R | `JCCBatCommon.getFormatedNextSeq` | - | - | Gets the next formatted sequence number for SEQ_ODR_HAKKO_JOKEN_NO (12 digits). |
| R | `executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_007` | (implied SC) | KK_T_SVKEI_KAISEN_UW | Queries service contract withdrawal details by withdrawal details number and operation date. Only executed for multi-functional router path (isTknrt=true). |
| R | `db_KK_T_SVKEI_KAISEN_UW.selectNext` | - | KK_T_SVKEI_KAISEN_UW | Gets the withdrawal details record. |
| R | `JBSbatKK_T_SVKEI_KAISEN_UW.GENE_ADD_DTM` | - | KK_T_SVKEI_KAISEN_UW | Reads generation registration datetime of withdrawal details for the work record. |
| R | `JBSbatKK_T_KKTK_SVC_KEI.SVC_KEI_KAISEN_UCWK_NO` | - | KK_T_KKTK_SVC_KEI | Reads the service contract withdrawal details number from the equipment provision service contract. |
| R | `executeKK_T_KKOP_SVC_KEI_KK_SELECT_018` | (implied SC) | KK_T_KKOP_SVC_KEI | Queries equipment operation service contract by contract number and operation date. |
| R | `db_KK_T_KKOP_SVC_KEI_018.selectNext` | - | KK_T_KKOP_SVC_KEI | Iterates through equipment operation service contract records. |
| R | `JBSbatKK_T_KKOP_SVC_KEI.KKOP_SVC_CD` | - | KK_T_KKOP_SVC_KEI | Reads equipment operation service code to check if it equals "G01" (eo光 Multi-functional Router). |
| R | `JBSbatKK_T_KKOP_SVC_KEI.KKOP_SVC_KEI_NO` | - | KK_T_KKOP_SVC_KEI | Reads equipment operation service contract number. |
| R | `JBSbatKK_T_KKOP_SVC_KEI.GENE_ADD_DTM` | - | KK_T_KKOP_SVC_KEI | Reads generation registration datetime of the equipment operation service contract. |
| R | `JBSbatKK_T_KKTK_SVC_KEI.TAKNKIKI_MODEL_CD` | - | KK_T_KKTK_SVC_KEI | Reads home equipment model code for the SOD record. |
| R | `JBSbatKK_T_KKTK_SVC_KEI.KIKI_SEIZO_NO` | - | KK_T_KKTK_SVC_KEI | Reads equipment serial number for the SOD record. |
| R | `JBSbatKK_T_KKTK_SVC_KEI.GENE_ADD_DTM` | - | KK_T_KKTK_SVC_KEI | Reads generation registration datetime of the equipment provision service contract. |
| R | `JCCBatCommon.getFormatedNextSeq` | - | - | Gets the next formatted sequence number for SEQ_ODR_INF_SKSI_WK_NO (12 digits). |
| C | `executeKK_T_ODR_HAKKO_JOKEN_PKINSERT` | (implied SC) | KK_T_ODR_HAKKO_JOKEN | Inserts the order issuance condition record with all gathered parameters. |
| C | `executeKK_T_ODR_INF_SKSI_WK_PKINSERT` | (implied SC) | KK_T_ODR_INF_SKSI_WK | Inserts the order information work record with all gathered parameters. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Method: JBSbatKKMiStcKikiCncl.hampinUpdateAndDelete() | `hampinUpdateAndDelete()` -> `insertSOD()` | `executeKK_T_ODR_HAKKO_JOKEN_PKINSERT [C] KK_T_ODR_HAKKO_JOKEN`, `executeKK_T_ODR_INF_SKSI_WK_PKINSERT [C] KK_T_ODR_INF_SKSI_WK`, `executeKK_T_SVC_KEI_UCWK_KK_SELECT_007 [R] KK_T_SVC_KEI_UCWK`, `executeKK_T_SVC_KEI_KK_SELECT_089 [R] KK_T_SVC_KEI`, `executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_007 [R] KK_T_SVKEI_KAISEN_UW`, `executeKK_T_KKOP_SVC_KEI_KK_SELECT_018 [R] KK_T_KKOP_SVC_KEI` |

**Note:** This method is a batch-side utility with no direct screen/batch entry points within 8 hops. Its sole known caller is `hampinUpdateAndDelete()` within the same class, which handles hapie point contract correction batch processing (はぴeポイント契約補正情報一括更新 削除補正).

## 6. Per-Branch Detail Blocks

**Block 1** — [SET/INIT] (L7178)

> Initialize system date and result maps for all database queries.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sysDate = JCCBatCommon.getSysDateTimeStamp()` // System date acquisition [SET sysDate] |
| 2 | SET | `svcKeiMap_089 = new JBSbatCommonDBInterface()` // Map for service contract query [INIT svcKeiMap_089] |
| 3 | SET | `svcKeiUcwkMap_07 = new JBSbatCommonDBInterface()` // Map for service contract line item query [INIT svcKeiUcwkMap_07] |
| 4 | SET | `svkeiKaienUwMap = new JBSbatCommonDBInterface()` // Map for service contract withdrawal details query [INIT svkeiKaienUwMap] |
| 5 | SET | `kkopSvcKeiMap_018 = new JBSbatCommonDBInterface()` // Map for equipment operation service contract query [INIT kkopSvcKeiMap_018] |
| 6 | SET | `svcKeiUcwkNo = ""` // Service contract line item number [INIT svcKeiUcwkNo] |
| 7 | SET | `geneAddDtmUcwk = ""` // Generation registration datetime for service contract line item [INIT geneAddDtmUcwk] |

**Block 2** — [IF-WHILE] Query service contract line items — find non-terminated record (L7196-L7222)

> Loop through service contract line item records. Skip records with status 910 (解約済み / Dissolved) or 920 (キャンセル / Cancelled). Take the first valid record's number and registration datetime.

| # | Type | Code |
|---|------|------|
| 1 | SET | `whereParam2 = {svcKeiNo, this.opeDate}` // WHERE parameters: service contract number + operation date |
| 2 | EXEC | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_007(whereParam2)` // Execute service contract line item SELECT query [CALL SELECT_007] |
| 3 | SET | `svcKeiUcwkMap_07 = db_KK_T_SVC_KEI_UCWK_007.selectNext()` // Fetch next result row |

**Block 2.1** — [WHILE] `(svcKeiUcwkMap_07 != null)` (L7201)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiUcwkStat = JBSbatStringUtil.Rtrim(svcKeiUcwkMap_07.getString(JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_UCWK_STAT))` // Read status field [-> SVC_KEI_UCWK_STAT] |

**Block 2.1.1** — [IF] `(svcKeiUcwkStat != "910" AND svcKeiUcwkStat != "920")` [SVC_KEI_STAT_DLS_ZM="910" (解約済み), SVC_KEI_STAT_CNCL_ZM="920" (キャンセル)] (L7209)

> Only records that are NOT dissolved and NOT cancelled are accepted. This ensures the service contract line item is still active.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiUcwkNo = JBSbatStringUtil.Rtrim(svcKeiUcwkMap_07.getString(JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_UCWK_NO))` // Set line item number [SET svcKeiUcwkNo] |
| 2 | SET | `geneAddDtmUcwk = JBSbatStringUtil.Rtrim(svcKeiUcwkMap_07.getString(JBSbatKK_T_SVC_KEI_UCWK.GENE_ADD_DTM))` // Set line item registration datetime [SET geneAddDtmUcwk] |
| 3 | EXEC | `break` // Exit while loop on first valid record |

**Block 2.1.2** — [ELSE] (implicit — record has terminated status, skip to next)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiUcwkMap_07 = db_KK_T_SVC_KEI_UCWK_007.selectNext()` // Fetch next row in loop |

**Block 3** — [SET/EXEC] Query service contract main record (L7226-L7231)

> Query the main service contract details using KK_T_SVC_KEI table, key SELECT_089.

| # | Type | Code |
|---|------|------|
| 1 | SET | `whereParam3 = {svcKeiNo, this.opeDate}` // WHERE parameters |
| 2 | EXEC | `executeKK_T_SVC_KEI_KK_SELECT_089(whereParam3)` // Execute service contract SELECT query [CALL SELECT_089] |
| 3 | SET | `svcKeiMap_089 = db_KK_T_SVC_KEI_089.selectNext()` // Fetch result |

**Block 4** — [SET] Get order sequence number (L7234)

| # | Type | Code |
|---|------|------|
| 1 | SET | `seqOdrHakkoJokenNo = JCCBatCommon.getFormatedNextSeq(commonItem, "SEQ_ODR_HAKKO_JOKEN_NO", "", 12)` // 12-digit sequence [GET SEQ] |
| 2 | SET | `ordSbtCd = ""` // Order subtype code [INIT ordSbtCd] |
| 3 | SET | `svcOrdCd = ""` // Service order code [INIT svcOrdCd] |
| 4 | SET | `svcKeiKaisenUcwkNo = ""` // Service contract withdrawal details number [INIT svcKeiKaisenUcwkNo] |
| 5 | SET | `ordNaiyoCd = ""` // Order content code [INIT ordNaiyoCd] |
| 6 | SET | `geneAddDtmKsUcwk = ""` // Generation registration datetime for withdrawal details [INIT geneAddDtmKsUcwk] |
| 7 | SET | `kkopSvcKeiNo = ""` // Equipment operation service contract number [INIT kkopSvcKeiNo] |
| 8 | SET | `geneAddDtmKkop = ""` // Generation registration datetime for equipment operation service contract [INIT geneAddDtmKkop] |

**Block 5** — [IF] `(isTknrt == true)` — Multi-functional Router Path (L7253)

> This branch handles the multi-functional router (多機能ルーター) case. Sets specific order subtype, service order, and order content codes, then performs additional lookups for withdrawal details and equipment operation service contract.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ordSbtCd = JBSbatKKConst.ORDER_SBT_CD_TEL` [-> "2"] // Order subtype: Telephone |
| 2 | SET | `svcOrdCd = JBSbatKKConst.SVC_ORDER_CD_TAKINORT` [-> "26"] // Service order: Multi-functional Router |
| 3 | SET | `svcKeiKaisenUcwkNo = JBSbatStringUtil.Rtrim(kktkSvcKei.getString(JBSbatKK_T_KKTK_SVC_KEI.SVC_KEI_KAISEN_UCWK_NO))` // Read withdrawal details number from equipment provision contract |
| 4 | SET | `ordNaiyoCd = JBSbatKKConst.ORDER_NAIYO_CD_TAKINORT_CHG` [-> "404"] // Order content: Multi-functional router settings/changes |

**Block 5.1** — [SET/EXEC] Query withdrawal details (L7263-L7275)

| # | Type | Code |
|---|------|------|
| 1 | SET | `whereParam4 = {svcKeiKaisenUcwkNo, this.opeDate}` // WHERE for withdrawal details query |
| 2 | EXEC | `executeKK_T_SVKEI_KAISEN_UW_KK_SELECT_007(whereParam4)` // Execute withdrawal details SELECT [CALL SELECT_007] |
| 3 | SET | `svkeiKaienUwMap = db_KK_T_SVKEI_KAISEN_UW.selectNext()` // Fetch result |

**Block 5.1.1** — [IF] `(svkeiKaienUwMap != null)` (L7277)

> If withdrawal details record exists, extract its generation datetime.

| # | Type | Code |
|---|------|------|
| 1 | SET | `geneAddDtmKsUcwk = JBSbatStringUtil.Rtrim(svkeiKaienUwMap.getString(JBSbatKK_T_SVKEI_KAISEN_UW.GENE_ADD_DTM))` // Set withdrawal details registration datetime [SET geneAddDtmKsUcwk] |

**Block 5.2** — [SET/EXEC] Query equipment operation service contract (L7285-L7308)

> Query the equipment operation service contract table using the equipment provision service contract number. Loop through results to find the router function record (G01).

| # | Type | Code |
|---|------|------|
| 1 | SET | `whereParam5 = {kktkSvcKeiNo, this.opeDate}` // WHERE for equipment operation service contract query |
| 2 | EXEC | `executeKK_T_KKOP_SVC_KEI_KK_SELECT_018(whereParam5)` // Execute equipment operation service contract SELECT [CALL SELECT_018] |
| 3 | SET | `kkopSvcKeiMap_018 = db_KK_T_KKOP_SVC_KEI_018.selectNext()` // Fetch result |

**Block 5.2.1** — [WHILE] `(kkopSvcKeiMap_018 != null)` (L7296)

| # | Type | Code |
|---|------|------|
| 1 | SET | `kkopSvcCd = JBSbatStringUtil.Rtrim(kkopSvcKeiMap_018.getString(JBSbatKK_T_KKOP_SVC_KEI.KKOP_SVC_CD))` // Read equipment operation service code |

**Block 5.2.1.1** — [IF] `(kkopSvcCd == "G01")` [KK2801_KKOP_SVC_CD_G01="G01" (eo光多機能ルーター ルーター機能)] (L7299)

> Only the record with service code "G01" (eo光 Multi-functional Router — router function) is accepted. Extracts the equipment operation service contract number and its generation datetime.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kkopSvcKeiNo = JBSbatStringUtil.Rtrim(kkopSvcKeiMap_018.getString(JBSbatKK_T_KKOP_SVC_KEI.KKOP_SVC_KEI_NO))` // Set equipment operation service contract number [SET kkopSvcKeiNo] |
| 2 | SET | `geneAddDtmKkop = JBSbatStringUtil.Rtrim(kkopSvcKeiMap_018.getString(JBSbatKK_T_KKOP_SVC_KEI.GENE_ADD_DTM))` // Set equipment operation service contract registration datetime [SET geneAddDtmKkop] |

**Block 5.2.1.2** — [ELSE] (implicit — non-G01 records are skipped)

| # | Type | Code |
|---|------|------|
| 1 | SET | `kkopSvcKeiMap_018 = db_KK_T_KKOP_SVC_KEI_018.selectNext()` // Continue loop |

**Block 5.2.2** — End of while loop (L7308)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `kkopSvcKeiMap_018 = db_KK_T_KKOP_SVC_KEI_018.selectNext()` // Advance cursor |

**Block 6** — [ELSE] `(isTknrt == false)` — Router Info Path (L7313)

> This branch handles the standard router information change case. Sets order subtype to Network, service order to Router Info, and order content to Router Info Change.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ordSbtCd = JBSbatKKConst.ORDER_SBT_CD_NET` [-> "1"] // Order subtype: Network |
| 2 | SET | `svcOrdCd = JBSbatKKConst.SVC_ORDER_CD_ROUTER_INFO` [-> "0A"] // Service order: Router connection info |
| 3 | SET | `ordNaiyoCd = JBSbatKKConst.ORDER_NAIYO_CD_ROUTER_INFO_CHG` [-> "163"] // Order content: Router connection info change |

**Block 7** — [SET] Prepare order issuance condition insert parameters (L7324-L7370)

> Build a 33-element parameter array for inserting the order issuance condition record (KK_T_ODR_HAKKO_JOKEN). Contains order numbers, contract numbers, codes, device information, timestamps, user IDs, and flags.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setParam[0] = seqOdrHakkoJokenNo` // Order issuance condition number |
| 2 | SET | `setParam[1] = svcKeiNo` // Service contract number |
| 3 | SET | `setParam[2] = svcKeiUcwkNo` // Service contract line item number |
| 4 | SET | `setParam[3] = kktkSvcKeiNo` // Equipment provision service contract number |
| 5 | SET | `setParam[4] = ""` // Blank placeholder |
| 6 | SET | `setParam[5] = ""` // Blank placeholder |
| 7 | SET | `setParam[6] = ""` // Blank placeholder |
| 8 | SET | `setParam[7] = ordSbtCd` // Order subtype code [SET from Block 5/6] |
| 9 | SET | `setParam[8] = svcOrdCd` // Service order code [SET from Block 5/6] |
| 10 | SET | `setParam[9] = JBSbatKKConst.YOKYU_SBT_CD_CHG` [-> "04"] // Request subtype: Change |
| 11 | SET | `setParam[10] = JBSbatKKConst.ORDER_HAKKO_JOKEN_CD_SOKUJI_HAKKO` [-> "01"] // Order issuance condition: Immediate issuance |
| 12 | SET | `setParam[11] = ""` // Blank placeholder |
| 13 | SET | `setParam[12] = ""` // Blank placeholder |
| 14 | SET | `setParam[13] = JBSbatStringUtil.Rtrim(kktkSvcKei.getString(JBSbatKK_T_KKTK_SVC_KEI.TAKNKIKI_MODEL_CD))` // Home equipment model code |
| 15 | SET | `setParam[14] = JBSbatStringUtil.Rtrim(kktkSvcKei.getString(JBSbatKK_T_KKTK_SVC_KEI.KIKI_SEIZO_NO))` // Equipment serial number |
| 16 | SET | `setParam[15] = ""` // Blank placeholder |
| 17 | SET | `setParam[16] = ""` // Blank placeholder |
| 18 | SET | `setParam[17] = svcKeiKaisenUcwkNo` // Service contract withdrawal details number |
| 19 | SET | `setParam[18] = ""` // Blank placeholder |
| 20 | SET | `setParam[19] = sysDate` // System datetime |
| 21 | SET | `setParam[20] = batchUserId` // Batch user ID |
| 22 | SET | `setParam[21] = sysDate` // System datetime (update) |
| 23 | SET | `setParam[22] = batchUserId` // Batch user ID (update) |
| 24 | SET | `setParam[23] = ""` // Blank placeholder |
| 25 | SET | `setParam[24] = ""` // Blank placeholder |
| 26 | SET | `setParam[25] = JBSbatKKConst.MK_FLG_YK` [-> "0"] // Invalid flag: Valid |
| 27 | SET | `setParam[26] = ""` // Blank placeholder |
| 28 | SET | `setParam[27] = ""` // Blank placeholder |
| 29 | SET | `setParam[28] = ""` // Blank placeholder |
| 30 | SET | `setParam[29] = ""` // Blank placeholder |
| 31 | SET | `setParam[30] = ""` // Blank placeholder |
| 32 | SET | `setParam[31] = ""` // Blank placeholder |

**Block 8** — [CALL] Insert order issuance condition record (L7372)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_ODR_HAKKO_JOKEN_PKINSERT(setParam)` // Insert into KK_T_ODR_HAKKO_JOKEN [C KK_T_ODR_HAKKO_JOKEN] |

**Block 9** — [SET] Get order information work sequence number (L7375)

| # | Type | Code |
|---|------|------|
| 1 | SET | `seqOdrInfSksiWkNo = JCCBatCommon.getFormatedNextSeq(commonItem, "SEQ_ODR_INF_SKSI_WK_NO", "", 12)` // 12-digit sequence [GET SEQ] |

**Block 10** — [SET] Prepare order information work insert parameters (L7378-L7409)

> Build a 45-element parameter array for inserting the order information work record (KK_T_ODR_INF_SKSI_WK). Contains order references, contract numbers, service codes, device model info, all registration datetimes, user IDs, and flags.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setWorkParam[0] = seqOdrInfSksiWkNo` // Order information work number |
| 2 | SET | `setWorkParam[1] = seqOdrHakkoJokenNo` // Order issuance condition number |
| 3 | SET | `setWorkParam[2] = ordNaiyoCd` // Order content code [SET from Block 5/6] |
| 4 | SET | `setWorkParam[3] = svcKeiNo` // Service contract number |
| 5 | SET | `setWorkParam[4] = JBSbatStringUtil.Rtrim(svcKeiMap_089.getString(JBSbatKK_T_SVC_KEI.GENE_ADD_DTM))` // Service contract generation datetime |
| 6 | SET | `setWorkParam[5] = svcKeiUcwkNo` // Service contract line item number |
| 7 | SET | `setWorkParam[6] = geneAddDtmUcwk` // Line item generation datetime |
| 8 | SET | `setWorkParam[7] = kktkSvcKeiNo` // Equipment provision service contract number |
| 9 | SET | `setWorkParam[8] = JBSbatStringUtil.Rtrim(kktkSvcKei.getString(JBSbatKK_T_KKTK_SVC_KEI.GENE_ADD_DTM))` // Equipment provision service contract generation datetime |
| 10 | SET | `setWorkParam[9-15] = ""` // Blank placeholders |
| 11 | SET | `setWorkParam[16] = svcKeiKaisenUcwkNo` // Added information contract number |
| 12 | SET | `setWorkParam[17] = geneAddDtmKsUcwk` // Added information contract generation datetime |
| 13 | SET | `setWorkParam[18-24] = ""` // Blank placeholders |
| 14 | SET | `setWorkParam[25] = sysDate` // System datetime |
| 15 | SET | `setWorkParam[26] = batchUserId` // Batch user ID |
| 16 | SET | `setWorkParam[27] = sysDate` // System datetime (update) |
| 17 | SET | `setWorkParam[28] = batchUserId` // Batch user ID (update) |
| 18 | SET | `setWorkParam[29-30] = ""` // Blank placeholders |
| 19 | SET | `setWorkParam[31] = JBSbatKKConst.MK_FLG_YK` [-> "0"] // Invalid flag: Valid |
| 20 | SET | `setWorkParam[32-36] = ""` // Blank placeholders |
| 21 | SET | `setWorkParam[37] = kkopSvcKeiNo` // Equipment operation service contract number 1 |
| 22 | SET | `setWorkParam[38] = geneAddDtmKkop` // Equipment operation service contract generation datetime 1 |
| 23 | SET | `setWorkParam[39-44] = ""` // Blank placeholders |

**Block 11** — [CALL] Insert order information work record (L7411)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_ODR_INF_SKSI_WK_PKINSERT(setWorkParam)` // Insert into KK_T_ODR_INF_SKSI_WK [C KK_T_ODR_INF_SKSI_WK] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svcKeiNo` | Field | Service contract number — primary key identifying a customer's service contract in the K-Opticom system. |
| `svcKeiUcwkNo` | Field | Service contract line item number — internal tracking ID for a specific line item within a service contract. |
| `svcKeiUcwkStat` | Field | Service contract line item status — indicates the state of a line item (e.g., 910=Dissolved, 920=Cancelled). Only non-terminated records are used. |
| `svcKeiKaisenUcwkNo` | Field | Service contract withdrawal details number — identifier for the withdrawal/change details of a service contract line item. |
| `kktkSvcKeiNo` | Field | Equipment provision service contract number — identifier for the contract where equipment (e.g., router) is provided to the customer. |
| `kkopSvcKeiNo` | Field | Equipment operation service contract number — identifier for the operation-side service contract related to equipment. |
| `geneAddDtm` | Field | Generation registration datetime — system timestamp when a record was created, used for audit trail and data lineage. |
| `ordSbtCd` | Field | Order subtype code — classifies the order by service category (1=Network, 2=Telephone, 3=Mobile). |
| `svcOrdCd` | Field | Service order code — identifies the type of service being ordered (e.g., 26=Multi-functional Router, 0A=Router Info). |
| `ordNaiyoCd` | Field | Order content code — specifies the exact order operation (e.g., 404=Multi-functional router change, 163=Router info change). |
| `isTknrt` | Parameter | Multi-functional router flag — `true` indicates the change involves a multi-functional router (多機能ルーター), `false` indicates standard router info change. |
| SOD | Acronym | Service Order Data — internal order record that triggers downstream service provisioning and billing changes. |
| KK_T_SVC_KEI | Table | Service contract main table — stores core service contract records. |
| KK_T_SVC_KEI_UCWK | Table | Service contract line items table — stores line item details including status. |
| KK_T_SVKEI_KAISEN_UW | Table | Service contract withdrawal details table — stores withdrawal/change details for service contracts. |
| KK_T_KKTK_SVC_KEI | Table | Equipment provision service contract table — stores contracts where equipment is provided. |
| KK_T_KKOP_SVC_KEI | Table | Equipment operation service contract table — stores operation-side equipment contracts. |
| KK_T_ODR_HAKKO_JOKEN | Table | Order issuance condition table — stores order trigger/condition records that initiate downstream processing. |
| KK_T_ODR_INF_SKSI_WK | Table | Order information work table — stores detailed order work records for processing pipeline. |
| TAKINORT | Business term | Multi-functional Router (多機能ルーター / Takino-Router) — eo光's branded multi-function router providing routing, Wi-Fi, and other network functions. |
| G01 | Code | Equipment operation service code — specifically identifies eo光 Multi-functional Router (router function). |
| MK_FLG_YK | Field | Invalid flag — "0" means valid/active, "1" means invalid/deactivated. |
| YOKYU_SBT_CD_CHG | Code | Request subtype: Change (変更) — indicates this is a modification request rather than new, cancel, or delete. |
| ORDER_HAKKO_JOKEN_CD_SOKUJI_HAKKO | Code | Order issuance condition: Immediate issuance (即時発行) — triggers immediate order processing. |
| `opeDate` | Instance Field | Operation date — the processing date used as a filter in all database queries to ensure data from the correct date range. |
| `batchUserId` | Instance Field | Batch user ID — the system user identifier for batch processes, used in audit trail fields. |
| `hampinUpdateAndDelete` | Method | Hapie point contract correction update-and-delete — the batch process that calls insertSOD as part of correcting hapie point (はぴeポイント) contract information in bulk. |
