# Business Logic — JBSbatKKAdChgTekkyoKjFinUpd.getMskmDtlNo() [33 LOC]

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

## 1. Role

### JBSbatKKAdChgTekkyoKjFinUpd.getMskmDtlNo()

This method serves as the **application detail information retrieval** routine within the KK delivery final update batch (`JBSbatKKAdChgTekkyoKjFinUpd`). Its business purpose is to fetch all application detail records — corresponding to a given **contract number** (`inMskmNo`) and **service type number** (`inSvcKeiNo`) — from the `T_MSKM_DTL_KK` database table, and accumulate them into the service instance's `mskm_dtl_inf_list` collection for downstream processing.

The method implements a **delegation pattern**: it delegates the actual database query to `executeKK_T_MSKM_DTL_KK_SELECT_037(param)`, a dedicated select-execution method, and then iterates the returned cursor via `db_KK_T_MSKM_DTL.selectNext()` to populate the in-memory list. This separation of concerns isolates query execution logic (parameter binding, SQL dispatch) from result collection logic (cursor iteration, list accumulation).

Within the larger batch, this method acts as a **shared internal utility** called by `execute()` — which orchestrates the full delivery final update workflow — and is also accessible from `JKKAplySeiopsvcKeiCC.editInEKK0441D010()` in the service component layer. Its private visibility restricts invocation to co-class collaborators, ensuring that detail records are always fetched through the controlled batch context.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getMskmDtlNo(inMskmNo, inSvcKeiNo)"])
    STEP1["Log: 申込明細情報を検索_START (Search application detail info_START)"]
    STEP2["Initialize mskm_dtl_inf_list = new ArrayList<JBSbatCommonDBInterface>()"]
    STEP3["Build param = Object[]{inMskmNo, inSvcKeiNo}"]
    STEP4["executeKK_T_MSKM_DTL_KK_SELECT_037(param)"]
    STEP5["db_map_inf_mskm_dtl = db_KK_T_MSKM_DTL.selectNext()"]
    COND{"db_map_inf_mskm_dtl != null?"}
    STEP6["mskm_dtl_inf_list.add(db_map_inf_mskm_dtl)"]
    STEP7["db_map_inf_mskm_dtl = db_KK_T_MSKM_DTL.selectNext()"]
    STEP8["Log: 申込明細情報件数 - row count"]
    STEP9["Log: 申込明細情報を検索_END"]
    END(["Return"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> COND
    COND -- true --> STEP6
    STEP6 --> STEP7
    STEP7 --> COND
    COND -- false --> STEP8
    STEP8 --> STEP9
    STEP9 --> END
```

The processing flow consists of five logical phases:

1. **Initialization** — A debug log marks the start of the "search application detail info" operation, then `mskm_dtl_inf_list` is freshly instantiated as an empty `ArrayList`, ensuring no residual data from prior invocations contaminates the result set.

2. **Parameter construction** — An `Object[]` array is built containing the two input parameters (`inMskmNo`, `inSvcKeiNo`) in positional order. These are passed as the search criteria to the delegated select method.

3. **Query execution** — `executeKK_T_MSKM_DTL_KK_SELECT_037(param)` is called. This method binds the parameter array to a SQL SELECT statement targeting the `T_MSKM_DTL_KK` table, filters rows where the contract number and service type number match, opens a cursor (`db_KK_T_MSKM_DTL`), and positions it on the first result row.

4. **Result accumulation loop** — The method enters a `while` loop that reads each row from the cursor via `selectNext()`. As long as the returned row object is non-null, the row is added to `mskm_dtl_inf_list` and the cursor advances. When `selectNext()` returns `null`, the loop terminates — indicating all matching rows have been collected.

5. **Completion logging** — A debug log records the total number of application detail rows retrieved (via `mskm_dtl_inf_list.size()`), followed by an end-of-operation debug marker.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMskmNo` | `String` | **Application number (contract/shadowing number)** — The unique identifier for a submitted application (`申込` = application/subscription). This value is used as the primary filter to find all detail records associated with a specific contract. It maps to the contract number column in the `T_MSKM_DTL_KK` table. |
| 2 | `inSvcKeiNo` | `String` | **Service type number** — A classification code that identifies the service category within an application (e.g., FTTH connection, mail service, additional options). This is used as a secondary filter alongside `inMskmNo` to narrow the result set to a specific service line item within a broader contract. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `mskm_dtl_inf_list` | `ArrayList<JBSbatCommonDBInterface>` | The service instance's application detail information list. This field is **written** (not read) by this method — it is overwritten with a fresh `ArrayList` at the start of processing and populated with retrieved detail records. The populated list is consumed by subsequent methods in the batch workflow. |
| `db_KK_T_MSKM_DTL` | `JBSbatCommonDBInterface` (cursor) | The database cursor instance used to iterate over result rows from the `T_MSKM_DTL_KK` table. It is positioned by the `executeKK_T_MSKM_DTL_KK_SELECT_037` call and advanced by `selectNext()` invocations. |
| `super.logPrint` | debug logger | The parent class's debug logging handler, used for traceability of the search lifecycle. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JBSbatCommonDBInterface.printDebugLog` | - | - | Logs debug message "申込明細情報を検索_START" marking the beginning of the retrieval operation. |
| CALL | `executeKK_T_MSKM_DTL_KK_SELECT_037` | `EKK037` (implied) | `T_MSKM_DTL_KK` | Executes a SQL SELECT query on the application detail table, filtering by `inMskmNo` (contract number) and `inSvcKeiNo` (service type number). Opens cursor `db_KK_T_MSKM_DTL` for iteration. |
| R | `db_KK_T_MSKM_DTL.selectNext` | - | `T_MSKM_DTL_KK` | Reads the next row from the cursor opened by the select query. Called repeatedly in a while-loop until null is returned, effectively fetching all matching application detail records. |
| - | `JBSbatCommonDBInterface.printDebugLog` | - | - | Logs the count of retrieved detail rows (`mskm_dtl_inf_list.size()`) for operational visibility. |
| - | `JBSbatCommonDBInterface.printDebugLog` | - | - | Logs debug message "申込明細情報を検索_END" marking the completion of the retrieval operation. |

**Classification rationale:**
- The method itself performs **zero** direct SQL writes. It is a pure **Read (R)** operation with respect to business data.
- `executeKK_T_MSKM_DTL_KK_SELECT_037` is the **query delegate** — it binds parameters, issues the SELECT, and returns a cursor.
- The `while` loop with `selectNext()` is a **fetch pattern** — each call reads one row from the open cursor and advances the position.
- The `mskm_dtl_inf_list.add()` calls are **in-memory operations** — no database write is performed.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKAdChgTekkyoKjFinUpd | `JBSbatKKAdChgTekkyoKjFinUpd.execute()` -> `getMskmDtlNo()` | `executeKK_T_MSKM_DTL_KK_SELECT_037 [R] T_MSKM_DTL_KK` |
| 2 | CC: JKKAplySeiopsvcKeiCC | `JKKAplySeiopsvcKeiCC.editInEKK0441D010()` -> `getMskmDtlNo()` | `executeKK_T_MSKM_DTL_KK_SELECT_037 [R] T_MSKM_DTL_KK` |

**Notes on callers:**
- **`execute()`** — The primary batch orchestration method in the same class. It invokes `getMskmDtlNo()` to retrieve application detail records as part of the delivery final update workflow.
- **`editInEKK0441D010()`** — A service component (CC) method in `JKKAplySeiopsvcKeiCC` that also needs application detail information, likely for editing or validation purposes in a screen-driven context (possibly the EKK0441 screen).

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(Initial log and list initialization)` (L545)

> Logs the start of the search operation and creates a fresh result list. This ensures idempotent behavior — no residual data from previous uses of this service instance contaminates the result.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printDebugLog("申込明細情報を検索_START")` // Logs "Search application detail info_START" |
| 2 | SET | `db_map_inf_mskm_dtl = null` // Declares cursor row holder, initialized to null before loop |
| 3 | SET | `mskm_dtl_inf_list = new ArrayList<JBSbatCommonDBInterface>()` // 申込明細情報リスト生成 — Initializes the application detail info list |

**Block 2** — [SET] `(Parameter construction)` (L551)

> Constructs the positional parameter array that will be passed to the select delegate method.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Object[] param = {inMskmNo, inSvcKeiNo}` // 検索条件の設定 — Search criteria: [0] = contract number, [1] = service type number |

**Block 3** — [CALL] `(Execute select query)` (L553)

> Delegates the actual database query execution. This method binds the parameters to a SQL SELECT, opens a cursor, and positions it.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `executeKK_T_MSKM_DTL_KK_SELECT_037(param)` // 申込明細情報検索実施 — Execute application detail info search. SQL: SELECT from T_MSKM_DTL_KK WHERE mskm_no = param[0] AND svc_kei_no = param[1] |

**Block 4** — [SET] `(Fetch first row)` (L556)

> Positions the cursor on the first result row before entering the accumulation loop.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_map_inf_mskm_dtl = db_KK_T_MSKM_DTL.selectNext()` // 申込明細情報情報取得 — Retrieve first application detail record |

**Block 5** — [WHILE] `(Loop: iterate cursor until null)` (L558)

> Iterates over all rows returned by the query. Each non-null row represents one application detail record for the given contract + service type combination.

| # | Type | Code |
|---|------|------|
| 1 | SET | `db_map_inf_mskm_dtl = db_KK_T_MSKM_DTL.selectNext()` // Advances cursor to next row at end of each iteration |

**Block 5.1** — [IF] `(Row is non-null: accumulate)` (L561)

> Condition: `db_map_inf_mskm_dtl != null`. When true, the current row is stored in the result list.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `mskm_dtl_inf_list.add(db_map_inf_mskm_dtl)` // 申込明細情報格納 — Store application detail record in list |

**Block 6** — [EXEC] `(Completion logging)` (L567-L569)

> Logs the row count for operational monitoring, then marks the end of the search operation.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.logPrint.printDebugLog("----申込明細情報件数: " + mskm_dtl_inf_list.size())` // Logs the number of retrieved detail rows |
| 2 | EXEC | `super.logPrint.printDebugLog("申込明細情報を検索_END")` // Logs "Search application detail info_END" |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `inMskmNo` | Parameter | **Application number (contract number)** — The unique identifier for a submitted application. Maps to "申込" (shinobi = application/subscription) in Japanese business terminology. |
| `inSvcKeiNo` | Parameter | **Service type number** — A classification code identifying the type of service within an application (e.g., FTTH, mail, add-on). Maps to "サービス種類番号" (saabisu shurui bangou). |
| `mskm_dtl_inf_list` | Field | **Application detail information list** — An instance-level `ArrayList` holding all application detail records (`JBSbatCommonDBInterface`) retrieved for a given contract. Populated by this method and consumed by downstream batch steps. |
| `db_KK_T_MSKM_DTL` | Field | **T_MSKM_DTL_KK cursor** — A database cursor object used to iterate over application detail records from the `T_MSKM_DTL_KK` table. The KK prefix denotes the KK (Kakaku/Contract) module context. |
| `T_MSKM_DTL_KK` | DB Table | **Application detail information table (KK context)** — Stores line-item detail records for applications. Key columns include contract number (`mskm_no`) and service type number (`svc_kei_no`). |
| `executeKK_T_MSKM_DTL_KK_SELECT_037` | Method | **Select delegate for T_MSKM_DTL_KK** — Binds parameters to a SQL SELECT statement and opens a cursor. The "037" suffix is a sequence number for this select operation within the batch. |
| selectNext | Method | **Cursor next-row fetch** — Advances the database cursor and returns the next row as a `JBSbatCommonDBInterface` object. Returns `null` when no more rows are available. |
| JBSbatCommonDBInterface | Interface | **Common database interface** — The shared interface for all database interaction objects in the batch framework, providing methods like `selectNext()`, `insert()`, `update()`, etc. |
| 申込 (Shinobi) | Japanese term | **Application / Subscription** — Refers to a customer's service application (contract request) in the telecom domain. |
| 明細 (Meisai) | Japanese term | **Detail** — Refers to line-item or sub-record data within a parent application. `申込明細` = application detail. |
| 検索 (Kensaku) | Japanese term | **Search / Query** — Database retrieval operation. |
| 格納 (Kakuno) | Japanese term | **Store / Register** — Store data into a collection or database. |
| 件数 (Kensuu) | Japanese term | **Row count / Record count** — The number of rows returned by a query. |
| KK | Acronym | **Kakaku / Contract** — Internal module prefix denoting the contract/order fulfillment domain. |
| SC | Acronym | **Service Component** — A class implementing business logic, typically named with a pattern like `EKKxxxxA010SC`. |
| DB | Acronym | **Database** — The relational data store. |
| CC | Acronym | **Common Component / Control Component** — A shared service-level component providing cross-cutting business logic. |
