# Business Logic — JBSbatKKCustDelTrgtCst.execute() [33 LOC]

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

## 1. Role

### JBSbatKKCustDelTrgtCst.execute()

This method is the **Customer Deletion Target Extraction** service within the K-Opticom eo Customer Base System (`eo顧客基幹システム`). Its sole responsibility is to produce output records that identify which customer data should be marked for deletion (aging update processing). It acts as a **pre-validation / extraction point** — populating deletion request output maps with all the fields required by downstream deletion-target-check components.

The method always produces at least one deletion target record identified by **eoID** (`DEL_TRGT_SBT=11`), which is the primary customer identifier in the system. When a secondary nickname (`NKNAME`) is present in the input message, a **second** deletion target record is produced using the nick name as the identifying key (`DEL_TRGT_SBT=12`). Both records share the same deletion processing type (`DEL_TRAN_SBT="2"`, meaning "aging update" — 削除処理種類（エイジング更新）), indicating that the deletion target is tracked via aging (time-based accumulation) rather than immediate removal.

The method implements the **delegation / data-prefilling pattern**: it does not perform any database CRUD operations or service component calls itself. Instead, it constructs `JBSbatServiceInterfaceMap` output records that are collected into a `JBSbatOutputItem`, which downstream batch consumers will route to appropriate service components (SCs) for actual deletion-target validation and processing. This makes the class a **shared batch utility** used by customer deletion workflows across the system.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute(inMap)"])
    COND1{NKNAME not null?}
    OUT1["Create outmap
Set DEL_TRAN_SBT=2
Set DEL_TRGT_SBT=11(eoID)
Set SYSID from inMap
Set EOID from inMap
Set outFlg=true
Add to outputBean"]
    OUT2["Create outmap
Set DEL_TRAN_SBT=2
Set DEL_TRGT_SBT=12(nick name)
Set SYSID from inMap
Set NKNAME from inMap
Set outFlg=true
Add to outputBean"]
    END(["Return outputBean"])

    START --> OUT1
    OUT1 --> COND1
    COND1 -->|true| OUT2
    COND1 -->|false| END
    OUT2 --> END
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input message carrying customer identification data. Must contain `SYSID` and `EOID` from the customer table (`CK_T_CUST`). Optionally contains `NKNAME` (nick name) — when present, triggers production of a secondary deletion target record keyed by nick name instead of eoID. |

**Instance / External State Read:**

| Source | Description |
|--------|-------------|
| `JBSbatKKIFM160.DEL_TRAN_SBT` | Constant key for deletion processing type field in the output map |
| `JBSbatKKIFM160.DEL_TRGT_SBT` | Constant key for deletion target type field in the output map |
| `JBSbatKKIFM160.SYSID` | Constant key for System ID field |
| `JBSbatKKIFM160.EOID` | Constant key for eoID field |
| `JBSbatKKIFM160.NKNAME` | Constant key for nick name field |
| `JBSbatCK_T_CUST.SYSID` | Constant key for SYSID from customer table |
| `JBSbatCK_T_CUST.EOID` | Constant key for EOID from customer table |
| `JBSbatCK_T_CUST.NKNAME` | Constant key for NKNAME from customer table |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JBSbatServiceInterfaceMap.set(String, String)` | - | - | Sets deletion processing type (aging update) on output map |
| U | `JBSbatServiceInterfaceMap.set(String, String)` | - | - | Sets deletion target type (eoID or nick name) on output map |
| U | `JBSbatServiceInterfaceMap.set(String, String)` | - | - | Sets SYSID on output map from input message |
| U | `JBSbatServiceInterfaceMap.set(String, String)` | - | - | Sets EOID on output map from input message |
| U | `JBSbatServiceInterfaceMap.set(String, String)` | - | - | Sets NKNAME on output map from input message (branch 2) |
| U | `JBSbatServiceInterfaceMap.setOutFlg(boolean)` | - | - | Flags output map as successfully processed |
| C | `JBSbatOutputItem.addOutMapList(JBSbatServiceInterfaceMap)` | - | - | Appends constructed output record to the output item collection |

**Note:** This method performs **no database reads, creates, or deletes**. It is a pure data-assembly step that transforms input identifiers into structured deletion-target output records for downstream consumers.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKCustDelTrgtCst | `JBSbatKKCustDelTrgtCst.execute(inMap)` | `setOutFlg [U] -` , `addOutMapList [C] -` |

**Caller Analysis:** The `search_files` scan found no external callers outside the class itself in the immediate codebase. This method is designed as a **batch service entry point** — it is invoked by the K-Opticom batch execution framework, which resolves service classes by convention and calls `execute()` with pre-built input maps derived from customer records identified for deletion.

## 6. Per-Branch Detail Blocks

### Block 1 — [SET / EXEC] Initialization (L71–82)

> Creates the primary deletion target output record keyed by eoID. Always executed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outmap = new JBSbatServiceInterfaceMap();` // Create output record |
| 2 | SET | `outputBean = new JBSbatOutputItem();` // Create output information container |
| 3 | CALL | `outmap.set(DEL_TRAN_SBT, "2");` // Set deletion processing type — aging update [-> DEL_TRAN_SBT_AGING_UPD="2"] |
| 4 | CALL | `outmap.set(DEL_TRGT_SBT, "11");` // Set deletion target type — eoID [-> DEL_TRGT_SBT_EOID="11"] |
| 5 | CALL | `outmap.set(SYSID, inMap.get(CUST.SYSID));` // Transfer SYSID from input |
| 6 | CALL | `outmap.set(EOID, inMap.get(CUST.EOID));` // Transfer EOID from input |
| 7 | EXEC | `outmap.setOutFlg(true);` // Flag output map as ready |
| 8 | CALL | `outputBean.addOutMapList(outmap);` // Append output record to result |

### Block 2 — [IF] Nick Name Branch (L84–97)

> When `inMap.get("NKNAME")` is not null, creates a **secondary** deletion target record keyed by nick name instead of eoID. This allows the same customer to be identified and deleted by their nick name. [NKNAME check] (L84)

| # | Type | Code |
|---|------|------|
| 1 | SET | `outmap = new JBSbatServiceInterfaceMap();` // Re-create output record [IT1-2013-0000285 2013/02/17] |
| 2 | CALL | `outmap.set(DEL_TRAN_SBT, "2");` // Same processing type — aging update [-> DEL_TRAN_SBT_AGING_UPD="2"] |
| 3 | CALL | `outmap.set(DEL_TRGT_SBT, "12");` // Set deletion target type — nick name [-> DEL_TRGT_SBT_NKNAME="12"] |
| 4 | CALL | `outmap.set(SYSID, inMap.get(CUST.SYSID));` // Transfer SYSID from input |
| 5 | CALL | `outmap.set(NKNAME, inMap.get(CUST.NKNAME));` // Transfer NKNAME from input |
| 6 | EXEC | `outmap.setOutFlg(true);` // Flag output map as ready |
| 7 | CALL | `outputBean.addOutMapList(outmap);` // Append secondary output record to result |

**Block 2.1** — [ELSE] Implicit no-op (L84)

> When `NKNAME` is null or absent, this branch does nothing — only the eoID-record from Block 1 is returned.

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `CK_T_CUST` | Table | Customer master table — holds all customer profile data including identifiers, addresses, contact info |
| `SYSID` | Field | System ID — internal system identifier for customer records in the CK_T_CUST table |
| `EOID` | Field | eo ID — primary customer identifier in the K-Opticom eo (fibre optic) customer base system |
| `NKNAME` | Field | Nick name — secondary customer alias, allowing customers to be identified by an alternate name in addition to their primary eoID |
| `DEL_TRAN_SBT` | Field | Deletion processing type — classifies what kind of deletion action to perform |
| `DEL_TRGT_SBT` | Field | Deletion target type — classifies what identifier field identifies the deletion target (eoID, nick name, phone number, etc.) |
| `outFlg` | Field | Output flag — indicates whether the output map has been successfully populated and is ready for downstream consumption |
| 2 | Constant Value | Aging update — a delayed/deferred deletion approach where the target is flagged and processed via aging (time-based accumulation) rather than immediate removal |
| 11 | Constant Value | eoID — identifies the deletion target by the customer's primary eoID identifier |
| 12 | Constant Value | Nick name — identifies the deletion target by the customer's secondary nick name |
| K-Opticom | Business term | Japanese telecommunications provider offering FTTH (fibre-to-the-home) and internet services |
| eo | Business term | K-Opticom's consumer broadband brand (fibre optic service) |
|エイジング更新 | Japanese term | Aging update — a batch processing pattern where records flagged for deletion are accumulated over time and processed in a scheduled batch run, rather than deleted immediately |
| JBSbatServiceInterfaceMap | Technical | Batch service interface map — a key-value container used to pass structured data between batch service components |
| JBSbatOutputItem | Technical | Batch output item — a collection container holding multiple output maps produced by a service, aggregating results for downstream batch consumers |
| IT1-2013-0000285 | Change ticket | Change request that added nick name (NKNAME) deletion target support on 2013/02/17 |
