# Business Logic — JBSbatTUBmpHaishiSodHakTrn.SingleCheckTUIFM012_INF1() [45 LOC]

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

## 1. Role

### JBSbatTUBmpHaishiSodHakTrn.SingleCheckTUIFM012_INF1()

This method performs single-item (field-level) validation for the **Banpo Cancellation (OPT Reception) SOD Target File** processing — i.e., it validates individual data items in batch records that represent customers who have submitted an opt-out request for bundled telecom services (the "banpo" process). The method is called by the batch `execute()` method after input records are read from the TXT source or database, serving as the first quality gate before further business processing or DB persistence. It implements a sequential validation-dispatch pattern: each field is validated in turn against mandatory and format rules, with immediate failure (error log write + exception throw) on the first violation, ensuring that no invalid record propagates downstream. It is a private, batch-scoped utility method — not called by any screen — and functions as a shared validation helper within the SOD issuance subsystem for telecom service termination orders.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["SingleCheckTUIFM012_INF1(rsMap, itemvalueMap)"])
    START --> INIT["Set strValue = null"]
    INIT --> STEP1["Step 1: Discontinuation Division"]
    STEP1 --> GET_DIV["strValue = rsMap.get(IDO_KUBUN)"]
    GET_DIV --> DIV_NULL{strValue == null<br>or empty?}
    DIV_NULL -->|Yes| ERR_DIV_MISSING["Log error ETUB0360TW<br>Throw JBSbatBusinessError"]
    DIV_NULL -->|No| DIV_VALUE{strValue equals 09001?}
    DIV_VALUE -->|No| ERR_DIV_VALUE["Log error ETUB0520AE<br>Throw JBSbatBusinessError"]
    DIV_VALUE -->|Yes| STEP2["Step 2: Phone Number"]
    STEP2 --> GET_TEL["strValue = rsMap.get(NTT_KEI_TEL_KAISEN_NO)"]
    GET_TEL --> TEL_NULL{strValue == null<br>or empty?}
    TEL_NULL -->|Yes| ERR_TEL_MISSING["Log error ETUB0360TW<br>Throw JBSbatBusinessError"]
    TEL_NULL -->|No| TEL_FORMAT{JBSbatCheckUtil.invoke<br>tel2 validation passed?}
    TEL_FORMAT -->|No| ERR_TEL_FORMAT["Log error ETUB0420TW<br>Throw JBSbatBusinessError"]
    TEL_FORMAT -->|Yes| END_NODE(["Method returns normally"])
    ERR_DIV_MISSING --> END_NODE
    ERR_DIV_VALUE --> END_NODE
    ERR_TEL_MISSING --> END_NODE
    ERR_TEL_FORMAT --> END_NODE
```

**Step descriptions:**

1. **Initialization** — declares a local `strValue` variable for field extraction.
2. **Step 1: Discontinuation Division (廃止区分)** — extracts `IDO_KUBUN` from `rsMap`. Validates it is not null/empty (mandatory check), then validates it equals the constant `IDO_KNUB = "09001"` (fixed-value check). Any failure logs a business error and throws `JBSbatBusinessError`, halting processing.
3. **Step 2: Phone Number (電話番号)** — extracts `NTT_KEI_TEL_KAISEN_NO` from `rsMap`. Validates it is not null/empty (mandatory check), then validates the format using `JBSbatCheckUtil.invoke(strValue, new String[]{"tel2"})` — the `tel2` format rule checks whether the string conforms to a valid Japanese telephone number format. Any failure logs a business error and throws `JBSbatBusinessError`.
4. If all checks pass, the method returns normally and the batch flow continues to subsequent processing.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `rsMap` | `HashMap<?, ?>` | Input data container holding field-value pairs extracted from the TXT source file or database query result. Each key corresponds to a business field name (e.g., `IDO_KUBUN`, `NTT_KEI_TEL_KAISEN_NO`) and the value is the raw string data from the current record being validated. This map represents one record from the Banpo Cancellation (OPT Reception) SOD target file. |
| 2 | `itemvalueMap` | `HashMap<?, ?>` | HashMap storing error message template values used for localized error logging. Currently passed as `null` from the caller (`execute()`), but the method signature supports it for future message customization. |

**Instance fields / external state read by this method:**

| No | Field Name | Type | Business Description |
|----|-----------|------|---------------------|
| 1 | `commonItem` | `JBSbatCommonItem` | Framework-provided common item accessor (inherited from `JBSbatBusinessService`). Used to retrieve the input record count (`getInputCount()`) for error logging context, and to access the log printer (`getLogPrint()`) for writing business error logs. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKBatOneTimeLogWriter.printBusinessErrorLog` | - | - | Writes a business error log entry to the one-time log (error logging, not a DB read/write). Error code `ETUB0360TW` or `ETUB0520AE` or `ETUB0420TW` depending on the validation failure. |

**Notes:**
- This method performs **no database reads, creates, updates, or deletes**. It is purely a validation layer that inspects in-memory data.
- The only external interaction is through error log writing via `JKKBatOneTimeLogWriter.printBusinessErrorLog`, which records the error code, input record count, and field name to the batch processing log.
- The validation relies on `JBSbatCheckUtil.invoke()` which is an in-memory utility for format validation (no DB access).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatTUBmpHaishiSodHakTrn | `JBSbatTUBmpHaishiSodHakTrn.execute()` -> `SingleCheckTUIFM012_INF1` | `printBusinessErrorLog` [log] — writes error log entries to batch processing log |

**Call chain detail:**
- `JBSbatTUBmpHaishiSodHakTrn.execute()` is the batch entry point. It reads input records (from TXT or DB) into a map and invokes `SingleCheckTUIFM012_INF1(inMap.getMap(), null)` at line 149 to validate each record's fields before proceeding to DB access operations.
- No screen (KKSV*) or external CBS entry points call this method directly. It is exclusively used within batch processing.

## 6. Per-Branch Detail Blocks

**Block 1** — [VARIABLE_DECLARATION] `(local variable)` (L378)

> Initializes the local string variable used for field value extraction during validation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String strValue = null;` // Local variable for extracting and checking field values |

---

**Block 2** — [IF-ELSEIF-CHAIN: Step 1: Discontinuation Division (廃止区分)] (L381)

> Validates the discontinuation division field (`IDO_KUBUN`). This field indicates the type of discontinuation reason code for the SOD record. Two sub-checks are performed: mandatory check, then fixed-value check.

| # | Type | Code |
|---|------|------|
| 1 | SET | `strValue = (String)rsMap.get("IDO_KUBUN");` // Extract discontinuation division value from input map |

**Block 2.1** — [IF] `(strValue == null || "".equals(strValue)) [Mandatory Check for Discontinuation Division]` (L383)

> Checks whether the discontinuation division field is missing or blank. If so, logs error `ETUB0360TW` (mandatory field missing) and aborts.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printBusinessErrorLog("ETUB0360TW", new String[]{String.valueOf(super.commonItem.getInputCount()), "廃止区分(Discontinuation Division)"})` // Logs error with record count and field name |
| 2 | CALL | `throw new JBSbatBusinessError();` // Terminates processing — validation failed |

**Block 2.2** — [IF] `(!IDO_KNUB.equals(strValue)) [Fixed-Value Check: IDO_KNUB = "09001"]` (L391)

> Validates that the discontinuation division equals the constant `IDO_KNUB = "09001"`. This fixed value represents the specific discontinuation type expected for OPT reception SOD records. Any other value is rejected as invalid.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printBusinessErrorLog("ETUB0520AE", new String[]{String.valueOf(super.commonItem.getInputCount()), "廃止区分(Discontinuation Division)"})` // Logs error with record count and field name — ETUB0520AE = fixed value mismatch |
| 2 | CALL | `throw new JBSbatBusinessError();` // Terminates processing — validation failed |

---

**Block 3** — [IF-ELSEIF-CHAIN: Step 2: Phone Number (電話番号)] (L399)

> Validates the NTT line phone number field (`NTT_KEI_TEL_KAISEN_NO`). The phone number identifies the customer's telephone line associated with the service cancellation request. Two sub-checks: mandatory check, then format check.

| # | Type | Code |
|---|------|------|
| 1 | SET | `strValue = (String)rsMap.get("NTT_KEI_TEL_KAISEN_NO");` // Extract phone number value from input map |

**Block 3.1** — [IF] `(strValue == null || "".equals(strValue)) [Mandatory Check for Phone Number]` (L402)

> Checks whether the phone number field is missing or blank. If so, logs error `ETUB0360TW` (mandatory field missing) and aborts.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printBusinessErrorLog("ETUB0360TW", new String[]{String.valueOf(super.commonItem.getInputCount()), "電話番号(Phone Number)"})` // Logs error with record count and field name |
| 2 | CALL | `throw new JBSbatBusinessError();` // Terminates processing — validation failed |

**Block 3.2** — [IF] `(!JBSbatCheckUtil.invoke(strValue, new String[]{"tel2"})) [Format Check: tel2 rule]` (L408)

> Validates the phone number format using the `tel2` format rule from `JBSbatCheckUtil`. The `tel2` rule checks whether the string conforms to a valid Japanese telephone number format (e.g., digit pattern, length, separator characters). If the format is invalid, logs error `ETUB0420TW` (format validation failure) and aborts.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printBusinessErrorLog("ETUB0420TW", new String[]{String.valueOf(super.commonItem.getInputCount()), "電話番号(Phone Number)"})` // Logs error with record count and field name — ETUB0420TW = format validation failure |
| 2 | CALL | `throw new JBSbatBusinessError();` // Terminates processing — validation failed |

---

**Block 4** — [RETURN] `(implicit)` (L416)

> All validations passed. Method returns normally. The batch flow continues to subsequent processing (e.g., DB access via `TU_SELECT_002` SQL key, data transformation, or output writing).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | (implicit return — void method, all checks passed) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `IDO_KUBUN` | Field | Discontinuation Division — the classification code for the type of service discontinuation reason in the SOD target file. |
| `NTT_KEI_TEL_KAISEN_NO` | Field | NTT Line Tel Kai-sen No — the customer's telephone number on the NTT (Nippon Telegraph and Telephone) line associated with the service being cancelled. |
| `IDO_KNUB` | Constant | Discontinuation Division (Dammy Value) — the fixed dummy code `"09001"` used as the expected valid value for the discontinuation division field in OPT reception SOD records. |
| BANPO (番ポ廃止) | Business term | Service Line Cancellation — the domain concept for terminating a customer's bundled telecom service line (fiber, phone, etc.). |
| OPT 受付 (Opt 受付) | Business term | Opt-in/Opt-out Reception — the process of accepting customer consent withdrawal (opt-out) requests for bundled service promotions. |
| SOD | Acronym | Service Order Data — the telecom order fulfillment entity representing a service order record for a customer's subscription, change, or cancellation. |
| JBSbatBusinessError | Framework Class | Custom business exception thrown to abort batch processing when a validation or business rule violation is detected. |
| `ETUB0360TW` | Error Code | Mandatory field missing — error code used when a required field is null or empty. |
| `ETUB0520AE` | Error Code | Fixed value mismatch — error code used when a field does not match the expected constant value. |
| `ETUB0420TW` | Error Code | Format validation failure — error code used when a field fails format validation (e.g., invalid phone number format). |
| `tel2` | Format Rule | Telephone number format validation rule — checks that a string conforms to a valid Japanese telephone number pattern (digits, separators, length). |
| `JBSbatCheckUtil.invoke()` | Utility | Input validation utility method — performs format checks on string values using predefined rules like `tel2`. |
| `commonItem` | Instance Field | Framework common item accessor inherited from `JBSbatBusinessService` — provides access to input metadata (record count) and logging facilities. |
| `printBusinessErrorLog()` | Method | Error logging method — writes structured business error entries to the batch processing log with error code, record count, and field context. |
| `JBSbatBusinessService` | Framework Class | Base class for batch business services — provides framework-level methods and common item access to batch processing classes. |
| `rsMap` | Parameter | Record data map — HashMap containing field-value pairs for a single input record from the TXT source or DB query. |
| `itemvalueMap` | Parameter | Item value map — HashMap containing error message template values; currently unused (passed as `null`). |
