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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.SCW00401SF.SCW00401SFLogic` |
| Layer | Controller / Web Logic (Package: `eo.web.webview.SCW00401SF`) |
| Module | `SCW00401SF` (VLAN-ID Registration — 電話用VLAN-ID登録) |

## 1. Role

### SCW00401SFLogic.search()

This method implements the **search button press handling** for the VLAN-ID new registration screen (VLAN-ID新規登録画面). It is the central entry point for searching service contracts (サービス契約番号) associated with a customer, which is a prerequisite step before registering a new telephone VLAN-ID. The method delegates to the SC code `SCSV0004` (`SCSV0004_SCSV0004OPDBMapper.getSCSV000401SC`) which is the search service component responsible for querying service contract data from the backend.

The method implements a **delegation pattern**: it handles screen-level concerns (input validation, bean management, message display, and screen navigation) while delegating the actual data search to the service layer. It also preserves the service contract number across the search operation via the data bean, ensuring the user's selection persists through the search-and-select interaction cycle.

The method processes two distinct scenarios: (1) when the search returns no results — it displays an error message `EKB0330--I` and prevents navigation forward; (2) when results are found — it navigates to the next screen (`SCW00401`, VLAN-ID New Registration Screen). If the downstream service itself returns an error, it displays that error and allows the user to correct the input.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["search() Entry"])
    SEARCH_INIT(["Initialize paramMap, inputMap, outputMap"])
    GET_BEAN(["Get service form bean"])
    WRAP_BEAN(["Wrap bean in paramBean array"])
    CHECK_INPUT["chkItemValue1(paramBean)"]
    INPUT_INVALID{Input Check<br/>Failed?}
    INPUT_RET_TRUE["Return false"]
    CLEAR_BEAN(["clearDatabean()"])
    PRESERVE_SVC_NO["Preserve scvKeiNo from bean"]
    SET_SCREEN_ID["Set USE_CASE_ID to SCSV0004"]
    CREATE_MAPPER(["Create SCSV0004_SCSV0004OPDBMapper"])
    SET_SC(["mapper.setSCSV000401SC(paramBean, inputMap, FUNC_CD_1)"])
    INVOKE_SVC["invokeService(paramMap, inputMap, outputMap)"]
    HAS_ERROR{msgResult != null?}
    SET_MSG_INFO(["JCCWebCommon.setMessageInfo(this, msgResult)"])
    ERROR_RET["Return true"]
    GET_RESULT(["mapper.getSCSV000401SC(paramBean, outputMap)"])
    GET_ERR_FLG(["JCCWebCommon.getSearchErrFlg(SCSV000401SC, outputMap)"])
    ZERO_RESULTS{searchErrFlg == SEARCH_ERR_FLG_ZERO?}
    SHOW_ZERO_MSG(["JCCWebCommon.setMessageInfo(EKB0330__I)"])
    ZERO_RET["Return false"]
    SET_NEXT_SCREEN(["setNextScreen(SCW00401, VLAN-ID New Registration)"])
    SUCCESS_RET["Return true"]

    START --> SEARCH_INIT --> GET_BEAN --> WRAP_BEAN --> CHECK_INPUT
    CHECK_INPUT --> INPUT_INVALID
    INPUT_INVALID -- true --> INPUT_RET_TRUE
    INPUT_INVALID -- false --> CLEAR_BEAN --> PRESERVE_SVC_NO --> SET_SCREEN_ID --> CREATE_MAPPER --> SET_SC --> INVOKE_SVC --> HAS_ERROR
    HAS_ERROR -- true --> SET_MSG_INFO --> ERROR_RET
    HAS_ERROR -- false --> GET_RESULT --> GET_ERR_FLG --> ZERO_RESULTS
    ZERO_RESULTS -- true --> SHOW_ZERO_MSG --> ZERO_RET
    ZERO_RESULTS -- false --> SET_NEXT_SCREEN --> SUCCESS_RET
```

**Constant Resolutions:**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `JPCModelConstant.FUNC_CD_1` | `"1"` | Function code "1" — indicates search operation mode |
| `JPCModelConstant.SEARCH_ERR_FLG_ZERO` | `"1"` | Search error flag = "1" means zero results found |
| `JPCOnlineMessageConstant.EKB0330__I` | `"EKB0330--I"` | Informational message key — "Search returned 0 results" |
| `JSCScreenConst.SCREEN_ID_SCW00401` | `"SCW00401"` | Target screen ID for navigation |
| `JSCScreenConst.SCREEN_NAME_SCW00401` | `"VLAN-ID新規登録画面"` | "VLAN-ID New Registration Screen" |
| `X31CWebConst.DATABEAN_GET_VALUE` | constant key | Read value from data bean |
| `X31CWebConst.DATABEAN_SET_VALUE` | constant key | Write value to data bean |
| `SCW00401SFConst.KEY_SVC_KEI_NO` | `"キーサービス契約番号"` | Key service contract number (search input field) |
| `SCW00401SFConst.KEY_SVC_KEI_NO_HOJI` | `"キーサービス契約番号保持"` | Key service contract number preservation field |
| `X31CWebConst.TELEGRAM_INFO_USECASE_ID` | constant key | Use case ID for service invocation context |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no external parameters. All input data is read from the page's form bean (Service Form Bean) which is obtained via `super.getServiceFormBean()`. |

**Instance fields / external state read:**

| Source | Description |
|--------|-------------|
| `super.getServiceFormBean()` | Returns `X31SDataBeanAccess` — the page's form bean containing user-entered search criteria (e.g., service contract number, customer filter fields) |
| `this` (logic instance) | Used for message context in `JCCWebCommon.setMessageInfo(this, ...)` |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| CALL | `chkItemValue1` | SCW00401SF | - | Validates input values entered on the search screen (e.g., format checks, mandatory field checks) |
| CALL | `clearDatabean` | SCW00401SF | - | Clears all data bean fields to prepare for fresh search results |
| CALL | `JCCWebCommon.setMessageInfo` | JCCWebCommon | - | Sets an informational/error message to be displayed on the screen |
| CALL | `SCSV0004_SCSV0004OPDBMapper.setSCSV000401SC` | SCSV0004 | - | Maps input parameters from the data bean into the input map for the SC code |
| R | `JCCBatCommon.invokeService` | SCSV0004 | SCSV000401SC | Invokes the search service `SCSV0004` (service contract search) — queries service contract data |
| R | `SCSV0004_SCSV0004OPDBMapper.getSCSV000401SC` | SCSV0004 | - | Retrieves search results from the output map into the data bean for display |
| R | `JCCWebCommon.getSearchErrFlg` | JCCWebCommon | - | Checks whether the search returned zero results, too many results, or normal results |
| CALL | `setNextScreen` | SCW00401SF | - | Sets the target screen for navigation after successful search (SCW00401 — VLAN-ID New Registration Screen) |

**Note:** The actual SC code invoked is `SCSV0004` (a search service component for service contracts). The SC code `SCSV000401SC` is the specific operation within that SC. The database tables accessed by `SCSV0004` are part of the service contract entity layer (the exact table names are internal to the `SCSV0004` SC component and are not referenced directly in this view layer).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:SCW00401 | `SCW00401SFLogic.search` | `invokeService [R] SCSV000401SC (service contract search)` |

**Explanation:** The `search()` method is the search button handler for the **SCW00401** screen (VLAN-ID New Registration Screen). It is invoked directly by the screen's view layer when the user presses the search button. The method does not have deep call chains from other screens — it is the screen's own controller entry point. The terminal effect of this method is the invocation of `SCSV0004` which searches service contract data.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] (L73)

Initialize local maps used for parameter passing and data exchange with the service layer.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = new HashMap()` // Service invocation parameter map |
| 2 | SET | `inputMap = new HashMap()` // Input data map for SC code |
| 3 | SET | `outputMap = new HashMap()` // Output data map from SC code |

**Block 2** — [SET] (L78)

Obtain the page's form bean from the parent class and wrap it in an array for passing to the SC code mapper methods.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bean = super.getServiceFormBean()` // Gets X31SDataBeanAccess from session |
| 2 | SET | `paramBean = {bean}` // Array wrapper for SC code mapper signature |

**Block 3** — [IF] `(chkItemValue1(paramBean[0]) == false)` [L83]

Input value validation. Calls `chkItemValue1` to validate user-entered search criteria (e.g., checking required fields, value formats).

> Japanese comment: 入力値チェック — "Input value check"

| # | Type | Code |
|---|------|------|
| 1 | CALL | `chkItemValue1(paramBean[0])` // Validates input values on the search screen |
| 2 | IF_FALSE | Branch when input validation fails — returns false to prevent further processing |
| 3 | RETURN | `false` // Input is invalid; stays on the same screen |

**Block 4** — [EXEC] (L88)

Clears all data bean fields to ensure stale search results are removed before a fresh search.

> Japanese comment: データビューニングクリア — "Data browsing clear"

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `clearDatabean()` // Clears all data bean fields for fresh search |

**Block 5** — [SET] (L90)

Preserves the key service contract number from the previous screen interaction. This ensures the user's previously entered or selected service contract number persists across the search operation.

> Japanese comment: 入力されたサービス契約番号を保持 — "Preserve entered service contract number"

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

**Block 6** — [SET] (L93)

Sets the use case ID to identify this service invocation as the SCSV0004 search operation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put(TELEGRAM_INFO_USECASE_ID, "SCSV0004")` // Identifies the service to invoke |

**Block 7** — [SET + EXEC] (L94–97)

Creates the database mapper and calls the SC code's setter to populate the input map with parameters from the data bean.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapper = new SCSV0004_SCSV0004OPDBMapper()` // Creates the SC mapping object |
| 2 | EXEC | `mapper.setSCSV000401SC(paramBean, inputMap, JPCModelConstant.FUNC_CD_1)` // Sets FUNC_CD_1 = "1" for search mode; maps input data |

**Block 8** — [EXEC] (L98)

Invokes the service layer. This is the core business operation that queries the database for service contract data.

> Japanese comment: サービス呼び出し(検索処理) — "Service call (search processing)"

| # | Type | Code |
|---|------|------|
| 1 | CALL | `invokeService(paramMap, inputMap, outputMap)` // Calls SCSV0004 SC code; returns X31CMessageResult |

**Block 9** — [IF] `(msgResult != null)` (L99)

Checks if the service invocation returned an error. If so, display the error message and return (the search did not complete successfully, but the user should see the error, not a blank page).

| # | Type | Code |
|---|------|------|
| 1 | IF_TRUE | Branch when msgResult is NOT null (error occurred during service invocation) |
| 2 | EXEC | `JCCWebCommon.setMessageInfo(this, msgResult)` // Displays the service-level error message |
| 3 | RETURN | `true` // Returns true because the error was handled and displayed to the user |

**Block 10** — [EXEC] (L103)

Retrieves search results from the output map into the data bean. This populates the screen with the service contract search results for the user to review.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `mapper.getSCSV000401SC(paramBean, outputMap)` // Retrieves SC code results into the data bean |

**Block 11** — [SET] (L105)

Checks the search result count by reading the error flag from the output map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `searchErrFlg = JCCWebCommon.getSearchErrFlg("SCSV000401SC", outputMap)` // Gets count indicator |

**Block 12** — [IF] `(JPCModelConstant.SEARCH_ERR_FLG_ZERO.equals(searchErrFlg))` (L106)

Checks whether the search returned zero results. If so, displays an informational message and prevents navigation.

> Constant: `SEARCH_ERR_FLG_ZERO = "1"` — Indicates zero records found

> Japanese comment: 検索結果が0件の場合の処理 — "Processing when search results are 0 records"

| # | Type | Code |
|---|------|------|
| 1 | IF_TRUE | Branch when search returned 0 results (searchErrFlg == "1") |
| 2 | EXEC | `JCCWebCommon.setMessageInfo(this, JPCOnlineMessageConstant.EKB0330__I)` // Shows "no results" message |
| 3 | RETURN | `false` // Prevents navigation; stays on search screen |

**Block 13** — [SET + RETURN] (L113–114)

Sets the target screen for navigation and returns true, indicating successful search. This navigates the user to the VLAN-ID new registration screen.

> Japanese comment: 自画面へ遷移 — "Navigate to self screen"

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `setNextScreen(SCREEN_ID_SCW00401, SCREEN_NAME_SCW00401)` // Navigates to "VLAN-ID新規登録画面" |
| 2 | RETURN | `true` // Search succeeded; navigation proceeds |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|-----------------|
| `svc_kei_ucwk_no` | Field | Service detail work number — internal tracking ID for service contract line items |
| KEY_SVC_KEI_NO | Constant | Key service contract number — the primary search criterion; the service contract number the user enters or selects |
| KEY_SVC_KEI_NO_HOJI | Constant | Key service contract number preservation — internal data bean field that retains the service contract number across the search operation |
| SCSV0004 | SC Code | Service Component for service contract search — queries service contract data from the backend |
| SCSV000401SC | SC Code | Specific search operation within the SCSV0004 service component |
| SCW00401 | Screen ID | VLAN-ID new registration screen — the target screen for registering a telephone VLAN-ID |
| VLAN-ID | Business term | Virtual Local Area Network Identifier — a network identifier assigned to a telephone line in K-Opticom's fiber service infrastructure |
| FUNC_CD_1 | Constant | Function code "1" — indicates search/read operation mode in the service framework |
| SEARCH_ERR_FLG_ZERO | Constant | Search error flag "1" — indicates zero records were found in the search result set |
| EKB0330--I | Constant | Informational message key — "The search returned 0 results. Please modify your search criteria." |
| DATABEAN_GET_VALUE | Constant | Data bean access key constant for reading a value from the session data bean |
| DATABEAN_SET_VALUE | Constant | Data bean access key constant for writing a value to the session data bean |
| TELEGRAM_INFO_USECASE_ID | Constant | Use case ID key — identifies the business use case context for service invocation |
| X31SDataBeanAccess | Class | X31S framework data bean access class — holds user-entered data and search results in the web session |
| JCCBatCommon.invokeService | Method | Common service invocation method — routes the call to the appropriate SC code based on USE_CASE_ID |
| X31CMessageResult | Class | Message result object returned by service invocation; contains error information if the service call failed |
| 入力値チェック | Japanese | Input value check — validation of user-entered data on the search screen |
| データビューニングクリア | Japanese | Data browsing clear — clearing data bean fields to remove stale results before a fresh search |
| サービス呼び出し | Japanese | Service call — invocation of backend service components (SC codes) |
| 検索結果が0件の場合の処理 | Japanese | Processing when search results are 0 records — handles the no-results scenario gracefully |
| 自画面へ遷移 | Japanese | Navigate to self screen — forwards to the target screen after successful processing |
