# Business Logic — JBSbatKKRsvTokiHakTgCst.setItnsSvcKeiUcwk() [27 LOC]

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

## 1. Role

### JBSbatKKRsvTokiHakTgCst.setItnsSvcKeiUcwk()

This method populates the **forwarded destination service contract detail information** for a transfer-post connection Toki (トーキ: a telecommunications service identifier/handle) into the input data map. In the broader batch processing flow, it acts as a data enrichment step that resolves the service contract detail status from the `KK_T_SVC_KEI_UCWK` (Service Contract Detail) database table using the forwarding destination service contract detail number, and writes the retrieved status back into the in-flight data map for downstream consumption. The method implements a conditional query pattern: if the forwarding destination service contract detail number (`ITNS_OPAF_TOKI_TSS_SVKUWNO`) is present and non-empty in the input map, it performs a database lookup via `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014` to fetch the service contract detail record and extract the service contract detail status field (`SVC_KEI_UCWK_STAT`). If the number is absent or the database query yields no result, the status is set to an empty string as a safe default. It is a private utility method called by the class's `execute()` method, functioning as an internal data-transfer and enrichment subroutine within the batch pipeline.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setItnsSvcKeiUcwk begins"])

    START --> S1["Initialize sakiSvcKeiUcwkStat = empty string"]
    S1 --> S2["Retrieve inMap value by key ITNS_OPAF_TOKI_TSS_SVKUWNO and trim it"]
    S2 --> COND1{itnsOpafTokiTssSvkuwno is not null AND not empty?}

    COND1 -- No --> END_RET["Set inMap SAKI_SVC_KEI_UCWK_STAT with sakiSvcKeiUcwkStat"]
    COND1 -- Yes --> EXEC1["Call executeKK_T_SVC_KEI_UCWK_KK_SELECT_014 with itnsOpafTokiTssSvkuwno and trnOpeDate"]

    EXEC1 --> SELECT["db_KK_T_SVC_KEI_UCWK.selectNext()"]
    SELECT --> COND2{svcKeiUcwk result is not null?}

    COND2 -- No --> GET_RESULT2["sakiSvcKeiUcwkStat remains empty string"]
    COND2 -- Yes --> GET_RESULT["Extract SVC_KEI_UCWK_STAT from result and trim"]
    GET_RESULT --> GET_RESULT2

    GET_RESULT2 --> END_RET
    END_RET --> FINISH(["Method returns void"])
```

**Conditional branches:**
- **Branch 1** (L455–L456): Checks if `itnsOpafTokiTssSvkuwno` is non-null and non-empty. If false, skips the database query entirely and the status defaults to empty string.
- **Branch 2** (L462–L464): Checks if the database query returned a non-null result. If false, the status remains empty string. If true, extracts and trims the `SVC_KEI_UCWK_STAT` field from the result.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | The in-flight data map carrying input/output data for the batch processing flow. It contains the forwarding destination service contract detail number (`ITNS_OPAF_TOKI_TSS_SVKUWNO`) as input, and receives the resolved forwarding destination service contract detail status (`SAKI_SVC_KEI_UCWK_STAT`) as output. |
| — | `trnOpeDate` | `String` (instance field) | The transaction operation date used as a second bind variable for the database query. This represents the application date for the service contract detail lookup, ensuring the query returns the record as of the relevant business date. |
| — | `db_KK_T_SVC_KEI_UCWK` | `JBSbatCommonDBInterface` (instance field) | The database access handle for the `KK_T_SVC_KEI_UCWK` (Service Contract Detail) table, used to execute the select query and retrieve results. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014` | EKK_SVC_KEI_UCWK | `KK_T_SVC_KEI_UCWK` | Selects the service contract detail record by bind variables: service contract detail number (`SVC_KEI_UCWK_NO`) and application effective date (`APPLY_YMD`), using SQLKEY `KK_SELECT_014`. Returns a single row from the Service Contract Detail table. |
| R | `JBSbatInterface.trim` | - | - | Trims whitespace from strings retrieved from `inMap` and database results. Utility call, no data operation. |
| R | `inMap.getString` | - | - | Reads the forwarding destination service contract detail number from the input data map. |
| - | `inMap.setString` | - | - | Writes the resolved service contract detail status back into the input data map as an output value. |

### CRUD Summary:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014` | EKK_SVC_KEI_UCWK | `KK_T_SVC_KEI_UCWK` | Read service contract detail record by number and business date to resolve the contract detail status for a forwarded Toki. |

**CRUD classification explanation:**
- The method performs a single database **Read (R)** operation via `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014`, which internally calls `selectBySqlDefine` with SQLKEY `KK_SELECT_014` on the `KK_T_SVC_KEI_UCWK` table. No create, update, or delete operations are performed.

## 5. Dependency Trace

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `setString` [-], `trim` [-], `getString` [R], `getString` [R], `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014` [-]  # NOSONAR

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch:JBSbatKKRsvTokiHakTgCst | `JBSbatKKRsvTokiHakTgCst.execute()` -> `JBSbatKKRsvTokiHakTgCst.setItnsSvcKeiUcwk` | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014 [R] KK_T_SVC_KEI_UCWK` |

**Call chain description:**
- This method is a private subroutine called directly from the `execute()` method of its own class (`JBSbatKKRsvTokiHakTgCst`), which serves as the batch processing entry point for service contract forwarding Toki processing. The batch invokes `setItnsSvcKeiUcwk()` to enrich the data map with the resolved service contract detail status before proceeding with downstream processing.

## 6. Per-Branch Detail Blocks

**Block 1** — INIT (variable initialization) (L449)

> Initializes the local variable that will hold the resolved service contract detail status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sakiSvcKeiUcwkStat = ""` // Initialize forwarded service contract detail status to empty string |

**Block 2** — INIT (retrieve input value) (L452)

> Retrieves the forwarding destination service contract detail number from the input map and trims whitespace.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.ITNS_OPAF_TOKI_TSS_SVKUWNO)` // Read forwarding destination service contract detail number from input map [-> ITNS_OPAF_TOKI_TSS_SVKUWNO = "ITNS_OPAF_TOKI_TSS_SVKUWNO"] |
| 2 | EXEC | `JBSbatInterface.trim(...)` // Trim whitespace from the retrieved value |
| 3 | SET | `itnsOpafTokiTssSvkuwno = ...` // Store trimmed forwarding destination service contract detail number |

**Block 3** — IF (null/non-empty check on forwarding destination number) (L455)

> Conditionally queries the database only if the forwarding destination service contract detail number is present. If absent, the status remains empty string and the method proceeds to write the empty result.

| # | Type | Code |
|---|------|------|
| 1 | COND | `null != itnsOpafTokiTssSvkuwno && !itnsOpafTokiTssSvkuwno.isEmpty()` // Forwarding destination service contract detail number exists and is non-empty |

**Block 3.1** — IF-THEN (database query) (L457)

> Executes the database select query with the forwarding destination number and operation date, then extracts the status from the result if available.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014(new String[]{itnsOpafTokiTssSvkuwno, trnOpeDate})` // Query KK_T_SVC_KEI_UCWK by service contract detail number and business date using SQLKEY KK_SELECT_014 |
| 2 | EXEC | `db_KK_T_SVC_KEI_UCWK.selectNext()` // Fetch the next row from the query result set |
| 3 | SET | `svcKeiUcwk = db_KK_T_SVC_KEI_UCWK.selectNext()` // Store the returned service contract detail row |

**Block 3.1.1** — IF (result not null check) (L462)

> If the database returned a valid service contract detail record, extract and trim the status field. If null, skip and leave the status as empty string.

| # | Type | Code |
|---|------|------|
| 1 | COND | `null != svcKeiUcwk` // Service contract detail record was returned from DB query |

**Block 3.1.1.1** — IF-THEN (extract status) (L463)

> Extracts the service contract detail status field from the database result and trims it.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `svcKeiUcwk.getString(JBSbatKK_T_SVC_KEI_UCWK.SVC_KEI_UCWK_STAT)` // Read service contract detail status field [-> SVC_KEI_UCWK_STAT = "SVC_KEI_UCWK_STAT"] |
| 2 | EXEC | `JBSbatInterface.trim(...)` // Trim whitespace from the status value |
| 3 | SET | `sakiSvcKeiUcwkStat = ...` // Assign extracted status to local variable |

**Block 3.1.2** — IF-ELSE (implicit else: null result) (L462)

> When the database query returns null (no matching record found), the status remains the initialized empty string — no action needed.

**Block 4** — OUTPUT (write result to map) (L470)

> Writes the resolved service contract detail status back into the input data map so downstream processing can consume it.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `inMap.setString(SAKI_SVC_KEI_UCWK_STAT, sakiSvcKeiUcwkStat)` // Write resolved status to output map [-> SAKI_SVC_KEI_UCWK_STAT = "SAKI_SVC_KEI_UCWK_STAT"] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ITNS_OPAF_TOKI_TSS_SVKUWNO` | Field | Forwarding destination service contract detail number — the internal identifier of the service contract detail line item to which the Toki is forwarded after transfer |
| `SAKI_SVC_KEI_UCWK_STAT` | Field | Forwarded service contract detail status — the status of the service contract detail record at the forwarding destination, stored as a string key in the data map |
| `SVC_KEI_UCWK_STAT` | Field | Service contract detail status — the current status code of a service contract detail record in the `KK_T_SVC_KEI_UCWK` table (e.g., active, completed, cancelled) |
| `SVC_KEI_UCWK_NO` | Field | Service contract detail number — unique identifier for a service contract detail line item |
| `trnOpeDate` | Field | Transaction operation date — the business date used to query the service contract detail record as of a specific point in time |
| `JBSbatKK_T_SVKEIUW_EOH_TEL` | Constant Class | Table constant class for the Service Contract Detail (End of Line) Telephone table — holds key names for TEL-related service contract fields |
| `JBSbatKK_T_SVC_KEI_UCWK` | Constant Class | Table constant class for the `KK_T_SVC_KEI_UCWK` database table — holds field name constants for service contract detail records |
| `KK_T_SVC_KEI_UCWK` | Database Table | Service Contract Detail table — stores detailed service contract line item information including status, effective dates, and contract classifications |
| `KK_SELECT_014` | SQL Key | SQLKEY used for selecting a single service contract detail record by number and application date |
| `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014` | Method | Private database query method that executes a select on `KK_T_SVC_KEI_UCWK` using SQLKEY `KK_SELECT_014` with bind variables for service contract detail number and business date |
| トーキ (Toki) | Business term | A telecommunications service identifier/handle — an internal identifier representing an activated telephone service line in NTT's infrastructure |
| 移転先 (Itensaki) | Business term | Transfer destination — the target location or service destination to which a Toki is forwarded after a transfer operation |
| 開通後 (Kaitsugo) | Business term | Post-connection / after activation — indicates a state where the service connection has been completed |
| 転送先 (Tensakyaku) | Business term | Forwarding destination — the target where the Toki data is routed in a forwarding scenario |
| サービス契約内訳 (Saabisu Keiyaku Naiwai) | Business term | Service contract detail — individual line items within a service contract that define specific service offerings, their status, and attributes |
| 番号 (Bangou) | Business term | Number / identifier — an internal tracking number for a specific record |
| `JBSbatServiceInterfaceMap` | Technical type | Data map used across the batch processing layer for passing input and output data between processing methods |
| `JBSbatCommonDBInterface` | Technical type | Database access interface providing `selectNext()`, `getString()`, and other row-level operations for querying database results |
| `trim` | Utility method | Whitespace trimming utility applied to string values retrieved from the input map or database to ensure clean data |
| `JBSbatInterface` | Utility class | Shared utility class providing common methods like `trim()` for data normalization |
| `JZMBatCommon` | Utility class | Batch common utility class providing data processing helpers |
