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

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

## 1. Role

### JBSbatKKRsvTokiHakTgCst.execute()

This method serves as the **main processing entry point** for a batch job that generates **provisional tokugi (tentative activation) files** for service contract transfers (portability/migration scenarios). In the Japanese telecom domain, "tokugi" (確定) refers to the scheduled activation/deactivation of telecom services. This method coordinates the entire workflow: it first populates downstream service contract status information by querying the `KK_T_SVC_KEI_UCWK` table via `setItnsSvcKeiUcwk`, then delegates all tokugi determination logic to `outputTokiStart` and `outputTokiEnd`.

The method handles **three distinct tokugi registration categories**, each with its own business rule set: **(a) destination-registration tokugi** -- tokugi triggered when a customer completes a service portability registration to a new provider; **(b) origin-cancellation tokugi** -- tokugi triggered when the original (port-out) service is cancelled or terminated; and **(c) pause tokugi** -- tokugi triggered when the service is suspended/paused. For each category, the method determines whether to emit a "Start SOD" (SOD_HAK_SBT_CD="1"), "End SOD" (SOD_HAK_SBT_CD="2"), or "No SOD" (SOD_HAK_SBT_CD="0") intermediate file based on date-based cutoff rules and current service status conditions.

The method implements the **delegation design pattern**, delegating the heavy conditional logic to two private methods (`outputTokiStart` and `outputTokiEnd`). It also employs a **route-to-handler** pattern through `createRsvTokiHakFile`, which transforms the input message into an output intermediate file with appropriate SOD activation type codes and tokugi registration codes. This batch service is called by the batch framework dispatcher based on the batch process configuration, serving as a shared utility invoked by many batch schedules.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute inMap"])
    STEP1["setItnsSvcKeiUcwk inMap"]
    STEP2["printDebugLog inMap"]
    STEP3["outputBean = new JBSbatOutputItem"]
    STEP4["isEndItenmDslToki = false"]
    STEP5["outputTokiStart inMap outputBean"]
    BRANCH_A["Destination Registration Tokugi"]
    BRANCH_B["Origin Cancellation Tokugi"]
    BRANCH_C["Pause Tokugi"]
    END1["outputTokiEnd inMap outputBean isEndItenmDslToki"]
    END2["return outputBean"]

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> BRANCH_A
    BRANCH_A --> BRANCH_B
    BRANCH_B --> BRANCH_C
    BRANCH_C --> END1
    END1 --> END2
```

**Processing Flow:**

1. **setItnsSvcKeiUcwk** -- Queries the `KK_T_SVC_KEI_UCWK` table to populate the destination service contract status (`SAKI_SVC_KEI_UCWK_STAT`) for portability scenarios.
2. **printDebugLog** -- Logs the current input message state for debugging.
3. **Initialize outputBean** -- Creates a new `JBSbatOutputItem` container for intermediate tokugi files.
4. **outputTokiStart** -- Generates tokugi intermediate files for tokugi *start* events (determines Start/End/No SOD type based on date checks and service conditions).
5. **outputTokiEnd** -- Generates tokugi intermediate files for tokugi *end* events (determines End SOD type based on past-date checks).
6. **Return** -- Returns the populated `JBSbatOutputItem` containing all intermediate tokugi files.

**Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|-----------------|
| `ITNTOKI_ADD_CD_ITENS` | `"1"` | Destination registration tokugi (portability to new provider) |
| `ITNTOKI_ADD_CD_ITENM` | `"2"` | Origin cancellation tokugi (port-out cancellation) |
| `ITNTOKI_ADD_CD_PAUSE` | `"3"` | Pause tokugi (service suspension) |
| `SVC_KEI_STAT_SVCTKCHU` | `"100"` | Service providing (active service) |
| `SVC_KEI_STAT_PAUSE_STP` | `"210"` | Paused/In-Pause |
| `SVC_KEI_STAT_STP` | `"220"` | Stopped |
| `SVC_KEI_STAT_DSL_ZM` | `"910"` | Contract terminated (cancellation completed) |
| `SVC_KEI_STAT_CNCL_ZM` | `"920"` | Contract cancelled |
| `PAUSE_STP_CD_PAUSECHU_SODHAKZM` | `"01"` | In-Pause (SOD issued) |
| `SVC_DLRE_CD_KSI_SLRE` | `"02"` | Compulsory cancellation (forced termination) |
| `SOD_HAK_SBT_CD_NONE` | `"0"` | No SOD issuance (cancellation) |
| `SOD_HAK_SBT_CD_STA` | `"1"` | Start SOD issuance |
| `SOD_HAK_SBT_CD_END` | `"2"` | End SOD issuance |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input message container carrying service contract data for portability scenarios. Contains fields: `DSL_PAUSE_TOKI_ADD_CD` (tokugi registration type code), `DSL_PAUSE_TOKI_STA_YMD` (pause tokugi start date), `DSL_PAUSE_TOKI_END_RSYMD` (pause tokugi end estimated date), `DSL_PAUSE_TOKI_END_YMD` (pause tokugi end date), `ITENS_OPAF_TOKI_ADD_CD` (destination tokugi registration code), `ITENS_OPAF_TOKI_STA_YMD` (destination tokugi start date), `ITENS_OPAF_TOKI_END_RSYMD` (destination tokugi end estimated date), `ITENS_OPAF_TOKI_END_YMD` (destination tokugi end date), `SVC_KEI_UCWK_STAT` (service contract status), `PAUSE_STP_CD` (pause stop code), `SVC_DLRE_CD` (service cancellation reason code), `SVC_KEI_NO` (service contract number), `SVC_KEI_UCWK_NO` (service contract line item number), plus date/timestamp fields for service generation lineage. |

**Instance Fields Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `trnOpeDate` | `String` | Online operation date -- the current processing date used for past-date comparisons in tokugi end estimated date checks (set from `super.onlineOpeDate` in `initial()`) |
| `db_KK_T_SVC_KEI_UCWK` | `JBSbatSQLAccess` | DB access object for the `KK_T_SVC_KEI_UCWK` (service contract line items) table, initialized in `initial()` |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JBSbatKKRsvTokiHakTgCst.setItnsSvcKeiUcwk` | JBSbatKKRsvTokiHakTgCst | - | Calls `setItnsSvcKeiUcwk` in `JBSbatKKRsvTokiHakTgCst` to populate destination service status |
| - | `JBSbatKKRsvTokiHakTgCst.outputTokiStart` | JBSbatKKRsvTokiHakTgCst | - | Calls `outputTokiStart` in `JBSbatKKRsvTokiHakTgCst` to generate start tokugi files |
| - | `JBSbatKKRsvTokiHakTgCst.outputTokiEnd` | JBSbatKKRsvTokiHakTgCst | - | Calls `outputTokiEnd` in `JBSbatKKRsvTokiHakTgCst` to generate end tokugi files |
| - | `JACBatCommon.printDebugLog` | JACBatCommon | - | Calls `printDebugLog` in `JACBatCommon` for debug logging |

### Full method call analysis:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKRsvTokiHakTgCst.setItnsSvcKeiUcwk` | JBSbatKKRsvTokiHakTgCst | `KK_T_SVC_KEI_UCWK` | Reads destination service contract status by executing `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014` to populate `SAKI_SVC_KEI_UCWK_STAT` |
| R | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014` | JBSbatKKRsvTokiHakTgCst | `KK_T_SVC_KEI_UCWK` | DB access via SQLKEY `KK_SELECT_014` -- queries service contract line items table for status by service contract line item number and operation date |
| C | `JBSbatKKRsvTokiHakTgCst.outputTokiStart` | JBSbatKKRsvTokiHakTgCst | - | Generates intermediate tokugi files for tokugi start events. Internally calls `createRsvTokiHakFile` to emit files with SOD_HAK_SBT_CD (Start/End/None) and ITNTOKI_ADD_CD registration codes |
| C | `JBSbatKKRsvTokiHakTgCst.outputTokiEnd` | JBSbatKKRsvTokiHakTgCst | - | Generates intermediate tokugi files for tokugi end events. Calls `createRsvTokiHakFile` to emit files with SOD_HAK_SBT_CD="2" (End SOD issuance) for past-date conditions |
| C | `JBSbatKKRsvTokiHakTgCst.createRsvTokiHakFile` | JBSbatKKRsvTokiHakTgCst | - | Creates intermediate tokugi output file (JBSbatServiceInterfaceMap) with service contract fields, SOD activation type, and tokugi registration code. Sets `setOutFlg(true)` to mark as output |
| C | `JBSbatOutputItem.addOutMapList` | JBSbatOutputItem | - | Appends intermediate tokugi file map to the output item list |
| C | `JBSbatInterface.trim` | JBSbatInterface | - | Trims whitespace from string values extracted from the input map |
| - | `JKKBatCommon.isPastDate` | JKKBatCommon | - | Date utility -- checks whether an estimated end date has passed the operation date |

**CRUD Classification Rationale:**
- **R** (Read): `setItnsSvcKeiUcwk` performs a DB SELECT on `KK_T_SVC_KEI_UCWK` to read the service contract line item status for the destination portability service.
- **C** (Create): `outputTokiStart`, `outputTokiEnd`, and `createRsvTokiHakFile` all create new intermediate file records (`JBSbatServiceInterfaceMap`) representing provisional tokugi activation events. These are not persisted to DB but are output files for downstream processing.
- **No U/D**: This method does not update or delete any records.

## 5. Dependency Trace

This method is a batch service class (`JBSbatKKRsvTokiHakTgCst`) that extends `JBSbatBusinessService`. It does not appear to be directly called by any other Java class in the codebase -- it is invoked through the batch framework's **dispatcher/routing mechanism**, which maps batch process names (e.g., `JBSbatKKRsvTokiHakTgCst`) to their `execute` methods at runtime via the batch configuration.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch:JBSbatKKRsvTokiHakTgCst | `BatchDispatcher.invoke("JBSbatKKRsvTokiHakTgCst")` -> `JBSbatBusinessService.execute` -> `JBSbatKKRsvTokiHakTgCst.execute` | `executeKK_T_SVC_KEI_UCWK_KK_SELECT_014 [R] KK_T_SVC_KEI_UCWK`, `createRsvTokiHakFile [C] intermediate tokugi file`, `addOutMapList [C] JBSbatOutputItem` |

**Note:** The batch service is invoked by the `JBSbat` framework's common batch dispatcher, which instantiates the service class and calls `execute(inMap)` based on the batch process configuration. No direct Java caller references were found in the codebase -- the dispatch is configured externally via batch process definitions.

## 6. Per-Branch Detail Blocks

**Block 1** -- [SET] `setItnsSvcKeiUcwk(inMap)` (L117)

> Sets the destination service contract status by querying the `KK_T_SVC_KEI_UCWK` table. This populates `SAKI_SVC_KEI_UCWK_STAT` in the input map for downstream tokugi determination logic. Part of resource reduction individual support (OM-2015-0002055). Original comment: "Post-tokugi destination service contract information is set into input information."

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setItnsSvcKeiUcwk(inMap)` // Populates destination service status for portability scenarios |

---

**Block 2** -- [SET] `printDebugLog` (L120)

> Logs the current input message state for debug purposes. Original comment: "Log print."

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printDebugLog(toString(inMap))` // Logs input message state for debugging |

---

**Block 3** -- [SET] Initialize output container (L123-L126)

> Creates the output container and initializes the "origin cancellation tokugi cancelled/ended" flag. Original comment: "Generate output common message" and "Check if origin cancellation tokugi was cancelled or ended."

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatOutputItem outputBean = new JBSbatOutputItem()` // Output message container |
| 2 | SET | `boolean isEndItenmDslToki = false` // Flag: was origin cancellation tokugi cancelled/ended? |

---

**Block 4** -- [CALL] `outputTokiStart` -- Main Tokugi Start Processing (L129)

> Delegates to `outputTokiStart` to generate intermediate tokugi files for start events. This method contains the core conditional logic for three tokugi categories.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isEndItenmDslToki = outputTokiStart(inMap, outputBean)` // Generates start tokugi files; returns flag indicating if origin cancellation tokugi was cancelled |

---

**Block 5** -- [CALL] `outputTokiEnd` -- Tokugi End Processing (L132)

> Delegates to `outputTokiEnd` to generate intermediate tokugi files for end events. Handles cases where tokugi end estimated dates have passed or the destination service has been stopped/terminated. Original comment: "Output file for tokugi end target."

| # | Type | Code |
|---|------|------|
| 1 | CALL | `outputTokiEnd(inMap, outputBean, isEndItenmDslToki)` // Generates end tokugi files based on past-date and status conditions |

---

**Block 6** -- [RETURN] (L135)

> Returns the populated output container with all intermediate tokugi files. Original comment: "Return output common message."

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return outputBean` // Returns the JBSbatOutputItem containing all generated intermediate tokugi files |

---

### Nested Block Analysis -- `outputTokiStart` (L144-L267)

**Block 4.1** -- [SET] Extract input fields (L149-L159)

> Extracts all necessary fields from the input map with trimming. Original comment: "Get necessary items from input message."

| # | Type | Code |
|---|------|------|
| 1 | SET | `dslPauseTokiAddCd = JBSbatInterface.trim(inMap.getString(DSL_PAUSE_TOKI_ADD_CD))` // Tokugi registration type code for pause/cancellation |
| 2 | SET | `dslPauseTokiStaYmd = JBSbatInterface.trim(inMap.getString(DSL_PAUSE_TOKI_STA_YMD))` // Pause tokugi start date |
| 3 | SET | `dslPauseTokiEndRsymd = JBSbatInterface.trim(inMap.getString(DSL_PAUSE_TOKI_END_RSYMD))` // Pause tokugi end estimated date |
| 4 | SET | `dslPauseTokiEndYmd = JBSbatInterface.trim(inMap.getString(DSL_PAUSE_TOKI_END_YMD))` // Pause tokugi end date |
| 5 | SET | `itensOpafTokiAddCd = JBSbatInterface.trim(inMap.getString(ITENS_OPAF_TOKI_ADD_CD))` // Destination tokugi registration code |
| 6 | SET | `itensOpafTokiStaYmd = JBSbatInterface.trim(inMap.getString(ITENS_OPAF_TOKI_STA_YMD))` // Destination tokugi start date |
| 7 | SET | `itensOpafTokiEndRsymd = JBSbatInterface.trim(inMap.getString(ITENS_OPAF_TOKI_END_RSYMD))` // Destination tokugi end estimated date |
| 8 | SET | `itensOpafTokiEndYmd = JBSbatInterface.trim(inMap.getString(ITENS_OPAF_TOKI_END_YMD))` // Destination tokugi end date |
| 9 | SET | `svcKeiUcwkStat = JBSbatInterface.trim(inMap.getString(SVC_KEI_UCWK_STAT))` // Service contract status |
| 10 | SET | `pauseStpCd = JBSbatInterface.trim(inMap.getString(PAUSE_STP_CD))` // Pause stop code |
| 11 | SET | `svcDlreCd = JBSbatInterface.trim(inMap.getString(SVC_DLRE_CD))` // Service cancellation reason code |
| 12 | SET | `sakiSvcKeiUcwkStat = JBSbatInterface.trim(inMap.getString(SAKI_SVC_KEI_UCWK_STAT))` // Destination service contract status |

---

**Block 4.2** -- [IF] `(a) Destination Registration Tokugi` (L169-L224)

> Branch (a): Destination registration tokugi. Conditions:
> - `ITNTOKI_ADD_CD_ITENS = "1"` (Destination registration tokugi)
> - Service status is either "Contract terminated (910)" with non-compulsory cancellation OR "Contract cancelled (920)"
> - Destination tokugi start date is null (not set)
> - Destination tokugi end date is null (not set)
> - Destination service status is "Service providing (100)"
>
> Original comment: "Destination registration tokugi -- Destination registration after opening, service contract status is 'Contract terminated' and not compulsory cancellation, or 'Cancellation completed'; Destination tokugi start/end dates not set; Destination service status is 'Service providing'."

| # | Type | Code |
|---|------|------|
| 1 | IF | `[ITNTOKI_ADD_CD_ITENS="1"] [SVC_KEI_STAT_DSL_ZM="910"] [SVC_DLRE_CD_KSI_SLRE="02"] [SVC_KEI_STAT_CNCL_ZM="920"] [SVC_KEI_STAT_SVCTKCHU="100"]` (L169-L177) |
| 2 | SET | `sodHkSbtCd = getSodHkSbtCd(itensOpafTokiEndRsymd)` // (a-1) Tokugi end estimated date check; if past date returns "0" (none), else returns "1" (start SOD) |

---

**Block 4.2.1** -- [IF] `(a-1) Tokugi End Estimated Date Check` (L179-L180)

> Checks whether tokugi end estimated date indicates "SOD issuance not needed". `getSodHkSbtCd` compares `itensOpafTokiEndRsymd` against `trnOpeDate`. If the end estimated date is past the operation date returns `"0"` (none/cancel). Otherwise returns `"1"` (start SOD issuance).

| # | Type | Code |
|---|------|------|
| 1 | IF | `!SOD_HAK_SBT_CD_NONE.equals(sodHkSbtCd)` // Not "0" (No SOD) -- i.e., tokugi not cancelled/ended (L180) |

---

**Block 4.2.1.1** -- [IF] `(a-2) Origin Cancellation Tokugi Check` (L182-L215)

> Branch (a-2): Origin cancellation tokugi check. Conditions:
> - `ITNTOKI_ADD_CD_ITENM = "2"` (Origin cancellation tokugi)
> - Pause tokugi end date is null (not set)
>
> Original comment: "Origin cancellation tokugi -- Registration code is 'Origin cancellation tokugi', pause tokugi end date not set."

| # | Type | Code |
|---|------|------|
| 1 | IF | `[ITNTOKI_ADD_CD_ITENM="2"] [isNullDate(dslPauseTokiEndYmd)]` (L182-L186) |

---

**Block 4.2.1.1.1** -- [IF] `(a-2-1) Origin Cancellation Tokugi Before Start` (L187-L190)

> Sub-branch (a-2-1): Pause tokugi start date is null (before start). Returns `SOD_HAK_SBT_CD_NONE = "0"` (SOD issuance not needed). Original comment: "SOD issuance type code is 'SOD issuance not'."

| # | Type | Code |
|---|------|------|
| 1 | IF | `isNullDate(dslPauseTokiStaYmd)` // Pause tokugi start date not set (L188-L190) |
| 2 | CALL | `outmapItenmEnd = createRsvTokiHakFile(inMap, SOD_HAK_SBT_CD_NONE, ITNTOKI_ADD_CD_ITENM)` // SOD_HAK_SBT_CD="0" [SOD issuance not] |
| 3 | SET | `isEndItenmDslToki = true` // Mark origin cancellation tokugi as cancelled/ended |

---

**Block 4.2.1.1.2** -- [ELSE] `(a-2-2) Origin Cancellation Tokugi In-Progress` (L191-L195)

> Sub-branch (a-2-2): Pause tokugi start date is set (tokugi in progress). Returns `SOD_HAK_SBT_CD_END = "2"` (End SOD issuance). Original comment: "SOD issuance type code is 'End SOD issuance'."

| # | Type | Code |
|---|------|------|
| 1 | CALL | `outmapItenmEnd = createRsvTokiHakFile(inMap, SOD_HAK_SBT_CD_END, ITNTOKI_ADD_CD_ITENM)` // SOD_HAK_SBT_CD="2" [End SOD issuance] |

---

**Block 4.2.1.1.3** -- [IF] Add origin cancellation to output (L198-L202)

> If an origin cancellation output map was created, append it to the output bean list (before other outputs). Original comment: "Output to intermediate file for provisional tokugi issuance, output before start."

| # | Type | Code |
|---|------|------|
| 1 | IF | `null != outmapItenmEnd` (L198) |
| 2 | EXEC | `outputBean.addOutMapList(outmapItenmEnd)` // Add to output list (precedence over start outputs) |

---

**Block 4.2.1.2** -- Destination Registration Tokugi Start Output (L205-L208)

> Outputs the intermediate file for the destination registration tokugi start. Uses the `sodHkSbtCd` value (determined by `getSodHkSbtCd` date check). Original comment: "Output to intermediate file for destination registration tokugi start."

| # | Type | Code |
|---|------|------|
| 1 | CALL | `outmap = createRsvTokiHakFile(inMap, sodHkSbtCd, ITNTOKI_ADD_CD_ITENS)` // Uses dynamic sodHkSbtCd (see KT1-2013-0000587: SOD start issued even if end date passed) |
| 2 | EXEC | `outputBean.addOutMapList(outmap)` // Append to output list |

---

**Block 4.3** -- [IF] `(!isEndItenmDslToki)` -- Origin Cancellation Tokugi (b) and Pause Tokugi (c) (L209-L260)

> Only processes origin cancellation and pause tokugi if the origin cancellation tokugi was NOT already cancelled/ended (i.e., `isEndItenmDslToki = false`). This prevents duplicate tokugi emissions.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!isEndItenmDslToki` // Origin cancellation tokugi was not cancelled/ended (L209) |

---

**Block 4.3.1** -- [IF] `(b) Origin Cancellation Tokugi` (L215-L231)

> Branch (b): Origin cancellation tokugi. Conditions:
> - `ITNTOKI_ADD_CD_ITENM = "2"` (Origin cancellation tokugi)
> - Service status is "Contract terminated (910)" with non-compulsory cancellation OR "Contract cancelled (920)"
> - Pause tokugi start date is null (not set)
> - Pause tokugi end date is null (not set)
>
> Original comment: "Origin cancellation tokugi -- Registration code is 'Origin cancellation tokugi', service contract status is 'Contract terminated' and not compulsory cancellation or 'Cancellation completed', pause tokugi start/end dates not set."

| # | Type | Code |
|---|------|------|
| 1 | IF | `[ITNTOKI_ADD_CD_ITENM="2"] [SVC_KEI_STAT_DSL_ZM="910"] [SVC_DLRE_CD_KSI_SLRE="02"] [SVC_KEI_STAT_CNCL_ZM="920"] [isNullDate(dslPauseTokiStaYmd)] [isNullDate(dslPauseTokiEndYmd)]` (L215-L223) |
| 2 | CALL | `outmap = createRsvTokiHakFile(inMap, getSodHkSbtCd(dslPauseTokiEndRsymd), ITNTOKI_ADD_CD_ITENM)` // Uses date-based SOD type; SOD_HAK_SBT_CD="2" if past date, else "1" |
| 3 | EXEC | `outputBean.addOutMapList(outmap)` // Append to output list |

---

**Block 4.3.2** -- [IF] `(c) Pause Tokugi` (L233-L259)

> Branch (c): Pause tokugi. Conditions:
> - `ITNTOKI_ADD_CD_PAUSE = "3"` (Pause tokugi)
> - Service status is "In-Pause (210)" with pause stop code `"01"` (In-Pause, SOD issued)
> - Pause tokugi start date is null (not set)
> - Pause tokugi end date is null (not set)
>
> Original comment: "Pause tokugi -- Registration code is 'Pause tokugi', service contract status is 'In-Pause' with pause stop code 'In-Pause (SOD issued)', pause tokugi start/end dates not set."

| # | Type | Code |
|---|------|------|
| 1 | IF | `[ITNTOKI_ADD_CD_PAUSE="3"] [SVC_KEI_STAT_PAUSE_STP="210"] [PAUSE_STP_CD_PAUSECHU_SODHAKZM="01"] [isNullDate(dslPauseTokiStaYmd)] [isNullDate(dslPauseTokiEndYmd)]` (L233-L241) |
| 2 | CALL | `outmap = createRsvTokiHakFile(inMap, getSodHkSbtCd(dslPauseTokiEndRsymd), ITNTOKI_ADD_CD_PAUSE)` // Uses date-based SOD type |
| 3 | EXEC | `outputBean.addOutMapList(outmap)` // Append to output list |

---

**Block 4.4** -- [RETURN] `outputTokiStart` (L267)

> Returns `isEndItenmDslToki` indicating whether the origin cancellation tokugi was cancelled or ended.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return isEndItenmDslToki` // True if origin cancellation tokugi was cancelled/ended |

---

### Nested Block Analysis -- `outputTokiEnd` (L274-L338)

**Block 4.5** -- [SET] Extract input fields (L280-L290)

> Same field extraction as `outputTokiStart`. Original comment: "Get necessary items from input message."

| # | Type | Code |
|---|------|------|
| 1-12 | SET | Extracts same 12 fields from `inMap` (same fields as Block 4.1) |

---

**Block 4.6** -- [IF] `(a) Destination Registration Tokugi End` (L296-L314)

> Branch (a) in `outputTokiEnd`: Destination registration tokugi. Conditions:
> - `ITNTOKI_ADD_CD_ITENS = "1"` (Destination registration tokugi)
> - Destination tokugi start date IS set (not null)
> - Destination tokugi end date is null (not set)
>
> Original comment: "Destination registration tokugi -- Registration code is 'Destination registration tokugi', destination tokugi start date set, destination tokugi end date not set."

| # | Type | Code |
|---|------|------|
| 1 | IF | `[ITNTOKI_ADD_CD_ITENS="1"] [!isNullDate(itensOpafTokiStaYmd)] [isNullDate(itensOpafTokiEndYmd)]` (L296-L300) |
| 2 | IF | `[isPastDate(itensOpafTokiEndRsymd, trnOpeDate, "1")] OR [SVC_KEI_STAT_DSL_ZM="910"] OR [SVC_KEI_STAT_CNCL_ZM="920"]` // (a-1) End date passed OR (a-2) Destination service stopped/cancelled (L302) |
| 3 | CALL | `outmap = createRsvTokiHakFile(inMap, SOD_HAK_SBT_CD_END, ITNTOKI_ADD_CD_ITENS)` // SOD_HAK_SBT_CD="2" [End SOD issuance] |
| 4 | EXEC | `outputBean.addOutMapList(outmap)` |

---

**Block 4.7** -- [IF] `(!isEndItenmDslToki)` -- (b) Origin Cancellation Tokugi End (L317-L330)

> Only processes if origin cancellation tokugi was NOT already cancelled. Conditions:
> - `ITNTOKI_ADD_CD_ITENM = "2"` (Origin cancellation tokugi)
> - Pause tokugi start date IS set
> - Pause tokugi end date is null
> - Pause tokugi end estimated date IS set AND is past the operation date
>
> Original comment: "Origin cancellation tokugi -- Registration code is 'Origin cancellation tokugi', pause tokugi start date set, end date not set, end estimated date passed operation date."

| # | Type | Code |
|---|------|------|
| 1 | IF | `[ITNTOKI_ADD_CD_ITENM="2"] [!isNullDate(dslPauseTokiStaYmd)] [isNullDate(dslPauseTokiEndYmd)] [isPastDate(dslPauseTokiEndRsymd, trnOpeDate, "1")]` (L317-L325) |
| 2 | CALL | `outmap = createRsvTokiHakFile(inMap, SOD_HAK_SBT_CD_END, ITNTOKI_ADD_CD_ITENM)` // SOD_HAK_SBT_CD="2" [End SOD issuance] |
| 3 | EXEC | `outputBean.addOutMapList(outmap)` |

---

**Block 4.8** -- [IF] `(c) Pause Tokugi End` (L332-L360)

> Only processes if origin cancellation tokugi was NOT already cancelled. Conditions:
> - `ITNTOKI_ADD_CD_PAUSE = "3"` (Pause tokugi)
> - Pause tokugi start date IS set
> - Pause tokugi end date is null
> - Either: pause tokugi end estimated date is past operation date OR service status is "Service providing", "In-Pause", "Cancelled", or "Contract terminated"
>
> Original comment: "Pause tokugi -- Registration code is 'Pause tokugi', pause tokugi start date set, end date not set, and either end estimated date passed or service is active/paused/cancelled/terminated."

| # | Type | Code |
|---|------|------|
| 1 | IF | `[ITNTOKI_ADD_CD_PAUSE="3"] [!isNullDate(dslPauseTokiStaYmd)] [isNullDate(dslPauseTokiEndYmd)]` (L332-L337) |
| 2 | IF | `[isPastDate(dslPauseTokiEndRsymd, trnOpeDate, "1")] OR [SVC_KEI_STAT_SVCTKCHU="100"] OR [SVC_KEI_STAT_STP="220"] OR [SVC_KEI_STAT_CNCL_ZM="920"] OR [SVC_KEI_STAT_DSL_ZM="910"]` // (c-1) End date passed OR (c-2) Service stopped/cancelled/terminated (L339) |
| 3 | CALL | `outmap = createRsvTokiHakFile(inMap, SOD_HAK_SBT_CD_END, ITNTOKI_ADD_CD_PAUSE)` // SOD_HAK_SBT_CD="2" [End SOD issuance] |
| 4 | EXEC | `outputBean.addOutMapList(outmap)` |

---

**Block 4.9** -- [RETURN] `outputTokiEnd` (L364)

> No explicit return (void method).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `// void -- method ends` |

---

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `dsl_pause_tokugi_add_cd` | Field | Tokugi registration type code -- classifies the type of tokugi event (destination registration, origin cancellation, pause) |
| `dsl_pause_tokugi_sta_ymd` | Field | Pause tokugi start date (year-month-day) -- when the pause tokugi was or will be activated |
| `dsl_pause_tokugi_end_rsymd` | Field | Pause tokugi end estimated date (year-month-day) -- the estimated date when the pause tokugi will end, used for past-date cutoff checks |
| `dsl_pause_tokugi_end_ymd` | Field | Pause tokugi actual end date (year-month-day) -- the actual date when the pause tokugi ended |
| `itens_opaf_tokugi_add_cd` | Field | Destination tokugi registration code -- classifies destination-side tokugi type in portability scenarios |
| `itens_opaf_tokugi_sta_ymd` | Field | Destination tokugi start date -- when the destination-side tokugi was activated |
| `itens_opaf_tokugi_end_rsymd` | Field | Destination tokugi end estimated date -- estimated end date for destination-side tokugi cutoff checks |
| `itens_opaf_tokugi_end_ymd` | Field | Destination tokugi actual end date -- actual end date for destination-side tokugi |
| `svc_kei_ucwk_stat` | Field | Service contract line item status -- current status of the service contract (e.g., providing, paused, cancelled, terminated) |
| `pause_stp_cd` | Field | Pause stop code -- reason/level for pause status (e.g., "01" = In-Pause, SOD issued) |
| `svc_dlre_cd` | Field | Service cancellation reason code -- reason for service cancellation (e.g., "02" = compulsory/forced cancellation) |
| `saki_svc_kei_ucwk_stat` | Field | Destination service contract line item status -- status of the portability destination service, populated by `setItnsSvcKeiUcwk` |
| `itns_opaf_tokugi_tss_svkuwno` | Field | Inter-portability tokugi transfer destination service contract line item number -- the service contract line item number of the destination service |
| `ITNTOKI_ADD_CD` | Constant | Tokugi registration code -- "1"=Destination registration tokugi, "2"=Origin cancellation tokugi, "3"=Pause tokugi |
| `SOD_HAK_SBT_CD` | Constant | SOD activation type code -- "0"=No SOD, "1"=Start SOD issuance, "2"=End SOD issuance |
| SOD | Acronym | Service Order Data -- telecom service order activation/deactivation data record |
| Tokugi (確定) | Business term | Provisional activation -- the process of scheduling or activating telecom service activation/deactivation events |
| ITENS (移転先) | Business term | Destination (in portability context) -- the new service provider/line receiving a ported service |
| DSL (移転元) | Business term | Origin (in portability context) -- the original service provider/line from which a service is ported out |
| SVC_KEI (サービス契約内容) | Business term | Service contract details -- master entity for service contract line items |
| SVC_KEI_UCWK_NO | Field | Service contract line item number -- unique identifier for a service contract line item |
| SVC_KEI_NO | Field | Service contract number -- unique identifier for a service contract |
| SK_GENE_ADD_DTM | Field | Generation add datetime (service contract) -- timestamp when the service contract was generated |
| SKU_GENE_ADD_DTM | Field | Generation add datetime (service contract line item) -- timestamp when the service contract line item was generated |
| SKUT_GENE_ADD_DTM | Field | Generation add datetime (service contract line item for eo光 phone) -- timestamp for eo光 phone service line items |
| ITNTOKI_ADD_CD_ITENS | Constant | "1" -- Destination registration tokugi -- tokugi registered due to portability destination registration |
| ITNTOKI_ADD_CD_ITENM | Constant | "2" -- Origin cancellation tokugi -- tokugi registered due to porting-out (origin cancellation) |
| ITNTOKI_ADD_CD_PAUSE | Constant | "3" -- Pause tokugi -- tokugi registered due to service suspension |
| SVC_KEI_STAT_SVCTKCHU | Constant | "100" -- Service providing -- active service, currently in operation |
| SVC_KEI_STAT_PAUSE_STP | Constant | "210" -- In-Pause -- service is in paused/suspended state |
| SVC_KEI_STAT_STP | Constant | "220" -- Stopped -- service has been stopped |
| SVC_KEI_STAT_DSL_ZM | Constant | "910" -- Contract terminated -- service contract has been terminated/cancelled |
| SVC_KEI_STAT_CNCL_ZM | Constant | "920" -- Contract cancelled -- service contract has been cancelled |
| PAUSE_STP_CD_PAUSECHU_SODHAKZM | Constant | "01" -- In-Pause with SOD issued -- pause state where service order data has already been issued |
| SVC_DLRE_CD_KSI_SLRE | Constant | "02" -- Compulsory cancellation -- service was cancelled due to forced/compulsory reasons (as opposed to voluntary) |
| trnOpeDate | Field | Transaction operation date -- the current online processing date used for date-based cutoff comparisons (set from batch runtime context) |
| KK_T_SVC_KEI_UCWK | Entity | Service contract line items table -- DB table storing service contract line item records including status, pause codes, and cancellation reasons |
| outputTokiStart | Method | Generates intermediate tokugi files for start events -- determines whether to emit Start SOD, End SOD, or No SOD files based on service status and date conditions |
| outputTokiEnd | Method | Generates intermediate tokugi files for end events -- emits End SOD files when tokugi end estimated dates have passed or destination services are stopped/terminated |
| createRsvTokiHakFile | Method | Creates an intermediate tokugi output file -- transforms input service contract data into an output map with SOD type, tokugi registration code, and timestamps |
| setItnsSvcKeiUcwk | Method | Populates destination service contract status -- queries `KK_T_SVC_KEI_UCWK` to fetch the destination side's service status for portability scenarios |
| executeKK_T_SVC_KEI_UCWK_KK_SELECT_014 | Method | Executes DB access via SQLKEY `KK_SELECT_014` -- queries `KK_T_SVC_KEI_UCWK` by service contract line item number and operation date |
| JBSbatServiceInterfaceMap | Type | Service interface message map -- key-value container for passing structured data between batch methods |
| JBSbatOutputItem | Type | Batch output item -- container holding a list of intermediate output files (`addOutMapList`) |
| JBSbatSQLAccess | Type | Batch SQL access object -- database accessor for executing queries and navigating result sets |
| isPastDate | Method | Date comparison utility -- checks if an estimated date has passed the current operation date (used for tokugi end cutoff logic) |
| isNullDate | Method | Null/empty date check -- returns true if the date string is null, empty, or the default max value |
| setOutFlg | Method | Sets output flag -- marks an intermediate file map as ready for output (`true` = will be output) |
