# Business Logic — JKKWribSvcKeiOperateCC.resolveContentsForSearch() [270 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKWribSvcKeiOperateCC` |
| Layer | CC / Common Component (Shared business logic helper class) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKWribSvcKeiOperateCC.resolveContentsForSearch()

This method implements the **search-to-registration candidate display** feature for the Fujitsu Futurity telecom billing and service ordering platform. It is called by `JKKWribSvcKeiOperateCC.execute()` (screen KKSV0237) to populate a search result list of **discount service contracts** (割引サービス = discount services) and **data extraction items** (データ抽出項目 = data extraction items) that a given customer (identified by SYSID) is eligible to register.

Specifically, it performs two parallel search-and-filter passes over eligible candidates:

- **Discount Services (割引サービス):** Retrieves discount service candidates (wribSvcCds) that match the customer's search conditions (campaign date range, receipt start/end date range, discount type, application conditions), then verifies whether each discount service is applicable to the customer's existing service contracts. For each eligible match, it builds a target record containing the discount service details and its associated service contract line items.

- **Data Extraction Items (データ抽出項目):** Retrieves data extraction item candidates (dchskmCds) that match the same search conditions, then applies the same eligibility verification against the customer's service contracts. Each eligible match produces a target record with item type code "d" (HNSOKU = deduction/extraction).

The method implements a **routing/dispatch pattern** — it separates the logic into two structurally identical passes (one for discount services, one for data extraction items), each with the same workflow: retrieve candidates → resolve service targets → check eligibility against customer's contracts → build target records → collect child detail records.

Its role in the larger system is as a **screen data preparation method** (indicated by the "CC" suffix in the class name and the KKSV0237 prefix in the data key). It acts as an intermediary between the search criteria entered on the screen and the registration confirmation screen, pre-computing which discount services and data extraction items the customer can register and how they map to the customer's existing service contracts.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["resolveContentsForSearch param"])
    START --> EXTRACT["Extract search conditions from param KKSV023701CC"]
    EXTRACT --> EXTRACT_MS["Extract: searchMskmKisanYmd searchCampaignCd searchUkStaymdJi searchUkStaymdIta searchUkEndymdJi searchUkEndymdIta searchWribTypeCd searchWribAplyOptntyCd searchSysid"]
    EXTRACT_MS --> GET_SVC_LIST["Call generateSvcKeiToSvcKeisWithAddJokenCd searchSysid"]
    GET_SVC_LIST --> GET_WRIB_SVCS["Call resolveWribSvcCds search conditions"]
    GET_WRIB_SVCS --> GET_DCH_SKM["Call resolveDchskmCds search conditions"]
    GET_DCH_SKM --> INIT_LISTS["Initialize targetList and targetChildList"]
    INIT_LISTS --> GET_CD_NM["Call retTekiyoYmdCdNm cdNmList"]
    GET_CD_NM --> GET_CD_RTR["Call retTakinoRtrChgUmuNm cdRtrChgUmuNmList"]
    GET_CD_RTR --> LOOP_WRIB["For each wribSvcCd in wribSvcCds"]
    LOOP_WRIB --> RESOLVE_WRIB["Call resolveWribSvc wribSvcCd"]
    RESOLVE_WRIB --> EXTRACT_WRIB_ATTR["Extract campaignCd campaignCdNm typeCd typeCdNm addJokenCd aplyJokenCd"]
    EXTRACT_WRIB_ATTR --> GET_WRIB_TRGT["Call resolveWribSvcTrgtSvcs wribSvcCd"]
    GET_WRIB_TRGT --> CHECK_WRIB_TRGT_NULL{wribSvcTrgtSvcs == null?}
    CHECK_WRIB_TRGT_NULL -->|Yes| SKIP_WRIB["Skip wribSvcCd continue"]
    CHECK_WRIB_TRGT_NULL -->|No| CHECK_WRIB_COLLECT["Call isCollectWribSvcTrgtSvcsToSvcKeisWithWribAddJokenCd"]
    CHECK_WRIB_COLLECT --> CHECK_WRIB_RESULT{isCollect == true?}
    CHECK_WRIB_RESULT -->|No| LOOP_NEXT_WRIB["Next wribSvcCd"]
    CHECK_WRIB_RESULT -->|Yes| GET_TARGET_SVC["Call uniqueSvcKeiNo with addJokenCd wribSvcTrgtSvcs aplyJokenCd"]
    GET_TARGET_SVC --> LOOP_SVC["For each svcKeiNo in targetSvcKeiNos"]
    LOOP_SVC --> GET_SVC_KEY["svcKeiNoToSvcKeisWithAddJokenCd.get svcKeiNo"]
    GET_SVC_KEY --> GET_SVC_ARR["svcKeisWithAddJokenCd.get addJokenCd"]
    GET_SVC_ARR --> CHECK_INNER["Call isCollectTrgtSvcsByAplyJokenCd wribSvcTrgtSvcs svcKeis aplyJokenCd"]
    CHECK_INNER --> CHECK_INNER_RESULT{isCollectInner == true?}
    CHECK_INNER_RESULT -->|No| LOOP_NEXT_SVC["Next svcKeiNo"]
    CHECK_INNER_RESULT -->|Yes| BUILD_TARGET["Build target HashMap"]
    BUILD_TARGET --> SET_WRIB_ATTR["Set: add_choice false sysid kei_kind w(wrib) svc_cd campaign_cd campaign_cd_nm type_cd type_cd_nm svc_kei_no aply_jun 0"]
    SET_WRIB_ATTR --> CHECK_DISP["Call retDispJkn1 searchSysid typeCd target wribSvcCd svcKeiNo"]
    CHECK_DISP --> SET_DISP["Set disp_jkn_1 dispJkn disp_jkn_2 false tekiyo_ymd 1 tekiyo_ymd_nm_1 tekiyo_ymd_nm_2"]
    SET_DISP --> SET_RTR["Call setRtrChgUmuRadio svcKeiNo wribSvcCd searchSysid target"]
    SET_RTR --> CHECK_WRSTA["Call isWrStaCset wribSvcCd"]
    CHECK_WRSTA --> SET_WRSTA["Set disp_riyo_sta_ymd true if isWrStaCset else false"]
    SET_WRSTA --> ADD_TARGET["Add target to targetList"]
    ADD_TARGET --> GEN_WRIB_TRGT["Call generateWribSvcTrgtKeisFromSearch countNoValue wribSvcTrgtSvcs svcKeis"]
    GEN_WRIB_TRGT --> ADD_CHILD["Add resolvedWribSvcTrgtKeis to targetChildList"]
    ADD_CHILD --> INC_COUNT["Increment countNoValue"]
    INC_COUNT --> LOOP_NEXT_SVC["Next svcKeiNo"]
    LOOP_NEXT_SVC --> LOOP_NEXT_WRIB["Next wribSvcCd"]
    SKIP_WRIB --> LOOP_NEXT_WRIB
    CHECK_INNER_RESULT -->|No| LOOP_NEXT_SVC
    LOOP_NEXT_WRIB --> CHECK_LOOP_WRIB_END{Loop wribSvcCds?}
    CHECK_LOOP_WRIB_END -->|Yes| LOOP_WRIB
    CHECK_LOOP_WRIB_END -->|No| LOOP_DCH["For each dchskmCd in dchskmCds"]
    LOOP_DCH --> RESOLVE_DCH["Call resolveDchskm dchskmCd"]
    RESOLVE_DCH --> EXTRACT_DCH_ATTR["Extract campaignCd campaignCdNm typeCd typeCdNm addJokenCd aplyJokenCd"]
    EXTRACT_DCH_ATTR --> GET_DCH_TRGT["Call resolveDchskmTrgtSvcs dchskmCd"]
    GET_DCH_TRGT --> CHECK_DCH_TRGT{dchskmTrgtSvcs == null?}
    CHECK_DCH_TRGT -->|Yes| SKIP_DCH["Skip dchskmCd continue"]
    CHECK_DCH_TRGT -->|No| CHECK_DCH_COLLECT["Call isCollectDchkmTrgtSvcsToSvcKeisWithAddJokenCd"]
    CHECK_DCH_COLLECT --> CHECK_DCH_RESULT{isCollect == true?}
    CHECK_DCH_RESULT -->|No| LOOP_NEXT_DCH["Next dchskmCd"]
    CHECK_DCH_RESULT -->|Yes| GET_DCH_TARGET["Call uniqueSvcKeiNo with addJokenCd dchskmTrgtSvcs aplyJokenCd"]
    GET_DCH_TARGET --> LOOP_DCH_SVC["For each svcKeiNo in targetSvcKeiNos"]
    LOOP_DCH_SVC --> GET_DCH_SVC_KEY["svcKeiNoToSvcKeisWithAddJokenCd.get svcKeiNo"]
    GET_DCH_SVC_KEY --> GET_DCH_SVC_ARR["svcKeisWithAddJokenCd.get addJokenCd"]
    GET_DCH_SVC_ARR --> CHECK_DCH_INNER["Call isCollectTrgtSvcsByAplyJokenCd dchskmTrgtSvcs svcKeis aplyJokenCd"]
    CHECK_DCH_INNER --> CHECK_DCH_INNER_RESULT{isCollectInner == true?}
    CHECK_DCH_INNER_RESULT -->|No| LOOP_NEXT_DCH_SVC["Next svcKeiNo"]
    CHECK_DCH_INNER_RESULT -->|Yes| BUILD_DCH_TARGET["Build target HashMap"]
    BUILD_DCH_TARGET --> SET_DCH_ATTR["Set: add_choice false sysid kei_kind d(hnsoku) svc_cd campaign_cd campaign_cd_nm type_cd type_cd_nm svc_kei_no aply_jun 0"]
    SET_DCH_ATTR --> ADD_DCH_TARGET["Add target to targetList"]
    ADD_DCH_TARGET --> GEN_DCH_TRGT["Call generateDchskmTrgtKeisFromSearch countNoValue dchskmTrgtSvcs svcKeis"]
    GEN_DCH_TRGT --> ADD_DCH_CHILD["Add resolvedDchskmTrgtKeis to targetChildList"]
    ADD_DCH_CHILD --> INC_DCH_COUNT["Increment countNoValue"]
    INC_DCH_COUNT --> LOOP_NEXT_DCH_SVC["Next svcKeiNo"]
    LOOP_NEXT_DCH_SVC --> LOOP_NEXT_DCH["Next dchskmCd"]
    SKIP_DCH --> LOOP_NEXT_DCH
    CHECK_DCH_INNER_RESULT -->|No| LOOP_NEXT_DCH_SVC
    LOOP_NEXT_DCH --> CHECK_LOOP_DCH_END{Loop dchskmCds?}
    CHECK_LOOP_DCH_END -->|Yes| LOOP_DCH
    CHECK_LOOP_DCH_END -->|No| WRITE_RESULTS["Write results to param"]
    WRITE_RESULTS --> WRITE_TARGET["param.setData KKSV023702CC targetList"]
    WRITE_TARGET --> WRITE_CHILD["param.setData KKSV023703CC targetChildList"]
    WRITE_CHILD --> RETURN["Return param"]
    RETURN --> END(["END"])
```

### Processing Description

1. **Extract search conditions** from the input `param` under the key `KKSV023701CC`. This retrieves 9 search parameters: billing start date, campaign code, receipt start/end date ranges (from/to), discount type code, discount application option code, and the customer's SYSID.

2. **Build the customer's service contract map** — calls `generateSvcKeiToSvcKeisWithAddJokenCd(searchSysid)` to create a map of service contract line numbers (`svcKeiNo`) to their associated service contracts with add conditions. This is used for eligibility checks in both passes.

3. **Retrieve discount service candidate codes** — calls `resolveWribSvcCds(...)` with all search conditions to get the list of discount service codes that match the criteria.

4. **Retrieve data extraction item candidate codes** — calls `resolveDchskmCds(...)` with the same search conditions to get the list of data extraction item codes.

5. **Initialize result lists** and fetch lookup reference data (application date codes, router change operation names).

6. **Discount Services pass** — for each discount service candidate code:
   - Resolve full discount service details
   - Resolve target service contracts for this discount service (skip if none exist)
   - Check if the discount service is applicable to the customer's contracts
   - For each matching customer service contract, verify application conditions
   - Build a target record with discount service details and set flags (`disp_jkn_1`, `disp_jkn_2`, `tekiyo_ymd`, router change radio settings, usage start date flag)
   - Generate child detail records and add to `targetChildList`

7. **Data Extraction Items pass** — structurally identical to the discount pass, but uses kei_kind = "d" (HNSOKU = data extraction/deduction) and does not set the disp_jkn, tekiyo_ymd, router change, or usage start date fields.

8. **Write results** — set `targetList` (main candidate list) to `KKSV023702CC` and `targetChildList` (detail line items) to `KKSV023703CC` in the param, then return.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Request/response parameter object carrying search criteria entered on the KKSV0237 registration candidate search screen. Under key `KKSV023701CC`, it holds a HashMap with 9 search condition fields: `mskm_kisan_ymd` (billing start date), `campaign_cd` (campaign code), `uk_staymd_ji` (receipt start date from), `uk_staymd_ita` (receipt start date to), `uk_endymd_ji` (receipt end date from), `uk_endymd_ita` (receipt end date to), `wrib_type_cd` (discount type code), `wrib_aply_optnty_cd` (discount application option code), and `sysid` (customer system ID). After processing, it receives two new keys: `KKSV023702CC` (main target list) and `KKSV023703CC` (child detail list). |

### Instance Fields / External State Read

The method is `private` and does not directly read instance fields. It relies entirely on:
- **Self-contained helper methods** defined within `JKKWribSvcKeiOperateCC` (all called methods are private methods of the same class)
- **Static constants** defined in this class and `JKKAdchgInitDspConstCC`
- **Enum types** `KeiKind` (WRIB="w" for discount, HNSOKU="d" for data extraction, NULL="") and `AplyJokenCd` (AND="1", ANY="2", GROUP="3")

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `generateSvcKeiToSvcKeisWithAddJokenCd` | EKK0841A010CBS (inferred) | KK_T_WRIB_SVC (discount service table) | Generates a map of service contract line numbers to service contracts with add conditions for the given SYSID |
| R | `resolveWribSvcCds` | EKK0841A010CBS (inferred) | KK_T_WRIB_SVC, KK_T_WRIB_SVC_TYPE (discount service lookup tables) | Retrieves discount service codes matching search conditions |
| R | `resolveDchskmCds` | EKK1351A010CBS (inferred) | KK_T_DCHSKM, KK_T_DCHSKM_TYPE (data extraction item lookup tables) | Retrieves data extraction item codes matching search conditions |
| R | `retTekiyoYmdCdNm` | - | Application date code reference data | Returns list of application date code names (e.g., "Application Date", "Designated Day") |
| R | `retTakinoRtrChgUmuNm` | - | Router change operation name reference data | Returns list of router change operation names (v7.00.00 enhancement) |
| R | `resolveWribSvc` | EKK0841A010CBS | KK_T_WRIB_SVC, KK_T_WRIB_SVC_TYPE | Resolves full discount service detail record from code |
| R | `resolveWribSvcTrgtSvcs` | EKK0841A010CBS | KK_T_WRIB_SVC_TRGT_SVC (discount service target service mapping) | Resolves the list of target services associated with a discount service |
| R | `isCollectWribSvcTrgtSvcsToSvcKeisWithWribAddJokenCd` | - | In-memory eligibility check | Checks if a discount service is applicable to the customer's service contracts based on add conditions |
| R | `uniqueSvcKeiNo` | - | In-memory deduplication | Returns unique service contract line numbers, with v5.00.15 enhancement to also consider target services and application conditions |
| R | `isCollectTrgtSvcsByAplyJokenCd` | - | In-memory eligibility check | Checks if any target service contracts satisfy the application condition (AND/ANY/GROUP) |
| R | `retDispJkn1` | - | Display flag check | Checks whether the discount application condition 1 display flag is enabled (v6.00.01 extended signature) |
| R | `retDispJkn2` | - | Display flag check | Checks whether the discount application condition 2 display flag is enabled |
| R | `isWrStaCset` | - | Usage start date configuration check | Determines if a usage start date field is configured for the given discount service code |
| R | `setRtrChgUmuRadio` | - | Router change radio setting | Sets default values for router change operation radio buttons based on customer's service contract |
| R | `generateWribSvcTrgtKeisFromSearch` | - | Child record generation | Builds child detail records for discount service target services |
| R | `resolveDchskm` | EKK1351A010CBS | KK_T_DCHSKM, KK_T_DCHSKM_TYPE | Resolves full data extraction item detail record from code |
| R | `resolveDchskmTrgtSvcs` | EKK1351A010CBS | KK_T_DCHSKM_TRGT_SVC (data extraction item target service mapping) | Resolves the list of target services associated with a data extraction item |
| R | `isCollectDchkmTrgtSvcsToSvcKeisWithAddJokenCd` | - | In-memory eligibility check | Checks if a data extraction item is applicable to the customer's service contracts based on add conditions |
| R | `generateDchskmTrgtKeisFromSearch` | - | Child record generation | Builds child detail records for data extraction item target services |

### CBS/SC Code Inference

- **EKK0841A010CBS** — Used for discount service (割引サービス) data. The method names `resolveWribSvc`, `resolveWribSvcCds`, `resolveWribSvcTrgtSvcs` all relate to the WribSvc (discount service) domain. The CBS message constants `EKK0841A010CBSMsg1List` referenced in the code confirm this SC code.
- **EKK1351A010CBS** — Used for data extraction item (データ抽出項目) data. The CBS message constants `EKK1351A010CBSMsg1List` (with fields `DSP_DCHSKM_CD`, `DCHSKM_NM`, `DCHS_TYPE_CD`, `DCHS_TYPE_CD_NM`, `DCHS_ADD_JOKEN_CD`, `APLY_JOKEN_CD`) confirm this SC code.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | KKSV0237 (Registration Candidate Search Screen) | `JKKWribSvcKeiOperateCC.execute()` -> `resolveContentsForSearch` | `resolveWribSvc [R] KK_T_WRIB_SVC`, `resolveDchskm [R] KK_T_DCHSKM`, `setData [U] KKSV023702CC/KKSV023703CC` |

## 6. Per-Branch Detail Blocks

### Block 1 — EXTRACT (input parameter extraction) (L2544)

Extracts 9 search condition values from the input param's data map under key `KKSV023701CC`.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `targetInfo = (HashMap<String, Object>) param.getData("KKSV023701CC")` // Extract search criteria map |
| 2 | SET | `searchMskmKisanYmd = (String) targetInfo.get("mskm_kisan_ymd")` // Billing start date (申し込起算日) |
| 3 | SET | `searchCampaignCd = (String) targetInfo.get("campaign_cd")` // Campaign code (キャンペーンコード) |
| 4 | SET | `searchUkStaymdJi = (String) targetInfo.get("uk_staymd_ji")` // Receipt start date from (受取開始日(自)) |
| 5 | SET | `searchUkStaymdIta = (String) targetInfo.get("uk_staymd_ita")` // Receipt start date to (受取開始日(至)) |
| 6 | SET | `searchUkEndymdJi = (String) targetInfo.get("uk_endymd_ji")` // Receipt end date from (受取終了日(自)) |
| 7 | SET | `searchUkEndymdIta = (String) targetInfo.get("uk_endymd_ita")` // Receipt end date to (受取終了日(至)) |
| 8 | SET | `searchWribTypeCd = (String) targetInfo.get("wrib_type_cd")` // Discount type code (割引タイプコード) |
| 9 | SET | `searchWribAplyOptntyCd = (String) targetInfo.get("wrib_aply_optnty_cd")` // Discount application option code (割引適用オプションコード) |
| 10 | SET | `searchSysid = (String) targetInfo.get("sysid")` // Customer system ID (SYSID) |

### Block 2 — CALL: Build customer service contract map (L2571)

Generates the customer's service contract map keyed by service contract line number.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `svcKeiNoToSvcKeisWithAddJokenCd = generateSvcKeiToSvcKeisWithAddJokenCd(searchSysid)` // Build map of svcKeiNo -> (addJokenCd -> CAANMsg[]) for customer's service contracts |

### Block 3 — CALL: Retrieve discount service candidate codes (L2576-2578)

Gets discount service codes matching search conditions.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `wribSvcCds = resolveWribSvcCds(searchMskmKisanYmd, searchCampaignCd, searchUkStaymdJi, searchUkStaymdIta, searchUkEndymdJi, searchUkEndymdIta, searchWribTypeCd, searchWribAplyOptntyCd)` // Resolve matching discount service codes |

### Block 4 — CALL: Retrieve data extraction item candidate codes (L2584-2586)

Gets data extraction item codes matching search conditions.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `dchskmCds = resolveDchskmCds(searchMskmKisanYmd, searchCampaignCd, searchUkStaymdJi, searchUkStaymdIta, searchUkEndymdJi, searchUkEndymdIta, searchWribTypeCd, searchWribAplyOptntyCd)` // Resolve matching data extraction item codes |

### Block 5 — INIT: Initialize result lists and lookup data (L2590-2597)

Initializes target lists and fetches reference data for display names.

| # | Type | Code |
|---|------|------|
| 1 | SET | `targetList = new ArrayList<HashMap<String, String>>(DEFAULT_HASH_SIZE)` // Main candidate list (DEFAULT_HASH_SIZE=50) |
| 2 | SET | `targetChildList = new ArrayList<HashMap<String, String>>(DEFAULT_HASH_SIZE)` // Child detail list |
| 3 | CALL | `cdNmList = retTekiyoYmdCdNm()` // Get application date code names list |
| 4 | CALL | `cdRtrChgUmuNmList = retTakinoRtrChgUmuNm()` // Get router change operation names list (v7.00.00 ADD) |
| 5 | SET | `countNoValue = 0` // Counter for iteration numbering |

### Block 6 — FOR LOOP: Discount services pass (L2603)

Iterates over each discount service candidate code obtained from `resolveWribSvcCds`.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (String wribSvcCd : wribSvcCds)` // Loop over discount service codes |

### Block 6.1 — IF: Null target service check (L2624-2627)

Skips discount services that have no associated target services.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `wribSvcTrgtSvcs = resolveWribSvcTrgtSvcs(wribSvcCd)` // Get target service contracts for this discount service |
| 2 | IF | `if (null == wribSvcTrgtSvcs)` [wribSvcTrgtSvcs==null] (L2625) |
| 2.1 | EXEC | `continue` // Skip this discount service (割引サービス対象サービスが存在しない場合は処理をスキップ) |

### Block 6.2 — CALL: Check discount service eligibility (L2632-2633)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isCollect = isCollectWribSvcTrgtSvcsToSvcKeisWithWribAddJokenCd(wribSvcTrgtSvcs, addJokenCd, svcKeiNoToSvcKeisWithAddJokenCd, aplyJokenCd)` // Check if discount service applies to customer's contracts based on add conditions |

### Block 6.3 — IF: Eligibility check result (L2636-2637)

Only processes discount services where eligibility check returns true.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (isCollect)` [isCollect==true] (L2636) |
| 1.1 | CALL | `targetSvcKeiNos = uniqueSvcKeiNo(svcKeiNoToSvcKeisWithAddJokenCd, addJokenCd, wribSvcTrgtSvcs, aplyJokenCd)` // Get unique service contract line numbers (v5.00.15 enhanced signature) |

### Block 6.3.1 — FOR LOOP: Iterate over matching customer service contracts (L2638)

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (String svcKeiNo : targetSvcKeiNos)` // Loop over customer service contracts matching the discount |

### Block 6.3.2 — GET: Resolve service contract array (L2641-2642)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeisWithWribAddJokenCd = svcKeiNoToSvcKeisWithAddJokenCd.get(svcKeiNo)` // Map lookup by service contract line number |
| 2 | SET | `svcKeis = svcKeisWithWribAddJokenCd.get(addJokenCd)` // Get service contract array for add condition |

### Block 6.3.3 — CALL: Check inner eligibility (L2645)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isCollectInner = isCollectTrgtSvcsByAplyJokenCd(wribSvcTrgtSvcs, svcKeis, aplyJokenCd)` // Check if target service contracts satisfy the application condition |

### Block 6.3.4 — IF: Inner eligibility check result (L2647-2648)

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (isCollectInner)` [isCollectInner==true] (L2647) |
| 1.1 | SET | `target = new HashMap<String, String>(DEFAULT_HASH_SIZE)` // Create new target record |

### Block 6.3.4.1 — SET: Build target record for discount service (L2649-2667)

Sets all fields for a discount service candidate record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `target.put("add_choice", "false")` // Addition choice flag |
| 2 | SET | `target.put("sysid", searchSysid)` // Customer SYSID |
| 3 | SET | `target.put("kei_kind", KeiKind.WRIB.getKeiKind())` // [-> KeiKind.WRIB="w"] Service contract type: discount (割引) |
| 4 | SET | `target.put("svc_cd", wribSvcCd)` // Discount service code |
| 5 | SET | `target.put("campaign_cd", campaignCd)` // Display campaign code |
| 6 | SET | `target.put("campaign_cd_nm", campaignCdNm)` // Discount service name (割引サービス名) |
| 7 | SET | `target.put("type_cd", typeCd)` // Discount type code (割引タイプコード) |
| 8 | SET | `target.put("type_cd_nm", typeCdNm)` // Discount type name (割引タイプ名称) |
| 9 | SET | `target.put("svc_kei_no", svcKeiNo)` // Service contract line number (サービス契約番号) |
| 10 | SET | `target.put("aply_jun", APLY_JUN_OFF)` // [-> APLY_JUN_OFF="0"] Application timing: not immediate (即時適用フラグ) |
| 11 | SET | `target.put("tekiyo_ymd", TEKIYO_NO)` // [-> TEKIYO_NO="1"] Application date flag (適用日フラグ) |

### Block 6.3.4.2 — IF: Display condition check (L2670-2676)

Checks whether the discount application condition display should be enabled.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dispJkn = ""` // Initialize display condition flag |
| 2 | CALL | `retDispJkn1(searchSysid, typeCd, target, wribSvcCd, svcKeiNo)` // v6.00.01 extended: checks condition 1 display flag with 5 params |
| 3 | CALL | `retDispJkn2(typeCd)` // Checks condition 2 display flag |
| 4 | IF | `if (Boolean.valueOf(retDispJkn1(...)) && Boolean.valueOf(retDispJkn2(typeCd)))` [both display flags true] (L2672) |
| 4.1 | SET | `dispJkn = "true"` // Display conditions enabled |
| 4.2 | ELSE-IF | `else` (L2674) |
| 4.2.1 | SET | `dispJkn = "false"` // Display conditions not enabled |
| 5 | SET | `target.put("disp_jkn_1", dispJkn)` // [-> dispJkn="true" or "false"] Application condition 1 display flag (適用条項1表示フラグ) |
| 6 | SET | `target.put("disp_jkn_2", "false")` // Application condition 2 display flag (適用条項2表示フラグ — v5.00.26 set to false) |
| 7 | SET | `target.put("tekiyo_ymd_nm_1", cdNmList.get(0))` // Application date name 1 (適用年月日名称1) |
| 8 | SET | `target.put("tekiyo_ymd_nm_2", cdNmList.get(1))` // Application date name 2 (適用年月日名称2) |

### Block 6.3.4.3 — SET: Router change operation names (v7.00.00 ADD) (L2680-2681)

| # | Type | Code |
|---|------|------|
| 1 | SET | `target.put("takinou_rtr_chg_nm_1", cdRtrChgUmuNmList.get(0))` // Router change operation name 1 (有無名称マスタから取得) |
| 2 | SET | `target.put("takinou_rtr_chg_nm_2", cdRtrChgUmuNmList.get(1))` // Router change operation name 2 |

### Block 6.3.4.4 — CALL: Set router change radio defaults (v7.00.00 ADD) (L2684)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setRtrChgUmuRadio(svcKeiNo, wribSvcCd, searchSysid, target)` // Determine ownership and set radio button initial values (所有ルーターを判定し、ラジオボタンの初期値を設定) |

### Block 6.3.4.5 — SET: Usage start date flag (v10.00.00 ADD) (L2688)

| # | Type | Code |
|---|------|------|
| 1 | SET | `target.put("disp_riyo_sta_ymd", isWrStaCset(wribSvcCd) ? "true" : "false")` // Display usage start date field only for special-set discount services (表示P利用開始希望日：スタチャント設定割引時のみ出力) |

### Block 6.3.4.6 — EXEC: Add target and generate child records (L2689-2693)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `targetList.add(target)` // Add main target record to results |
| 2 | CALL | `resolvedWribSvcTrgtKeis = generateWribSvcTrgtKeisFromSearch(countNoValue, wribSvcTrgtSvcs, svcKeis)` // Generate child detail records for discount service target services |
| 3 | EXEC | `targetChildList.addAll(resolvedWribSvcTrgtKeis)` // Add child records to child list |
| 4 | SET | `countNoValue++` // Increment counter for record numbering |

### Block 7 — FOR LOOP: Data extraction items pass (L2705)

Structurally identical to the discount services pass, but for data extraction items.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (String dchskmCd : dchskmCds)` // Loop over data extraction item codes |

### Block 7.1 — CALL: Resolve data extraction item details (L2708-2715)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `dchskm = resolveDchskm(dchskmCd)` // Resolve full data extraction item detail |
| 2 | SET | `campaignCd = dchskm.getString(EKK1351A010CBSMsg1List.DSP_DCHSKM_CD)` // Display data extraction item code |
| 3 | SET | `campaignCdNm = dchskm.getString(EKK1351A010CBSMsg1List.DCHSKM_NM)` // Data extraction item name (データ抽出項目名) |
| 4 | SET | `typeCd = dchskm.getString(EKK1351A010CBSMsg1List.DCHS_TYPE_CD)` // Data extraction type code (データ抽出タイプコード) |
| 5 | SET | `typeCdNm = dchskm.getString(EKK1351A010CBSMsg1List.DCHS_TYPE_CD_NM)` // Data extraction type name (データ抽出タイプ名称) |
| 6 | SET | `addJokenCd = dchskm.getString(EKK1351A010CBSMsg1List.DCHS_ADD_JOKEN_CD)` // Data extraction registration condition code (データ抽出登録条件コード) |
| 7 | SET | `aplyJokenCd = dchskm.getString(EKK1351A010CBSMsg1List.APLY_JOKEN_CD)` // Application condition code (適用条件コード) |

### Block 7.2 — IF: Null target service check (L2720-2723)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `dchskmTrgtSvcs = resolveDchskmTrgtSvcs(dchskmCd)` // Get target services for this data extraction item |
| 2 | IF | `if (dchskmTrgtSvcs == null)` [dchskmTrgtSvcs==null] (L2721) |
| 2.1 | EXEC | `continue` // Skip (データ抽出項目対象サービスが存在しない場合は処理をスキップ) |

### Block 7.3 — CALL: Check eligibility (L2730-2731)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isCollect = isCollectDchkmTrgtSvcsToSvcKeisWithAddJokenCd(dchskmTrgtSvcs, addJokenCd, svcKeiNoToSvcKeisWithAddJokenCd, aplyJokenCd)` // Check if data extraction item applies to customer's contracts |

### Block 7.4 — IF: Eligibility check result (L2734-2735)

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (isCollect)` [isCollect==true] (L2734) |
| 1.1 | CALL | `targetSvcKeiNos = uniqueSvcKeiNo(svcKeiNoToSvcKeisWithAddJokenCd, addJokenCd, dchskmTrgtSvcs, aplyJokenCd)` // Get unique service contract line numbers |

### Block 7.4.1 — FOR LOOP: Iterate over matching customer service contracts (L2736)

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (String svcKeiNo : targetSvcKeiNos)` // Loop over matching service contracts |

### Block 7.4.2 — GET: Resolve service contract array (L2739-2740)

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeisWithAddJokenCd = svcKeiNoToSvcKeisWithAddJokenCd.get(svcKeiNo)` // Map lookup by service contract line number |
| 2 | SET | `svcKeis = svcKeisWithAddJokenCd.get(addJokenCd)` // Get service contract array for add condition |

### Block 7.4.3 — CALL: Check inner eligibility (L2743)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `isCollectInner = isCollectTrgtSvcsByAplyJokenCd(dchskmTrgtSvcs, svcKeis, aplyJokenCd)` // Check if target service contracts satisfy the application condition |

### Block 7.4.4 — IF: Inner eligibility check result (L2745-2746)

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (isCollectInner)` [isCollectInner==true] (L2745) |
| 1.1 | SET | `target = new HashMap<String, String>(DEFAULT_HASH_SIZE)` // Create new target record |

### Block 7.4.4.1 — SET: Build target record for data extraction item (L2747-2757)

| # | Type | Code |
|---|------|------|
| 1 | SET | `target.put("add_choice", "false")` // Addition choice flag |
| 2 | SET | `target.put("sysid", searchSysid)` // Customer SYSID |
| 3 | SET | `target.put("kei_kind", KeiKind.HNSOKU.getKeiKind())` // [-> KeiKind.HNSOKU="d"] Service contract type: data extraction/deduction (データ抽出) |
| 4 | SET | `target.put("svc_cd", dchskmCd)` // Data extraction item code |
| 5 | SET | `target.put("campaign_cd", campaignCd)` // Display data extraction item code |
| 6 | SET | `target.put("campaign_cd_nm", campaignCdNm)` // Data extraction item name |
| 7 | SET | `target.put("type_cd", typeCd)` // Data extraction type code |
| 8 | SET | `target.put("type_cd_nm", typeCdNm)` // Data extraction type name |
| 9 | SET | `target.put("svc_kei_no", svcKeiNo)` // Service contract line number |
| 10 | SET | `target.put("aply_jun", APLY_JUN_OFF)` // [-> APLY_JUN_OFF="0"] Application timing: not immediate |
| 11 | EXEC | `targetList.add(target)` // Add target record to results |
| 12 | CALL | `resolvedDchskmTrgtKeis = generateDchskmTrgtKeisFromSearch(countNoValue, dchskmTrgtSvcs, svcKeis)` // Generate child detail records |
| 13 | EXEC | `targetChildList.addAll(resolvedDchskmTrgtKeis)` // Add child records to child list |
| 14 | SET | `countNoValue++` // Increment counter |

### Block 8 — WRITE RESULTS (L2760-2771)

Writes the computed results back to the param object for screen consumption.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kksv023702CC = new HashMap<String, Object>(DEFAULT_HASH_SIZE)` // Create result map for main list |
| 2 | SET | `kksv023702CC.put("target_list", targetList)` // Store main target list |
| 3 | EXEC | `param.setData("KKSV023702CC", kksv023702CC)` // Set result data for main candidate list |
| 4 | SET | `kksv023703CC = new HashMap<String, Object>(DEFAULT_HASH_SIZE)` // Create result map for child list |
| 5 | SET | `kksv023703CC.put("target_child_list", targetChildList)` // Store child detail list |
| 6 | EXEC | `param.setData("KKSV023703CC", kksv023703CC)` // Set result data for child detail list |
| 7 | RETURN | `return param` // Return updated param with search results |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `resolveContentsForSearch` | Method | Search-to-registration candidate display — retrieves eligible discount services and data extraction items for a customer based on search criteria |
| `wribSvcCd` | Field | Discount service code (割引サービスコード) — unique identifier for a discount/service campaign |
| `dchskmCd` | Field | Data extraction item code (データ抽出項目コード) — unique identifier for a data extraction/deduction item |
| `wribSvcTrgtSvcs` | Field | Discount service target services (割引サービス対象サービス) — list of service contracts that a discount service can be applied to |
| `dchskmTrgtSvcs` | Field | Data extraction item target services (データ抽出項目対象サービス) — list of service contracts that a data extraction item applies to |
| `svcKeiNo` | Field | Service contract line number (サービス契約番号) — unique identifier for a customer's service contract line item |
| `svcKeiNoToSvcKeisWithAddJokenCd` | Field | Map from service contract line number to map of add condition code to service contract arrays — data structure organizing customer's service contracts by add condition |
| `addJokenCd` | Field | Registration condition code (登録条件コード) — code defining conditions under which a discount or extraction item can be registered |
| `aplyJokenCd` | Field | Application condition code (適用条件コード) — code defining how conditions are evaluated (AND="1"=all must match, ANY="2"=any matches, GROUP="3"=group evaluation) |
| `searchMskmKisanYmd` | Field | Billing start date (申し込起算日) — the billing start date used for campaign eligibility filtering |
| `searchCampaignCd` | Field | Campaign code (キャンペーンコード) — the campaign identifier for matching discount/extraction items |
| `searchUkStaymdJi` / `searchUkStaymdIta` | Field | Receipt start date range (受取開始日(自) / (至)) — date range filter for when service receipts start |
| `searchUkEndymdJi` / `searchUkEndymdIta` | Field | Receipt end date range (受取終了日(自) / (至)) — date range filter for when service receipts end |
| `searchWribTypeCd` | Field | Discount type code (割引タイプコード) — category of discount (e.g., price reduction, free trial) |
| `searchWribAplyOptntyCd` | Field | Discount application option code (割引適用オプションコード) — option controlling how discount application is evaluated |
| `searchSysid` | Field | Customer system ID (SYSID) — unique identifier for the customer account |
| `kei_kind` | Field | Service contract type (契約種別) — "w" (WRIB=discount) or "d" (HNSOKU=data extraction/deduction) |
| `WRIB` | Enum | Discount service contract type (割引契約種別) — internal enum value "w" for discount services |
| `HNSOKU` | Enum | Data extraction/deduction type (データ抽出種別) — internal enum value "d" for data extraction items |
| `APLY_JUN_OFF` | Constant | "0" — Application not immediate (適用瞬時オフ) — indicates the discount/extraction does not take effect immediately upon registration |
| `TEKIYO_NO` | Constant | "1" — Application date flag set to apply (適用日フラグ) — indicates the application date is applicable |
| `disp_jkn_1` | Field | Application condition 1 display flag (適用条項1表示フラグ) — whether to show condition 1 on screen |
| `disp_jkn_2` | Field | Application condition 2 display flag (適用条項2表示フラグ) — whether to show condition 2 on screen |
| `tekiyo_ymd` | Field | Application date (適用年月日) — the date the discount/extraction takes effect |
| `tekiyo_ymd_nm_1` / `tekiyo_ymd_nm_2` | Field | Application date names (適用年月日名称) — display names for application date options |
| `takinou_rtr_chg_nm_1` / `takinou_rtr_chg_nm_2` | Field | Router change operation names (有無名称) — display names for router change operation radio buttons (v7.00.00) |
| `disp_riyo_sta_ymd` | Field | Display usage start date (表示利用開始希望日) — flag indicating whether to show the usage start date field (v10.00.00) |
| `add_choice` | Field | Addition choice flag (追加選択フラグ) — indicates whether this is an additional choice selection |
| `aply_jun` | Field | Application timing (適用順序) — indicates immediate (0=off) or deferred application |
| `targetList` | Field | Main candidate list (候補一覧) — list of eligible discount/extraction candidates for display on the registration search screen |
| `targetChildList` | Field | Child detail list (対象契約情報) — list of associated service contract line item details for each candidate |
| `KKSV023701CC` | Constant | Data key string — key used to store/search condition parameters in the param object |
| `KKSV023702CC` | Constant | Data key string — key used to store the main result target list |
| `KKSV023703CC` | Constant | Data key string — key used to store the child detail result list |
| KKSV0237 | Screen | Registration candidate search screen — the screen that uses this method to display eligible discount and data extraction candidates |
| EKK0841A010CBS | SC Code | Discount service CBS (割引サービス保守保守) — service component for discount service data |
| EKK1351A010CBS | SC Code | Data extraction item CBS (データ抽出項目保守) — service component for data extraction item data |
| DEFAULT_HASH_SIZE | Constant | 50 — default initial capacity for HashMaps in this method |
| KK_T_WRIB_SVC | DB Table | Discount service master table (割引サービスマスタ) — stores discount service definitions |
| KK_T_DCHSKM | DB Table | Data extraction item master table (データ抽出項目マスタ) — stores data extraction item definitions |
| KK_T_WRIB_SVC_TYPE | DB Table | Discount service type master table (割引サービスタイプマスタ) — stores discount type definitions |
| KK_T_DCHSKM_TYPE | DB Table | Data extraction item type master table (データ抽出項目タイプマスタ) — stores data extraction type definitions |
| KK_T_WRIB_SVC_TRGT_SVC | DB Table | Discount service target service mapping table (割引サービス対象サービス紐付け) — maps discount services to their target service contracts |
| KK_T_DCHSKM_TRGT_SVC | DB Table | Data extraction item target service mapping table (データ抽出項目対象サービス紐付け) — maps data extraction items to their target service contracts |
| AplyJokenCd | Enum | Application condition code enum: AND="1" (all conditions), ANY="2" (any condition), GROUP="3" (group) |
| CAANMsg | Class | Message object class — generic carrier of structured data fields (used throughout for CBS result data) |
| IRequestParameterReadWrite | Interface | Request parameter read/write interface — the data transfer object passed between screen processing and business logic |
