---

# Business Logic — JBSbatKKAdChgPlaceNoChgRnki.execute() [86 LOC]

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

## 1. Role

### JBSbatKKAdChgPlaceNoChgRnki.execute()

This method implements the **Location Number Change Integration** (住所変更場所番号変更連联动部品) for K-Opticom's customer backbone system. Its primary responsibility is to process the transfer of service contracts (SVC contracts) from a pre-migration location to a post-migration location — i.e., updating the "location number" (place number) associated with service lines after a customer has moved premises.

The method follows a **two-phase batch dispatch pattern**. When invoked with a `null` inMap (the post-batch "flush" phase), it iterates over all accumulated output items collected during the batch run, enriches each item with device model code, device serial number, device change reason code, post-change installation place number, service contract number, and the prior service contract number (obtained via a DB lookup on `KK_T_ADCHG_DTL`), then forwards the enriched batch to an external ES integration service (`JCCBatchEsbInterface.invokeService`) identified by use case `KKSV0711` and operation `KKSV0711OP`. If the integration returns a non-success return code, a `JBSbatBusinessException` (EKKB0270CE) is thrown.

When invoked with a non-null `inMap` (the in-batch "accumulate" phase), it performs input validation on the incoming record — checking each required field (device model code, device serial number, device change reason code, post-change installation place number, and service contract number) via `isSingleCheckKKIFM270_INF1`. If validation passes, the record is appended to the output list and returned immediately so the caller can continue accumulating. If validation fails, a `JBSbatBusinessException` (EKKB0090TE) is thrown indicating the row number of the error.

The method is instantiated and managed by `JBSbatKKAdChgCstScreenKidou` (Batch `KKSV0711`), which calls `execute(null, outputItem)` as the final step to trigger the post-batch flush. It is also invoked indirectly from the BPM side via `JKKAdChgPlaceNoChgRnkiCC.addChgPlaceNo` and `JKKKktkSvcSendAdchgCC` in screens `KKSV0674`, `KKSV0698`, `KKSV0325`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute inMap outputInItem"])
    START --> C1{"inMap == null"}
    C1 -->|true| C2{"outputInItem null or list empty"}
    C1 -->|false| C3{"isSingleCheckKKIFM270_INF1 valid"}
    C2 -->|true| R1["return null"]
    C2 -->|false| L1["Loop over outputInItem.getOutMapList"]
    L1 --> E1["Extract data fields into trgtData HashMap"]
    E1 --> E2["getBfSvcKeiNo lookup prior service contract"]
    E2 --> C4{"bfSvcKeiNo not empty"}
    C4 -->|yes| E3["Add bf_svc_kei_no to trgtData"]
    C4 -->|no| E4["Add trgtData to trgDataList"]
    E3 --> E4
    E4 --> C5{"More loop items"}
    C5 -->|yes| L1
    C5 -->|no| M1["Set USECASE_ID OPERATION_ID FIXED_TEXT in maps"]
    M1 --> M2["JCCBatchEsbInterface.invokeService"]
    M2 --> C6{"returnCode equals SUCCESS"}
    C6 -->|false| E5["throw JBSbatBusinessException EKKB0270CE"]
    C6 -->|true| R2["return outputInItem post-batch"]
    E5 --> END(["End"])
    R2 --> END
    C3 -->|false| E6["throw JBSbatBusinessException EKKB0090TE"]
    C3 -->|true| E7["outputInItem.addOutMapList inMap"]
    E7 --> R3["return outputInItem during-batch"]
    E6 --> END
    R3 --> END
    R1 --> END
```

**Phase 1 — Post-batch flush (`inMap == null`)**

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | COND | `if (inMap == null)` | Determines if this is the final flush call. Constant: `USECASE_ID = "KKSV0711"`, `OPERATION_ID = "KKSV0711OP"` |
| 2 | COND | `if (outputInItem == null || outputInItem.getOutMapList().isEmpty())` | If no accumulated items, return null early |
| 3 | INIT | `trgDataList = new ArrayList<HashMap<String, Object>>()` | Prepare the list of enriched data items |
| 4 | LOOP | `for (int i = 0; i < outputInItem.getOutMapList().size(); i++)` | Iterate over each accumulated item |
| 5 | SET | `trgMap = (JBSbatServiceInterfaceMap) outputInItem.getOutMapList().get(i)` | Cast list item to service interface map |
| 6 | SET | `trgtData = new HashMap<String, Object>()` | Create new data map for this item |
| 7 | SET | `trgtData.put("taknkiki_model_cd", trgMap.getString(JBSbatKKIFM270.TAKNKIKI_MODEL_CD))` | Extract device model code — Field: 家中機器型式コード |
| 8 | SET | `trgtData.put("kiki_seizo_no", trgMap.getString(JBSbatKKIFM270.KIKI_SEIZO_NO))` | Extract device serial number — Field: 機器製造番号 |
| 9 | SET | `trgtData.put("kiki_chg_rsn_cd", trgMap.getString(JBSbatKKIFM270.KIKI_CHG_RSN_CD))` | Extract device change reason code — Field: 機器変更理由コード |
| 10 | SET | `trgtData.put("setplace_no", trgMap.getString(JBSbatKKIFM270.KIKI_STC_SAKI_PLACE_NO))` | Extract post-change installation place number — Field: 設置場所番号 |
| 11 | SET | `trgtData.put("svc_kei_no", trgMap.getString(JBSbatKKIFM270.SVC_KEI_NO))` | Extract service contract number — Field: サービス契約番号 |
| 12 | CALL | `getBfSvcKeiNo(trgMap.getString(JBSbatKKIFM270.SVC_KEI_NO))` | Lookup prior service contract number from DB table `KK_T_ADCHG_DTL` |
| 13 | COND | `if (!JKKStringUtil.isNullSpace(bfSvcKeiNo))` | Check if prior service contract exists |
| 14 | SET | `trgtData.put("bf_svc_kei_no", bfSvcKeiNo)` | Add prior service contract number to data |
| 15 | SET | `trgDataList.add(trgtData)` | Add enriched data item to list |
| 16 | INIT | `paramMap = new HashMap<>()` | Build ES invocation parameter map |
| 17 | INIT | `inputMap = new HashMap<>()` | Build input payload map |
| 18 | INIT | `outputMap = new HashMap<>()` | Build output map for response |
| 19 | SET | `paramMap.put(JCCBatchEsbInterface.TELEGRAM_INFO_USECASE_ID, USECASE_ID)` | Set use case ID constant: `KKSV0711` |
| 20 | SET | `paramMap.put(JCCBatchEsbInterface.TELEGRAM_INFO_OPERATION_ID, OPERATION_ID)` | Set operation ID constant: `KKSV0711OP` |
| 21 | SET | `inputMap.put(FIXED_TEXT, trgDataList)` | Set fixed text key: `KKSV071101CC`, attach enriched data |
| 22 | CALL | `JCCBatchEsbInterface.invokeService(super.commonItem, paramMap, inputMap, outputMap)` | Invoke ES integration service |
| 23 | SET | `returnCode = outputMap.get(JCCBatchEsbInterface.RETURN_CODE).toString()` | Get return code from response |
| 24 | COND | `if (!JCCBatchEsbInterface.RETURN_CODE_SUCCESS.equals(returnCode))` | Check if ES service succeeded |
| 25 | THROW | `throw new JBSbatBusinessException(JPCBatchMessageConstant.EKKB0270CE, new String[]{"住所変更場所番号変更連联动"})` | Throw exception on failure |
| 26 | RETURN | `return outputInItem` | Return accumulated output after successful flush |

**Phase 2 — In-batch accumulation (`inMap != null`)**

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `isSingleCheckKKIFM270_INF1(inMap.getMap(), getItemvalueMap())` | Validate required fields of incoming record |
| 2 | COND | `if (validation returns false)` | Check if validation passed |
| 3 | SET | `length = outputInItem.getOutMapList().size()` | Get current count of items |
| 4 | THROW | `throw JBSbatBusinessException(EKKB0090TE, ... + "行目")` | Throw error for specific row number |
| 5 | SET | `outputInItem.addOutMapList(inMap)` | Append validated record to output list |
| 6 | RETURN | `return outputInItem` | Return during-batch accumulation |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | The input message envelope carrying a single location change record. During the in-batch phase (non-null), it contains validated fields such as `TAKNKIKI_MODEL_CD` (device model code), `KIKI_SEIZO_NO` (device serial number), `KIKI_CHG_RSN_CD` (device change reason code), `KIKI_STC_SAKI_PLACE_NO` (post-change installation place number), and `SVC_KEI_NO` (service contract number). During the post-batch flush phase, this is `null` to signal the end-of-batch trigger. |
| 2 | `outputInItem` | `JBSbatOutputItem` | The output accumulator that holds a list of `JBSbatServiceInterfaceMap` records collected during the batch run. During in-batch processing, records are appended to its list via `addOutMapList()`. During post-batch flush, the method iterates over its list to enrich and forward all records. Can be `null` in which case the method returns `null`. |

**Instance fields / external state read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `commonItem` | `JBSbatCommonItem` | Common batch parameter envelope (inherited from `JBSbatBusinessService`), carries job context, logging, and ES service invocation settings. |
| `db_KK_T_ADCHG_DTL` | `JBSbatSQLAccess` | DB access object for table `KK_T_ADCHG_DTL` (Location Change Detail Table), used to look up prior service contract identifiers. Initialized in `initial()`. |
| `USECASE_ID` | `String` | Constant `"KKSV0711"` — the ES use case ID for the location change integration. |
| `OPERATION_ID` | `String` | Constant `"KKSV0711OP"` — the ES operation ID. |
| `FIXED_TEXT` | `String` | Constant `"KKSV071101CC"` — the fixed text key used in the ES input payload. |
| `D_TBL_NAME_KK_T_ADCHG_DTL` | `String` | Constant `"KK_T_ADCHG_DTL"` — the database table name for location change detail data. |
| `KK_T_ADCHG_DTL_KK_SELECT_023` | `String` | Constant `"KK_SELECT_023"` — the SQL define key for querying the prior service contract identifier. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKAdChgPlaceNoChgRnki.getBfSvcKeiNo` | - | `KK_T_ADCHG_DTL` | Reads prior service contract identifier (`CHBF_SKBT_NO`) from location change detail table via SQL key `KK_SELECT_023` |
| C | `JCCBatchEsbInterface.invokeService` | - | - | Invokes the ES integration service for location change data transmission (creates outbound integration records) |
| R | `JBSbatKKAdChgPlaceNoChgRnki.isSingleCheckKKIFM270_INF1` | - | - | Validates individual fields of the input record (no DB access, in-memory validation only) |
| R | `JBSbatKKAdChgPlaceNoChgRnki.getItemvalueMap` | - | - | Returns error message text mapping for validation error reporting |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch:JBSbatKKAdChgCstScreenKidou | `JBSbatKKAdChgCstScreenKidou.execute` -> `execRunObjPlaceNoChg.execute(outMap, outputItemPlaceNoChg)` | `getBfSvcKeiNo [R] KK_T_ADCHG_DTL`; `invokeService [C] ES Integration` |
| 2 | Screen:KKSV0711 | `KKSV0711OPOperation.run` -> `KKKktkSvcSendAdchgCC.addChgPlaceNo` -> (BPM flow) -> batch dispatch | `getBfSvcKeiNo [R] KK_T_ADCHG_DTL`; `invokeService [C] ES Integration` |
| 3 | Screen:KKSV0674 | `KKSV0674OPOperation.run` -> `JKKKktkSvcSendAdchgCC.kktkSvcSendAdchg` -> `placeNoChgRnkiCC.addChgPlaceNo` | `getBfSvcKeiNo [R] KK_T_ADCHG_DTL`; `invokeService [C] ES Integration` |
| 4 | Screen:KKSV0698 | `KKSV0698OPOperation.run` -> `JKKKktkSvcSendAdchgCC.kktkSvcSendAdchg` -> `placeNoChgRnkiCC.addChgPlaceNo` | `getBfSvcKeiNo [R] KK_T_ADCHG_DTL`; `invokeService [C] ES Integration` |
| 5 | Screen:KKSV0325 | `KKSV0325OPOperation.run` -> `JKKKktkSvcSendAdchgCC.kktkSvcSendAdchgReUpd` -> `placeNoChgRnkiCC.addChgPlaceNo` | `getBfSvcKeiNo [R] KK_T_ADCHG_DTL`; `invokeService [C] ES Integration` |

## 6. Per-Branch Detail Blocks

### Block 1 — IF `(inMap == null)` [Post-batch flush phase] (L92)

> When `inMap` is null, this indicates the end-of-batch flush. The method iterates over all accumulated output items collected during in-batch processing, enriches them with device and prior-contract data, and forwards them to the ES integration service.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | COND | `if (inMap == null)` | Phase 1: post-batch flush signal |

#### Block 1.1 — IF `(outputInItem == null || outputInItem.getOutMapList().isEmpty())` (L99)

> If there are no items to process, return null immediately.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | COND | `if (outputInItem == null || outputInItem.getOutMapList().isEmpty())` | No accumulated items |
| 2 | RETURN | `return null` | Early return: no data to process |

#### Block 1.2 — FOR LOOP `[outputInItem.getOutMapList().size() iterations]` (L104)

> Iterate over each accumulated output item, extract and enrich its data fields.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | INIT | `trgDataList = new ArrayList<HashMap<String, Object>>()` | Create enriched data list |
| 2 | SET | `trgMap = (JBSbatServiceInterfaceMap) outputInItem.getOutMapList().get(i)` | Get item at index i |
| 3 | SET | `trgtData = new HashMap<String, Object>()` | Create new data map |
| 4 | SET | `trgtData.put("taknkiki_model_cd", trgMap.getString(JBSbatKKIFM270.TAKNKIKI_MODEL_CD))` | Extract device model code [-> TAKNKIKI_MODEL_CD = "TAKNKIKI_MODEL_CD"] |
| 5 | SET | `trgtData.put("kiki_seizo_no", trgMap.getString(JBSbatKKIFM270.KIKI_SEIZO_NO))` | Extract device serial number [-> KIKI_SEIZO_NO = "KIKI_SEIZO_NO"] |
| 6 | SET | `trgtData.put("kiki_chg_rsn_cd", trgMap.getString(JBSbatKKIFM270.KIKI_CHG_RSN_CD))` | Extract device change reason code [-> KIKI_CHG_RSN_CD = "KIKI_CHG_RSN_CD"] |
| 7 | SET | `trgtData.put("setplace_no", trgMap.getString(JBSbatKKIFM270.KIKI_STC_SAKI_PLACE_NO))` | Extract post-change installation place number [-> KIKI_STC_SAKI_PLACE_NO = "KIKI_STC_SAKI_PLACE_NO"] |
| 8 | SET | `trgtData.put("svc_kei_no", trgMap.getString(JBSbatKKIFM270.SVC_KEI_NO))` | Extract service contract number [-> SVC_KEI_NO = "SVC_KEI_NO"] |
| 9 | CALL | `getBfSvcKeiNo(trgMap.getString(JBSbatKKIFM270.SVC_KEI_NO))` | Lookup prior service contract number |
| 10 | SET | `trgDataList.add(trgtData)` | Add enriched item to list |
| 11 | LOOP | `i++` | Advance loop counter |

##### Block 1.2.1 — IF `(!JKKStringUtil.isNullSpace(bfSvcKeiNo))` [IKK-2013-0000707] (L115)

> When the prior service contract number is found for the given service contract, add it to the enriched data.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `executeKK_T_ADCHG_DTL_KK_SELECT_023(new String[]{svcKeiNo})` | Query DB for prior contract identifier using SQL key `KK_SELECT_023` on table `KK_T_ADCHG_DTL` |
| 2 | SET | `adchgDtlInf = db_KK_T_ADCHG_DTL.selectNext()` | Fetch the query result row |
| 3 | COND | `if (adchgDtlInf != null)` | Check if result found |
| 4 | RETURN | `adchgDtlInf.getString(JBSbatKK_T_ADCHG_DTL.CHBF_SKBT_NO)` | Return prior service contract identifier [-> CHBF_SKBT_NO = "CHBF_SKBT_NO"] |
| 5 | RETURN | `return null` | No prior contract found |
| 6 | COND | `if (!JKKStringUtil.isNullSpace(bfSvcKeiNo))` | Prior contract exists |
| 7 | SET | `trgtData.put("bf_svc_kei_no", bfSvcKeiNo)` | Add prior service contract number [-> bf_svc_kei_no = prior SVC contract number] |

#### Block 1.3 — Post-loop ES invocation (L128)

> After collecting all enriched data, invoke the ES integration service to transmit the batch.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | INIT | `paramMap = new HashMap<String, Object>()` | Create parameter map |
| 2 | INIT | `inputMap = new HashMap<String, Object>()` | Create input map |
| 3 | INIT | `outputMap = new HashMap<String, Object>()` | Create output map |
| 4 | SET | `paramMap.put(JCCBatchEsbInterface.TELEGRAM_INFO_USECASE_ID, USECASE_ID)` | Set use case ID [-> USECASE_ID = "KKSV0711"] |
| 5 | SET | `paramMap.put(JCCBatchEsbInterface.TELEGRAM_INFO_OPERATION_ID, OPERATION_ID)` | Set operation ID [-> OPERATION_ID = "KKSV0711OP"] |
| 6 | SET | `inputMap.put(FIXED_TEXT, trgDataList)` | Set fixed text key [-> FIXED_TEXT = "KKSV071101CC"] with enriched data list |
| 7 | CALL | `JCCBatchEsbInterface.invokeService(super.commonItem, paramMap, inputMap, outputMap)` | Call ES integration service |
| 8 | SET | `returnCode = outputMap.get(JCCBatchEsbInterface.RETURN_CODE).toString()` | Extract return code |
| 9 | COND | `if (!JCCBatchEsbInterface.RETURN_CODE_SUCCESS.equals(returnCode))` | Check return code |
| 10 | THROW | `throw new JBSbatBusinessException(JPCBatchMessageConstant.EKKB0270CE, new String[]{"住所変更場所番号変更連联动"})` | Business exception on failure |
| 11 | RETURN | `return outputInItem` | Return accumulated output after successful flush |

### Block 2 — ELSE `(inMap != null)` [In-batch accumulation phase] (L143)

> When `inMap` is non-null, this is an in-batch call. The method validates the incoming record and appends it to the output list for later batch processing.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | COND | `if (!isSingleCheckKKIFM270_INF1(inMap.getMap(), getItemvalueMap()))` | Validate incoming record fields |
| 2 | SET | `length = outputInItem.getOutMapList().size()` | Get current item count |
| 3 | THROW | `throw JBSbatBusinessException(EKKB0090TE, (length+1) + "行目")` | Throw error for failing row |
| 4 | SET | `outputInItem.addOutMapList(inMap)` | Append validated record to output list |
| 5 | RETURN | `return outputInItem` | Return during-batch accumulated output |

### Block 3 — RETURN (final line) (L166)

> Fallback return after the if-else block (reaches only if inMap is null and outputInItem was not null after the flush phase).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return outputInItem` | Return the output accumulator |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service Contract Number — the unique identifier for a telecom service line/contract. Also displayed as `SVC_KEI_NO` in file formats. |
| `bf_svc_kei_no` | Field | Before-service Contract Number — the original service contract number before location change migration. |
| `taknkiki_model_cd` | Field | Device Model Code — the model identifier for in-home customer premises equipment (CPE). |
| `kiki_seizo_no` | Field | Device Serial Number — the manufacturing serial number of the CPE device. |
| `kiki_chg_rsn_cd` | Field | Device Change Reason Code — the reason code for replacing/changes to the CPE device (2 characters, half-width numeric). |
| `setplace_no` | Field | Installation Place Number — the post-change location address number where the device is installed. |
| `adchg_no` | Field | Address Change Number — the unique identifier for a location change record. |
| `mskm_no` | Field | Customer Number — the unique identifier for the customer. |
| `chbf_skbt_no` | Field | Change-Before Service Billing Identifier — the pre-change billing/contract identifier. |
| `chaf_skbt_no` | Field | Change-After Service Billing Identifier — the post-change billing/contract identifier. |
| `itnm_svkei_kisuw_no` | Field | Migration-From Service Contract Line Number — the service contract line number before migration. |
| `itens_svkei_kisuw_no` | Field | Migration-To Service Contract Line Number — the service contract line number after migration. |
| `ch_tg_kei_no` | Field | Change-Target Contract Number — the specific contract being migrated. |
| KKSV0711 | Screen | Location Number Change Integration — the batch screen/use case for processing post-location-change data transfers. |
| KKSV0711OP | Operation | Location Number Change Integration Operation — the ES operation identifier for the integration. |
| KKSV071101CC | Fixed Text | User-defined text key — the fixed text key for ES input payload, mapping to "KKSV071101CC". |
| KK_T_ADCHG_DTL | DB Table | Location Change Detail Table — stores detail records of address/location changes including prior and after billing identifiers. |
| KK_SELECT_023 | SQL Define | SQL definition key — the pre-defined SQL query for looking up prior service contract identifiers from `KK_T_ADCHG_DTL`. |
| K-Opticom | Business term | K-Opticom — a Japanese telecommunications provider offering FTTH, cable, and broadband services. |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service. |
| CPE | Business term | Customer Premises Equipment — the device installed at the customer's premises (e.g., ONT, modem). |
| ES | Technical | Enterprise Service — the enterprise service bus/integration layer for cross-system data transmission. |
| SC | Technical | Service Component — a service component in the system architecture. |
| SOD | Technical | Service Order Data — service order fulfillment entity. |
| IS_DELAYED | Field | Delayed Processing Flag — when set to "1", indicates this record is for delayed/asynchronous processing. |
| JBSbatBusinessException | Class | Business Exception — the custom checked exception for business rule violations in the batch system. |
| EKKB0270CE | Error Code | Integration service error — thrown when the ES integration service returns a non-success return code. |
| EKKB0090TE | Error Code | Validation error — thrown when input validation fails, includes the failing row number. |
| EKKB0060TE | Error Code | Required field missing — thrown when a required field is null or empty during single-item check. |
| EKKB0070TE | Error Code | Field length validation failed — thrown when a field value does not meet length requirements. |
| EKKB0080TE | Error Code | Field attribute validation failed — thrown when a field value fails character set/attribute validation. |
| JBSbatKKIFM270 | Class | Location Change Integration File Constants — constant definitions for the KKIFM270 file format fields. |
| JBSbatKK_T_ADCHG_DTL | Class | Location Change Detail Table Constants — constant definitions for the KK_T_ADCHG_DTL table column names. |
| JCCBatchEsbInterface | Class | Batch ES Interface — the interface for invoking enterprise service bus services from batch processing. |

---
