# Business Logic — JBSbatKKSodUpdInfCst.getSysId() [16 LOC]

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

## 1. Role

### JBSbatKKSodUpdInfCst.getSysId()

This method retrieves the system identifier (`SYSID`) for a specific service contract line item from the `KK_T_SVC_KEI` (Service Contract) table. In the K-Opticom customer core system, every service contract record is assigned a unique system-level identifier that is used for audit trail logging and inter-process correlation. The method follows a simple **repository-access pattern**: it receives a service contract number (`svcKeiNo`), constructs a query parameter set including the current operation date (`opeDate`), executes a database lookup using SQL definition key `KK_SELECT_023`, and returns the `SYSID` from the fetched row. If no matching service contract record is found, it returns an empty string as a safe sentinel value. This method serves as a **shared utility** within the batch processing framework, currently consumed by `getLogMsgKojiStop()` to enrich stop-phase log messages with the service contract's system identifier for traceability. The method is private, indicating it is an internal helper rather than a public API surface.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getSysId(svcKeiNo)"])
    STEP1["Create paramList (JBSbatCommonDBInterface)"]
    STEP2["paramList.setValue(svcKeiNo)"]
    STEP3["paramList.setValue(opeDate)"]
    STEP4["db_KK_T_SVC_KEI.selectBySqlDefine(paramList, KK_SELECT_023)"]
    STEP5["svcKei = db_KK_T_SVC_KEI.selectNext()"]
    COND{svcKei != null?}
    STEP6["return svcKei.getString(SYSID)"]
    STEP7["return \"\""]
    END(["End"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> COND
    COND -- true --> STEP6 --> END
    COND -- false --> STEP7 --> END
```

**Processing Description:**

1. **Parameter Preparation**: A new `JBSbatCommonDBInterface` instance (`paramList`) is created to hold query parameters. The input `svcKeiNo` (service contract number) is bound as the primary lookup key, and the inherited `opeDate` (operation date) is bound as a secondary condition — likely used for record versioning or effective-date filtering in the SQL query.
2. **Database Query**: The method delegates the actual SQL execution to `db_KK_T_SVC_KEI.selectBySqlDefine()`, using the pre-defined SQL key `KK_T_SVC_KEI_KK_SELECT_023` ("KK_SELECT_023"). This key references a pre-compiled SQL statement in the iBatis/SQL map configuration that queries the `KK_T_SVC_KEI` table.
3. **Row Retrieval**: `selectNext()` fetches the next result row from the executed query as a `JBSbatCommonDBInterface` object.
4. **Null Guard**: If the fetched row is `null` (no matching service contract found), the method returns an empty string. Otherwise, it extracts and returns the `SYSID` column value via `getString(JBSbatKK_T_SVC_KEI.SYSID)`.

**Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `SYSID` | `"SYSID"` | Column name for the system identifier in the `KK_T_SVC_KEI` table |
| `KK_T_SVC_KEI_KK_SELECT_023` | `"KK_SELECT_023"` | SQL define key for the service contract lookup query |
| `D_TBL_NAME_KK_T_SVC_KEI` | `"KK_T_SVC_KEI"` | Table name for Service Contract (サービス契約) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `svcKeiNo` | `String` | Service contract line item number — the unique identifier for a specific service contract record. This is the primary lookup key used to find the corresponding SYSID in the `KK_T_SVC_KEI` table. Each service contract line item represents a distinct service offering (e.g., FTTH internet, phone, TV) associated with a customer account. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `opeDate` | `String` | Operation date — inherited from the batch common item, representing the business date for the current batch run. Used as a secondary query condition to filter records by effective date. |
| `db_KK_T_SVC_KEI` | `JBSbatSQLAccess` | Database access instance for the `KK_T_SVC_KEI` (Service Contract) table. Initialized by the framework before batch processing begins. |

## 4. CRUD Operations / Called Services

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

All method calls within this method and their CRUD classification:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatCommonDBInterface.setValue` | - | - | Binds the `svcKeiNo` parameter as a query condition value into the parameter list |
| R | `JBSbatCommonDBInterface.setValue` | - | - | Binds the `opeDate` (operation date) as a query condition value into the parameter list |
| R | `JBSbatSQLAccess.selectBySqlDefine` | (SQL map) | `KK_T_SVC_KEI` | Executes the pre-defined SQL query (key: `KK_SELECT_023`) against the Service Contract table, using `paramList` as bind parameters |
| R | `JBSbatSQLAccess.selectNext` | (SQL map) | `KK_T_SVC_KEI` | Fetches the next result row from the executed query as a `JBSbatCommonDBInterface` |
| R | `JBSbatCommonDBInterface.getString` | - | - | Extracts the `SYSID` column value from the fetched service contract row |

**How to classify:**
- **R** (Read): All operations in this method are read-only. The method constructs query parameters, executes a SQL SELECT against `KK_T_SVC_KEI`, retrieves a result row, and extracts a column value. No INSERT, UPDATE, or DELETE operations occur.

**Entity/DB Table Analysis:**

| Entity / DB Table | Access Pattern | Description |
|-------------------|---------------|-------------|
| `KK_T_SVC_KEI` | R (SELECT) | Service Contract table — stores service contract line item details including system ID, service code, pricing group, and pricing code. Queried by service contract number (`svcKeiNo`) and operation date (`opeDate`) using SQL key `KK_SELECT_023`. |

## 5. Dependency Trace

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

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

Trace who calls this method and what this method ultimately calls:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JBSbatKKSodUpdInfCst.getLogMsgKojiStop()` | `JBSbatKKSodUpdInfCst.getLogMsgKojiStop()` -> `JBSbatKKSodUpdInfCst.getSysId(svcKeiNo)` | `getString [R] KK_T_SVC_KEI` |

**Caller Analysis:**

`getLogMsgKojiStop()` is a private method in the same class (`JBSbatKKSodUpdInfCst`). It is called during the batch job's stop phase to construct a log message that includes the service contract's system identifier. The `getSysId()` call is embedded within string concatenation to produce a log message in the format `" SYSID:" + sysId + msgSvcKei`. This enables operations teams to trace batch processing events back to the specific service contract line item being processed.

**Call Direction Summary:**

- **Called by**: `JBSbatKKSodUpdInfCst.getLogMsgKojiStop()` (same class, private)
- **Calls**: `JBSbatCommonDBInterface.setValue()` (x2), `JBSbatSQLAccess.selectBySqlDefine()`, `JBSbatSQLAccess.selectNext()`, `JBSbatCommonDBInterface.getString()`
- **Terminal operations**: All are Read operations against the `KK_T_SVC_KEI` table

## 6. Per-Branch Detail Blocks

**Block 1** — SET (parameter preparation) (L1118)

> Creates the query parameter container and binds the service contract number and operation date as lookup conditions.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramList = new JBSbatCommonDBInterface()` // Create new parameter list container |
| 2 | CALL | `paramList.setValue(svcKeiNo)` // Bind service contract number as primary lookup key [-> svcKeiNo] |
| 3 | CALL | `paramList.setValue(opeDate)` // Bind operation date as secondary condition [-> inherited field opeDate] |

**Block 2** — CALL (database query execution) (L1122)

> Executes the SQL SELECT query against the Service Contract table using the pre-compiled SQL definition key `KK_SELECT_023`.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_KK_T_SVC_KEI.selectBySqlDefine(paramList, KK_T_SVC_KEI_KK_SELECT_023)` // Execute SQL query [KK_SELECT_023] on KK_T_SVC_KEI table [-> "KK_SELECT_023"] |

**Block 3** — SET (row retrieval) (L1123)

> Fetches the next result row from the executed query. Returns null if no matching record exists.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKei = db_KK_T_SVC_KEI.selectNext()` // Retrieve next row as JBSbatCommonDBInterface [-> null if no match] |

**Block 4** — IF (null check on result) `(svcKei != null)` (L1124)

> Determines whether a matching service contract record was found. If found, extracts and returns the SYSID; otherwise falls through to return an empty string.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sysId = svcKei.getString(JBSbatKK_T_SVC_KEI.SYSID)` // Extract SYSID column [-> SYSID = "SYSID"] |

**Block 4.1** — RETURN (true branch) (L1125)

> Returns the system identifier from the matched service contract record.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return sysId` // Return SYSID value [-> string, e.g. "12345"] |

**Block 5** — RETURN (false branch / fall-through) (L1127)

> Returns an empty string when no matching service contract is found. This acts as a null-sentinel, ensuring the caller never receives a null reference.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return ""` // Return empty string sentinel [-> no SYSID found] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svcKeiNo` | Field | Service contract line item number — the unique identifier for a specific service contract record (e.g., a FTTH line, phone line, or TV subscription). Used as the primary key for querying the `KK_T_SVC_KEI` table. |
| `SYSID` | Field | System identifier — a unique system-level ID assigned to each record in the `KK_T_SVC_KEI` (Service Contract) table. Used for internal audit trail correlation and inter-process identification. |
| `opeDate` | Field | Operation date — the business date associated with the current batch processing run. Inherited from `JBSbatBusinessService` via the batch common item. Used as a date filter in SQL queries to ensure the correct version of a record is retrieved. |
| `KK_T_SVC_KEI` | Entity | Service Contract (サービス契約) table — stores service contract line item details including system ID, service code, pricing group, pricing code, and provision method contract number. |
| `KK_SELECT_023` | SQL Key | Pre-defined SQL query key for selecting a service contract record by service contract number and operation date. Referenced via `KK_T_SVC_KEI_KK_SELECT_023`. |
| `JBSbatCommonDBInterface` | Class | Framework item class representing a database row. Provides `setValue()` for binding query parameters and `getString()` for reading column values. |
| `JBSbatSQLAccess` | Class | Framework database access class that executes SQL queries defined in iBatis/SQL map configuration files. Provides `selectBySqlDefine()` and `selectNext()` methods. |
| `JBSbatBusinessService` | Class | Base class for all batch business services. Provides shared fields including `opeDate` (operation date) and `onlineOpeDate` (online operation date), initialized from the batch common item. |
| KK_T_ | Prefix | K-Opticom Transaction table prefix — database tables prefixed with `KK_T_` are core customer transaction tables in the K-Opticom system. |
| SOD | Acronym | Service Order Data — the module/package context for service contract update information extraction. |
| `KK_T_SVKEI_KAISEN_UW` | Entity | Service contract route details (サービス契約回線内訳) table — stores detailed routing information for service contract line items. |
| KKSV | Prefix | K-Opticom Service Screen prefix — web screen classes (e.g., `KKSV0004`). |
