# Business Logic — JBSbatKKSkaWrkCnclProc.initial() [16 LOC]

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

## 1. Role

### JBSbatKKSkaWrkCnclProc.initial()

This method performs the **initialization phase** of the **Scope Worker Cancellation Batch** (スカパー工取消), which handles the cancellation of work (工) associated with SCAPE (スカーパ, a satellite broadcasting digital service by SKY Perfect JSAT). The class `JBSbatKKSkaWrkCnclProc` extends `JBSbatBusinessService`, making it a standard batch processing service component within the enterprise batch framework. As the entry point for initialization, this method prepares the batch's operational context by delegating to the parent class's `setCommonInfo` to register shared batch parameters, and then instantiates database access handles (`JBSbatSQLAccess`) for three critical tables: `KK_T_IDO_RSV` (異動予約 / change reservation table), `KK_T_CASCD_KNRI` (CASカード管理 / CAS card management table), and `KK_T_OP_SVC_KEI` (オプションサービス契約 / option service contract table). The design pattern employed here is **infrastructure delegation** — the method does not contain business logic itself but instead sets up the necessary database connectivity layer that subsequent processing stages (notably the `execute` method) will use to read, update, and cancel reservation records, CAS card assignments, and option service contracts. It is the shared initialization routine called once per batch run, establishing all DB access instances that the cancellation workflow depends on.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["initial(commonItem)"])
    START --> CALL_SET["CALL: super.setCommonInfo(commonItem)"]
    CALL_SET --> INIT_IDO["SET: db_KK_T_IDO_RSV = new JBSbatSQLAccess(commonItem, KK_T_IDO_RSV)"]
    INIT_IDO --> INIT_CASC["SET: db_KK_T_CASCD_KNRI = new JBSbatSQLAccess(commonItem, KK_T_CASCD_KNRI)"]
    INIT_CASC --> INIT_OP1["SET: db_KK_T_OP_SVC_KEI = new JBSbatSQLAccess(commonItem, KK_T_OP_SVC_KEI)"]
    INIT_OP1 --> INIT_OP2["SET: db_KK_T_OP_SVC_KEI_094 = new JBSbatSQLAccess(commonItem, KK_T_OP_SVC_KEI)"]
    INIT_OP2 --> END_RETURN(["Return - initialization complete"])
```

**Processing Description:**
1. **Delegation to parent initialization** — The method first calls `super.setCommonInfo(commonItem)` to pass the batch common parameter interface to the parent `JBSbatBusinessService`. This registers the batch metadata, configuration, and common settings that all batch services need.
2. **Database access creation for change reservation table** — A `JBSbatSQLAccess` instance is created for `KK_T_IDO_RSV` and assigned to `db_KK_T_IDO_RSV`. This table tracks change/reservation operations for service subscriptions.
3. **Database access creation for CAS card management table** — A `JBSbatSQLAccess` instance is created for `KK_T_CASCD_KNRI` and assigned to `db_KK_T_CASCD_KNRI`. This table manages CAS (Conditional Access System) cards used for decryption authorization.
4. **Database access creation for option service contract table (primary)** — A `JBSbatSQLAccess` instance is created for `KK_T_OP_SVC_KEI` and assigned to `db_KK_T_OP_SVC_KEI`. This table holds option service contract records.
5. **Database access creation for option service contract table (secondary)** — A second `JBSbatSQLAccess` instance is created for the same table `KK_T_OP_SVC_KEI` and assigned to `db_KK_T_OP_SVC_KEI_094`. Having two separate access instances for the same table allows concurrent or differentiated SQL operations without state interference — likely used for the select query key `KK_SELECT_094` (defined as constant `KK_T_OP_SVC_KEI_KK_SELECT_094`).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | The batch common parameter interface carrying shared batch execution metadata — including batch job ID, execution date, transaction context, and database connection settings. This object is the standard parameter envelope passed to all batch services in the framework to ensure consistent execution context. |

**Instance fields read/assigned by this method:**

| No | Field Name | Type | Business Description |
|----|-----------|------|---------------------|
| 1 | `D_TBL_NAME_KK_T_IDO_RSV` | `String` ("KK_T_IDO_RSV") | Constant: the name of the change reservation table (異動予約) |
| 2 | `D_TBL_NAME_KK_T_CASCD_KNRI` | `String` ("KK_T_CASCD_KNRI") | Constant: the name of the CAS card management table (CASカード管理) |
| 3 | `D_TBL_NAME_KK_T_OP_SVC_KEI` | `String` ("KK_T_OP_SVC_KEI") | Constant: the name of the option service contract table (オプションサービス契約) |
| 4 | `db_KK_T_IDO_RSV` | `JBSbatSQLAccess` | Instance field initialized to a new SQL access handle for the change reservation table |
| 5 | `db_KK_T_CASCD_KNRI` | `JBSbatSQLAccess` | Instance field initialized to a new SQL access handle for the CAS card management table |
| 6 | `db_KK_T_OP_SVC_KEI` | `JBSbatSQLAccess` | Instance field initialized to a new SQL access handle for the option service contract table |
| 7 | `db_KK_T_OP_SVC_KEI_094` | `JBSbatSQLAccess` | Secondary instance field for the same option service contract table, enabling separate query contexts |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JBSbatBusinessService.setCommonInfo` | JBSbatBusinessService | In-memory batch context | Sets/registers common batch parameters (JBSbatCommonItem) in the parent service's internal state |
| C | `new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_IDO_RSV)` | N/A | KK_T_IDO_RSV | Creates a new SQL access handle for the change reservation table |
| C | `new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_CASCD_KNRI)` | N/A | KK_T_CASCD_KNRI | Creates a new SQL access handle for the CAS card management table |
| C | `new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_OP_SVC_KEI)` | N/A | KK_T_OP_SVC_KEI | Creates a new SQL access handle for the option service contract table (primary) |
| C | `new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_OP_SVC_KEI)` | N/A | KK_T_OP_SVC_KEI | Creates a new SQL access handle for the option service contract table (secondary, 094) |

**Classification notes:**
- `setCommonInfo` is classified as **U** (Update) because it modifies the parent service's internal state to register batch context.
- The four `new JBSbatSQLAccess(...)` calls are classified as **C** (Create) because they instantiate new database access objects that will be used for subsequent read/update operations. These are factory-level objects, not direct CRUD operations on database tables.
- No actual R/U/D operations on database tables occur in this method — it is purely an initialization/setup phase.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKSkaWrkCnclProc (framework) | Batch framework -> `JBSbatKKSkaWrkCnclProc.initial(commonItem)` | `setCommonInfo [U] in-memory batch context` |

**Call chain detail:** In the standard batch framework, the batch scheduler invokes the batch service class by first calling the `initial(JBSbatCommonItem)` method to initialize the service, followed by `execute(JBSbatServiceInterfaceMap)` for the main processing logic. The `initial` method serves as the framework's lifecycle hook for one-time setup per batch run.

**Methods ultimately called FROM this method:**
- `JBSbatBusinessService.setCommonInfo` — updates parent service state
- `JBSbatSQLAccess` constructor (×4) — creates DB access handles for `KK_T_IDO_RSV`, `KK_T_CASCD_KNRI`, `KK_T_OP_SVC_KEI` (×2)

## 6. Per-Branch Detail Blocks

This method contains no conditional branches, loops, or exception handling blocks. It executes a linear sequence of assignments and method calls.

**Block 1** — [CALL] `(parent initialization)` (L97)

> Calls the parent service's common info setter to register batch context.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.setCommonInfo(commonItem);` // Sets common batch parameters [-> JBSbatBusinessService.setCommonInfo] |

**Block 2** — [CALL + SET] `(DB access creation - change reservation table)` (L100)

> Creates a SQL access handle for the change reservation table (異動予約).

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_KK_T_IDO_RSV = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_IDO_RSV);` // DB access class creation for change reservation table [-> D_TBL_NAME_KK_T_IDO_RSV = "KK_T_IDO_RSV"] |

**Block 3** — [CALL + SET] `(DB access creation - CAS card management table)` (L101)

> Creates a SQL access handle for the CAS card management table (CASカード管理).

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_KK_T_CASCD_KNRI = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_CASCD_KNRI);` // DB access class creation for CAS card management table [-> D_TBL_NAME_KK_T_CASCD_KNRI = "KK_T_CASCD_KNRI"] |

**Block 4** — [CALL + SET] `(DB access creation - option service contract table, primary)` (L102)

> Creates a SQL access handle for the option service contract table (オプションサービス契約). This is the primary access instance used for general operations.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_KK_T_OP_SVC_KEI = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_OP_SVC_KEI);` // DB access class creation for option service contract table [-> D_TBL_NAME_KK_T_OP_SVC_KEI = "KK_T_OP_SVC_KEI"] |

**Block 5** — [CALL + SET] `(DB access creation - option service contract table, secondary)` (L103)

> Creates a second SQL access handle for the same option service contract table. This separate instance is used to maintain an independent query context, likely bound to the `KK_SELECT_094` SQL key defined as constant `KK_T_OP_SVC_KEI_KK_SELECT_094`. This pattern allows the batch to execute different queries on the same table without SQL key conflicts.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_KK_T_OP_SVC_KEI_094 = new JBSbatSQLAccess(commonItem, D_TBL_NAME_KK_T_OP_SVC_KEI);` // DB access class creation for option service contract table (secondary 094) [-> D_TBL_NAME_KK_T_OP_SVC_KEI = "KK_T_OP_SVC_KEI"] |

**Block 6** — [RETURN] `(initialization complete)` (L107)

> Method returns void. Initialization is complete.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | (implicit) `return;` // End of initialization |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `JBSbatKKSkaWrkCnclProc` | Class | SCAPE Work Cancellation Processing — the batch service class that handles cancellation of work associated with SCAPE satellite broadcasting subscriptions |
| `スカパー工取消` | Business term | SCAPE Work Cancellation — cancellation processing for SCAPE (スカーパ) service subscription work orders |
| SCAPE (スカーパ) | Business term | A digital satellite broadcasting service operated by SKY Perfect JSAT in Japan |
| `commonItem` | Field | Batch common parameter interface — carries shared batch execution metadata across all batch services |
| `JBSbatCommonItem` | Type | The standard batch common parameter envelope in the enterprise batch framework |
| `JBSbatBusinessService` | Type | Parent class for batch services — provides shared initialization (`setCommonInfo`) and framework lifecycle management |
| `JBSbatSQLAccess` | Type | Database access abstraction class — provides standardized SQL execution for a specific table |
| KK_T_IDO_RSV | DB Table | Change Reservation Table (異動予約) — tracks reservation/change operations for service subscriptions |
| KK_T_CASCD_KNRI | DB Table | CAS Card Management Table (CASカード管理) — manages Conditional Access System cards for decryption authorization |
| KK_T_OP_SVC_KEI | DB Table | Option Service Contract Table (オプションサービス契約) — stores option service contract records |
| `SPTVKEYINFOOPERATECC` | Constant | SCAPE Key Information Operation CC — identifier for SCAPE key information operation component |
| `FUNC_CD_UPD` | Constant | "1" — Function code for update operations (更新) |
| `FUNC_CD_CHK` | Constant | "2" — Function code for check-only operations (チェックのみ) |
| `SHORI_CD_CRS_CHG_CL` | Constant | "3" — Processing code for course change cancellation (コース変更取消) |
| `KK_SELECT_094` | Constant | SQL definition key — a named SQL query for the option service contract table |
| `KK_SELECT_114` | Constant | SQL definition key — a named SQL query for the change reservation table |
| `KK_SELECT_115` | Constant | SQL definition key — a named SQL query for the change reservation table |
| `KK_SELECT_005` | Constant | SQL definition key — a named SQL query for the CAS card management table |
| CAS | Acronym | Conditional Access System — a digital rights management system used in satellite broadcasting for decryption authorization |
