# Business Logic — JBSBatKKKkOpDlRvChsht.getHontaiDslFlg() [51 LOC]

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

## 1. Role

### JBSBatKKKkOpDlRvChsht.getHontaiDslFlg()

This method determines whether a **main (hontai) DSL cancellation flag** needs to be set during the batch processing of device option service contract termination data (iki op service kaisyo joho). It is a private utility method called from `execute()` which assembles the CSV output for device option service cancellation information. The method evaluates whether the customer's service contract device is eligible for DSL cancellation by inspecting the service detail status (KKTK_SVC_KEI_STAT), the presence of reserved move numbers (IDO_RSV_NO) for network (net) and telephone (denwa) options, and the option contract statuses (KKOP_SVC_KEI_STAT) for both option 1 and option 2. If any of the eligible conditions are met — both network and telephone options need cancellation, only the network option needs cancellation, or only the telephone option needs cancellation — the flag is set to `"1"` (FLG_ON); otherwise it returns an empty string, indicating no main DSL cancellation is required.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getHontaiDslFlg inMap"])

    START --> INIT["flg = empty string"]

    INIT --> GETSTAT["getCsv KKTK_SVC_KEI_STAT inMap"]

    GETSTAT --> COND1{Service detail status NOT
100 AND 210 AND 220
KKTK_SVC_KEI_STAT != 100
and != 210 and != 220}

    COND1 -->|true - No eligible device| EARLY_RET["Return flg empty
No cancellation target"]

    COND1 -->|false - Eligible device| CHECKOPT["Check option statuses"]

    CHECKOPT --> COND2{Option1 NOT empty OR STAT1 in 910 920
AND
Option2 NOT empty OR STAT2 in 910 920}

    COND2 -->|true - Both network and tel options| SETON1["flg = 1
Network op cancellation target
and Tel op cancellation target"]

    COND2 -->|false| COND3{IDO_RSV_NO_1 NOT empty
AND KKOP_SVC_KEI_NO_2 empty}

    COND3 -->|true - Network only| SETON2["flg = 1
Network op cancellation only"]

    COND3 -->|false| COND4{IDO_RSV_NO_2 NOT empty
AND KKOP_SVC_KEI_NO_1 empty}

    COND4 -->|true - Tel only| SETON3["flg = 1
Tel op cancellation only"]

    COND4 -->|false - None matched| FINAL_RET["Return flg empty
No cancellation needed"]

    SETON1 --> FINAL_RET
    SETON2 --> FINAL_RET
    SETON3 --> FINAL_RET
```

**Block Descriptions:**

1. **Initialization (L215):** The method initializes the return flag `flg` to an empty string `""` (BLANK).

2. **Service Detail Status Check (L220-225):** Retrieves the service detail status (`KKTK_SVC_KEI_STAT`) from `inMap`. If the status is NOT 100, 210, or 220, the device is not an eligible cancellation target — the method returns an empty string immediately. The Japanese comment states: "In the case where the device for cancellation target does not exist" (解約対象のステータスの機器がない場合).

3. **Option Status Check — Both Network and Telephone (L228-241):** Checks if either option 1 has a non-empty reserved move number (`IDO_RSV_NO_1`) OR its status is 910 (cancellation target) / 920 (cancellation completed), AND the same condition holds for option 2. If true, the flag is set to `"1"`. The Japanese comment states: "When both network and telephone options are cancellation targets or already cancelled" (ネットオプションが解約対象か解約済みかつ電話オプションが解約対象か解約済みの場合).

4. **Network-Only Check (L242-246):** If option 1's reserved move number is non-empty AND option 2's service contract number (`KKOP_SVC_KEI_NO_2`) is empty, this indicates only the network option exists on a multifunc router. Flag set to `"1"`. Japanese comment: "When the only option on the multifunc router is network, and the network option is being cancelled" (多機能ルータに紐つくオプションがネットのみかつネットオプションの解約の場合).

5. **Telephone-Only Check (L247-251):** If option 2's reserved move number is non-empty AND option 1's service contract number (`KKOP_SVC_KEI_NO_1`) is empty, this indicates only the telephone option exists. Flag set to `"1"`. Japanese comment: "When the only option on the multifunc router is telephone, and the telephone option is being cancelled" (多機能ルータに紐つくオプションが電話のみかつ電話オプションの解約の場合).

6. **Final Return (L253):** Returns the flag — `"1"` if any cancellation condition matched, or empty string otherwise.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input parameter map carrying device option service contract cancellation data. Contains keys for service detail status (`KKTK_SVC_KEI_STAT`), reserved move numbers for network and telephone options (`IDO_RSV_NO_1`, `IDO_RSV_NO_2`), option contract statuses (`KKOP_SVC_KEI_STAT_1`, `KKOP_SVC_KEI_STAT_2`), and option contract numbers (`KKOP_SVC_KEI_NO_1`, `KKOP_SVC_KEI_NO_2`). This map is populated by prior batch processing steps and feeds into the CSV output assembled by the `execute()` method. |

**Referenced constants (IFM field keys):**

| Constant | Value | Business Meaning |
|----------|-------|------------------|
| `JBSbatKKIFM553.KKTK_SVC_KEI_STAT` | `"KKTK_SVC_KEI_STAT"` | Device provider service contract status — the service detail status of the cancellation target device |
| `JBSbatKKIFM553.IDO_RSV_NO_1` | `"IDO_RSV_NO_1"` | Reserved move number 1 — tracks network option relocation reservation |
| `JBSbatKKIFM553.IDO_RSV_NO_2` | `"IDO_RSV_NO_2"` | Reserved move number 2 — tracks telephone option relocation reservation |
| `JBSbatKKIFM553.KKOP_SVC_KEI_STAT_1` | `"KKOP_SVC_KEI_STAT_1"` | Device option contract status 1 — status of option 1 (typically network) |
| `JBSbatKKIFM553.KKOP_SVC_KEI_STAT_2` | `"KKOP_SVC_KEI_STAT_2"` | Device option contract status 2 — status of option 2 (typically telephone) |
| `JBSbatKKIFM553.KKOP_SVC_KEI_NO_1` | `"KKOP_SVC_KEI_NO_1"` | Device op service contract number 1 |
| `JBSbatKKIFM553.KKOP_SVC_KEI_NO_2` | `"KKOP_SVC_KEI_NO_2"` | Device op service contract number 2 |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `getCsv` | — | — | Reads values from `inMap` by field key. This is a map lookup operation (get) on the input parameter — retrieves service detail status, reserved move numbers, and option contract statuses/numbers from the input map. No direct DB access; `inMap` is already populated by prior batch processing. |

**Note:** The method calls `getCsv()` (inherited from `JBSbatBusinessService`) multiple times to read values from the input parameter map. This is an in-memory map retrieval, not a database operation. The data source is the batch processing pipeline's intermediate data structure.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `getCsv` [R], `getCsv` [R], `getCsv` [R], `getCsv` [R], `getCsv` [R], `getCsv` [R], `getCsv` [R], `getCsv` [R], `getCsv` [R], `getCsv` [R], `getCsv` [R], `getCsv` [R], `getCsv` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSBatKKKkOpDlRvChsht.execute() | `JBSBatKKKkOpDlRvChsht.execute` -> `getHontaiDslFlg(inMap)` | `getCsv [R] inMap (service contract data)` |

## 6. Per-Branch Detail Blocks

**Block 1** — INIT (L215)

> Initializes the return flag to an empty string.

| # | Type | Code |
|---|------|------|
| 1 | SET | `flg = ""` // Initialize DSL cancellation flag to empty (no cancellation) |

**Block 2** — IF (early-return condition) `(KKTK_SVC_KEI_STAT NOT in [100, 210, 220])` (L220-225)

> Checks if the device's service detail status is not among the eligible statuses (100, 210, 220). If the device is not of an eligible type, return immediately with no cancellation flag. The Japanese comment states: "No eligible device for cancellation" (解約対象のステータスの機器がない場合). This corresponds to a v22.00.00 code change from `KK0341_STAT_*` to `JBSbatKKConst.CD00056_KKTK_SVC_KEI_STAT_*` constants.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `getCsv(JBSbatKKIFM553.KKTK_SVC_KEI_STAT, inMap)` // Get service detail status |
| 2 | COND | `result != JBSbatKKConst.CD00056_KKTK_SVC_KEI_STAT_100` // `!= "100"` (NTT) |
| 3 | AND | `&& result != JBSbatKKConst.CD00056_KKTK_SVC_KEI_STAT_210` // `!= "210"` (Hikari) |
| 4 | AND | `&& result != JBSbatKKConst.CD00056_KKTK_SVC_KEI_STAT_220` // `!= "220"` (Hikari RT) |
| 5 | RETURN | `return flg` // Return empty — no cancellation target device |

**Block 3** — IF (both options need cancellation) `(IDO_RSV_NO_1 OR STAT_1 in [910,920]) AND (IDO_RSV_NO_2 OR STAT_2 in [910,920])` (L228-241)

> Checks if both option 1 and option 2 have a reserved move number (indicating relocation cancellation) OR their contract status is 910 (cancellation target) or 920 (cancellation completed). If both are true, this means both network and telephone options are cancellation targets or already cancelled. The Japanese comment states: "When both network and telephone options are cancellation targets or already cancelled" (ネットオプションが解約対象か解約済みかつ電話オプションが解約対象か解約済みの場合). This block was also updated in v22.00.00 to use `JBSbatKKConst.CD00056_KKTK_SVC_KEI_STAT_*` constants instead of `KK2811_STAT_*`.

| # | Type | Code |
|---|------|------|
| 1 | COND | `!BLANK.equals(getCsv(IDO_RSV_NO_1, inMap))` // `!= ""` — network option has move reservation |
| 2 | OR | `|| JBSbatKKConst.CD00056_KKTK_SVC_KEI_STAT_910.equals(getCsv(KKOP_SVC_KEI_STAT_1, inMap))` // `== "910"` — option 1 is cancellation target |
| 3 | OR | `|| JBSbatKKConst.CD00056_KKTK_SVC_KEI_STAT_920.equals(getCsv(KKOP_SVC_KEI_STAT_1, inMap))` // `== "920"` — option 1 is cancellation completed |
| 4 | AND | `&&` |
| 5 | COND | `!BLANK.equals(getCsv(IDO_RSV_NO_2, inMap))` // `!= ""` — telephone option has move reservation |
| 6 | OR | `|| JBSbatKKConst.CD00056_KKTK_SVC_KEI_STAT_910.equals(getCsv(KKOP_SVC_KEI_STAT_2, inMap))` // `== "910"` — option 2 is cancellation target |
| 7 | OR | `|| JBSbatKKConst.CD00056_KKTK_SVC_KEI_STAT_920.equals(getCsv(KKOP_SVC_KEI_STAT_2, inMap))` // `== "920"` — option 2 is cancellation completed |
| 8 | SET | `flg = FLG_ON` // `= "1"` — set cancellation flag |

**Block 4** — ELSE IF (network option only) (L242-246)

> Checks if option 1 has a reserved move number AND option 2's contract number is empty. This indicates a multifunc router where only the network option exists and is being cancelled. The Japanese comment states: "When the only option on the multifunc router is network, and the network option is being cancelled" (多機能ルータに紐つくオプションがネットのみかつネットオプションの解約の場合).

| # | Type | Code |
|---|------|------|
| 1 | COND | `!BLANK.equals(getCsv(IDO_RSV_NO_1, inMap))` // `!= ""` — option 1 has move reservation |
| 2 | AND | `&&` |
| 3 | COND | `BLANK.equals(getCsv(KKOP_SVC_KEI_NO_2, inMap))` // `== ""` — option 2 contract number is empty (no option 2) |
| 4 | SET | `flg = FLG_ON` // `= "1"` — set cancellation flag |

**Block 5** — ELSE IF (telephone option only) (L247-251)

> Checks if option 2 has a reserved move number AND option 1's contract number is empty. This indicates a multifunc router where only the telephone option exists and is being cancelled. The Japanese comment states: "When the only option on the multifunc router is telephone, and the telephone option is being cancelled" (多機能ルータに紐つくオプションが電話のみかつ電話オプションの解約の場合).

| # | Type | Code |
|---|------|------|
| 1 | COND | `!BLANK.equals(getCsv(IDO_RSV_NO_2, inMap))` // `!= ""` — option 2 has move reservation |
| 2 | AND | `&&` |
| 3 | COND | `BLANK.equals(getCsv(KKOP_SVC_KEI_NO_1, inMap))` // `== ""` — option 1 contract number is empty (no option 1) |
| 4 | SET | `flg = FLG_ON` // `= "1"` — set cancellation flag |

**Block 6** — RETURN (L253)

> Returns the computed flag. If any cancellation condition matched above, returns `"1"`; otherwise returns `""`.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return flg` // Return DSL cancellation flag |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `HONTAI_DSL_FLG` | Field | Main DSL cancellation flag — indicates whether the primary DSL service contract needs cancellation processing. `"1"` means cancellation required; empty means no cancellation needed. |
| `KKTK_SVC_KEI_STAT` | Field | Device provider service contract status — the service detail status code for the device type. Values `100` (NTT), `210` (Hikari), `220` (Hikari RT) indicate eligible device types for DSL cancellation processing. |
| `IDO_RSV_NO` | Field | Reserved move number — tracks relocation/move reservations for service options. Non-empty value indicates the option is being relocated (cancellation in progress). |
| `KKOP_SVC_KEI_STAT` | Field | Device option contract status — the current status of an option contract. Values `910` (cancellation target) and `920` (cancellation completed) indicate the option is or was a cancellation candidate. |
| `KKOP_SVC_KEI_NO` | Field | Device option service contract number — identifies an option contract. Empty value indicates the option does not exist. |
| `CD00056_KKTK_SVC_KEI_STAT_100` | Constant | Service detail status code `"100"` — NTT type device |
| `CD00056_KKTK_SVC_KEI_STAT_210` | Constant | Service detail status code `"210"` — Hikari type device |
| `CD00056_KKTK_SVC_KEI_STAT_220` | Constant | Service detail status code `"220"` — Hikari RT type device |
| `CD00056_KKTK_SVC_KEI_STAT_910` | Constant | Option contract status code `"910"` — cancellation target |
| `CD00056_KKTK_SVC_KEI_STAT_920` | Constant | Option contract status code `"920"` — cancellation completed |
| `FLG_ON` | Constant | Flag value `"1"` — indicates true/on state for cancellation flags |
| `BLANK` | Constant | Empty string `""` — represents null or empty field value |
| v22.00.00 | Version | v22.00.00 code change — migrated from local constant names (KK0341_STAT_*, KK2811_STAT_*) to centralized constants (CD00056_KKTK_SVC_KEI_STAT_*) |
| iki op | Abbreviation | Iki (move/relocation) option — service option relocation during customer address change |
| kaisyo joho | Term | Cancellation information — data about service contract terminations |
| multifunc router | Term | Multifunc router (多機能ルータ) — an integrated router providing both network and telephone (VoIP) services |
| net option | Abbreviation | Network option — the broadband/internet service option on a multifunc router |
| tel option | Abbreviation | Telephone option — the VoIP/phone service option on a multifunc router |
