# Business Logic — JBSbatKKRsvTokiHakTgCst.createRsvTokiHakFile() [43 LOC]

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

## 1. Role

### JBSbatKKRsvTokiHakTgCst.createRsvTokiHakFile()

This method creates output data for the provisional tokki (advance notification / advance billing) issuance intermediate file used in K-Opticom's fiber-optic service transfer (porting) batch processing. The method acts as a **data assembler** — it extracts a fixed set of service-contract fields from the incoming message map (`inMap`), branches to resolve the appropriate transfer-notification start/end date fields based on the tokki registration code (`itntokiAddCd`), assembles all values into a new output message map, flags the record for output via `setOutFlg(true)`, and returns it for downstream file writing.

The method is central to the **provisional tokki issuance** workflow, which determines when advance billing notifications (tokki) should be sent to customers whose fiber services are being transferred (ported) to another carrier or terminated. It supports three transfer-notification categories: (a) "tokki due to destination registration" (port-forward), (b) "tokki due to source contract cancellation" (port-back/cancellation), and (c) "tokki due to suspension" (service pause). The SOD issuance type code (`sodHakSbtCd`) parameter controls whether the issuance type is start (`"1"`) or end (`"2"`).

The method implements a **data transformation / routing pattern**: it reads raw input fields, applies conditional branch logic to resolve which date fields apply based on the tokki registration code, and writes a normalized output map using the intermediate file format constants (`JBSbatKKIFM112`). It is a private utility method called exclusively by `outputTokiEnd()` and `outputTokiStart()` within the same class, serving as a shared assembly step for the tokki intermediate file output pipeline.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["createRsvTokiHakFile"])
    EXTRACT1["Extract svcKeiNo from inMap"]
    EXTRACT2["Extract skGeneAddDtm from inMap"]
    EXTRACT3["Extract svcKeiUcwkNo from inMap"]
    EXTRACT4["Extract skuGeneAddDtm from inMap"]
    EXTRACT5["Extract sketGeneAddDtm from inMap"]
    INIT["Initialize date fields to empty strings"]
    COND{itntokiAddCd equals ITNTOKI_ADD_CD_ITENS?}
    BRANCH_ITENS["Read ITENS_OPAF_TOKI dates"]
    BRANCH_OTHER["Read DSL_PAUSE_TOKI dates"]
    CREATE_OUT["Create new JBSbatServiceInterfaceMap"]
    SET_OUT1["Set SVC_KEI_NO in outmap"]
    SET_OUT2["Set SK_GENE_ADD_DTM in outmap"]
    SET_OUT3["Set SVC_KEI_UCWK_NO in outmap"]
    SET_OUT4["Set SKU_GENE_ADD_DTM in outmap"]
    SET_OUT5["Set SKET_GENE_ADD_DTM in outmap"]
    SET_OUT6["Set ITNTOKI_STA_YMD in outmap"]
    SET_OUT7["Set ITNTOKI_END_YMD in outmap"]
    SET_OUT8["Set SOD_HAK_SBT_CD in outmap"]
    SET_OUT9["Set ITNTOKI_ADD_CD in outmap"]
    SET_FLG["Set outFlg true in outmap"]
    RETURN(["Return outmap"])
    START --> EXTRACT1
    EXTRACT1 --> EXTRACT2
    EXTRACT2 --> EXTRACT3
    EXTRACT3 --> EXTRACT4
    EXTRACT4 --> EXTRACT5
    EXTRACT5 --> INIT
    INIT --> COND
    COND -->|Yes| BRANCH_ITENS
    COND -->|No| BRANCH_OTHER
    BRANCH_ITENS --> CREATE_OUT
    BRANCH_OTHER --> CREATE_OUT
    CREATE_OUT --> SET_OUT1
    SET_OUT1 --> SET_OUT2
    SET_OUT2 --> SET_OUT3
    SET_OUT3 --> SET_OUT4
    SET_OUT4 --> SET_OUT5
    SET_OUT5 --> SET_OUT6
    SET_OUT6 --> SET_OUT7
    SET_OUT7 --> SET_OUT8
    SET_OUT8 --> SET_OUT9
    SET_OUT9 --> SET_FLG
    SET_FLG --> RETURN
```

**Constant Resolution:**
- `JKKBatConst.ITNTOKI_ADD_CD_ITENS = "1"` (Business meaning: "Tokki due to destination registration" — forward port notification)
- When `itntokiAddCd != "1"` (else branch): covers codes `"2"` (ITNTOKI_ADD_CD_ITENM = "Tokki due to source contract cancellation") and `"3"` (ITNTOKI_ADD_CD_PAUSE = "Tokki due to suspension")

**Processing Flow:**
1. Extract 5 service-contract fields from the input map (`inMap`), trimming whitespace.
2. Initialize the two tokki date variables to empty strings as defaults.
3. Branch on `itntokiAddCd`: if it equals `"1"`, read the forward-port-specific dates; otherwise read the cancellation/suspension-specific dates.
4. Create a new output map and populate all 9 fields using intermediate file format constants (`JBSbatKKIFM112`).
5. Set the output flag to `true` to signal downstream that this record should be written to the intermediate file.
6. Return the assembled output map.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | The input message map containing all service contract and tokki-related fields extracted from the upstream data source. This carries the raw input telegram with fields such as service contract number, service contract detail number, generation timestamps, and tokki registration/dates. |
| 2 | `sodHakSbtCd` | `String` | SOD (Service Order Data) issuance type code. Determines whether the tokki is a **start** issuance (`"1"`, `SOD_HAK_SBT_CD_STA`) or **end** issuance (`"2"`, `SOD_HAK_SBT_CD_END`). Passed through to the output map unchanged. |
| 3 | `itntokiAddCd` | `String` | Transfer tokki registration code. Controls which date fields to extract from `inMap`. `"1"` (`ITNTOKI_ADD_CD_ITENS`) means "tokki due to destination registration (forward port)" and triggers extraction of ITENS_OPAF date fields. Any other value (e.g., `"2"` for source cancellation, `"3"` for suspension) triggers extraction of DSL_PAUSE date fields. |

**Instance fields / external state read:**
- `SOD_HAK_SBT_CD_END` (class constant = `"2"`) — referenced in caller context, though not directly read in this method.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `inMap.getString(...)` | - | - | Reads values from input message map for service contract number, generation timestamps, and tokki dates |
| - | `JBSbatInterface.trim(...)` | JBSbatInterface | - | Trims whitespace from extracted string values |
| - | `new JBSbatServiceInterfaceMap()` | - | - | Creates a new output message map instance |
| - | `outmap.setString(...)` | - | - | Sets output fields into the intermediate file format map using `JBSbatKKIFM112` field keys |
| - | `outmap.setOutFlg(true)` | - | - | Sets the output flag to `true` to mark this record for file output |

**Analysis:**
This method is a **pure data transformation / assembly** method. It performs no database operations, no SC calls, and no entity-level CRUD. All operations are in-memory: it reads from the input `JBSbatServiceInterfaceMap`, conditionally extracts date fields, and writes to a new output map.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `inMap.getString(JBSbatKK_T_SVC_KEI.SVC_KEI_NO)` | - | Service contract entity | Reads the service contract number (SVC_KEI_NO) from input map |
| R | `inMap.getString(SK_GENE_ADD_DTM)` | - | Service contract entity | Reads the service contract generation add timestamp |
| R | `inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.SVC_KEI_UCWK_NO)` | - | Service contract detail entity | Reads the service contract detail work number |
| R | `inMap.getString(SKU_GENE_ADD_DTM)` | - | Service contract detail entity | Reads the service contract detail generation add timestamp |
| R | `inMap.getString(SKUT_GENE_ADD_DTM)` | - | Service contract detail (EO light phone) entity | Reads the service contract detail EO light phone generation add timestamp |
| R | `inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.ITENS_OPAF_TOKI_STA_YMD)` | - | Transfer port advance notification dates entity | Reads the forward-port tokki start date (only when `itntokiAddCd = "1"`) |
| R | `inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.ITENS_OPAF_TOKI_END_YMD)` | - | Transfer port advance notification dates entity | Reads the forward-port tokki end date (only when `itntokiAddCd = "1"`) |
| R | `inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.DSL_PAUSE_TOKI_STA_YMD)` | - | DSL pause/cancellation tokki dates entity | Reads the cancellation/suspension tokki start date (when `itntokiAddCd != "1"`) |
| R | `inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.DSL_PAUSE_TOKI_END_YMD)` | - | DSL pause/cancellation tokki dates entity | Reads the cancellation/suspension tokki end date (when `itntokiAddCd != "1"`) |
| - | `outmap.setString(JBSbatKKIFM112.SVC_KEI_NO, svcKeiNo)` | - | Intermediate file (JBSbatKKIFM112) | Writes service contract number to output intermediate file format |
| - | `outmap.setString(JBSbatKKIFM112.SK_GENE_ADD_DTM, skGeneAddDtm)` | - | Intermediate file (JBSbatKKIFM112) | Writes service contract generation timestamp to output |
| - | `outmap.setString(JBSbatKKIFM112.SVC_KEI_UCWK_NO, svcKeiUcwkNo)` | - | Intermediate file (JBSbatKKIFM112) | Writes service contract detail number to output |
| - | `outmap.setString(JBSbatKKIFM112.SKU_GENE_ADD_DTM, skuGeneAddDtm)` | - | Intermediate file (JBSbatKKIFM112) | Writes service contract detail generation timestamp to output |
| - | `outmap.setString(JBSbatKKIFM112.SKET_GENE_ADD_DTM, sketGeneAddDtm)` | - | Intermediate file (JBSbatKKIFM112) | Writes service contract detail EO light phone generation timestamp to output |
| - | `outmap.setString(JBSbatKKIFM112.ITNTOKI_STA_YMD, itntokiStaYmd)` | - | Intermediate file (JBSbatKKIFM112) | Writes transfer tokki start date to output |
| - | `outmap.setString(JBSbatKKIFM112.ITNTOKI_END_YMD, itntokiEndYmd)` | - | Intermediate file (JBSbatKKIFM112) | Writes transfer tokki end date to output |
| - | `outmap.setString(JBSbatKKIFM112.SOD_HAK_SBT_CD, sodHakSbtCd)` | - | Intermediate file (JBSbatKKIFM112) | Writes SOD issuance type code to output |
| - | `outmap.setString(JBSbatKKIFM112.ITNTOKI_ADD_CD, itntokiAddCd)` | - | Intermediate file (JBSbatKKIFM112) | Writes transfer tokki registration code to output |
| - | `outmap.setOutFlg(true)` | - | Intermediate file (JBSbatKKIFM112) | Sets the output record flag to mark this record for file output |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 2 methods.
Terminal operations from this method: `setOutFlg` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-], `setString` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `outputTokiEnd` | `JBSbatKKRsvTokiHakTgCst.outputTokiEnd` -> `createRsvTokiHakFile` | `setOutFlg`, `setString` (19 field writes to intermediate file map) |
| 2 | Batch: `outputTokiStart` | `JBSbatKKRsvTokiHakTgCst.outputTokiStart` -> `createRsvTokiHakFile` | `setOutFlg`, `setString` (19 field writes to intermediate file map) |

**Call Chain Context:**
- `outputTokiEnd()` — Called when processing tokki **end** scenarios (cancellation/suspension tokki with past end dates, or port-forward scenarios where the destination service is already terminated/cancelled). Passes `SOD_HAK_SBT_CD_END = "2"` as the issuance type code.
- `outputTokiStart()` — Called when processing tokki **start** scenarios (port-forward with past end dates, or destination service stopped). Passes the result of `getSodHkSbtCd()` (which resolves to `SOD_HAK_SBT_CD_STA = "1"` when the end date is past, otherwise `"2"`).

Both callers feed `outmap` results (returned from `createRsvTokiHakFile`) into `outputBean.addOutMapList(outmap)` for intermediate file output.

## 6. Per-Branch Detail Blocks

**Block 1** — [EXTRACT/TRIM] (L370)

> Extracts 5 service-contract fields from the input map and trims whitespace.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiNo = JBSbatInterface.trim(inMap.getString(JBSbatKK_T_SVC_KEI.SVC_KEI_NO))` // Service contract number |
| 2 | SET | `skGeneAddDtm = JBSbatInterface.trim(inMap.getString(SK_GENE_ADD_DTM))` // Service contract generation timestamp [-> SK_GENE_ADD_DTM="SK_GENE_ADD_DTM"] |
| 3 | SET | `svcKeiUcwkNo = JBSbatInterface.trim(inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.SVC_KEI_UCWK_NO))` // Service contract detail work number |
| 4 | SET | `skuGeneAddDtm = JBSbatInterface.trim(inMap.getString(SKU_GENE_ADD_DTM))` // Service contract detail generation timestamp [-> SKU_GENE_ADD_DTM="SKU_GENE_ADD_DTM"] |
| 5 | SET | `sketGeneAddDtm = JBSbatInterface.trim(inMap.getString(SKUT_GENE_ADD_DTM))` // Service contract detail EO light phone generation timestamp [-> SKUT_GENE_ADD_DTM="SKUT_GENE_ADD_DTM"] |

**Block 2** — [INIT] (L377-L378)

> Initializes the two tokki date variables to empty strings as defaults. These will be populated by the conditional branch below.

| # | Type | Code |
|---|------|------|
| 1 | SET | `itntokiStaYmd = ""` // Transfer tokki start date (default empty) |
| 2 | SET | `itntokiEndYmd = ""` // Transfer tokki end date (default empty) |

**Block 3** — [IF/ELSE] (`JKKBatConst.ITNTOKI_ADD_CD_ITENS.equals(itntokiAddCd)`) [ITNTOKI_ADD_CD_ITENS="1"] (L380)

> Branches on the transfer tokki registration code to select the appropriate date fields. If the code is "1" (forward port / destination registration), extracts the ITENS_OPAF (forward port advance notification) date fields. Otherwise (codes "2" or "3" — source cancellation or suspension), extracts the DSL_PAUSE (cancellation/suspension tokki) date fields.

**Block 3.1** — [IF-THEN: `ITNTOKI_ADD_CD_ITENS = "1"`] (L381-L384)

> Forward port (destination registration) tokki. Reads dates from ITENS_OPAF (forward port advance notification) fields.

| # | Type | Code |
|---|------|------|
| 1 | SET | `itntokiStaYmd = JBSbatInterface.trim(inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.ITENS_OPAF_TOKI_STA_YMD))` // Forward port tokki start date |
| 2 | SET | `itntokiEndYmd = JBSbatInterface.trim(inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.ITENS_OPAF_TOKI_END_YMD))` // Forward port tokki end date |

**Block 3.2** — [ELSE: other codes ("2"=source cancellation, "3"=suspension)] (L387-L390)

> Source contract cancellation or suspension tokki. Reads dates from DSL_PAUSE (cancellation/suspension tokki) fields.

| # | Type | Code |
|---|------|------|
| 1 | SET | `itntokiStaYmd = JBSbatInterface.trim(inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.DSL_PAUSE_TOKI_STA_YMD))` // Cancellation/suspension tokki start date |
| 2 | SET | `itntokiEndYmd = JBSbatInterface.trim(inMap.getString(JBSbatKK_T_SVKEIUW_EOH_TEL.DSL_PAUSE_TOKI_END_YMD))` // Cancellation/suspension tokki end date |

**Block 4** — [CREATE OUTMAP] (L392)

> Creates a new output message map for the intermediate file.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outmap = new JBSbatServiceInterfaceMap()` // New output intermediate file map |

**Block 5** — [SET OUTPUT FIELDS] (L395-L403)

> Populates the output map with all 9 fields for the provisional tokki issuance intermediate file format (`JBSbatKKIFM112`).

| # | Type | Code |
|---|------|------|
| 1 | SET | `outmap.setString(JBSbatKKIFM112.SVC_KEI_NO, svcKeiNo)` // Service contract number |
| 2 | SET | `outmap.setString(JBSbatKKIFM112.SK_GENE_ADD_DTM, skGeneAddDtm)` // Service contract generation timestamp |
| 3 | SET | `outmap.setString(JBSbatKKIFM112.SVC_KEI_UCWK_NO, svcKeiUcwkNo)` // Service contract detail work number |
| 4 | SET | `outmap.setString(JBSbatKKIFM112.SKU_GENE_ADD_DTM, skuGeneAddDtm)` // Service contract detail generation timestamp |
| 5 | SET | `outmap.setString(JBSbatKKIFM112.SKET_GENE_ADD_DTM, sketGeneAddDtm)` // Service contract detail EO light phone generation timestamp |
| 6 | SET | `outmap.setString(JBSbatKKIFM112.ITNTOKI_STA_YMD, itntokiStaYmd)` // Transfer tokki start date (from branch) |
| 7 | SET | `outmap.setString(JBSbatKKIFM112.ITNTOKI_END_YMD, itntokiEndYmd)` // Transfer tokki end date (from branch) |
| 8 | SET | `outmap.setString(JBSbatKKIFM112.SOD_HAK_SBT_CD, sodHakSbtCd)` // SOD issuance type code ("1"=start, "2"=end) |
| 9 | SET | `outmap.setString(JBSbatKKIFM112.ITNTOKI_ADD_CD, itntokiAddCd)` // Transfer tokki registration code |

**Block 6** — [SET OUTPUT FLAG] (L405)

> Sets the output record flag to `true`, marking this record for intermediate file output.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outmap.setOutFlg(true)` // Record output decision flag — marks for file output |

**Block 7** — [RETURN] (L408)

> Returns the fully assembled output map to the caller.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return outmap` // Output data for intermediate file |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service contract number — the unique identifier for a customer's service contract line |
| `svc_kei_ucwk_no` | Field | Service contract detail work number — internal tracking ID for service contract line items |
| `sk_gene_add_dtm` | Field | Service contract generation add date/time — timestamp when the service contract was created/registered |
| `sku_gene_add_dtm` | Field | Service contract detail generation add date/time — timestamp when the service contract detail was registered |
| `sket_gene_add_dtm` | Field | Service contract detail (EO light phone) generation add date/time — timestamp for the fiber-optic phone detail registration |
| `itntoki_sta_ymd` | Field | Transfer tokki start year/month/day — the date when the advance notification (tokki) period begins |
| `itntoki_end_ymd` | Field | Transfer tokki end year/month/day — the date when the advance notification (tokki) period ends |
| `itntoki_add_cd` | Field | Transfer tokki registration code — classifies the type of advance notification (forward port, source cancellation, or suspension) |
| `sod_hak_sbt_cd` | Field | SOD issuance type code — distinguishes between start issuance ("1") and end issuance ("2") of the service order |
| `ITENS_OPAF_TOKI_STA_YMD` | Field | Forward port (destination registration) advance notification start date |
| `ITENS_OPAF_TOKI_END_YMD` | Field | Forward port (destination registration) advance notification end date |
| `DSL_PAUSE_TOKI_STA_YMD` | Field | DSL pause/cancellation advance notification start date |
| `DSL_PAUSE_TOKI_END_YMD` | Field | DSL pause/cancellation advance notification end date |
| `JBSbatKK_T_SVC_KEI` | Constant Class | Key class for service contract (SVC_KEI) table field definitions |
| `JBSbatKK_T_SVKEIUW_EOH_TEL` | Constant Class | Key class for service contract detail (SVKEIUW_EOH_TEL) table field definitions — includes port and tokki date fields |
| `JBSbatKKIFM112` | Constant Class | Intermediate file format (IFM) constants for the provisional tokki issuance intermediate file |
| ITNTOKI_ADD_CD_ITENS | Constant | Value `"1"` — "Tokki due to destination registration" (forward port) |
| ITNTOKI_ADD_CD_ITENM | Constant | Value `"2"` — "Tokki due to source contract cancellation" (port-back/cancellation) |
| ITNTOKI_ADD_CD_PAUSE | Constant | Value `"3"` — "Tokki due to suspension" (service pause) |
| SOD_HAK_SBT_CD_STA | Constant | Value `"1"` — SOD issuance type: Start (advance billing commencement) |
| SOD_HAK_SBT_CD_END | Constant | Value `"2"` — SOD issuance type: End (advance billing cessation) |
| SOD | Acronym | Service Order Data — the telecom order fulfillment entity that triggers advance billing notifications |
| Tokki (通知) | Term | Advance notification / advance billing — a pre-service notification sent to customers before service changes (porting, cancellation, suspension) take effect |
| ITENS (移転先登録) | Term | Forward port / destination registration — the process of registering the new carrier destination when a customer ports their service |
| ITENM (移転元解約) | Term | Source contract cancellation — the process of cancelling the service contract at the original carrier when a customer ports away |
| DSL_PAUSE (休止) | Term | Service suspension/pause — a temporary halt to service that triggers advance billing notification |
| JBSbatServiceInterfaceMap | Class | Service interface map — a key-value message container used for passing data between batch processing components |
| setOutFlg | Method | Sets the output record flag — when true, signals that this record should be written to the intermediate file |
| FTTH | Business term | Fiber To The Home — the fiber-optic broadband service operated by K-Opticom |
