# Business Logic — JBSbatKKintrjhAdd.setDchskmstTgInfo() [46 LOC]

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

## 1. Role

### JBSbatKKintrjhAdd.setDchskmstTgInfo()

This method constructs the registration parameter set (a `String[27]` array) for the **Target Contract Master Table** (`DCHSKMST_TG`) used in batch processing. It takes a target contract sequence number and a service category number, then assembles a fully populated parameter array that will be inserted into the database as a new target contract master record. The method acts as a **data assembler / builder**, mapping incoming batch parameters into a standardized 27-field structure that conforms to the target table's schema. It includes system date stamping, sequence-based key generation, and populates audit fields (operation date, operation user ID, update system, update user) alongside static lifecycle values such as the effective start date and the far-future expiration date (`20991231`). This method implements the **Builder pattern** within the larger batch service flow — it does not branch or conditionally route, but deterministically populates every field position in the output array. Its role in the larger system is to prepare a single-row registration payload for the DCHSKMST_TG (Target Contract Master) table, which tracks contract line items eligible for service status targeting during the batch run.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setDchskmstTgInfo(seq_no_dchkmst, svcKeiNo)"])
    START --> S1["Get system date stamp via JCCBatCommon.getSysDateTimeStamp()"]
    S1 --> S2["Retrieve next sequence value from SEQ_DCHSKMST_TG_KEI_NO"]
    S2 --> S3["Format sequence to 12-digit zero-padded string via padNumFormString"]
    S3 --> S4["Initialize String[27] array (setParam)"]
    S4 --> S5["Populate fields 0-26:
  [0] = seq_no_dchkmst (target contract seq)
  [1] = seq_no_tg_kei_no (generated key)
  [2] = sysDate
  [3] = OYA_KEI_SKBT_CD_SVC_KEI = \"01\" (Parent service detail classification code — Service Detail)
  [4] = svcKeiNo
  [5-10] = \"\" (empty)
  [11] = super.opeDate
  [12] = super.opeDate
  [13] = \"20991231\" (expiration date)
  [14] = sysDate
  [15] = super.batchUserId
  [16] = sysDate
  [17] = super.batchUserId
  [18-19] = \"\" (empty)
  [20] = MK_FLG_YK = \"0\" (modification flag — No)
  [21-26] = \"\" (empty)"]
    S5 --> END(["Return setParam String[27]"])
```

### Constant Resolution

| Constant Name | Value | Business Meaning |
|---------------|-------|-----------------|
| `JBSbatKKConst.OYA_KEI_SKBT_CD_SVC_KEI` | `"01"` | Parent service detail classification code — indicates "Service Detail" type for the contract line item |
| `JBSbatKKConst.MK_FLG_YK` | `"0"` | Modification flag — "0" means no modification (new record flag) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `seq_no_dchkmst` | `String` | Target contract master sequence number — the unique identifier of the contract record being registered as a service target |
| 2 | `svcKeiNo` | `String` | Service category number — identifies the type of service (e.g., FTTH, Mail, ENUM) associated with this contract line item |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `super.opeDate` | `String` | Current operation date (from parent class) — used as operation date for both creation and update timestamps |
| `super.batchUserId` | `String` | Batch user ID — identifies the batch job as the operator performing this registration |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCBatCommon.getSysDateTimeStamp` | JCCBatCommon | - | Retrieves the current system date-time stamp for audit fields |
| R | `JBSbatOracleSeqUtil.getNextSeq` | JBSbatOracleSeqUtil | SEQ_DCHSKMST_TG_KEI_NO | Obtains the next sequence number for the target contract key (`SEQ_DCHSKMST_TG_KEI_NO`) |
| - | `JBSbatStringUtil.padNumFormString` | JBSbatStringUtil | - | Formats a number string to a fixed 12-character zero-padded representation |

**Notes:**
- No direct Create/Read/Update/Delete operations on DB tables occur within this method. It is a pure **parameter assembler** — all data retrieval (system date, sequence) is read-only.
- The entity table being targeted by the returned data is `DCHSKMST_TG` (Target Contract Master Table).

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `padNumFormString` [-], `getNextSeq` [R], `getSysDateTimeStamp` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JBSbatKKintrjhAdd.createSvcStaTgInf()` | `JBSbatKKintrjhAdd.createSvcStaTgInf()` -> `JBSbatKKintrjhAdd.setDchskmstTgInfo` | `padNumFormString [-], getNextSeq [R] SEQ_DCHSKMST_TG_KEI_NO, getSysDateTimeStamp [R]` |

## 6. Per-Branch Detail Blocks

This method has no conditional branching (no if/else, switch, or loops). It follows a single linear path from start to return.

**Block 1** — [LINEAR PROCESSING] `(No conditional branches)` (L1541)

> System date retrieval and sequence generation.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `sysDate = JCCBatCommon.getSysDateTimeStamp()` // Get system date (システム日付を取得) |
| 2 | CALL | `seq_no_tg_kei_no = JBSbatStringUtil.padNumFormString(JBSbatOracleSeqUtil.getNextSeq(super.commonItem.getConnection(), "SEQ_DCHSKMST_TG_KEI_NO"), 12)` // Generate sequence key (シーケンス採番) |

**Block 2** — [ARRAY INITIALIZATION] `(No condition)` (L1546)

> Initialize the 27-element parameter array.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String[] setParam = new String[27]` // Initialize parameter array |

**Block 3** — [FIELD POPULATION] `(Sequential assignment)` (L1548–L1577)

> Populate all 27 fields with target contract master registration data. The v22.00.00 changes updated field [3] from hardcoded "01" to the constant `OYA_KEI_SKBT_CD_SVC_KEI`, and field [20] from hardcoded "0" to `MK_FLG_YK`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `setParam[0] = seq_no_dchkmst` // Target contract master sequence number |
| 2 | SET | `setParam[1] = seq_no_tg_kei_no` // Generated target key number |
| 3 | SET | `setParam[2] = sysDate` // System date |
| 4 | SET | `setParam[3] = JBSbatKKConst.OYA_KEI_SKBT_CD_SVC_KEI` // [-> OYA_KEI_SKBT_CD_SVC_KEI="01"] Parent service detail classification code (v22.00.00: changed from hardcoded "01") |
| 5 | SET | `setParam[4] = svcKeiNo` // Service category number |
| 6 | SET | `setParam[5] = ""` // Empty field |
| 7 | SET | `setParam[6] = ""` // Empty field |
| 8 | SET | `setParam[7] = ""` // Empty field |
| 9 | SET | `setParam[8] = ""` // Empty field |
| 10 | SET | `setParam[9] = ""` // Empty field |
| 11 | SET | `setParam[10] = ""` // Empty field |
| 12 | SET | `setParam[11] = super.opeDate` // Operation date (creation) |
| 13 | SET | `setParam[12] = super.opeDate` // Operation date (update) |
| 14 | SET | `setParam[13] = "20991231"` // Effective expiration date (far future) |
| 15 | SET | `setParam[14] = sysDate` // Update system date |
| 16 | SET | `setParam[15] = super.batchUserId` // Update user ID |
| 17 | SET | `setParam[16] = sysDate` // Effective start date |
| 18 | SET | `setParam[17] = super.batchUserId` // Create user ID |
| 19 | SET | `setParam[18] = ""` // Empty field |
| 20 | SET | `setParam[19] = ""` // Empty field |
| 21 | SET | `setParam[20] = JBSbatKKConst.MK_FLG_YK` // [-> MK_FLG_YK="0"] Modification flag — no modification (v22.00.00: changed from hardcoded "0") |
| 22 | SET | `setParam[21] = ""` // Empty field |
| 23 | SET | `setParam[22] = ""` // Empty field |
| 24 | SET | `setParam[23] = ""` // Empty field |
| 25 | SET | `setParam[24] = ""` // Empty field |
| 26 | SET | `setParam[25] = ""` // Empty field |
| 27 | SET | `setParam[26] = ""` // Empty field |

**Block 4** — [RETURN] `(L1579)`

> Return the fully assembled parameter array.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return setParam` // Return String[27] registration payload for DCHSKMST_TG |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `seq_no_dchkmst` | Field | Target contract master sequence number — unique identifier of the contract record being registered |
| `seq_no_tg_kei_no` | Field | Target key number — generated sequence number used as the primary key for the contract line item in the target table |
| `svcKeiNo` | Field | Service category number — identifies the type of telecom service (e.g., FTTH, Mail) for the contract |
| `DCHSKMST_TG` | Table | Target Contract Master Table — batch table storing contract records eligible for service status targeting |
| `SEQ_DCHSKMST_TG_KEI_NO` | Sequence | Database sequence for generating unique key numbers in DCHSKMST_TG |
| `OYA_KEI_SKBT_CD_SVC_KEI` | Constant | Parent service detail classification code — "01" indicates a Service Detail type contract line item |
| `MK_FLG_YK` | Constant | Modification flag — "0" indicates no modification (new record); used to distinguish insert from update operations |
| `opeDate` | Field | Operation date — the current batch operation date from the parent class context |
| `batchUserId` | Field | Batch user ID — identifies the batch job as the operator performing the registration |
| `20991231` | Value | Far-future expiration date — standard placeholder indicating the record is valid indefinitely until explicitly cancelled |
