# Business Logic — JBSbatKKKjFinDataInTrn.svcStartOpSvcKei() [294 LOC]

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

## 1. Role

### JBSbatKKKjFinDataInTrn.svcStartOpSvcKei()

This method performs the **option service contract start registration and update processing** (オプションサービス契約のサービス開始登録・更新処理) for the batch job pipeline. It is the core dispatching method that determines whether an option service contract should be newly registered or updated based on its current status, and ensures all required auxiliary data (IPv6 access info, my-home page URL, etc.) is present before proceeding.

The method operates on a **routing/dispatch pattern**: it reads the parent service contract to obtain the service code, price group code, and effective start dates, then iterates over each associated option service contract record. For each option record, it runs two business rules — `callRule0074001` (service start date calculation, 開始日設定定義) and `callRule0066001` (charge start date calculation, 課金開始日設定定義) — to compute the actual service start date and charge start date.

It implements a **gate-skipping strategy**: certain option service codes (PC Plan B133, TV Plan B134) are explicitly excluded from processing, as are records without a valid subscription period (mskmPrd equals "0"), IPv6-dependent options missing their interface ID, and my-home page options without URL domain/account data. This ensures only fully-qualified option contracts enter the registration/update lifecycle.

When the option contract status is "100" (Service in Provision, SVC_KEI_STAT_SVCTK_CHU), it **updates** the existing record — except for free/open promotional options (B085-B089) which are skipped. For all other statuses, it **inserts** a new option service contract record. This dual path makes it a shared batch utility called by the `execute()` entry point to process all pending option service contracts during the nightly batch run.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["svcStartOpSvcKei(svcKeiNo, svcKeiUcwkNo, mskmDtlNo, idoDiv, planStaymd, planChrgStaymd, rsvAplyYmd)"])
    START --> LOG_START["printDebugLog svcStartOpSvcKei_START"]
    LOG_START --> SELECT_SVC["selectSvcKei023(svcKeiNo_151)"]
    SELECT_SVC --> CHECK_OUT023{"outMap023 != null?"}
    CHECK_OUT023 -->|null| END_RETURN["return"]
    CHECK_OUT023 -->|data| EXTRACT_SVC["Extract svcCd023, svcStaYmdSvc, svcChrgStaymd, prcGrpCd023"]
    EXTRACT_SVC --> DEBUG_SVC["printDebugLog service contract info"]
    DEBUG_SVC --> SELECT_OP["selectOpSvcKei095(svcKeiUcwkNo)"]
    SELECT_OP --> WHILE_LOOP{"outMap095 != null?"}
    WHILE_LOOP -->|null| END_LOG["printDebugLog svcStartOpSvcKei_END"]
    WHILE_LOOP -->|data| GET_MSKMYMD["getMskmYmd(mskmDtlNo)"]
    GET_MSKMYMD --> EXTRACT_OP["Extract opSvcKeiNo, geneAddDtm, opSvcCd, rsvAplyYmdOp, idoDiv095, opSvcKeiStat, oyaKeiSkbtCd"]
    EXTRACT_OP --> DEBUG_OP["printDebugLog option service info"]
    DEBUG_OP --> CHECK_SKIP_PC{"opSvcCd == B133 or B134?"}
    CHECK_SKIP_PC -->|true| NEXT_ROW["outMap095 = selectNext()"]
    CHECK_SKIP_PC -->|false| GET_MSKMPRD["getMskmPrd(mskmDtlNo, oyaKeiSkbtCd, planStaymd, planChrgStaymd, mskmYmdOp, svcStaYmdSvc, svcChrgStaymd)"]
    GET_MSKMPRD --> CHECK_MSKM{"mskmPrd == 0?"}
    CHECK_MSKM -->|true| NEXT_ROW
    CHECK_MSKM -->|false| CALL_RULE074["callRule0074001(svcCd023, opSvcCd, mskmPrd, idoDiv095, svcStaYmdSvc, )"]
    CALL_RULE074 --> GET_SVCUSE["Extract svcUseStaKiboYmd"]
    GET_SVCUSE --> GET_SVCSTAYMD["getSvcStaymd(checkList074, oyaKeiSkbtCd, planStaymd, svcUseStaKiboYmd, mskmYmdOp, svcStaYmdSvc, svcChrgStaymd, svcKeiNo_151, )"]
    GET_SVCSTAYMD --> CALL_RULE066["callRule0066001(svcCd023, opSvcCd, prcGrpCd023, mskmPrd)"]
    CALL_RULE066 --> GET_CHRG["getOpSvcChrgStaymd(checkList, planChrgStaymd, oyaKeiSkbtCd, kjnYmd074, svcChrgStaymd)"]
    GET_CHRG --> CHECK_IPV6{"opSvcCd == B070(IPv6)?"}
    CHECK_IPV6 -->|true| EXEC_069["executeKK_T_OP_SVC_KEI_KK_SELECT_069(opSvcKeiNo, opeDate)"]
    EXEC_069 --> GET_IFID["outMap = db_KK_T_OP_SVC_KEI_069.selectNext()"]
    GET_IFID --> CHECK_IFID{"outMap != null AND IPV6_AD_IFID not empty?"}
    CHECK_IFID -->|false| NEXT_ROW
    CHECK_IFID -->|true| CHECK_MYHP{"opSvcCd == B002(My HP)?"}
    CHECK_IPV6 -->|false| CHECK_MYHP
    CHECK_MYHP -->|true| EXEC_080["executeKK_T_OP_SVC_KEI_KK_SELECT_080(opSvcKeiNo, opeDate)"]
    EXEC_080 --> GET_URL["outMap = db_KK_T_OP_SVC_KEI_080.selectNext()"]
    GET_URL --> CHECK_URL{"outMap != null AND URL_DOMAIN and URL_ACCOUNT not empty?"}
    CHECK_URL -->|false| NEXT_ROW
    CHECK_URL -->|true| CHECK_STAT{"opSvcKeiStat == 100?"}
    CHECK_MYHP -->|false| CHECK_STAT
    CHECK_STAT -->|true| CHECK_SPECIAL{"opSvcCd in (B085,B086,B087,B088,B089)?"}
    CHECK_STAT -->|false| INSERT_OP["insertOpSvcKei(opSvcKeiNo, geneAddDtm, mskmDtlNo, idoDiv, kjnYmd074, rsvAplyYmd, hnkAtoSvcChrgStaymd)"]
    INSERT_OP --> NEXT_ROW
    CHECK_SPECIAL -->|true| NEXT_ROW
    CHECK_SPECIAL -->|false| UPDATE_OP["updateOpSvcKei(opSvcKeiNo, geneAddDtm, mskmDtlNo, idoDiv, kjnYmd074, rsvAplyYmd, hnkAtoSvcChrgStaymd)"]
    UPDATE_OP --> NEXT_ROW
    NEXT_ROW --> WHILE_LOOP
    END_LOG --> END_NODE(["End"])
    END_RETURN --> END_NODE
```

**CRITICAL — Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|------------------|
| `OP_SVC_CD_PCPLAN` | `"B133"` | PC Plan — device compensation (PC) optional service |
| `OP_SVC_CD_TVPLAN` | `"B134"` | TV Plan — device compensation (TV) optional service |
| `OP_SVC_CD_IPV6_AD` | `"B070"` | IPv6 Access — IPv6 internet access option |
| `OP_SVC_CD_MY_HP` | `"B002"` | My Home Page — optional personal home page service |
| `SVC_KEI_STAT_SVCTK_CHU` | `"100"` | Service in Provision — active service status |
| `OP_SVC_CD_SHK_MRYO` | `"B085"` | Initial Free Option — no-charge promotional start |
| `OP_SVC_CD_WORK_FULL` | `"B086"` | Business Full Open — business-use full open option |
| `OP_SVC_CD_RYOHNTN_DEMO` | `"B087"` | Retail Store Demo Open — retail demo open option |
| `OP_SVC_CD_HIKKOSHI_MRYO` | `"B088"` | Moving Free Open — free option for relocating customers |
| `OP_SVC_CD_MRYO` | `"B089"` | Free Option (Old Package Add-on) — no-charge add-on |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `svcKeiNo_151` | `String` | Service contract number — the primary key identifying the parent service contract (FTTH, Telephone, TV, etc.) against which option services are registered. Used to look up the parent service record. |
| 2 | `svcKeiUcwkNo` | `String` | Service contract detail number — a grouping key used to query the `KK_T_OP_SVC_KEI` table for all option service contracts associated with a particular service contract detail line. Drives the iteration loop. |
| 3 | `mskmDtlNo` | `String` | Application detail number — identifies the specific subscription application line item. Used to resolve the subscription period (`mskmPrd`) and subscription end date (`mskmYmdOp`) via helper methods. |
| 4 | `idoDiv` | `String` | Movement division (異動区分) — indicates the type of contract change (e.g., new addition, modification, cancellation). Passed through to `updateOpSvcKei`/`insertOpSvcKei` to record the change reason. |
| 5 | `planStaymd` | `String` | Plan start date (プラン開始日) — the scheduled start date from the plan configuration. Used as a baseline in rule 0074001 and `getSvcStaymd` to compute the actual service start date. |
| 6 | `planChrgStaymd` | `String` | Billing start date (課金開始日) — the scheduled billing start date from the plan configuration. Used in rule 0066001 and `getOpSvcChrgStaymd` to compute the actual charge start date. |
| 7 | `rsvAplyYmd` | `String` | Reservation application date (予約適用年月日) — the date the reservation was applied. Passed to `updateOpSvcKei`/`insertOpSvcKei` as a data field on the option service contract record. |

**Instance fields / external state read by this method:**

| Field | Source | Usage |
|-------|--------|-------|
| `super.opeDate` | Parent class field | Passed as the second parameter to `executeKK_T_OP_SVC_KEI_KK_SELECT_069` and `executeKK_T_OP_SVC_KEI_KK_SELECT_080` as the operation date filter |
| `db_KK_T_OP_SVC_KEI` | Instance database handle | Used to call `selectNext()` for cursor iteration through option service contract rows |
| `db_KK_T_OP_SVC_KEI_069` | Instance database handle | Used to read the next row from IPv6 access info result set |
| `db_KK_T_OP_SVC_KEI_080` | Instance database handle | Used to read the next row from My Home Page URL result set |
| `super.logPrint` | Parent class logger | Used throughout for debug log output |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `selectSvcKei023` | (internal) | `KK_T_SVC_KEI` | Reads parent service contract record by service contract number (`svcKeiNo_151`) to obtain service code, start date, charge start date, and price group code |
| R | `selectOpSvcKei095` | (internal) | `KK_T_OP_SVC_KEI` | Queries option service contract records by service contract detail number (`svcKeiUcwkNo`), returns an iterable cursor for the while-loop |
| R | `getMskmYmd` | (internal) | — | Retrieves subscription end date based on application detail number (`mskmDtlNo`) |
| R | `getMskmPrd` | (internal) | — | Retrieves subscription period (申込期間) based on application detail number, parent contract key, plan dates, and service dates |
| C | `insertOpSvcKei` | (internal) | `KK_T_OP_SVC_KEI` | Inserts a new option service contract record when status is not "100" (Service in Provision) |
| U | `updateOpSvcKei` | (internal) | `KK_T_OP_SVC_KEI` | Updates an existing option service contract record when status is "100" (Service in Provision) and the option code is not a free/promotional type |
| - | `callRule0074001` | (internal) | — | Calls business rule for **service start date setting definition** (開始日設定定義) for option services. Computes the actual service start date based on service code, option code, subscription period, movement division, and service start date |
| - | `callRule0066001` | (internal) | — | Calls business rule for **charge start date setting definition** (課金開始日設定定義) for services. Computes the actual charge/billing start date based on service code, option code, price group code, and subscription period |
| R | `getSvcStaymd` | (internal) | — | Extracts the computed service start date from the rule 0074001 result, using parent contract key for decision logic |
| R | `getOpSvcChrgStaymd` | (internal) | — | Extracts the computed charge start date from the rule 0066001 result, incorporating parent contract key and computed service start date |
| - | `executeKK_T_OP_SVC_KEI_KK_SELECT_069` | (internal) | `KK_T_OP_SVC_KEI` (via SELECT_069 view) | Executes a specialized SELECT for IPv6 access info when the option service code is B070 (IPv6 Access). Filters by option service contract number and operation date |
| R | `db_KK_T_OP_SVC_KEI_069.selectNext` | (internal) | `KK_T_OPSVKEI_ISP` | Reads the IPv6 access info row including the IPv6 address interface ID |
| - | `executeKK_T_OP_SVC_KEI_KK_SELECT_080` | (internal) | `KK_T_OP_SVC_KEI` (via SELECT_080 view) | Executes a specialized SELECT for My Home Page info when the option service code is B002. Filters by option service contract number and operation date |
| R | `db_KK_T_OP_SVC_KEI_080.selectNext` | (internal) | `KK_T_OPSVKEI_ISP` | Reads the My Home Page URL info row including domain and account URLs |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `printDebugLog` [-], `insertOpSvcKei` [C], `updateOpSvcKei` [U], `Rtrim` [-], `Rtrim` [-], `Rtrim` [-], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `Rtrim` [-], `Rtrim` [-], `Rtrim` [-], `getString` [R], `getString` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKKjFinDataInTrn.execute()` | `execute()` -> `svcStartOpSvcKei(svcKeiNo_151, svcKeiUcwkNo, mskmDtlNo, idoDiv, planStaymd, planChrgStaymd, rsvAplyYmd)` | `insertOpSvcKei [C] KK_T_OP_SVC_KEI`, `updateOpSvcKei [U] KK_T_OP_SVC_KEI` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET/EXEC] Initialize and query parent service contract (L7300)

> Logs start and retrieves the parent service contract record. If not found, returns early (this service contract has no option services to process).

| # | Type | Code |
|---|------|------|
| 1 | LOG | `super.logPrint.printDebugLog("svcStartOpSvcKei_START")` |
| 2 | CALL | `outMap023 = this.selectSvcKei023(svcKeiNo_151)` // Query parent service contract by service contract number |
| 3 | COND | `if (null == outMap023)` → return early [L7314] |

**Block 1.1** — [ELSE] Extract service contract fields (L7320)

> Retrieves service code, service start date, service charge start date, and price group code from the parent service contract record. These values drive all subsequent branching logic.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcStaYmdSvc = JBSbatStringUtil.Rtrim(outMap023.getString(JBSbatKK_T_SVC_KEI.SVC_STA_YMD))` // Service start date from parent contract |
| 2 | SET | `svcChrgStaymd = JBSbatStringUtil.Rtrim(outMap023.getString(JBSbatKK_T_SVC_KEI.SVC_CHRG_STAYMD))` // Service charge start date from parent contract |
| 3 | SET | `svcCd023 = JBSbatStringUtil.Rtrim(outMap023.getString(JBSbatKK_T_SVC_KEI.SVC_CD))` // Service code (01=Internet, 02=Telephone, 03=TV, etc.) |
| 4 | SET | `prcGrpCd023 = JBSbatStringUtil.Rtrim(outMap023.getString(JBSbatKK_T_SVC_KEI.PRC_GRP_CD))` // Price group code |
| 5 | LOG | `super.logPrint.printDebugLog(...)` × 4 // Logs all four extracted fields |

**Block 2** — [QUERY/WHILE] Query and iterate option service contracts (L7336)

> Queries the option service contract table for all records associated with the given service contract detail number. Iterates through each row with a cursor-based while loop.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `outMap095 = this.selectOpSvcKei095(svcKeiUcwkNo)` // Query option service contracts |
| 2 | WHILE | `while (null != outMap095)` — loop until no more rows [L7339] |

**Block 2.1** — [WHILE BODY] Extract option service contract fields (L7344)

> Within each iteration, extracts all relevant fields from the current option service contract row.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mskmYmdOp = this.getMskmYmd(mskmDtlNo)` // Subscription end date from application detail |
| 2 | SET | `opSvcKeiNo = JBSbatStringUtil.Rtrim(outMap095.getString(JBSbatKK_T_OP_SVC_KEI.OP_SVC_KEI_NO))` // Option service contract number |
| 3 | SET | `geneAddDtm = JBSbatStringUtil.Rtrim(outMap095.getString(JBSbatKK_T_OP_SVC_KEI.GENE_ADD_DTM))` // Generation/addition datetime |
| 4 | SET | `opSvcCd = JBSbatStringUtil.Rtrim(outMap095.getString(JBSbatKK_T_OP_SVC_KEI.OP_SVC_CD))` // Option service code (B001=Email, B002=My HP, B070=IPv6, etc.) |
| 5 | SET | `rsvAplyYmdOp = JBSbatStringUtil.Rtrim(outMap095.getString(JBSbatKK_T_OP_SVC_KEI.RSV_APLY_YMD))` // Reservation application date |
| 6 | SET | `idoDiv095 = JBSbatStringUtil.Rtrim(outMap095.getString(JBSbatKK_T_OP_SVC_KEI.IDO_DIV))` // Movement division |
| 7 | SET | `opSvcKeiStat = JBSbatStringUtil.Rtrim(outMap095.getString(JBSbatKK_T_OP_SVC_KEI.OP_SVC_KEI_STAT))` // Option service contract status |
| 8 | SET | `oyaKeiSkbtCd = JBSbatStringUtil.Rtrim(outMap095.getString(JBSbatKK_T_OP_SVC_KEI.OYA_KEI_SKBT_CD))` // Parent contract identification code |
| 9 | LOG | `super.logPrint.printDebugLog(...)` × 7 // Logs all extracted fields |

**Block 2.2** — [IF-ELSE] Skip PC Plan and TV Plan (ANK-3484) (L7405)

> Option service codes B133 (PC Plan) and B134 (TV Plan) are device compensation plans that should NOT be processed through this service start registration flow. These rows are skipped by fetching the next record.

| # | Type | Code |
|---|------|------|
| 1 | COND | `JBSbatKKConst.OP_SVC_CD_PCPLAN.equals(opSvcCd) || JBSbatKKConst.OP_SVC_CD_TVPLAN.equals(opSvcCd)` — PC Plan or TV Plan → skip [-> OP_SVC_CD_PCPLAN="B133" (PC device compensation), OP_SVC_CD_TVPLAN="B134" (TV device compensation)] |
| 2 | EXEC | `outMap095 = db_KK_T_OP_SVC_KEI.selectNext()` // Fetch next row |
| 3 | EXEC | `continue` // Skip remaining processing for this row |

**Block 2.3** — [IF-ELSE] Skip records with empty subscription period (L7432)

> If the subscription period (`mskmPrd`) resolves to "0", the record is outside the valid subscription window and should be skipped.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mskmPrd = this.getMskmPrd(mskmDtlNo, oyaKeiSkbtCd, planStaymd, planChrgStaymd, mskmYmdOp, svcStaYmdSvc, svcChrgStaymd)` // Get subscription period with parent contract key for decision logic |
| 2 | COND | `"0".equals(mskmPrd)` — Subscription period is zero, skip this record [L7436] |
| 3 | EXEC | `outMap095 = db_KK_T_OP_SVC_KEI.selectNext()` // Fetch next row |
| 4 | EXEC | `continue` // Skip remaining processing |

**Block 2.4** — [EXEC] Rule 0074001 — Service Start Date Calculation (L7443)

> Calls the business rule for computing the actual service start date based on service code, option code, subscription period, movement division, and the parent service start date.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `checkList074 = callRule0074001(svcCd023, opSvcCd, mskmPrd, idoDiv095, svcStaYmdSvc, "")` // Compute service start date setting definition |

**Block 2.5** — [EXEC] Extract service use start desired date (L7448)

> Reads the optional "service use start desired date" field from the option service contract record. This is used as a preference date for when the customer wants the service to begin.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcUseStaKiboYmd = JBSbatStringUtil.Rtrim(outMap095.getString(JBSbatKK_T_OP_SVC_KEI.SVC_USE_STA_KIBO_YMD))` // Service use start desired date |

**Block 2.6** — [EXEC] Compute service start date from rule result (L7456)

> Extracts the computed service start date (`kjnYmd074`) from the rule 0074001 result set, using the parent contract identification code for hierarchical decision logic.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `kjnYmd074 = getSvcStaymd(checkList074, oyaKeiSkbtCd, planStaymd, svcUseStaKiboYmd, mskmYmdOp, svcStaYmdSvc, svcChrgStaymd, svcKeiNo_151, "")` // Compute actual service start date |

**Block 2.7** — [EXEC] Rule 0066001 — Charge Start Date Calculation (L7473)

> Calls the business rule for computing the actual charge/billing start date based on service code, option code, price group code, and subscription period.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `checkList = this.callRule0066001(svcCd023, opSvcCd, prcGrpCd023, mskmPrd)` // Compute charge start date setting definition |

**Block 2.8** — [EXEC] Compute charge start date from rule result (L7489)

> Extracts the computed charge start date (`hnkAtoSvcChrgStaymd`) from the rule 0066001 result set.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `hnkAtoSvcChrgStaymd = getOpSvcChrgStaymd(checkList, planChrgStaymd, oyaKeiSkbtCd, kjnYmd074, svcChrgStaymd)` // Compute actual charge start date |

**Block 2.9** — [IF-ELSE] IPv6 Access Special Processing (ANK-3754) (L7494)

> For IPv6 Access option service code B070, the method must verify that the IPv6 address information (interface ID) exists and is valid before proceeding.

| # | Type | Code |
|---|------|------|
| 1 | COND | `JBSbatKKConst.OP_SVC_CD_IPV6_AD.equals(opSvcCd)` — IPv6 Access option [-> OP_SVC_CD_IPV6_AD="B070"] |
| 2 | SET | `param = new Object[]{opSvcKeiNo, super.opeDate}` // Set query parameters: option service contract number + operation date |
| 3 | EXEC | `executeKK_T_OP_SVC_KEI_KK_SELECT_069(param)` // Execute IPv6 access info SELECT |
| 4 | SET | `outMap = db_KK_T_OP_SVC_KEI_069.selectNext()` // Get the IPv6 access info row |
| 5 | COND | `null == outMap` — IPv6 info not found, skip → [L7512] |
| 6 | EXEC | `outMap095 = db_KK_T_OP_SVC_KEI.selectNext(); continue` |
| 7 | COND | `"".equals(JBSbatStringUtil.Rtrim(outMap.getString(JBSbatKK_T_OPSVKEI_ISP.IPV6_AD_IFID)))` — IPv6 interface ID empty, skip → [L7519] |
| 8 | EXEC | `outMap095 = db_KK_T_OP_SVC_KEI.selectNext(); continue` |

**Block 2.10** — [IF-ELSE] My Home Page Special Processing (L7525)

> For My Home Page option service code B002, the method must verify that both the URL domain and URL account are set before proceeding.

| # | Type | Code |
|---|------|------|
| 1 | COND | `JBSbatKKConst.OP_SVC_CD_MY_HP.equals(opSvcCd)` — My Home Page option [-> OP_SVC_CD_MY_HP="B002"] |
| 2 | SET | `param = new Object[]{opSvcKeiNo, super.opeDate}` // Set query parameters |
| 3 | EXEC | `executeKK_T_OP_SVC_KEI_KK_SELECT_080(param)` // Execute My Home Page URL SELECT |
| 4 | SET | `outMap = db_KK_T_OP_SVC_KEI_080.selectNext()` // Get the My Home Page URL row |
| 5 | COND | `null == outMap` — URL info not found, skip → [L7542] |
| 6 | EXEC | `outMap095 = db_KK_T_OP_SVC_KEI.selectNext(); continue` |
| 7 | COND | `URL_DOMAIN empty OR URL_ACCOUNT empty` — Missing URL configuration, skip → [L7548] |
| 8 | EXEC | `outMap095 = db_KK_T_OP_SVC_KEI.selectNext(); continue` |

**Block 2.11** — [IF-ELSE] Status-based Update vs Insert (L7556)

> The final decision: if the option service contract status is "100" (Service in Provision), update the existing record. Otherwise, insert a new record.

| # | Type | Code |
|---|------|------|
| 1 | COND | `JBSbatKKConst.SVC_KEI_STAT_SVCTK_CHU.equals(opSvcKeiStat)` — Status is "100" (Service in Provision) [-> SVC_KEI_STAT_SVCTK_CHU="100"] |
| 2 | [IF INSIDE TRUE] [IF-ELSE] Skip free/promotional options when status is "100" (L7564) |
| 3 | COND | `opSvcCd in (B085, B086, B087, B088, B089)` — Free/promotional option types, skip update → [OP_SVC_CD_SHK_MRYO="B085", OP_SVC_CD_WORK_FULL="B086", OP_SVC_CD_RYOHNTN_DEMO="B087", OP_SVC_CD_HIKKOSHI_MRYO="B088", OP_SVC_CD_MRYO="B089"] |
| 4 | EXEC | `outMap095 = db_KK_T_OP_SVC_KEI.selectNext(); continue` |
| 5 | EXEC | `updateOpSvcKei(opSvcKeiNo, geneAddDtm, mskmDtlNo, idoDiv, kjnYmd074, rsvAplyYmd, hnkAtoSvcChrgStaymd)` // Update existing option contract with computed dates |
| 6 | [ELSE INSIDE FALSE] — Status is NOT "100" → Insert new record |
| 7 | EXEC | `insertOpSvcKei(opSvcKeiNo, geneAddDtm, mskmDtlNo, idoDiv, kjnYmd074, rsvAplyYmd, hnkAtoSvcChrgStaymd)` // Register new option contract with computed dates |

**Block 2.12** — [WHILE TRAILER] Fetch next row (L7575)

> After processing each row (whether updated, inserted, or skipped), fetch the next option service contract row from the cursor.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outMap095 = db_KK_T_OP_SVC_KEI.selectNext()` // Move to next row in cursor |

**Block 3** — [SET/EXEC] Log end (L7579)

> After all option service contract rows have been processed, log the end of the method.

| # | Type | Code |
|---|------|------|
| 1 | LOG | `super.logPrint.printDebugLog("svcStartOpSvcKei_END")` |
| 2 | RETURN | (implicit void return) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no_151` | Field | Service contract number — primary key identifying the parent telecom service contract (FTTH, Telephone, TV, etc.) |
| `svc_kei_ucwk_no` | Field | Service contract detail number — grouping key for option service contracts under a service contract line item |
| `mskm_dtl_no` | Field | Application detail number (申込明細番号) — identifies the specific subscription application line item |
| `ido_div` | Field | Movement division (異動区分) — indicates the type of contract change (new addition, modification, cancellation) |
| `plan_staymd` | Field | Plan start date (プラン開始日) — the scheduled start date from the plan configuration |
| `plan_chrg_staymd` | Field | Billing start date (課金開始日) — the scheduled billing start date from the plan configuration |
| `rsv_aply_ymd` | Field | Reservation application date (予約適用年月日) — the date the reservation was applied |
| `op_svc_cd` | Field | Option service code — classifies the type of optional service (Email B001, My HP B002, IPv6 B070, etc.) |
| `op_svc_kei_stat` | Field | Option service contract status — "100" means Service in Provision (active), other values indicate pending or other states |
| `oya_kei_skbt_cd` | Field | Parent contract identification code (親契約識別コード) — hierarchical key linking option contracts to their parent service contracts |
| `mskm_prd` | Field | Subscription period (申込期間) — the duration of the subscription; "0" means outside the valid period |
| `mskm_ymd_op` | Field | Subscription end date (申込年月日オプション) — the end date of the subscription period |
| `kjn_ymd074` | Variable | Service start date computed by Rule 0074001 (計算年月日) |
| `hnkAtoSvcChrgStaymd` | Variable | Charge start date computed by Rule 0066001 (引当先課金開始日) |
| `OP_SVC_CD_PCPLAN` | Constant | "B133" — PC device compensation optional plan |
| `OP_SVC_CD_TVPLAN` | Constant | "B134" — TV device compensation optional plan |
| `OP_SVC_CD_IPV6_AD` | Constant | "B070" — IPv6 Internet Access optional service |
| `OP_SVC_CD_MY_HP` | Constant | "B002" — My Home Page optional service |
| `SVC_KEI_STAT_SVCTK_CHU` | Constant | "100" — Service in Provision status code |
| `OP_SVC_CD_SHK_MRYO` | Constant | "B085" — Initial Free Option (no-charge promotional start) |
| `OP_SVC_CD_WORK_FULL` | Constant | "B086" — Business Full Open option |
| `OP_SVC_CD_RYOHNTN_DEMO` | Constant | "B087" — Retail Store Demo Open option |
| `OP_SVC_CD_HIKKOSHI_MRYO` | Constant | "B088" — Moving Free Open option (free for relocating customers) |
| `OP_SVC_CD_MRYO` | Constant | "B089" — Free Option for old package add-on |
| `KK_T_SVC_KEI` | Table | Service Contract table — parent service contract master data |
| `KK_T_OP_SVC_KEI` | Table | Option Service Contract table — stores option service contract records |
| `KK_T_OPSVKEI_ISP` | Table | Option Service Contract ISP table — stores ISP-specific data (IPv6 interface ID, My HP URLs) |
| Rule 0074001 | Business Rule | Service Start Date Setting Definition (開始日設定定義) for option services — computes the actual service start date |
| Rule 0066001 | Business Rule | Charge Start Date Setting Definition (課金開始日設定定義) for services — computes the actual billing/charge start date |
| `SVC_CD_IN_SVC` | Constant | "01" — Internet Service code |
| `SVC_CD_TEL_SVC` | Constant | "02" — Telephone Service code |
| `SVC_CD_TV_SVC` | Constant | "03" — Television Service code |
| `SVC_CD_HOSTING` | Constant | "04" — Hosting Service code |
| `SVC_CD_ELEC_SVC` | Constant | "05" — Electricity Service code |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service (primary parent service) |
| My HP | Business term | My Home Page — optional personal web hosting service for customers |
| IPv6 | Business term | Internet Protocol version 6 — next-generation IP addressing protocol for internet access |
