---

# Business Logic — SCW00301SFLogic.search() [46 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.SCW00301SF.SCW00301SFLogic` |
| Layer | Controller (Web Business Logic) |
| Module | `SCW00301SF` (Package: `eo.web.webview.SCW00301SF`) |

## 1. Role

### SCW00301SFLogic.search()

This method handles the **Search button press processing** for the VLAN-ID dispatch registration screen (電話用VLAN-ID発行依存登録 screen). It is the primary entry point for the user-initiated search of telephone VLAN-Oda (dispatch) records within the K-Opticom customer backbone system (eo顧客基幹システム). The method follows a **gate-query-route** design pattern: first it validates input data integrity via `chkItemValue1()`, then clears and resets the current data bean state, preserves the service contract number for downstream use, delegates the actual database query to the SCSV0004 sub-screen service via a data mapper and `invokeService()`, and finally routes the user based on the search outcome — either displaying an error when zero records are found, or navigating to the next screen (`SCREEN_ID_SCW00301`) when results exist. The method serves as the **screen-specific search controller** in the MVC-like X31 framework, bridging the presentation layer (form bean) with the data access layer (DB mapper and service invocation).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["search()"])
    CHECK_INPUT["chkItemValue1()"]
    CLEAR_DB["clearDatabean()"]
    PRESERVE_SVC_NO["Preserve service contract number: scvKeiNo"]
    SETUP_PARAMS["Setup paramMap with Usecase ID SCSV0004"]
    CREATE_MAPPER["Create SCSV0004_SCSV0004OPDBMapper"]
    MAP_INPUT["mapper.setSCSV000401SC()"]
    INVOKE_SVC["invokeService(paramMap, inputMap, outputMap)"]
    SVC_ERROR{"invokeService returned error?"}
    SET_SVC_MSG["JCCWebCommon.setMessageInfo(msgResult)"]
    RET_TRUE_1(["Return true"])
    GET_OUTPUT["mapper.getSCSV000401SC(paramBean, outputMap)"]
    GET_ERR_FLG["JCCWebCommon.getSearchErrFlg(SCSV000401SC, outputMap)"]
    ZERO_RESULTS{"SEARCH_ERR_FLG_ZERO = \"1\""}
    SET_ZERO_MSG["JCCWebCommon.setMessageInfo(EKB0330)"]
    RET_FALSE_1(["Return false"])
    SET_SCREEN["setNextScreen(SCREEN_ID_SCW00301, SCREEN_NAME_SCW00301)"]
    RET_TRUE_2(["Return true"])
    END_NODE(["End"])

    START --> CHECK_INPUT
    CHECK_INPUT -->|false| RET_FALSE_1
    CHECK_INPUT -->|true| CLEAR_DB
    CLEAR_DB --> PRESERVE_SVC_NO
    PRESERVE_SVC_NO --> SETUP_PARAMS
    SETUP_PARAMS --> CREATE_MAPPER
    CREATE_MAPPER --> MAP_INPUT
    MAP_INPUT --> INVOKE_SVC
    INVOKE_SVC --> SVC_ERROR
    SVC_ERROR -->|msgResult != null| SET_SVC_MSG
    SET_SVC_MSG --> RET_TRUE_1
    SVC_ERROR -->|msgResult == null| GET_OUTPUT
    GET_OUTPUT --> GET_ERR_FLG
    GET_ERR_FLG --> ZERO_RESULTS
    ZERO_RESULTS -->|true| SET_ZERO_MSG
    SET_ZERO_MSG --> RET_FALSE_1
    ZERO_RESULTS -->|false| SET_SCREEN
    SET_SCREEN --> RET_TRUE_2
    RET_FALSE_1 --> END_NODE
    RET_TRUE_1 --> END_NODE
    RET_TRUE_2 --> END_NODE
```

**Processing Flow Summary:**

1. **Input Validation** (L77-80): Calls `chkItemValue1()` to validate input fields. If validation fails, returns `false`.
2. **Data Bean Clear** (L83): Calls `clearDatabean()` to reset the current form state.
3. **Service Contract Number Preservation** (L86-87): Retrieves the service contract number (サービス契約番号) from the form bean and stores it in the preservation field (サービス契約番号保持) for use by subsequent screens.
4. **Service Query Setup** (L90-92): Creates a `HashMap` with usecase ID "SCSV0004", instantiates the `SCSV0004_SCSV0004OPDBMapper`, and maps input data via `setSCSV000401SC()`.
5. **Service Invocation** (L93): Calls `invokeService()` to execute the SCSV0004 sub-screen search service.
6. **Error Handling Branch** (L94-98): If `invokeService` returns a non-null `X31CMessageResult` (indicating a system/service error), sets the error message and returns `true` (success flag for error display).
7. **Output Data Retrieval** (L99): On success, maps the output data from the service response into the form bean via `getSCSV000401SC()`.
8. **Zero-Results Check** (L102-106): Checks if the search found zero records (using `SEARCH_ERR_FLG_ZERO = "1"`). If so, displays the "no results found" message (EKB0330) and returns `false`.
9. **Screen Navigation** (L109-110): On successful search with results, calls `setNextScreen()` to navigate to the VLAN-ID dispatch new registration screen and returns `true`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no explicit parameters. It operates on the screen's form data bean obtained via `super.getServiceFormBean()` and internal instance fields inherited from `JCCWebBusinessLogic`. |

**Internal/External State Read:**

| No | Source | Type | Business Description |
|----|--------|------|---------------------|
| 1 | `super.getServiceFormBean()` | `X31SDataBeanAccess` | The screen's form data bean containing user input fields and display data for the VLAN-ID dispatch registration screen. |
| 2 | `SCW00401SFConst.KEY_SVC_KEI_NO` | `String` (constant = "キーサービス契約番号") | Data bean key for the service contract number field (input). |
| 3 | `SCW00401SFConst.KEY_SVC_KEI_NO_HOJI` | `String` (constant = "キーサービス契約番号保持") | Data bean key for preserving the service contract number across screen transitions. |
| 4 | `X31CWebConst.DATABEAN_GET_VALUE` | `String` (constant) | Data bean operation code for reading a value from the form bean. |
| 5 | `X31CWebConst.DATABEAN_SET_VALUE` | `String` (constant) | Data bean operation code for writing a value to the form bean. |
| 6 | `JPCModelConstant.FUNC_CD_1` | `String` (constant = "1") | Function code "1" — used as the standard function code for search/query operations in the mapper layer. |
| 7 | `JPCModelConstant.SEARCH_ERR_FLG_ZERO` | `String` (constant = "1") | Search error flag value indicating zero records were returned by the query. |
| 8 | `JPCOnlineMessageConstant.EKB0330__I` | `String` (constant) | Informational message code for "no search results found." |
| 9 | `SCREEN_ID_SCW00301` | `String` (constant = "SCW00301") | Screen identifier for the VLAN-ID dispatch new registration screen. |
| 10 | `SCREEN_NAME_SCW00301` | `String` (constant = "VLAN-ID発行依存新規登録") | Screen name label: "VLAN-ID Dispatch New Registration." |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| V | `chkItemValue1` | - | - | Validates input item values on the search form (internal SCW00301SFLogic method). |
| V | `clearDatabean` | - | - | Clears/clears the current data bean state (internal SCW00301SFLogic method). |
| V | `setNextScreen` | - | - | Sets the next screen navigation target (internal SCW00301SFLogic method). |
| R | `SCSV0004_SCSV0004OPDBMapper.setSCSV000401SC` | SCSV0004 | - | Maps form bean search parameters (search type, max search count, display count, display page number, key service contract number) into a HashMap for the sub-screen service. |
| R | `invokeService` (JCCBatCommon.invokeService) | SCSV0004 | - | Invokes the SCSV0004 sub-screen search service, which queries the telephone VLAN-Oda (dispatch) records (電話用VLAN-Oda一覧). The data is backed by entity `ESC0021A010CBS`. |
| R | `SCSV0004_SCSV0004OPDBMapper.getSCSV000401SC` | SCSV0004 | - | Maps the service response back into the form bean — sets total search count, total page count, search error flag, and populates the telephone VLAN-Oda list (電話用VLAN-Oda一覧) with contract number, customer name, customer phone number, telephone VLAN-ID, BAS-host ID, EO telephone flag, SOD work linkage status, service code, service code name, order date, and service status. |
| - | `JCCWebCommon.getSearchErrFlg` | - | - | Extracts the search error flag from the output map for the SCSV000401SC result. |
| - | `JCCWebCommon.setMessageInfo` | - | - | Sets a message (error/info) to be displayed to the user on the screen. |

**How to classify:**

- **V** (Void/Value): Methods called that do not directly perform CRUD on a database but handle validation, UI navigation, or data mapping.
- **R** (Read): The core search operation — the method queries the database for VLAN dispatch records and retrieves them to the form.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:SCW00301SF (search button) | `SCW00301SFController.search()` -> `SCW00301SFLogic.search()` | `invokeService [R] ESC0021A010CBS (電話用VLAN-Oda一覧)` |

**Note:** The `SCW00301SFLogic.search()` method is the business logic handler for the search button action on the SCW00301SF screen. The screen controller delegates the `search()` call directly to this method. The only caller found in the codebase is within the same module (`SCW00301SFLogic` itself does not appear to be called from external controllers in the searchable scope).

**Call Chain Detail:**
- The screen controller receives the search button event from the user.
- It delegates to `SCW00301SFLogic.search()`.
- Inside `search()`, the method invokes `invokeService` with usecase ID "SCSV0004", which routes to the SCSV0004 sub-screen search service.
- The SCSV0004 service queries `ESC0021A010CBS` (the telephone VLAN-Oda data entity) and returns results via the `SCSV0004_SCSV0004OPDBMapper`.

## 6. Per-Branch Detail Blocks

**Block 1** — [VARIABLE DEclaration] (L73-75)

Variable preparation: declares three HashMaps for parameter passing and data mapping.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = new HashMap()` // Maps parameters for invokeService |
| 2 | SET | `inputMap = new HashMap()` // Maps input data for the service mapper |
| 3 | SET | `outputMap = new HashMap()` // Maps output data from the service |

**Block 2** — [VARIABLE Declaration] (L77-78)

Acquires the form bean from the X31 framework and wraps it in an array for the mapper.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bean = super.getServiceFormBean()` // Gets the screen's form data bean |
| 2 | SET | `paramBean = {bean}` // Wraps bean in array for mapper method signature |

**Block 3** — [IF-ELSE] `(chkItemValue1(paramBean[0]) == false)` — Input Validation (L80-83)

> If input validation fails, the method returns `false` immediately without proceeding to the query.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `chkItemValue1(paramBean[0])` // Validates input field values on the search form |
| 2 | RETURN | `return false` // Input validation failed — abort search |

**Block 4** — [EXEC] — Data Bean Clear (L86)

> Clears the current data bean state to ensure stale data from previous searches does not persist.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `clearDatabean()` // Clears data bean to reset form state |

**Block 5** — [EXEC] — Service Contract Number Preservation (L89-90)

> Preserves the service contract number (サービス契約番号) from the input into the preservation field (サービス契約番号保持) so downstream screens (e.g., the next VLAN-ID registration screen) can reference it.

| # | Type | Code |
|---|------|------|
| 1 | SET | `scvKeiNo = bean.sendMessageString(KEY_SVC_KEI_NO, DATABEAN_GET_VALUE)` // Reads the service contract number from the form bean |
| 2 | EXEC | `bean.sendMessageString(KEY_SVC_KEI_NO_HOJI, DATABEAN_SET_VALUE, scvKeiNo)` // Stores the service contract number in the preservation field |

**Block 6** — [EXEC] — Service Query Setup (L93-96)

> Sets up the service invocation parameters and creates the data mapper for the SCSV0004 sub-screen.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put(TELEGRAM_INFO_USECASE_ID, "SCSV0004")` // Sets the usecase ID for the sub-screen |
| 2 | SET | `mapper = new SCSV0004_SCSV0004OPDBMapper()` // Instantiates the data mapper for SCSV0004 |
| 3 | CALL | `mapper.setSCSV000401SC(paramBean, inputMap, FUNC_CD_1)` // Maps form data (search type, max search count, display count, display page, key service contract number) into inputMap |

**Block 7** — [EXEC] — Service Invocation (L97)

> Invokes the SCSV0004 sub-screen search service through the common batch service invocation framework.

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgResult = invokeService(paramMap, inputMap, outputMap)` // Calls the sub-screen search service; returns X31CMessageResult |

**Block 8** — [IF-ELSE] `(msgResult != null)` — Service Error Handling (L98-102)

> If invokeService returns a non-null result, it indicates a service-level error occurred. The error message is displayed and the method returns `true` (signaling the caller that the operation completed with a message to show).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `JCCWebCommon.setMessageInfo(this, msgResult)` // Sets the error/info message for display |
| 2 | RETURN | `return true` // Operation complete with message displayed |

**Block 9** — [EXEC] — Output Data Mapping (L103)

> On successful service return (null message result), maps the output data back to the form bean.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `mapper.getSCSV000401SC(paramBean, outputMap)` // Maps service response: total search count, total page count, search error flag, and the telephone VLAN-Oda list items |

**Block 10** — [IF-ELSE] `(SEARCH_ERR_FLG_ZERO.equals(searchErrFlg))` — Zero Results Check (L106-110)

> Checks if the search returned zero records. The constant `JPCModelConstant.SEARCH_ERR_FLG_ZERO = "1"` means the query matched no rows.

| # | Type | Code |
|---|------|------|
| 1 | SET | `searchErrFlg = JCCWebCommon.getSearchErrFlg("SCSV000401SC", outputMap)` // Extracts search error flag from output |
| 2 | CALL | `JCCWebCommon.setMessageInfo(this, EKB0330__I)` // Displays "no search results found" info message |
| 3 | RETURN | `return false` // Search returned no results |

**Block 11** — [ELSE: Success Navigation] (L113-114)

> When the search returns one or more results and no service errors occurred, navigates to the next screen.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setNextScreen(SCREEN_ID_SCW00301, SCREEN_NAME_SCW00301)` // Sets next screen to "VLAN-ID発行依存新規登録" (VLAN-ID Dispatch New Registration) |
| 2 | RETURN | `return true` // Search succeeded, navigating to next screen |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service contract number — the unique identifier for a customer's service contract line item. Used as the primary search key. |
| `scv_kei_no` | Field | Abbreviated form of service contract number, used as the data bean key for the service contract number input field. |
| `KEY_SVC_KEI_NO_HOJI` | Field | Service contract number preservation field — a hidden form field that carries the service contract number across screen transitions. |
| `search_err_flg` | Field | Search error flag — a status code returned by the service indicating the result of the search query. "1" means zero records found. |
| `ESC0021A010CBS` | Entity | Telephone VLAN-Oda (dispatch) entity — the database entity that stores records of telephone VLAN dispatch orders, including contract number, customer name, customer phone, VLAN-ID, BAS-host ID, EO telephone flag, SOD linkage status, service code, and service status. |
| SCSV0004 | Sub-screen | Sub-screen module for searching telephone VLAN-Oda dispatch records. Invoked via the data mapper and service invocation framework. |
| `EKB0330__I` | Message Code | Informational message code displayed when a search query returns zero results. |
| `FUNC_CD_1` | Constant | Function code "1" — the standard function code used for search/query operations in the mapper layer. |
| `SCREEN_ID_SCW00301` | Constant | Screen ID "SCW00301" — the identifier for the VLAN-ID dispatch new registration screen. |
| `SCREEN_NAME_SCW00301` | Constant | Screen name "VLAN-ID発行依存新規登録" — the display label for the VLAN-ID dispatch new registration screen. |
| VLAN-ID | Business term | Virtual LAN Identifier — used in this system for telephone service network segmentation. This module manages the registration of VLAN-ID dispatch requests. |
| Oda (dispatch) | Business term | Dispatch / work order — in this telecom system, refers to the work order or dispatch record for provisioning a telephone VLAN. |
| SOD | Acronym | Service Order Data — the business linkage status field indicating whether the order has been synchronized with external service order systems. |
| BAS | Acronym | Broadband Access Server — network equipment that aggregates broadband connections. The BAS-host ID identifies the specific BAS associated with a VLAN dispatch record. |
| EO | Business term | K-Opticom's brand/service prefix — used in fields like `eo_tel_flg` (EO telephone flag) to indicate whether the line is an EO (K-Opticom) telephone service. |
| X31SDataBeanAccess | Framework class | The X31 framework's form data bean access class used for reading/writing screen field values via a key-based sendMessageString interface. |
| `chkItemValue1` | Method | Input validation method — validates the fields entered on the search form before proceeding with the query. |
| `clearDatabean` | Method | Data bean clearing method — resets all form bean fields to their default/empty state. |
| `setNextScreen` | Method | Screen navigation method — configures the next screen to transition to after the current operation completes successfully. |
| `invokeService` | Framework method | Common service invocation method — dispatches to the specified usecase (SCSV0004) for remote/local service execution. |

---
