# Business Logic — JBSbatKKHnsokuCdIktTrkm.setMskmParam() [66 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKHnsokuCdIktTrkm` |
| Layer | Service (Batch processing within koptBatch module) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKHnsokuCdIktTrkm.setMskmParam()

This method is a **parameter builder** (Builder pattern) that assembles a 54-element `Object[]` array representing all columns of a subscription header record (`KK_T_MSKM`) destined for batch insertion. It is invoked exclusively by `JBSbatKKHnsokuCdIktTrkm.execute()` during the subscription registration flow: the caller invokes `executeKK_T_MSKM_PKINSERT(setMskmParam(svcKeiInfo, mskmNo))` to persist the new subscription master entry.

The method maps business identity data — the subscription number (`mskmNo`), a system timestamp, and the service detail identifier (`SYSID` from `svcKeiMap`) — alongside static domain constants (subscription status, subscription type, subscription state) and operational metadata (operator date, batch user ID, invalidation flag) into a fixed-order array contract. Most fields default to `null` because this registration step captures only the core header; optional attributes (contact preferences, reservation data, cancellation data, etc.) are left blank and populated later by downstream detail registration or post-processing batches.

The method implements **delegation** — it reads data from the input `svcKeiMap` interface, calls common utility services for timestamp resolution, and references superclass fields (`super.opeDate`, `super.batchUserId`) for operational context. It does not branch on input type; every invocation produces the same structurally identical array with only the identity-sensitive fields (`mskmNo`, `SYSID`, timestamps) varying per invocation.

Its **role in the larger system** is that of a data adapter: it bridges the runtime execution context (who is running the batch, when, against which service line) with the persistence contract expected by `executeKK_T_MSKM_PKINSERT()`. Without this method, the subscription master table would lack the minimal required header row before child detail records (`KK_T_MSKM_DTL`) are created.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setMskmParam Start<br/>Build parameter array for<br/>subscription schema registration"])
    START --> TS_SYS["sysAddDtm = JCCBatCommon.getSysDateTimeStamp()"]
    TS_SYS --> CONST1["CD00060_130 = 130 (申込ステータス 承認済)"]
    CONST1 --> SYSID["svcKeiMap.getString(SYSID)<br/>Extract service line identifier"]
    SYSID --> CONST2["MSKM_SBT_CD_HNSK_MSKM = 00030<br/>申込種別コード: 販売促申込"]
    CONST2 --> TS_OPE["JKKBatCommon.getOpeDateTimeStamp(commonItem)<br/>Get operation timestamp"]
    TS_OPE --> CONST3["CD00760_04 = 04<br/>申込状態識別コード: 承認済"]
    CONST3 --> CONST4["S_MK_FLG = 0 (無効フラグ)"]
    CONST4 --> BUILD["BUILD: Construct Object[54] setParam<br/>Fixed-order array for KK_T_MSKM columns"]
    BUILD --> RETURN["RETURN setParam"]
    RETURN --> END(["setMskmParam End"])
```

**Block-level constant resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|-----------------|
| `CD00060_130` | `"130"` | 申込ステータス 承認済 (Subscription status: Approved) |
| `MSKM_SBT_CD_HNSK_MSKM` | `"00030"` | 申込種別コード 販売促申込 (Subscription type code: Sales promotion subscription) |
| `CD00760_04` | `"04"` | 申込状態識別コード 承認済 (Subscription state identification code: Approved) |
| `S_MK_FLG` | `"0"` | 無効フラグ (Invalid flag: deactivated) |

**Processing flow:**

The method performs **zero conditional branching**. It executes linearly:

1. Constructs an `Object[]` array literal with 54 elements.
2. Each element position corresponds to a specific column in the `KK_T_MSKM` table.
3. Identity-sensitive fields pull live values (`mskmNo` parameter, `SYSID` from `svcKeiMap`, timestamps from `JCCBatCommon` and `JKKBatCommon`).
4. Domain-constant fields embed static classification codes.
5. Super-class fields (`super.opeDate`, `super.batchUserId`) inject the batch runtime context.
6. All remaining fields are `null`, serving as placeholders for future population.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `svcKeiMap` | `JBSbatCommonDBInterface` | A database row interface representing a service detail line item (`KK_T_SVC_KEI`). It carries the system identifier (`SYSID`) for the service being subscribed to, which links the subscription header to the correct service line in the data model. |
| 2 | `mskmNo` | `String` | The subscription number — a unique identifier for the subscription header record being registered in `KK_T_MSKM`. This is the primary key for the new record being created. |

**Class-level instance fields referenced:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `super.opeDate` | `String` | The operator date — the date on which the batch operation is executed, used for business record dates. |
| `super.batchUserId` | `String` | The batch user ID — identifies which batch job / operator account performed the registration and update operations. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCBatCommon.getSysDateTimeStamp` | — | — | Retrieves the current system date-time stamp for the registration date (`sysAddDtm`) and update timestamp fields. Called 3 times. |
| R | `JKKBatCommon.getOpeDateTimeStamp(commonItem)` | — | — | Retrieves the operation date-time stamp for the subscription reception timestamp (`ssDate`). |
| R | `svcKeiMap.getString(JBSbatKK_T_SVC_KEI.SYSID)` | — | `KK_T_SVC_KEI` | Extracts the SYSID field from the service detail row, linking the subscription to the correct service line. |

**Note:** This method performs **no direct CRUD** (no insert/select/update/delete) operations itself. It is a pure parameter builder. All actual database interaction is deferred to the caller (`executeKK_T_MSKM_PKINSERT`), which receives the built `Object[]` and performs the insert into `KK_T_MSKM`.

## 5. Dependency Trace

### Callers of setMskmParam

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKHnsokuCdIktTrkm | `execute()` → `setMskmParam(svcKeiInfo, mskmNo)` | `executeKK_T_MSKM_PKINSERT [C] KK_T_MSKM` |

**From JBSbatKKHnsokuCdIktTrkm.execute() — full call chain:**
The batch entry `execute()` processes subscription registration. It retrieves service detail info into `svcKeiInfo`, then:
1. `executeKK_T_MSKM_PKINSERT(setMskmParam(svcKeiInfo, mskmNo))` — Creates the subscription header
2. `insertMskmDtl(svcKeiInfo, mskmNo, mskmDtlNo)` — Creates subscription detail records
3. `executeKK_T_DCHSKMST_PKINSERT(...)` — Creates data extraction items
4. `executeKK_T_DCHSKMST_TG_KEI_PKINSERT(...)` — Creates data extraction target contracts
5. `executeKK_T_PRG_PKINSERT(...)` — Creates progress records

### Terminal operations from setMskmParam

| Terminal Operation | Type | Target |
|-------------------|------|--------|
| `JCCBatCommon.getSysDateTimeStamp()` | R | System timestamp (called 3x) |
| `JKKBatCommon.getOpeDateTimeStamp(commonItem)` | R | Operation timestamp |
| `svcKeiMap.getString(JBSbatKK_T_SVC_KEI.SYSID)` | R | `KK_T_SVC_KEI.SYSID` |

## 6. Per-Branch Detail Blocks

### Block 1 — [CONSTRUCTOR] Object[] array literal construction (L4035)

> Creates a 54-element Object array. Each position maps to a column in the KK_T_MSKM table. The method builds the entire parameter array in a single expression — no loops, no conditionals.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setParam = new Object[54]` | // 申込テーブル (Subscription table) |
| 2 | SET | `setParam[0] = mskmNo` | // 申込番号 (Subscription number) |
| 3 | SET | `setParam[1] = JCCBatCommon.getSysDateTimeStamp()` | // 世代登録年月日時分秒 (Generation registration datetime) |
| 4 | SET | `setParam[2] = JKKStrConst.CD00060_130` | // 申込ステータス → CD00060_130 = "130" (申込ステータス 承認済) |
| 5 | SET | `setParam[3] = svcKeiMap.getString(JBSbatKK_T_SVC_KEI.SYSID)` | // SYSID (Service identifier) |
| 6 | SET | `setParam[4] = JKKStrConst.MSKM_SBT_CD_HNSK_MSKM` | // 申込種別コード → MSKM_SBT_CD_HNSK_MSKM = "00030" (販売促申込) |
| 7 | SET | `setParam[5] = null` | // 申込書到着年月日 (Subscription document arrival date) |
| 8 | SET | `setParam[6] = JKKBatCommon.getOpeDateTimeStamp(commonItem)` | // 申込受付年月日時分秒 (Subscription reception datetime) |
| 9 | SET | `setParam[7] = null` | // 申込受付担当者ユーザーID (Subscription reception operator user ID) |
| 10 | SET | `setParam[8] = super.opeDate` | // 申込年月日 (Subscription date) |
| 11 | SET | `setParam[9] = null` | // 総合営業センター受付番号 (General sales center reception number) |
| 12 | SET | `setParam[10] = null` | // 総合営業申込契約コード (General sales subscription contract code) |
| 13 | SET | `setParam[11] = null` | // 申込連絡先電話番号 (Subscription contact phone number) |
| 14 | SET | `setParam[12] = null` | // 申込実施者種別コード (Subscription implementer type code) |
| 15 | SET | `setParam[13] = null` | // お客様ご要望事項 (Customer request items) |
| 16 | SET | `setParam[14] = null` | // 電話連絡希望日種別コード (Phone contact preferred date type code) |
| 17 | SET | `setParam[15] = null` | // 電話連絡希望時間帯コード (Phone contact preferred time slot code) |
| 18 | SET | `setParam[16] = null` | // 自宅調査希望日種別コード (Home survey preferred date type code) |
| 19 | SET | `setParam[17] = null` | // 自宅調査希望時間帯コード (Home survey preferred time slot code) |
| 20 | SET | `setParam[18] = null` | // 申込保留年月日時分秒 (Subscription reservation datetime) |
| 21 | SET | `setParam[19] = null` | // 申込保留理由コード (Subscription reservation reason code) |
| 22 | SET | `setParam[20] = null` | // 申込保留解除年月日 (Subscription reservation release date) |
| 23 | SET | `setParam[21] = null` | // 申込差戻し年月日 (Subscription return date) |
| 24 | SET | `setParam[22] = null` | // 申込差戻し理由コード (Subscription return reason code) |
| 25 | SET | `setParam[23] = null` | // 仮申込フラグ (Provisional subscription flag) |
| 26 | SET | `setParam[24] = null` | // 申込内容確認完了年月日 (Subscription content confirmation complete date) |
| 27 | SET | `setParam[25] = null` | // 申込キャンセル年月日 (Subscription cancellation date) |
| 28 | SET | `setParam[26] = null` | // 申込キャンセル理由コード (Subscription cancellation reason code) |
| 29 | SET | `setParam[27] = null` | // 申込キャンセル取消年月日 (Subscription cancellation reversal date) |
| 30 | SET | `setParam[28] = null` | // リフィルタ (Re-filter — unused) |
| 31 | SET | `setParam[29] = null` | // 最終画面ID (Final screen ID) |
| 32 | SET | `setParam[30] = null` | // 申込内容承認申請年月日 (Subscription content approval application date) |
| 33 | SET | `setParam[31] = null` | // 申込内容承認年月日 (Subscription content approval date) |
| 34 | SET | `setParam[32] = null` | // 関西電力お客様情報授受同意有無 (Kansai Electric customer information consent) |
| 35 | SET | `setParam[33] = null` | // 代理店集計項目コード (Agency summary item code) |
| 36 | SET | `setParam[34] = null` | // 照会前連絡事項要否 (Pre-inquiry contact item necessity) |
| 37 | SET | `setParam[35] = null` | // 照会前連絡事項 (Pre-inquiry contact items) |
| 38 | SET | `setParam[36] = null` | // 利用サービス継続種別コード (Service continuation type code) |
| 39 | SET | `setParam[37] = null` | // アウトレングルメント希望有無 (Outrempling request availability) |
| 40 | SET | `setParam[38] = null` | // 差し中申込破棄年月日時分秒 (Discontinued subscription abandonment datetime) |
| 41 | SET | `setParam[39] = JKKStrConst.CD00760_04` | // コンシュマ事業用申込状態識別コード → CD00760_04 = "04" (申込状態識別コード 承認済) |
| 42 | SET | `setParam[40] = null` | // 受付担当者識別コード (Reception operator identification code) |
| 43 | SET | `setParam[41] = null` | // 工事依頼情報連絡事項 (Construction request information contact items) |
| 44 | SET | `setParam[42] = null` | // 申込経路識別コード (Subscription path identification code) |
| 45 | SET | `setParam[43] = null` | // 代理店申込取次有無 (Agency subscription forwarding availability) |
| 46 | SET | `setParam[44] = JCCBatCommon.getSysDateTimeStamp()` | // 登録年月日時分秒 (Registration datetime) |
| 47 | SET | `setParam[45] = super.batchUserId` | // 登録オペレーターアカウント (Registration operator account) |
| 48 | SET | `setParam[46] = JCCBatCommon.getSysDateTimeStamp()` | // 更新年月日時分秒 (Update datetime) |
| 49 | SET | `setParam[47] = super.batchUserId` | // 更新オペレーターアカウント (Update operator account) |
| 50 | SET | `setParam[48] = null` | // 削除年月日時分秒 (Deletion datetime) |
| 51 | SET | `setParam[49] = null` | // 削除オペレーターアカウント (Deletion operator account) |
| 52 | SET | `setParam[50] = JKKBatConst.S_MK_FLG` | // 無効フラグ → S_MK_FLG = "0" (無効フラグ) |
| 53 | SET | `setParam[51] = super.opeDate` | // 登録運用年月日 (Registration operation date) |
| 54 | SET | `setParam[52] = super.batchUserId` | // 登録処理ID (Registration process ID) |
| 55 | SET | `setParam[53] = super.opeDate` | // 更新運用年月日 (Update operation date) |
| 56 | SET | `setParam[54] = super.batchUserId` | // 更新処理ID (Update process ID) |
| 57 | SET | `setParam[55] = null` | // 削除運用年月日 (Deletion operation date) |
| 58 | SET | `setParam[56] = null` | // 削除処理ID (Deletion process ID) |

### Block 2 — [RETURN] Return parameter array (L4100)

> Returns the fully constructed parameter array to the caller for insertion into KK_T_MSKM.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return setParam` | // 申込テーブル登録用パラメータ (Parameters for subscription table registration) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|-----------------|
| `mskmNo` | Field | Subscription number (申込番号) — Unique identifier for a subscription header record in KK_T_MSKM. |
| `mskmDtlNo` | Field | Subscription detail number (申込詳細番号) — Unique identifier for subscription detail child records. |
| `svcKeiMap` | Field | Service detail line interface (サービス計上マップ) — Database row interface carrying service contract information including SYSID. |
| `SYSID` | Field | System ID — Unique identifier for a service detail line (KK_T_SVC_KEI), linking subscriptions to specific services. |
| `opeDate` | Field | Operator date (操作日) — Business date of the batch operation, stored as a string. |
| `batchUserId` | Field | Batch user ID (バッチユーザーID) — Identifies the batch job/operator that performed the operation. |
| `KK_T_MSKM` | Entity | Subscription master table (申込マスタテーブル) — Core table storing subscription header records. |
| `KK_T_MSKM_DTL` | Entity | Subscription detail table (申込詳細テーブル) — Child table storing line items within a subscription. |
| `KK_T_SVC_KEI` | Entity | Service detail table (サービス計上テーブル) — Table storing service contract line items. |
| `KK_T_DCHSKMST` | Entity | Data extraction items table (データ抽出項目テーブル) — Table for data extraction item settings. |
| `KK_T_PRG` | Entity | Progress table (進捗テーブル) — Table tracking batch processing progress. |
| `CD00060_130` | Constant | Subscription status: Approved (申込ステータス 承認済) — Value "130". |
| `CD00760_04` | Constant | Subscription state identification code: Approved (申込状態識別コード 承認済) — Value "04". |
| `MSKM_SBT_CD_HNSK_MSKM` | Constant | Subscription type code: Sales promotion subscription (申込種別コード 販売促申込) — Value "00030". |
| `MSKM_DTL_STAT_UKETSUKEZUMI` | Constant | Subscription detail status: Received (申込詳細ステータス 受付済み) — Value "010". |
| `S_MK_FLG` | Constant | Invalidation flag (無効フラグ) — Value "0" means record is inactive/not marked for deletion. |
| `TG_GAI_FLG_TG` | Constant | Discount auto-apply target flag: Target (割引自動適用対象外フラグ 対象) — Value "0" means eligible. |
| `CD_DIV_UM_NASHI` | Constant | Option service continuation: None (オプションサービス継承有無 なし) — Value "0". |
| CD | — | Code (コード) — Classification code prefix used throughout the system. |
| 申込 (Shin'you) | Business term | Subscription / Order — A customer order for a telecommunications service. |
| 販売促申込 | Business term | Sales promotion subscription — A subscription type triggered by sales/promotional activities. |
| 承認済 (Shounin-zumi) | Business term | Approved — Status indicating a subscription has passed approval. |
| 受付済み (Uketsuke-zumi) | Business term | Received — Status indicating a subscription detail has been accepted but not yet processed. |
| 無効 (Mukou) | Business term | Invalid / Inactive — Flag indicating a record is not active. |
| JCCBatCommon | Component | Batch common utility class — Provides system-wide timestamp and utility methods for batch processing. |
| JKKBatCommon | Component | KK batch common utility class — Provides operation-specific timestamp methods for KK batch. |
| JBSbatKKHnsokuCdIktTrkm | Class | KK Subscription addition confirmation service — Batch service for processing new subscription registrations. |
| executeKK_T_MSKM_PKINSERT | Method | Inserts a record into KK_T_MSKM using primary key — The actual database insert triggered after param building. |
| insertMskmDtl | Method | Registers subscription detail records — Called after setMskmParam to create child detail rows. |
