# Business Logic — KKIFE403.run() [16 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `local.gyomu.api.KKIFE403` |
| Layer | Controller (REST API layer — JAX-RS `@Path` / `@POST`) |
| Module | `api` (Package: `local.gyomu.api`) |

## 1. Role

### KKIFE403.run()

This method implements the core business logic entry point for the **Discount Interrelated Contract Information Inquiry** (割当関連契約情報照会) API. It is the server-side processing method invoked after the JAX-RS `execute` endpoint receives a POST request to the `/KKIFE403` path. The `run` method delegates all actual work to `logicExecute`, which in turn dispatches to the business process management (BPM) service `KKSV0909`. That service calls the common component `JKKWrbkKnrnKeiInfoListCC`, which queries the contract inquiry CBS (`EKK0081B043CBS`) to retrieve discounted interrelated contract details including service numbers, system IDs, invoice numbers, contractor address codes, and service codes.

The method follows the **delegation / routing design pattern** — it acts as a thin orchestrator within the API layer, forwarding to `logicExecute` without any conditional branching or data transformation of its own. The input check is intentionally commented out, as validation is handled by the downstream business service side.

This API is a **shared utility endpoint** used by screen KKSV0909 to display discount interrelated contract information. It is identified by the `@Path("KKIFE403")` annotation and carries API ID `KKIFE403` for logging and routing purposes.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["run(reqPartsBean)"])
    INPUT_CHECK_SKIP["Input Check — SKIPPED (delegated to BPM service side)"]
    LOGIC["logicExecute(reqPartsBean)"]
    BP_SERVICE["callBpService(SERVICE_ID='KKSV0909', reqPartsBean, GYOMU_ERR_CODES_LIST)"]
    OP_OPERATION["KKSV0909OPOperation.run()"]
    CC_SEARCH["JKKWrbkKnrnKeiInfoListCC.searchKeiInfoList()"]
    CBS_CALL["callSC(EKK0081B043CBS) — Contract Inquiry"]
    EXTRACT["Extract resultMap = outMap.get('KKSV090901SC')"]
    CREATE_RESPONSE["new ApiServerPartsBean()"]
    SET_BODY["resPartsBean.setBody(resultMap)"]
    RETURN(["Return resPartsBean"])

    START --> INPUT_CHECK_SKIP
    INPUT_CHECK_SKIP --> LOGIC
    LOGIC --> BP_SERVICE
    BP_SERVICE --> OP_OPERATION
    OP_OPERATION --> CC_SEARCH
    CC_SEARCH --> CBS_CALL
    CBS_CALL --> EXTRACT
    EXTRACT --> CREATE_RESPONSE
    CREATE_RESPONSE --> SET_BODY
    SET_BODY --> RETURN
```

**CRITICAL — Constant Resolution:**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `APIID` | `"KKIFE403"` | API identifier for logging and routing |
| `SERVICE_ID` | `"KKSV0909"` | The BPM business service ID to invoke |
| `GYOMU_ERR_CODES` | `["1001", "1002", "1003", "2001", "1000"]` | Business error codes handled by the service side (input validation is delegated to BPM) |

The `run` method contains **no conditional branches** — it is a straight-line flow: invoke `logicExecute`, which performs the single delegation to the BPM service, then return the response.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `reqPartsBean` | `ApiServerPartsBean` | Server business API linkage data (request) — carries the request payload containing the input acceptance number and other parameters needed to query discount interrelated contract information from the BPM service. |

**External state read by the method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `APIID` | `static final String = "KKIFE403"` | API identifier — used for logging and routing within the API framework |
| `SERVICE_ID` | `static final String = "KKSV0909"` | Business service ID — identifies the BPM service (KKSV0909) that performs the actual contract inquiry |
| `GYOMU_ERR_CODES_LIST` | `static final List<String>` | List of business error codes `["1001", "1002", "1003", "2001", "1000"]` — passed to the service caller for error handling delegation |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `KKIFE403.logicExecute` | KKIFE403 | - | Calls `logicExecute` in `KKIFE403` which delegates to BPM service |
| R | `ApiServerLocalBase.callBpService` | KKSV0909SC | KKSV0909OPOperation → JKKWrbkKnrnKeiInfoListCC → EKK0081B043CBS | Calls BPM service KKSV0909 which queries discounted interrelated contract information |

**Downstream service chain analysis:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `searchKeiInfoList` (JKKWrbkKnrnKeiInfoListCC) | KKSV090901SC | EKK0081B043CBSMsg / EKK0081B043CBSMsg1List | Reads discount interrelated contract details — service number, system ID, invoice number, contractor address code, service code using template `EKK0081B043` with acceptance number as key |

**Classification rationale:**
- The entire chain is a **Read (R)** operation. The method flow goes: REST API → `logicExecute` → `callBpService` → `KKSV0909OPOperation` → `JKKWrbkKnrnKeiInfoListCC.searchKeiInfoList` → `EKK0081B043CBS` (contract inquiry CBS).
- The CBS `EKK0081B043CBS` is called with `FUNC_CODE = "1"` (read operation) and `KEY_MSKMSHO_NO` (input acceptance number) to look up contract information.
- Results are extracted from `EKK0081B043CBSMsg1List` and mapped to fields like `serviceNum`, `sysid`, `invoiceNum`, `contractorAddressCode`, `service`.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | API:KKIFE403 (JAX-RS POST) | `KKIFE403.execute(request, context)` → `super.exec("KKIFE403", ...)` → `KKIFE403.run(reqPartsBean)` | `logicExecute -> callBpService -> KKSV090901SC [R] EKK0081B043CBS` |

**Notes:**
- `KKIFE403` is exclusively called via the JAX-RS `@POST` endpoint `execute()`, which is the HTTP entry point for the REST API.
- No other classes or screens directly invoke `KKIFE403.run()` — it is a REST API endpoint invoked by front-end clients or other services via HTTP.
- The terminal call chain reaches: `KKIFE403.run → logicExecute → callBpService(KKSV0909) → KKSV0909OPOperation → JKKWrbkKnrnKeiInfoListCC.searchKeiInfoList → EKK0081B043CBS` which reads discount interrelated contract information.

## 6. Per-Branch Detail Blocks

**Block 1** — [COMMENT] `Input check is delegated to BPM service side` (L89)

> The input check is commented out. Validation is handled by the downstream business service (KKSV0909) rather than at this API layer.

| # | Type | Code |
|---|------|------|
| 1 | COMMENT | `// 入力チェックは業務サービス側で行う。` // Input check is performed on the business service side |

**Block 2** — [BLOCK] `Response data generation` (L93)

> Delegates business logic execution to `logicExecute`, which handles the BPM service call and returns the response bean.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `resPartsBean = this.logicExecute(reqPartsBean)` // Calls logicExecute to dispatch to BPM service KKSV0909 |
| 2 | SET | `String serviceId = SERVICE_ID = "KKSV0909"` // Business service ID for BPM dispatch |
| 3 | CALL | `callBpService(serviceId, reqPartsBean, GYOMU_ERR_CODES_LIST)` // Invokes BPM service KKSV0909 |
| 4 | EXEC | `KKSV0909OPOperation.run(param)` // Operations component executes the BPM flow |
| 5 | CALL | `JKKWrbkKnrnKeiInfoListCC.searchKeiInfoList(handle, param, fixedText)` // Queries discount interrelated contract info |
| 6 | CALL | `callSC(handle, scCall, param, fixedText, ekk0081b043In, ...)` // Invokes CBS EKK0081B043CBS |
| 7 | SET | `ekk0081b043In = {TEMPLATE_ID="EKK0081B043", FUNC_CODE="1", KEY_MSKMSHO_NO=inputScceptanceNum}` // CBS call parameters |
| 8 | SET | `resultMap = (Map<String,Object>)outMap.get("KKSV090901SC")` // Extracts SC result from output map |
| 9 | EXEC | `resPartsBean.setBody(resultMap)` // Sets the query result as the response body |

**Block 3** — [COMMENT] `Base logic call — return statement` (L100)

> Marks the end of the base processing section. Returns the response bean to the caller.

| # | Type | Code |
|---|------|------|
| 1 | COMMENT | `// 基礎ロジック呼び出し` // Base logic call |
| 2 | RETURN | `return resPartsBean;` // Returns response containing contract inquiry results |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `割当関連契約情報照会` | Japanese | Discount Interrelated Contract Information Inquiry — the business domain of this API, used to query contract details for orders with interrelated service discounts |
| `サーバ業務AP連携データ` | Japanese | Server Business API Interchange Data — the request/response data structure (`ApiServerPartsBean`) used to carry data between the REST API layer and the BPM business service layer |
| `入力チェック` | Japanese | Input Check — validation of request data, intentionally delegated to the BPM service side in this method |
| `レスポンスデータ生成` | Japanese | Response Data Generation — the process of creating the response bean by calling `logicExecute` |
| `基礎ロジック呼び出し` | Japanese | Base Logic Call — annotation marker for the standard business logic invocation pattern |
| APIID | Field | API Identifier — uniquely identifies this API endpoint as `"KKIFE403"` for logging, routing, and monitoring |
| SERVICE_ID | Field | Business Service ID — identifies the BPM service to invoke (`"KKSV0909"`), which contains the actual business logic for contract inquiry |
| GYOMU_ERR_CODES | Field | Business Error Codes — error codes `["1001", "1002", "1003", "2001", "1000"]` that are handled by the service side for validation |
| KKIFE403 | API | Discount Interrelated Contract Information Inquiry API — the REST endpoint at `/KKIFE403` for querying interrelated contract details |
| KKSV0909 | BPM Service | Business Process Management service — the backend service that orchestrates the contract inquiry flow |
| KKSV090901SC | SC Code | Service Component code for KKSV0909 — the SC-level key used to extract results from the BPM service response map |
| JKKWrbkKnrnKeiInfoListCC | CC | Joint/Common Component — Common Component for querying discount interrelated contract information list (Wrbk = WaDate/Wakate, Knrn = Kanren/Related, Kei = Keiyaku/Contract) |
| EKK0081B043CBS | CBS | Contract Business Service — the CBS (Business Service) that performs the actual database query for contract information using template `EKK0081B043` |
| TEMPLATE_ID_EKK0081B043 | Field | Template ID for the CBS call — `"EKK0081B043"` identifies the query template used |
| FUNC_CODE | Field | Function Code — `"1"` indicates a read/query operation in the CBS |
| KEY_MSKMSHO_NO | Field | Key Masked Acceptance Number — the input acceptance number used as the lookup key for contract information |
| inputAcceptanceNum | Field | Input Acceptance Number — the acceptance number from the request used to look up contract records |
| serviceNum | Field | Service Number — the service contract identifier returned from the inquiry |
| sysid | Field | System ID — the system identifier associated with the contract |
| invoiceNum | Field | Invoice Number — the invoice processing number (`SEIKY_KEI_NO`) |
| contractorAddressCode | Field | Contractor Address Code (`KEISHA_AD_CD`) — the address code of the contracted entity |
| service | Field | Service Code (`SVC_CD`) — the type of service associated with the contract |
