# Business Logic — JKKSeikyKeiHenkoCC.editInMsg_EKK1031D010() [356 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKSeikyKeiHenkoCC` |
| Layer | CC / Common Component (Controller/Common Component — business logic routing component) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKSeikyKeiHenkoCC.editInMsg_EKK1031D010()

This method creates the input message (CAANMsg template) for **credit card first-time authorization registration** — the core business operation that assembles all data fields required to register a new credit card for recurring billing in a telecom service contract lifecycle. The Javadoc states: "クレジット初回オーソリ登録のメッセージを作成します" (Create a message for credit first-time authorization registration).

The method handles **two functional modes** distinguished by the `FUNC_CODE_KEY` value: **mode "1"** (initial authorization request — sets the actual masked card number from the payment gateway) and **mode "2"** (check/verification — sets a dummy card number "0000000000000000" since first-time authorization only executes at final confirmation). Additionally, when `funcCd` is "2" or the contract registration datetime is missing, the method nullifies certain timestamp fields to skip their transmission.

The method implements a **builder pattern** — it creates a `CAANMsg` template, sets each field with null-safety checks, and assembles the result into a `CAANMsg[]` array placed in the parameter's mapping area. It acts as a **data transformation and routing layer**, reading from three sources: the `param` control map (operator ID, dates), the `dataMap` (functional code), and the `childMap` (raw billing/authorization data and payment-gateway results). When a **token** is present (indicing a modern payment gateway flow via PY), fields are sourced from the payment gateway's response objects; otherwise, they fall back to legacy `childMap` values. Its role in the larger system is to produce the canonical input message that will be dispatched to the downstream CBS (Centered Business System) for credit card authorization registration.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editInMsg_EKK1031D010"])

    START --> B1["B1: Common area setup - call editInMsg param"]
    B1 --> B2["B2: Create CAANMsg template from EKK1031D010CBSMsg"]
    B2 --> B3["B3: Set TEMPLATEID FUNC_CODE 1"]
    B3 --> B4["B4: Get operatorId operateDate operateDateTime from param"]
    B4 --> B5["B5: Get workMap from param"]
    B5 --> B6["B6: Get kksv040531sc from childMap"]
    B6 --> B7["B7: Get token from kksv040531sc"]
    B7 --> B8["B8: Overwrite FUNC_CODE from dataMap"]

    B8 --> B9{funcCd equals 2 or add DTM empty}
    B9 -->|Yes| B10["SEIKY_KEI_GENE_ADD_DTM null"]
    B9 -->|No| B11["SEIKY_KEI_GENE_ADD_DTM from childMap"]

    B10 --> B12{CRECARD way no empty}
    B11 --> B12

    B12 -->|Yes| B13["SEIKY_WAY_NO_CRECARD null"]
    B12 -->|No| B14["SEIKY_WAY_NO_CRECARD from childMap"]

    B13 --> B15{CRECARD gene DTM empty}
    B14 --> B15

    B15 -->|Yes| B16["CRECARD_GENE_ADD_DTM null"]
    B15 -->|No| B17["CRECARD_GENE_ADD_DTM from childMap"]

    B16 --> B18{SEIKY_KEI_NO empty}
    B17 --> B18

    B18 -->|Yes| B19["SEIKY_KEI_NO null"]
    B18 -->|No| B20["SEIKY_KEI_NO from childMap"]

    B19 --> B21["CRECARD_COMP_CD pyCardBrand"]
    B20 --> B21

    B21 --> B22{AUTH_TRAN_CD empty}
    B22 -->|Yes| B23["AUTH_TRAN_CD null"]
    B22 -->|No| B24["AUTH_TRAN_CD from childMap"]

    B23 --> B25{SALES_AMNT empty}
    B24 --> B25

    B25 -->|Yes| B26["SALES_AUTHORI_AMNT null"]
    B25 -->|No| B27["SALES_AUTHORI_AMNT from childMap"]

    B26 --> B28["Get pyMaskedCardNumber from kksv040531sc"]
    B27 --> B28

    B28 --> B29{funcCd equals 1}
    B29 -->|Yes| B30["CRECARD_NO pyMaskedCardNumber"]
    B29 -->|No| B31{funcCd equals 2}
    B30 --> B35["Set remaining fields from childMap"]
    B31 -->|Yes| B32["CRECARD_NO 0000000000000000"]
    B31 -->|No| B33["CRECARD_NO null"]
    B32 --> B35
    B33 --> B35

    B35 --> B36["Get list from kksv040532SC"]
    B36 --> B37["Extract membstrNo from list"]
    B37 --> B38["MEMBSTR_NO membstrNo"]

    B38 --> B39["Get pyCardValidTerm from kksv040531sc"]
    B39 --> B40{pyCardValidTerm null}
    B40 -->|Yes| B41["CRECARD_YK_KIGEN null"]
    B40 -->|No| B42["CRECARD_YK_KIGEN 20 plus validTerm"]

    B41 --> B43{AUTHORI_YOKYU_CD empty}
    B42 --> B43

    B43 -->|Yes| B44["AUTHORI_YOKYU_CD null"]
    B43 -->|No| B45["AUTHORI_YOKYU_CD from childMap"]

    B44 --> B46{TRN_FLG empty}
    B45 --> B46

    B46 -->|Yes| B47["TRN_FLG null"]
    B46 -->|No| B48["TRN_FLG from childMap"]

    B47 --> B49{CHSHT_FLG empty}
    B48 --> B49

    B49 -->|Yes| B50["CHSHT_FLG null"]
    B49 -->|No| B51["CHSHT_FLG from childMap"]

    B50 --> B52{CL_CD empty}
    B51 --> B52

    B52 -->|Yes| B53["CL_CD null"]
    B52 -->|No| B54["CL_CD from childMap"]

    B53 --> B55["Get pyAcqId from kksv040531sc"]
    B54 --> B55

    B55 --> B56["SHIKOSAKI_COMP_CD pyAcqId"]

    B56 --> B57{token null}
    B57 -->|Yes| B58["PAYMENT_ID null TRADING_ID null"]
    B57 -->|No| B59["Set PAYMENT_ID and TRADING_ID from kksv040531sc"]
    B58 --> B65["Get response code and detail from kksv040531sc"]
    B59 --> B60["Set PAYMENT_ID pyPaymentId MERCHANT_TRADING_ID pyTradingId"]
    B60 --> B65

    B65 --> B66["AUTH_RSLT_RSP_CD pyResponseCode"]
    B66 --> B67["AUTH_RSLT_RSP_DTL pyResponseDetail"]

    B67 --> B68["Create CAANMsg array put in paramMap"]
    B68 --> END(["Return paramMap"])
```

**Constant Resolution:**
- `FUNC_CODE_KEY` values: `"1"` = JPCModelConstant.FUNC_CD_1 (initial authorization request), `"2"` = FUNC_CD_2 (check/verification mode)
- `MAP_KEY_KKSV040531SC = "KKSV040531SC"` — childMap key holding the first-time authorization mapping data from screen KKSV040531
- `MAP_KEY_KKSV040532SC = "KKSV040532SC"` — childMap key holding the credit card company approval information mapping
- `JPCModelConstant.FUNC_CD_1 = "1"` — functional code for initial authorization
- `JPCModelConstant.FUNC_CD_2 = "2"` — functional code for check/verification

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Request parameter handler carrying the operator context (operator ID, operation date, operation time) via its control map, and the work area mapping. The method calls `editInMsg(param)` to initialize the common-area parameter map and sets the final template list into `param`'s mapping area. |
| 2 | `dataMap` | `Map<String, Object>` | Business data map containing the functional code (`JCMConstants.FUNC_CODE_KEY`) which determines whether this is an initial authorization (mode "1") or a check/verification (mode "2"). This controls card number handling logic. |
| 3 | `childMap` | `HashMap<String, Object>` | Child data map holding raw billing and authorization fields from prior screen processing, keyed by simple string identifiers (e.g., `"kksv040512_seiky_kei_no"`, `"kksv040512_auth_tran_cd"`). It also contains the `MAP_KEY_KKSV040531SC` entry (a HashMap with payment gateway response data including token, masked card number, card brand, valid term, acquiring company ID, customer ID) and `MAP_KEY_KKSV040532SC` entry (approval detail list with member store number). |

**Instance fields / external state:**
- `MAP_KEY_KKSV040531SC` (`"KKSV040531SC"`) — static constant, key for retrieving the initial authorization mapping from childMap
- `MAP_KEY_KKSV040532SC` (`"KKSV040532SC"`) — static constant, key for retrieving the credit card company approval mapping from childMap
- `PY_CARD_BRAND`, `PY_MASKED_CARD_NUMBER`, `PY_CARD_VALID_TERM`, `PY_RESPONSE_CODE`, `PY_RESPONSE_DETAIL`, `PY_ACQ_ID` — static constants mapping payment gateway field keys
- `JCMConstants.OPERATOR_ID_KEY`, `JCMConstants.OPERATE_DATE_KEY`, `JCMConstants.OPERATE_DATETIME_KEY`, `JCMConstants.TEMPLATE_LIST_KEY`, `JCMConstants.FUNC_CODE_KEY` — standard JCM framework constants

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JKKSeikyKeiHenkoCC.editInMsg` | - | - | Calls `editInMsg(param)` in `JKKSeikyKeiHenkoCC` — updates the parameter map with common area data for the request |
| R | `JACBatCommon.isNull` | - | - | Calls `isNull` in `JACBatCommon` — null-check utility for `pyCardValidTerm` |
| R | `JPCModelConstant.FUNC_CD_1` | - | - | Static constant reference: functional code `"1"` for initial authorization mode |
| R | `JPCModelConstant.FUNC_CD_2` | - | - | Static constant reference: functional code `"2"` for check/verification mode |

**Notes on SC Codes and Entities:**
This method does not directly call SC Codes or CBS methods. It is a **message-building (mapping) layer** that transforms raw data from `param`, `dataMap`, and `childMap` into a structured `CAANMsg` template and places it into the parameter mapping area. The `editInMsg` call is an internal helper on the same class. Actual SC/CBS dispatch happens upstream — this method feeds into `JKKSeikyKeiHenkoCC.execEKK1031D010()` which then invokes the downstream service components for the actual credit card authorization.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKSeikyKeiHenkoCC.execEKK1031D010` | `execEKK1031D010` -> `editInMsg_EKK1031D010` | `setNull` [-], `editInMsg [U] -` |

**Terminal operations from this method:**
- `editInMsg(param)` [U] — updates parameter map
- `template.setNull(...)` [U] — nullifies message fields (SEIKY_KEI_GENE_ADD_DTM, SEIKY_WAY_NO_CRECARD, CRECARD_GENE_ADD_DTM, CRECARD_NO, CRECARD_YK_KIGEN, AUTHORI_YOKYU_CD, TRN_FLG, CHSHT_FLG, CL_CD, CRECARD_NO_AZKRI_ID, PAYMENT_ID, MERCHANT_TRADING_ID)
- `template.set(...)` [U] — sets message fields on the CAANMsg template (18 fields total)
- `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` [U] — places template array into parameter map

**Call chain details:**
The only direct caller is `execEKK1031D010()` within the same class `JKKSeikyKeiHenkoCC`. This method is a CBS-level entry point that is invoked as part of the credit card first-time authorization registration workflow. The caller builds the `childMap` with authorization data before invoking this message-builder method, then uses the returned `paramMap` to dispatch the assembled template downstream.

## 6. Per-Branch Detail Blocks

### Block 1 — SET `(common area initialization)` (L4999-5007)

> Initialize common area and create the CAANMsg template.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `HashMap<String, Object> paramMap = editInMsg(param)` // calls parent/common message builder [-> sets common area in paramMap] |
| 2 | SET | `CAANMsg template = new CAANMsg(EKK1031D010CBSMsg.class.getName())` // creates template with CBS message schema |
| 3 | SET | `template.set(EKK1031D010CBSMsg.TEMPLATEID, TEMPLATE_ID_EKK1031D010)` // sets template ID |
| 4 | SET | `template.set(EKK1031D010CBSMsg.FUNC_CODE, "1")` // default functional code "1" (initial authorization) |
| 5 | EXEC | `Object operatorId = param.getControlMapData(SCControlMapKeys.OPERATOR_ID)` // get operator ID [-> user context] |
| 6 | SET | `template.set(JCMConstants.OPERATOR_ID_KEY, operatorId)` // set operator ID on template |
| 7 | EXEC | `Object operateDate = param.getControlMapData(SCControlMapKeys.OPE_DATE)` // operation date |
| 8 | SET | `template.set(JCMConstants.OPERATE_DATE_KEY, operateDate)` |
| 9 | EXEC | `Object operateDateTime = param.getControlMapData(SCControlMapKeys.OPE_TIME)` |
| 10 | SET | `template.set(JCMConstants.OPERATE_DATETIME_KEY, operateDateTime)` |

### Block 2 — SET `(retrieve work area and authorization mapping)` (L5023-5034)

> Get the work area mapping and the initial authorization child map (KKSV040531SC) containing payment gateway data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Map<Object, Object> workMap = param.getMappingWorkArea()` // get work area (unused in this method) |
| 2 | SET | `HashMap<String, Object> kksv040531sc = (HashMap<String, Object>)childMap.get(MAP_KEY_KKSV040531SC)` // ANK-3313-00-00 ADD [-> retrieves first-time authorization mapping; MAP_KEY_KKSV040531SC = "KKSV040531SC"] |
| 3 | SET | `String token = (String)kksv040531sc.get("token")` // ANK-3846-00-00 ADD [-> token from payment gateway session; presence indicates modern PY flow] |
| 4 | EXEC | `template.set(EKK1031D010CBSMsg.FUNC_CODE, dataMap.get(JCMConstants.FUNC_CODE_KEY))` // overwrite FUNC_CODE from dataMap [-> actual functional code; replaces default "1"] |

### Block 3 — IF/ELSE `(billing contract registration datetime)` (L5037-5044) `[funcCd equals "2" or empty]`

> Check and set the billing contract registration datetime. If check mode (funcCd="2") or the datetime is empty/missing, null it out.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String funcCd = (String)dataMap.get(JCMConstants.FUNC_CODE_KEY)` // extract functional code [-> FUNC_CD_1="1" or FUNC_CD_2="2"] |
| 2 | IF | `[funcCd equals "2" or "" equals childMap.get("ekk0491c240_gene_add_dtm") or !childMap.containsKey("ekk0491c240_gene_add_dtm")]` (L5039) — check mode or missing datetime |
| 3 | EXEC | `template.setNull(EKK1031D010CBSMsg.SEIKY_KEI_GENE_ADD_DTM)` |
| 4 | ELSE | (L5042) |
| 5 | EXEC | `template.set(EKK1031D010CBSMsg.SEIKY_KEI_GENE_ADD_DTM, (String)childMap.get("ekk0491c240_gene_add_dtm"))` |

### Block 4 — IF/ELSE `(billing method number — credit card)` (L5045-5054) `[empty or missing]`

> Set the billing method number. For credit card billing, this carries the card payment method code.

| # | Type | Code |
|---|------|------|
| 1 | IF | `[childMap.get("ekk0521d010_seiky_way_no_crecard") empty or missing]` (L5045) |
| 2 | EXEC | `template.setNull(EKK1031D010CBSMsg.SEIKY_WAY_NO_CRECARD)` |
| 3 | ELSE | (L5048) |
| 4 | EXEC | `template.set(EKK1031D010CBSMsg.SEIKY_WAY_NO_CRECARD, (String)childMap.get("ekk0521d010_seiky_way_no_crecard"))` |

### Block 5 — IF/ELSE `(credit card registration datetime)` (L5055-5064) `[empty or missing]`

> Set the credit card registration datetime.

| # | Type | Code |
|---|------|------|
| 1 | IF | `[childMap.get("ekk0521c030_gene_add_dtm") empty or missing]` (L5055) |
| 2 | EXEC | `template.setNull(EKK1031D010CBSMsg.CRECARD_GENE_ADD_DTM)` |
| 3 | ELSE | (L5058) |
| 4 | EXEC | `template.set(EKK1031D010CBSMsg.CRECARD_GENE_ADD_DTM, (String)childMap.get("ekk0521c030_gene_add_dtm"))` |

### Block 6 — IF/ELSE `(billing contract number)` (L5068-5075) `[empty or missing]`

> Set the billing contract number (seiky_kei_no), the unique contract identifier.

| # | Type | Code |
|---|------|------|
| 1 | IF | `[childMap.get("kksv040512_seiky_kei_no") empty or missing]` (L5068) |
| 2 | EXEC | `template.setNull(EKK1031D010CBSMsg.SEIKY_KEI_NO)` |
| 3 | ELSE | (L5071) |
| 4 | EXEC | `template.set(EKK1031D010CBSMsg.SEIKY_KEI_NO, (String)childMap.get("kksv040512_seiky_kei_no"))` |

### Block 7 — SET `(credit card company code — card brand)` (L5093-5099)

> Set the credit card company code. ANK-3846-00-00 migrated from generic card brand option code to the payment gateway card brand field.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String pyCardBrand = (String)kksv040531sc.get(PY_CARD_BRAND)` // ANK-3846-00-00 MOD [-> PY_CARD_BRAND = "py_card_brand"; payment gateway card brand (e.g., VISA, MasterCard)] |
| 2 | SET | `template.set(EKK1031D010CBSMsg.CRECARD_COMP_CD, pyCardBrand)` // credit card company code [-> migrated from EKKA0010001CBSMsg.CR_CARD_BRAND_OPTCD] |

### Block 8 — IF/ELSE `(authorization processing code)` (L5102-5109) `[empty or missing]`

> Set the authorization processing code (auth_tran_cd).

| # | Type | Code |
|---|------|------|
| 1 | IF | `[childMap.get("kksv040512_auth_tran_cd") empty or missing]` (L5102) |
| 2 | EXEC | `template.setNull(EKK1031D010CBSMsg.AUTH_TRAN_CD)` |
| 3 | ELSE | (L5105) |
| 4 | EXEC | `template.set(EKK1031D010CBSMsg.AUTH_TRAN_CD, (String)childMap.get("kksv040512_auth_tran_cd"))` |

### Block 9 — IF/ELSE `(sales authorization amount)` (L5112-5119) `[empty or missing]`

> Set the sales authorization amount.

| # | Type | Code |
|---|------|------|
| 1 | IF | `[childMap.get("kksv040512_sales_authori_amnt") empty or missing]` (L5112) |
| 2 | EXEC | `template.setNull(EKK1031D010CBSMsg.SALES_AUTHORI_AMNT)` |
| 3 | ELSE | (L5115) |
| 4 | EXEC | `template.set(EKK1031D010CBSMsg.SALES_AUTHORI_AMNT, (String)childMap.get("kksv040512_sales_authori_amnt"))` |

### Block 10 — IF/ELSE/ELSE `(credit card number — branch on functional code)` (L5140-5149)

> Set the credit card number. In **mode "1"** (initial authorization), use the actual masked card number from the payment gateway. In **mode "2"** (check), set a dummy "0000000000000000" since first-time authorization only executes at final confirmation. ANK-3846-00-00 migrated from inquiry card number to masked card number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String pyMaskedCardNumber = (String)kksv040531sc.get(PY_MASKED_CARD_NUMBER)` // ANK-3846-00-00 MOD [-> PY_MASKED_CARD_NUMBER = "py_masked_card_number"; masked card number from payment gateway] |
| 2 | IF | `[JPCModelConstant.FUNC_CD_1 equals dataMap.get(JCMConstants.FUNC_CODE_KEY)]` i.e., `funcCd equals "1"` (L5140) — ANK-2810-00-00 MOD: initial authorization request |
| 3 | EXEC | `template.set(EKK1031D010CBSMsg.CRECARD_NO, pyMaskedCardNumber)` // ANK-3846-00-00 MOD: use masked card number [-> comment: 機能コードが"1"の場合、初回オーソリ依存マッピング.問合せ用カード番号を設定する (When func code is "1", set the inquiry card number from first-time authorization mapping)] |
| 4 | ELSE-IF | `[JPCModelConstant.FUNC_CD_2 equals dataMap.get(JCMConstants.FUNC_CODE_KEY))]` i.e., `funcCd equals "2"` (L5147) — check/verification mode |
| 5 | EXEC | `template.set(EKK1031D010CBSMsg.CRECARD_NO, "0000000000000000")` // dummy card number [-> comment: 初回オーソリ依存は確定時のみ実行されているため、チェック用の仮カード番号を設定する (Set dummy card number for check; first-time authorization is only executed at confirmation)] |

### Block 11 — SET `(merchant store number from approval list)` (L5155-5175)

> Get the member/store number (MEMBSTR_NO, 15 digits) from the credit card company approval detail list. ANK-3313-00-00 replaced the legacy approach with direct lookup from kksv040532SC.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap<String, Object> kksv040532sc = (HashMap<String, Object>)childMap.get(MAP_KEY_KKSV040532SC)` // ANK-3313-00-00 MOD [-> MAP_KEY_KKSV040532SC = "KKSV040532SC"; credit card company approval mapping] |
| 2 | SET | `ArrayList<HashMap<String, Object>> ekk0531a010CBSMsgList = (ArrayList<HashMap<String, Object>>)kksv040532sc.get(EKK0531A010CBSMsg.EKK0531A010CBSMSG1LIST)` // approval detail list |
| 3 | SET | `String membstrNo = null` |
| 4 | IF | `[null not equals ekk0531a010CBSMsgList and size > 0]` (L5168) |
| 5 | SET | `membstrNo = (String)ekk0531a010CBSMsgList.get(0).get(EKK0531A010CBSMsg1List.MEMBSTR_NO_15)` // extract first entry's 15-digit member store number |
| 6 | EXEC | `template.set(EKK1031D010CBSMsg.MEMBSTR_NO, membstrNo)` // set merchant store number [-> comment: 加盟店番号] |

### Block 12 — IF/ELSE `(credit card validity period — with "20" prefix)` (L5178-5188) `[pyCardValidTerm is null]`

> Set the credit card validity period. ANK-3846-00-00 migrated from childMap to payment gateway field and adds "20" prefix to convert YYMM to 20YYMM format.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String pyCardValidTerm = (String)kksv040531sc.get(PY_CARD_VALID_TERM)` // ANK-3846-00-00 MOD [-> PY_CARD_VALID_TERM = "py_card_valid_term"; YYMM format validity period from payment gateway] |
| 2 | IF | `[JKKCommonUtil.isNull(pyCardValidTerm)]` (L5180) |
| 3 | EXEC | `template.setNull(EKK1031D010CBSMsg.CRECARD_YK_KIGEN)` |
| 4 | ELSE | (L5182) |
| 5 | EXEC | `template.set(EKK1031D010CBSMsg.CRECARD_YK_KIGEN, "20" + pyCardValidTerm)` // prepend "20" to convert YYMM to 20YYMM [-> comment: カード有効期限(YYMM -> 20YYMM変換) (Card validity period: YYMM to 20YYMM conversion)] |

### Block 13 — IF/ELSE `(authorization request code)` (L5188-5195) `[empty or missing]`

> Set the authorization request code (authori_yokyu_cd).

| # | Type | Code |
|---|------|------|
| 1 | IF | `[childMap.get("kksv040512_authori_yokyu_cd") empty or missing]` (L5188) |
| 2 | EXEC | `template.setNull(EKK1031D010CBSMsg.AUTHORI_YOKYU_CD)` |
| 3 | ELSE | (L5191) |
| 4 | EXEC | `template.set(EKK1031D010CBSMsg.AUTHORI_YOKYU_CD, (String)childMap.get("kksv040512_authori_yokyu_cd"))` |

### Block 14 — IF/ELSE `(process flag)` (L5198-5205) `[empty or missing]`

> Set the process flag (trn_flg) — transaction processing flag.

| # | Type | Code |
|---|------|------|
| 1 | IF | `[childMap.get("kksv040512_trn_flg") empty or missing]` (L5198) |
| 2 | EXEC | `template.setNull(EKK1031D010CBSMsg.TRN_FLG)` |
| 3 | ELSE | (L5201) |
| 4 | EXEC | `template.set(EKK1031D010CBSMsg.TRN_FLG, (String)childMap.get("kksv040512_trn_flg"))` |

### Block 15 — IF/ELSE `(extraction flag)` (L5208-5215) `[empty or missing]`

> Set the extraction flag (chsht_flg) — batch extraction flag.

| # | Type | Code |
|---|------|------|
| 1 | IF | `[childMap.get("kksv040512_chsht_flg") empty or missing]` (L5208) |
| 2 | EXEC | `template.setNull(EKK1031D010CBSMsg.CHSHT_FLG)` |
| 3 | ELSE | (L5211) |
| 4 | EXEC | `template.set(EKK1031D010CBSMsg.CHSHT_FLG, (String)childMap.get("kksv040512_chsht_flg"))` |

### Block 16 — IF/ELSE `(cancel code)` (L5218-5225) `[empty or missing]`

> Set the cancel code (cl_cd) — cancellation/reversal code.

| # | Type | Code |
|---|------|------|
| 1 | IF | `[childMap.get("kksv040512_cl_cd") empty or missing]` (L5218) |
| 2 | EXEC | `template.setNull(EKK1031D010CBSMsg.CL_CD)` |
| 3 | ELSE | (L5221) |
| 4 | EXEC | `template.set(EKK1031D010CBSMsg.CL_CD, (String)childMap.get("kksv040512_cl_cd"))` |

### Block 17 — SET `(acquiring company code)` (L5230-5236)

> Set the downstream company code. ANK-3846-00-00 migrated from the legacy credit exchange code (EKKA0010001CBSMsg.CR_BRANDCODE) to the payment gateway acquiring ID. ANK-2565-00-00 ADD added this section.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String pyAcqId = (String)kksv040531sc.get(PY_ACQ_ID)` // ANK-3846-00-00 MOD [-> PY_ACQ_ID from EKKA0010003CBSMsg; acquiring/payment processor company ID] |
| 2 | SET | `template.set(EKK1031D010CBSMsg.SHIKOSAKI_COMP_CD, pyAcqId)` // downstream company code [-> comment: 仕向け先会社コード (Destination company code)] |

### Block 18 — IF/ELSE `(token-based — payment ID / merchant trading ID)` (L5237-5255) `[token is null]`

> ANK-3846-00-00 ADD: When a payment gateway token is present, nullify the payment ID and merchant trading ID (they are managed by the tokenized session). Otherwise, fetch them from the payment gateway result.

| # | Type | Code |
|---|------|------|
| 1 | IF | `[!JKKCommonUtil.isNull(token)]` i.e., token is NOT null (L5240) — payment gateway token flow |
| 2 | EXEC | `template.setNull(EKK1031D010CBSMsg.PAYMENT_ID)` // payment ID [-> comment: 決済ID] |
| 3 | EXEC | `template.setNull(EKK1031D010CBSMsg.MERCHANT_TRADING_ID)` // merchant trading ID [-> comment: マーチャント取引ID] |
| 4 | ELSE | (L5246) — legacy fallback |
| 5 | SET | `String pyPaymentId = (String)kksv040531sc.get(EKKA0010004CBSMsg.PY_PAYMENT_ID)` // ANK-3846-00-00 MOD [-> payment ID from payment gateway] |
| 6 | SET | `template.set(EKK1031D010CBSMsg.PAYMENT_ID, pyPaymentId)` |
| 7 | SET | `String pyTradingId = (String)kksv040531sc.get(EKKA0010004CBSMsg.PY_TRADING_ID)` [-> merchant trading/deal ID from payment gateway] |
| 8 | SET | `template.set(EKK1031D010CBSMsg.MERCHANT_TRADING_ID, pyTradingId)` |

### Block 19 — SET `(authorization result response code and detail)` (L5257-5263)

> Set the authorization result response code and detail from the payment gateway response. ANK-3846-00-00 ADD.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String pyResponseCode = (String)kksv040531sc.get(PY_RESPONSE_CODE)` [-> PY_RESPONSE_CODE = "py_response_code"; authorization result response code] |
| 2 | SET | `template.set(EKK1031D010CBSMsg.AUTH_RSLT_RSP_CD, pyResponseCode)` [-> comment: オーソリ結果応答コード (Authorization result response code)] |
| 3 | SET | `String pyResponseDetail = (String)kksv040531sc.get(PY_RESPONSE_DETAIL)` [-> PY_RESPONSE_DETAIL = "py_response_detail"; authorization result response detail] |
| 4 | SET | `template.set(EKK1031D010CBSMsg.AUTH_RSLT_RSP_DTL, pyResponseDetail)` [-> comment: オーソリ結果応答詳細 (Authorization result response detail)] |

### Block 20 — RETURN `(assemble template array and return)` (L5265-5269)

> Create a `CAANMsg[]` array containing the single template, place it in the paramMap under `JCMConstants.TEMPLATE_LIST_KEY`, and return.

| # | Type | Code |
|---|------|------|
| 1 | SET | `CAANMsg[] templates = new CAANMsg[1]` |
| 2 | SET | `templates[0] = template` |
| 3 | SET | `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` // place assembled template list in parameter map |
| 4 | RETURN | `return paramMap` [-> HashMap<String, Object> containing the fully-built CAANMsg template array] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `seiky_kei_gene_add_dtm` | Field | Billing contract registration datetime — when the billing contract line item was registered |
| `seiky_way_no_crecard` | Field | Billing method number (credit card) — identifies the credit card as the billing payment method |
| `crecard_gene_add_dtm` | Field | Credit card registration datetime — when the credit card was first registered in the system |
| `seiky_kei_no` | Field | Billing contract number — unique identifier for a billing contract line item |
| `crecard_comp_cd` | Field | Credit card company code — identifies the card brand/issuer (e.g., VISA, MasterCard) |
| `py_card_brand` | Field | Payment gateway card brand — card brand code from the payment gateway response (PY = Payment) |
| `auth_tran_cd` | Field | Authorization processing code — type of authorization transaction (e.g., sale, installment) |
| `sales_authori_amnt` | Field | Sales authorization amount — the monetary amount authorized by the card network |
| `crecard_no` | Field | Credit card number — masked card number used for authorization |
| `py_masked_card_number` | Field | Payment gateway masked card number — partially redacted card number from the PY system (e.g., "4111********1234") |
| `membstr_no` | Field | Merchant store number (15 digits) — identifies the merchant/store accepting the payment |
| `crecard_yk_kigen` | Field | Credit card validity period — expiration date in YYYYMM format (converted from YYMM with "20" prefix) |
| `py_card_valid_term` | Field | Payment gateway card validity term — YYMM format expiration from the PY system |
| `authori_yokyu_cd` | Field | Authorization request code — code specifying the type of authorization request |
| `trn_flg` | Field | Process/transaction flag — indicates the processing state of the transaction |
| `chsht_flg` | Field | Extraction flag — batch extraction processing flag |
| `cl_cd` | Field | Cancel code — cancellation or reversal code |
| `crecard_no_azkri_id` | Field | Credit card number reservation ID — ID reserved for the credit card number (used when token is absent) |
| `py_customer_id` | Field | Payment gateway customer ID — customer identifier from the payment gateway (used as reservation ID when token exists) |
| `payment_id` | Field | Payment ID — payment transaction identifier from the payment gateway |
| `merchant_trading_id` | Field | Merchant trading ID — merchant deal/trade identifier from the payment gateway |
| `py_payment_id` | Field | Payment gateway payment ID |
| `py_trading_id` | Field | Payment gateway trading ID |
| `auth_rslt_rsp_cd` | Field | Authorization result response code — response code from the card network authorization |
| `auth_rslt_rsp_dtl` | Field | Authorization result response detail — detailed response from the card network authorization |
| `shikosaki_comp_cd` | Field | Downstream company code — the acquiring/processing company code for card transactions |
| `py_acq_id` | Field | Payment gateway acquiring ID — the payment processor/acquirer company identifier |
| `token` | Field | Payment gateway session token — indicates a modern PY (Payment) flow; presence triggers token-based field sourcing |
| `kksv040531sc` | Field | ChildMap entry — initial authorization mapping data from screen KKSV040531 (first-time credit card authorization) |
| `kksv040532sc` | Field | ChildMap entry — credit card company approval detail mapping from screen KKSV040532 |
| `kksv040512_*` | Fields | Legacy childMap key prefix — raw billing/authorization fields from screen KKSV040512 |
| FUNC_CODE_KEY | Constant | Functional code key — determines processing mode ("1" = initial authorization, "2" = check/verification) |
| CAANMsg | Class | Common Authorization And Notification Message — the message template class used to assemble CBS input data |
| EKK1031D010CBSMsg | Class | CBS message constant class for EKK1031 (credit card first-time authorization registration) |
| EKK0531A010CBSMsg | Class | CBS message constant class for EKK0531A010 (credit card company approval detail) |
| PY | Prefix | Payment — indicates payment gateway fields (as opposed to legacy internal system fields) |
| editInMsg | Method | Internal common area message builder — initializes the parameter map with shared/common data |
| JKKCommonUtil.isNull | Method | Utility null-check method for String/Object values |
| JPCModelConstant | Class | JPC (JCM Payment Component) model constant definitions (FUNC_CD_1, FUNC_CD_2) |
| IRequestParameterReadWrite | Interface | Request parameter interface — provides access to control map data (operator ID, dates) and mapping work areas |
| MAP_KEY_KKSV040531SC | Constant | "KKSV040531SC" — childMap key for initial authorization mapping |
| MAP_KEY_KKSV040532SC | Constant | "KKSV040532SC" — childMap key for credit card company approval mapping |
| SCREEN KKSV040531 | Screen | Screen for first-time credit card authorization processing |
| SCREEN KKSV040532 | Screen | Screen for credit card company approval detail processing |
| SCREEN KKSV040512 | Screen | Screen for billing contract number and authorization data entry |