---

# Business Logic — JBSbatKKAdChgSmtvlRnki.execute() [327 LOC]

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

## 1. Role

### JBSbatKKAdChgSmtvlRnki.execute()

This method is the main processing entry point for the **Address Change Smart Billing Linkage** feature within K-Opticom's customer base system. It handles synchronization between address change operations and smart billing systems, managing both batch-mode (post-file-input) and direct (in-message) processing paths.

In the **batch path** (when `inMap` is null), the method iterates over a list of output maps from a previous processing step. For each map, it validates six required input fields (original service contract number, target service contract number, third-party carrier discount contract number, third-party carrier discount target contract number, registration date/time, and update date/time). When the original and target service contract numbers differ — indicating a new contract or contract termination — it updates the third-party carrier discount target contract's service contract number via `changeTajgswkeiTgkeiSvcKeiNo()`, commits the transaction, and optionally invokes the smart billing linkage external service (KKSV071001CC) to push anomaly notification data.

In the **direct path** (when `inMap` is non-null), the method builds anomaly notification records for KDDI regarding smart billing discrepancies during customer moves between home and metro regions. It first checks whether all third-party carrier discount contracts associated with the current contract have been fully terminated or have full termination notifications — if so, it short-circuits and returns early. Otherwise, it queries the service contract information, and if the target service is an FTTH (fiber-to-the-home) service with an active status (service code `CD00130_01 = "01"`, contract status between `"100"` (inclusive) and `"910"` (exclusive)), it determines whether the data qualifies as anomaly notification target data. If the original and target service contract numbers differ, it's flagged as target data. If they are the same, it further checks for pending course change contracts: only if the pricing plan actually changed (both were fixed-rate but plans differ) is it flagged as target data — this avoids redundant notifications when moving between metro-to-metro with the same plan. When `isTrgtData` is true, it constructs a notification record with service contract number, migration division code `"00019"`, program status `"1000"`, system timestamp, and additional fields (adchgNo, sysid, hanteiFlg) set via later enhancement patches, adding it to the `trgDataList` for smart billing linkage.

The method implements a **routing/dispatch design pattern**: it branches into two entirely different processing paths based on whether `inMap` is null, and within the direct path, further dispatches to specialized validation and data-building logic. It acts as a **shared batch service component** called by the constant screen batch class `JBSbatKKAdChgCstScreenKidou`, which itself is invoked through the BPM operation `KKSV0710OPOperation`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute inMap, outputInItem"])
    START --> CHECK_NULL{inMap == null?}

    CHECK_NULL -->|true| BATCH["Batch Path: Process Output Map List"]
    CHECK_NULL -->|false| DIRECT["Direct Path: Build Anomaly Notification"]

    BATCH --> LOOP["For each item in outputInItem.getOutMapList"]
    LOOP --> EXTRACT["Extract input data from trgMap"]
    EXTRACT --> VALIDATE{All 6 fields non-blank?}

    VALIDATE -->|false| NEXT_ITEM["Next iteration"]
    VALIDATE -->|true| COMPARE{inItnmSvcKeiNo != inItnsSvcKeiNo?}

    COMPARE -->|false| NEXT_ITEM
    COMPARE -->|true| UPDATE_THIRDPARTY["changeTajgswkeiTgkeiSvcKeiNo"]
    UPDATE_THIRDPARTY --> COMMIT["super.commit"]

    COMMIT --> CHECK_DATA{trgDataList has data?}
    CHECK_DATA -->|true| INVOKE_SMART["invokeService for smart billing"]
    CHECK_DATA -->|false| BATCH_END["Batch branch complete"]
    INVOKE_SMART --> CHECK_RC{RETURN_CODE == SUCCESS?}
    CHECK_RC -->|true| BATCH_END
    CHECK_RC -->|false| THROW_SMART["throw EKKB0270CE"]

    DIRECT --> CHECK_TAJGS{tajgsWribKeiList has data?}

    CHECK_TAJGS -->|false| GET_SVC_INFO["Get svcKei info by svcKeiNo"]
    CHECK_TAJGS -->|true| DSL_LOOP["For each tajgsWribKeiMap in tajgsWribKeiList"]

    DSL_LOOP --> CHECK_CNC{tajgsCncYmd != MAX_DATE?}
    CHECK_CNC -->|false| SET_ALL_FALSE["allDslTchiZumiFlg=false, break"]
    CHECK_CNC -->|true| CHECK_DSL{tajgsDslYmd != MAX_DATE?}

    CHECK_DSL -->|true| SET_DSK_TRUE["dskZumiFlg=true, break"]
    CHECK_DSL -->|false| CHECK_TCH{tajgsTchYmd set and not MAX_DATE?}

    CHECK_TCH -->|false| SET_ALL_FALSE2["allDslTchiZumiFlg=false, break"]
    CHECK_TCH -->|true| NEXT_ITEM2["Next iteration"]

    SET_DSK_TRUE --> CHECK_FLAGS{dskZumi or allDslTchi?}
    SET_ALL_FALSE --> CHECK_FLAGS
    SET_ALL_FALSE2 --> CHECK_FLAGS

    CHECK_FLAGS -->|true| EARLY_RETURN["return outputInItem (skip)"]
    CHECK_FLAGS -->|false| GET_SVC_INFO2["Get svcKei info by svcKeiNo"]

    GET_SVC_INFO --> CHECK_SVC_CODE{itnsSvcCd == CD00130_01 and svcKeiStat >= 100 and < 910?}
    GET_SVC_INFO2 --> CHECK_SVC_CODE2{itnsSvcCd == CD00130_01 and svcKeiStat >= 100 and < 910?}

    CHECK_SVC_CODE -->|false| ADD_OUTPUT["outputInItem.addOutMapList inMap"]
    CHECK_SVC_CODE -->|true| IS_TARGET{isTrgtData?}

    IS_TARGET -->|false| ADD_OUTPUT
    IS_TARGET -->|true| CHECK_ITNM{itnmSvcKeiNo != svcKeiNo?}

    CHECK_ITNM -->|true| SET_TRGT["isTrgtData=true"]
    CHECK_ITNM -->|false| GET_IDO["getIdoRsvCourseChg itnmSvcKeiNo"]

    GET_IDO --> CHECK_IDO{idoRsv != null?}
    CHECK_IDO -->|false| ADD_OUTPUT2["outputInItem.addOutMapList inMap"]
    CHECK_IDO -->|true| CHECK_PLAN{Both pricing plans == CD01421_TEGAK?}

    CHECK_PLAN -->|false| ADD_OUTPUT2
    CHECK_PLAN -->|true| CHECK_PPLAN{oldPplanCd != newPplanCd?}

    CHECK_PPLAN -->|true| SET_TRGT_PPLAN["isTrgtData=true"]
    CHECK_PPLAN -->|false| SET_TRGT_FALSE["isTrgtData=false (skip)"]

    SET_TRGT --> PRE_ADD["Build trgtData HashMap"]
    SET_TRGT_PPLAN --> PRE_ADD2["Build trgtData HashMap"]
    SET_TRGT_FALSE --> ADD_OUTPUT2

    PRE_ADD --> ADD_OUTPUT3["outputInItem.addOutMapList inMap"]
    PRE_ADD2 --> ADD_OUTPUT3
    ADD_OUTPUT --> END_NODE(["Return outputInItem"])
    BATCH_END --> END_NODE
    THROW_SMART --> CATCH_END(["End"])
    EARLY_RETURN --> END_NODE
```

### Constant Resolution Reference

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `JKKStrConst.CD00130_01` | `"01"` | FTTH (Fiber-to-the-Home) service code |
| `JKKStrConst.CD01421_TEGAK` | `"0"` | Fixed-rate pricing plan (定額制) |
| `MAX_DATE` | `"20991231"` | Maximum date sentinel — indicates "not yet effective / not terminated" |
| `USECASE_ID` | `"KKSV0710"` | Smart billing linkage use case identifier |
| `OPERATION_ID` | `"KKSV0710OP"` | Smart billing linkage operation identifier |
| `FIXED_TEXT` | `"KKSV071001CC"` | User-defined string for smart billing linkage CC (Comonent Class) |
| `IDO_DIV_00019` | `"00019"` | Migration/diversion type code for course change anomaly |
| `PRG_STAT_1000` | `"1000"` | Program status code for anomaly notification pending |
| `HANTEI_FLG_1` | `"1"` | Judgment flag — set when UPS management SE customer F/T modification |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | The input message container. When **null**, indicates batch-mode processing where results from a prior file-read step are available in `outputInItem.getOutMapList()`. When **non-null**, contains a single service contract record (including original/target service contract numbers, third-party carrier discount info, timestamps) being processed in direct message-driven mode. Carries fields such as `ITNM_SVC_KEI_NO` (original service contract number), `ITNS_SVC_KEI_NO` (target/migrated service contract number), `TAJGS_WRIB_KEI_NO` (third-party carrier discount contract number), `ADCHG_NO` (address change number). |
| 2 | `outputInItem` | `JBSbatOutputItem` | The output item container. In batch mode, its `outMapList` holds the list of data records (intermediate files) from a previous processing step — each element is a `JBSbatServiceInterfaceMap` representing one record to process. The method mutates this object by adding the processed `inMap` to its output list and returns it. Used to carry structured batch results back to the caller. |

**Instance fields / external state read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `trgDataList` | `ArrayList<HashMap<String, Object>>` | Processing target data list — accumulates anomaly notification records to be pushed to the smart billing linkage external service |
| `db_KK_T_TAJGSWKEI_TGKEI` | `JBSbatSQLAccess` | SQL access object for `KK_T_TAJGSWKEI_TGKEI` (Third-party carrier discount target contract table) |
| `db_KK_T_SVC_KEI` | `JBSbatSQLAccess` | SQL access object for `KK_T_SVC_KEI` (Service contract table) |
| `db_KK_T_IDO_RSV` | `JBSbatSQLAccess` | SQL access object for `KK_T_IDO_RSV` (Migration/pending order table) |
| `db_KK_T_TAJGS_WRIB_KEI` | `JBSbatSQLAccess` | SQL access object for `KK_T_TAJGS_WRIB_KEI` (Third-party carrier discount contract table) |
| `super.opeDate` | `String` | Operation date inherited from `JBSbatBusinessService` parent — used for date-based queries |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `db_KK_T_SVC_KEI.selectBySqlDefine` + `selectNext` | KK_T_SVC_KEI_KK_SELECT_023 | KK_T_SVC_KEI | `getSvcKei(svcKeiNo)` — Reads service contract info (service code, contract status, system ID) from the service contract table using SQL key KK_SELECT_023 |
| U | `changeTajgswkeiTgkeiSvcKeiNo` | Internal | KK_T_TAJGSWKEI_TGKEI | Updates third-party carrier discount target contract by reading existing record and inserting two new records: one marking the end of the old mapping (end date = previous operating day) and one creating the new mapping (start date = operating day, new service contract number) |
| C | `insertKK_T_TAJGSWKEI_TGKEI` | Internal | KK_T_TAJGSWKEI_TGKEI | Inserts a new third-party carrier discount target contract record. Called twice: first with `newSvcKeiNo=null` to set the end date of the old record, second with the new service contract number to create the new active mapping |
| R | `db_KK_T_TAJGSWKEI_TGKEI.selectByPrimaryKeys` | Internal | KK_T_TAJGSWKEI_TGKEI | Reads the existing third-party carrier discount target contract record by composite primary key (TAJGS_WRIB_KEI_NO, TAJGSWKEI_TGKEI_NO, GENE_ADD_DTM) as the source record for creating updated mappings |
| R | `JBSbatOracleSeqUtil.getFormatedNextSeq` | Internal | Sequence (SEQ_TAJGSWKEI_TGKEI_NO) | Generates a formatted next sequence number for the third-party carrier discount target contract number when creating a new mapping record |
| R | `db_KK_T_TAJGS_WRIB_KEI.selectBySqlDefine` + `selectNext` | KK_T_TAJGS_WRIB_KEI_KK_SELECT_004 | KK_T_TAJGS_WRIB_KEI | `selectTajgsWribKeiByTajgsWribSvcKeiNo(tajgsWribKeiNo)` — Retrieves all third-party carrier discount contracts associated with a given third-party carrier discount contract number, using SQL key KK_SELECT_004 |
| R | `db_KK_T_IDO_RSV.selectBySqlDefine` + `selectNext` | KK_T_IDO_RSV_KK_SELECT_080 | KK_T_IDO_RSV | `getIdoRsvCourseChg(itnmSvcKeiNo)` — Retrieves pending migration course change records for the original service contract number using SQL key KK_SELECT_080, to check if pricing plan actually changed |
| C | `trgDataList.add(trgtData)` | Internal | (in-memory) | Creates and adds anomaly notification data records to the `trgDataList`. Each record contains: svc_kei_no, ido_div ("00019"), prg_stat ("1000"), prg_dtm (system timestamp), adchg_no, sysid, hantei_flg |
| - | `JCCBatchEsbInterface.invokeService` | JCCBatchEsbInterface | External Service (KKSV071001CC) | Invokes the smart billing linkage external service with USECASE_ID "KKSV0710", OPERATION_ID "KKSV0710OP", and the accumulated `trgDataList` as the FIXED_TEXT key data. Returns a return code indicating success/failure |
| R | `JBSbatDateUtil.getSystemDateTimeStamp` | JBSbatDateUtil | - | Gets the current system date/time stamp as a string for prg_dtm fields |
| R | `JBSbatDateUtil.adjustDate` | JBSbatDateUtil | - | Calculates the previous operating day (opeDate - 1) for use as the end date when marking the old mapping record as expired |
| - | `JBSbatBusinessService.commit` | JBSbatBusinessService | Transaction | Commits the current database transaction after batch-mode processing of third-party carrier discount target contract updates |
| - | `JBSbatCommonDBInterface.getString` / `setValue` / `getMap` | JBSbatCommonDBInterface | - | Generic data access methods used throughout for reading/writing database interface values |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0710 (BPM Operation) | `KKSV0710OPOperation.run` → `JKKAdChgSmtvlRnkiCC.addSmtvlIdoInf` → `JKKBpCommon.addSmtvlIdoInf` → External smart billing service | `invokeService [R] External: Smart Billing Linkage` |
| 2 | Screen:KKSV0729 (BPM Operation) | `KKSV0729OPOperation.run` → `JKKAdChgSmtvlRnkiCC.addSmtvlIdoInf` → `JKKBpCommon.addSmtvlIdoInf` → External smart billing service | `invokeService [R] External: Smart Billing Linkage` |
| 3 | Batch: KK Address Change Screen Kidou (Constant) | `JBSbatKKAdChgCstScreenKidou` → `execRunObjSmtvl.execute(inMap, outputInItem)` | `changeTajgswkeiTgkeiSvcKeiNo [U] KK_T_TAJGSWKEI_TGKEI`, `getSvcKei [R] KK_T_SVC_KEI`, `getIdoRsvCourseChg [R] KK_T_IDO_RSV`, `selectTajgsWribKeiByTajgsWribSvcKeiNo [R] KK_T_TAJGS_WRIB_KEI`, `invokeService [C] KKSV071001CC` |

## 6. Per-Branch Detail Blocks

**Block 1** — IF `[inMap == null]` (Batch Processing Path) (L173)

> When `inMap` is null, the method operates in batch mode, processing a list of output maps from a previous file-read step.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outputInItem.getOutMapList().isEmpty()` // Check if intermediate file is empty [-> No records] |
| 2 | RETURN | `return null;` // If outputInItem or its list is empty, return null early |
| 3 | FOR | `for (int i = 0; i < outputInItem.getOutMapList().size(); i++)` // Iterate over each record in the output list |
| 4 | SET | `trgMap = (JBSbatServiceInterfaceMap) outputInItem.getOutMapList().get(i);` // Get the current record as ServiceInterfaceMap |
| 5 | SET | `inItnmSvcKeiNo = trgMap.getString(JBSbatKKIFM267.ITNM_SVC_KEI_NO);` // Original (transferor) service contract number |
| 6 | SET | `inItnsSvcKeiNo = trgMap.getString(JBSbatKKIFM267.ITNS_SVC_KEI_NO);` // Target (transferee) service contract number |
| 7 | SET | `inTajgsWribKeiNo = trgMap.getString(JBSbatKKIFM267.TAJGS_WRIB_KEI_NO);` // Third-party carrier discount contract number |
| 8 | SET | `inTajgswkeiTgkeiNo = trgMap.getString(JBSbatKKIFM267.TAJGSWKEI_TGKEI_NO);` // Third-party carrier discount target contract number |
| 9 | SET | `inGeneAddDtm = trgMap.getString(JBSbatKKIFM267.GENE_ADD_DTM);` // Registration date/time |
| 10 | SET | `inUpdDtm = trgMap.getString(JBSbatKKIFM267.UPD_DTM);` // Update date/time |

**Block 1.1** — IF `[All 6 fields are non-blank]` (isBlank check) (L206)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `isBlank(inItnmSvcKeiNo) \|\| isBlank(inItnsSvcKeiNo) \|\| ...` // Validates that all 6 required fields have values |
| 2 | SET | (All 6 variables already extracted above; condition passes only if none are blank/empty) |

**Block 1.1.1** — IF `[Original != Target service contract number]` (L208)

> When the original and target service contract numbers differ, it means a new contract or termination has occurred, requiring the third-party carrier discount target contract's service contract number to be updated.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `changeTajgswkeiTgkeiSvcKeiNo(inTajgsWribKeiNo, inTajgswkeiTgkeiNo, inGeneAddDtm, inItnsSvcKeiNo);` // Updates third-party carrier discount target contract with new service contract number |
| 2 | COMMENT | `// If network is terminated/new, replace the service contract number of the third-party carrier discount target contract` |

**Block 1.2** — EXEC `[super.commit]` (L258)

> Commits the database transaction. This is the commit point for the batch path, enabling the smart billing linkage component (KKSV071001CC) to see the committed changes — because it cannot detect service contract number replacements on its own.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `super.commit();` // Commits transaction so smart billing linkage can see updated data |

**Block 1.2.1** — IF `[trgDataList has data]` (L260)

> After committing, if any anomaly notification data was accumulated in `trgDataList`, invoke the smart billing linkage external service.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = new HashMap<String, Object>();` // Prepare parameters for ESb invocation |
| 2 | SET | `inputMap = new HashMap<String, Object>();` // Prepare input for ESb invocation |
| 3 | SET | `outputMap = new HashMap<String, Object>();` // Prepare output from ESb invocation |
| 4 | SET | `paramMap.put(JCCBatchEsbInterface.TELEGRAM_INFO_USECASE_ID, "KKSV0710");` // Set use case ID |
| 5 | SET | `paramMap.put(JCCBatchEsbInterface.TELEGRAM_INFO_OPERATION_ID, "KKSV0710OP");` // Set operation ID |
| 6 | SET | `inputMap.put("KKSV071001CC", trgDataList);` // Set target data list keyed by user-defined string |
| 7 | CALL | `JCCBatchEsbInterface.invokeService(super.commonItem, paramMap, inputMap, outputMap);` // Invoke smart billing linkage external service |
| 8 | SET | `returnCode = outputMap.get(JCCBatchEsbInterface.RETURN_CODE).toString();` // Get return code from external service |

**Block 1.2.1.1** — IF `[RETURN_CODE != SUCCESS]` (L270)

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JBSbatBusinessException(JPCBatchMessageConstant.EKKB0270CE, new String[]{"Address change smart billing linkage"});` // Business exception if smart billing linkage fails |

---

**Block 2** — ELSE `[inMap != null]` (Direct Processing Path) (L278)

> When `inMap` is non-null, the method processes a single service contract record directly (not batch mode). It builds anomaly notification data for KDDI regarding smart billing discrepancies during customer moves between home and metro regions.

**Block 2.1** — IF `[tajgsWribKeiList has data]` (L312)

> Retrieves all third-party carrier discount contracts associated with the current contract. If any exist, checks whether they have all been fully terminated (or full termination notified to the third-party carrier). If so, the smart billing notification is skipped.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tajgsWribKeiNo = inMap.getString(JBSbatKKIFM267.TAJGS_WRIB_KEI_NO);` // Get third-party carrier discount contract number |
| 2 | CALL | `tajgsWribKeiList = selectTajgsWribKeiByTajgsWribSvcKeiNo(tajgsWribKeiNo);` // Query third-party carrier discount contracts |
| 3 | SET | `dskZumiFlg = false;` // Flag: "termination completed" — whether any contract has been terminated |
| 4 | SET | `allDslTchiZumiFlg = true;` // Flag: "all termination notification completed" — whether all contracts have termination notification set |

**Block 2.1.1** — FOR `[Each tajgsWribKeiMap in tajgsWribKeiList]` (L320)

> Iterates through each third-party carrier discount contract to check termination status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tajgsDslYmd = (String) tajgsWribKeiMap.get(JBSbatKK_T_TAJGS_WRIB_KEI.TAJGS_WRIB_KEI_DSL_YMD);` // Third-party carrier discount contract termination date |
| 2 | SET | `tajgsCncYmd = (String) tajgsWribKeiMap.get(JBSbatKK_T_TAJGS_WRIB_KEI.TAJGS_WRIB_KEI_CNC_YMD);` // Third-party carrier discount contract conclusion date |
| 3 | SET | `tajgsTchYmd = (String) tajgsWribKeiMap.get(JBSbatKK_T_TAJGSWKEI_TGKEI.DSL_TAJGS_TCH_YMD);` // Termination third-party carrier notification date |

**Block 2.1.1.1** — IF `[tajgsCncYmd != MAX_DATE]` — Contract is not in pending registration (L340)

> The contract conclusion date is set (not the sentinel max date), meaning the contract has been concluded.

| # | Type | Code |
|---|------|------|
| 1 | IF | `null != tajgsCncYmd && !MAX_DATE.equals(tajgsCncYmd)` // Smart billing contract has been concluded (not pending) |

**Block 2.1.1.1.1** — IF `[tajgsDslYmd != MAX_DATE]` — Contract has been terminated (L342)

> The termination date is set, meaning this specific contract has been terminated.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dskZumiFlg = true;` // Mark as "termination completed" |
| 2 | EXEC | `break;` // Exit loop — one terminated contract is enough |

**Block 2.1.1.1.2** — ELSE `[tajgsDslYmd == MAX_DATE]` — Not yet terminated (L347)

> The contract has not yet been terminated. Check if termination notification has been sent.

| # | Type | Code |
|---|------|------|
| 1 | IF | `null == tajgsTchYmd \|\| MAX_DATE.equals(tajgsTchYmd)` // Termination notification date is not set (or equals max date sentinel) |
| 2 | SET | `allDslTchiZumiFlg = false;` // Not all termination notifications completed |
| 3 | EXEC | `break;` // Exit loop |

**Block 2.1.1.2** — ELSE `[tajgsCncYmd == MAX_DATE]` — Contract is in pending registration (L357)

| # | Type | Code |
|---|------|------|
| 1 | SET | `allDslTchiZumiFlg = false;` // Pending registration means not fully terminated |
| 2 | EXEC | `break;` // Exit loop |

**Block 2.1.2** — IF `[dskZumiFlg || allDslTchiZumiFlg]` — All contracts terminated or all notified (L364)

> If any contract has been terminated, OR if all contracts have had termination notifications sent, skip the anomaly notification entirely.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return outputInItem;` // Skip anomaly notification — smart billing is already handled |

**Block 2.2** — GET svcKei info (L369)

> Retrieve service contract details for the target service contract number to determine if it's an FTTH active contract that requires anomaly notification.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiNo = inMap.getString(JBSbatKKIFM267.ITNS_SVC_KEI_NO);` // Target service contract number |
| 2 | SET | `adchgNo = inMap.getString(JBSbatKKIFM267.ADCHG_NO);` // Address change number (ANK-1918 patch) |
| 3 | SET | `itnsSvcCd = "";` // Initialize target service code |
| 4 | SET | `itnsSvcKeiStat = "";` // Initialize target service contract status |
| 5 | SET | `itnsSysid = "";` // Initialize target system ID (ANK-1918 patch) |
| 6 | IF | `!isBlank(svcKeiNo)` // Service contract number is set |
| 7 | CALL | `itnsSvcKei = getSvcKei(svcKeiNo);` // Query KK_T_SVC_KEI by service contract number |
| 8 | SET | `itnsSvcCd = itnsSvcKei.getString(JBSbatKK_T_SVC_KEI.SVC_CD);` // Service code |
| 9 | SET | `itnsSvcKeiStat = itnsSvcKei.getString(JBSbatKK_T_SVC_KEI.SVC_KEI_STAT);` // Service contract status |
| 10 | SET | `itnsSysid = itnsSvcKei.getString(JBSbatKK_T_SVC_KEI.SYSID);` // System ID (ANK-1918 patch) |

**Block 2.3** — IF `[itnsSvcCd == CD00130_01 AND svcKeiStat >= "100" AND < "910"]` — FTTH active contract (L382)

> Checks if the target service contract is an FTTH (Fiber-to-the-Home) service with active status. Service code `CD00130_01 = "01"` means FTTH, and contract status between `"100"` (inclusive) and `"910"` (exclusive) means the service is currently being provided (not terminated).

| # | Type | Code |
|---|------|------|
| 1 | SET | `isTrgtData = false;` // Initialize target data flag |
| 2 | SET | `itnmSvcKeiNo = inMap.getString(JBSbatKKIFM267.ITNM_SVC_KEI_NO);` // Get original service contract number for comparison |

**Block 2.3.1** — IF `[itnmSvcKeiNo != svcKeiNo]` — Service contract number changed (L388)

> The original and target service contract numbers differ, indicating a contract change. This is automatically flagged as anomaly notification target data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `isTrgtData = true;` // Contract number changed — anomaly notification needed |

**Block 2.3.2** — ELSE `[itnmSvcKeiNo == svcKeiNo]` — Same service contract number (L391)

> The service contract number is the same (no contract change). Need to check if there's a pending course change and whether the pricing plan actually changed.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `idoRsv = getIdoRsvCourseChg(itnmSvcKeiNo);` // Query pending migration course change records from KK_T_IDO_RSV |
| 2 | IF | `null != idoRsv` // There is a pending course change |

**Block 2.3.2.1** — IF `[Both pricing plans == CD01421_TEGAK]` — Both fixed-rate (L397)

> Both the original and target pricing plans are fixed-rate (定額制). In this case (e.g., metro-to-metro move), only notify if the pricing plan actually changed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `newPplanCd = idoRsv.getString(JBSbatKK_T_IDO_RSV.NEW_PPLAN_CD);` // New pricing plan code |
| 2 | SET | `oldPplanCd = idoRsv.getString(JBSbatKK_T_IDO_RSV.OLD_PPLAN_CD);` // Old pricing plan code |
| 3 | IF | `!isBlank(oldPplanCd) && !oldPplanCd.equals(newPplanCd);` // Plans are different |
| 4 | SET | `isTrgtData = true;` // Different plans after change — anomaly notification needed |
| 5 | COMMENT | `// If plans are the same before/after change, notification is NOT needed (metro-to-metro with same plan)` |

**Block 2.3.2.1.1** — ELSE `[Pricing plans are different or one is volume-based]` (L405)

> The pricing plans are both fixed-rate but different (e.g., plan A → plan B), OR one/both are volume-based (従量制). For volume-based ↔ volume-based, notification is unnecessary (already notified at the time of the contract change). For fixed-rate changes, see Block 2.3.2.1. For mixed cases, no action is taken (the else does nothing).

| # | Type | Code |
|---|------|------|
| 1 | COMMENT | `// Fixed-rate ↔ volume-based: course change confirmation processing handles smart billing anomaly registration` |
| 2 | COMMENT | `// Volume-based ↔ volume-based: no notification needed (already notified at contract change time)` |

**Block 2.3.3** — IF `[isTrgtData == true]` — Build anomaly notification record (L413)

| # | Type | Code |
|---|------|------|
| 1 | IF | `trgDataList == null` // Initialize list if null |
| 2 | SET | `trgDataList = new ArrayList<HashMap<String, Object>>();` |
| 3 | SET | `trgtData = new HashMap<String, Object>();` // Create new data record |
| 4 | SET | `trgtData.put("svc_kei_no", svcKeiNo);` // Service contract number |
| 5 | SET | `trgtData.put("ido_div", "00019");` // Migration/diversion type code |
| 6 | SET | `trgtData.put("prg_stat", "1000");` // Program status: anomaly notification pending |
| 7 | SET | `trgtData.put("prg_dtm", JBSbatDateUtil.getSystemDateTimeStamp());` // System timestamp |
| 8 | SET | `trgtData.put("adchg_no", adchgNo);` // Address change number (ANK-1918 patch) |
| 9 | SET | `trgtData.put("sysid", itnsSysid);` // System ID (ANK-1918 patch) |
| 10 | SET | `trgtData.put("hantei_flg", "1");` // Judgment flag: UPS management SE customer F/T modification (ST-2014-0000158 patch) |
| 11 | EXEC | `trgDataList.add(trgtData);` // Add to the target data list |

**Block 2.4** — EXEC `[outputInItem.addOutMapList(inMap)]` (L423)

> Adds the processed input map to the output list. This carries the result forward to the calling component.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `outputInItem.addOutMapList(inMap);` // Add processed record to output list |
| 2 | RETURN | `return outputInItem;` // Return the output item |

---

**Block 3** — ELSE (final fallback) (L428)

> The ultimate fallback: when execution reaches the end of the direct path without returning, this catches any unhandled cases.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return outputInItem;` // Return the output item unchanged |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `itnm_svc_kei_no` / `ITNM_SVC_KEI_NO` | Field | Original (transferor) service contract number — the service contract number before the address change / migration |
| `itns_svc_kei_no` / `ITNS_SVC_KEI_NO` | Field | Target (transferee) service contract number — the service contract number after the address change / migration |
| `svc_kei_no` | Field | Service contract number — the unique identifier for a customer's service contract line item |
| `svc_kei_ucwk_no` | Field | Service detail work number — internal tracking ID for service contract work items |
| `svc_cd` | Field | Service code — classifies the type of telecom service (e.g., "01" = FTTH) |
| `svc_kei_stat` / `SVC_KEI_STAT` | Field | Service contract status — numeric code indicating the lifecycle state of a service contract (e.g., "100" = service started, "910" = contract ended) |
| `sysid` | Field | System ID — identifies which system manages this service contract (for UPS management) |
| `adchg_no` | Field | Address change number — unique identifier for a specific address change operation |
| `ido_div` | Field | Migration/diversion type code — classifies the type of course migration (e.g., "00019" = address change related) |
| `prg_stat` | Field | Program status — status code for the anomaly notification program (e.g., "1000" = pending) |
| `prg_dtm` | Field | Program date/time — timestamp when the anomaly notification record was created |
| `hantei_flg` | Field | Judgment flag — indicates whether this is a special case requiring additional processing (e.g., UPS management SE customer) |
| `tajgs_wrib_kei_no` | Field | Third-party carrier discount contract number — identifier for a contract that applies third-party carrier discount pricing |
| `tajgswkei_tgkei_no` | Field | Third-party carrier discount target contract number — unique identifier for a mapping between a third-party carrier discount contract and its associated service contract |
| `dsl_ymd` | Field | Termination year/month/day — date when a third-party carrier discount contract was terminated |
| `cnc_ymd` | Field | Conclusion year/month/day — date when a third-party carrier discount contract was concluded |
| `dsl_tajgs_tch_ymd` | Field | Termination third-party carrier notification date — date when the termination of the third-party carrier discount was notified to the third-party carrier |
| `ppchg_tajgs_tch_ymd` | Field | Pricing plan change third-party carrier notification date — date when a pricing plan change was notified to the third-party carrier |
| `ido_rsv` | Entity | Migration/Pending Order — database entity representing pending migration or course change orders |
| `old_ppplan_cd` / `new_ppplan_cd` | Field | Old/New pricing plan code — the pricing plan codes before and after a course change |
| SOD | Acronym | Service Order Data — telecom order fulfillment entity used in service contract management |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service (service code `CD00130_01 = "01"`) |
| CD00130_01 | Constant | Service code value "01" — represents FTTH (Fiber-to-the-Home) service type |
| CD01421_TEGAK | Constant | Pricing plan code value "0" — represents fixed-rate pricing plan (定額制) as opposed to volume-based pricing (従量制) |
| MAX_DATE | Constant | "20991231" — maximum date sentinel used to indicate "not yet set / not effective / not terminated" |
| KKSV0710 | Constant | Use case ID — identifies the smart billing linkage use case |
| KKSV0710OP | Constant | Operation ID — identifies the smart billing linkage operation |
| KKSV071001CC | Constant | User-defined string — key used to pass target data to the smart billing linkage Component Class (CC) |
| KK_T_TAJGSWKEI_TGKEI | Table | Third-party carrier discount target contract table — stores mappings between third-party carrier discount contracts and service contracts, including effective start/end dates for tracking contract number changes over time |
| KK_T_SVC_KEI | Table | Service contract table — stores service contract master data including service code, contract status, and system ID |
| KK_T_IDO_RSV | Table | Migration/Pending Order table — stores pending migration and course change orders including old/new pricing plan codes |
| KK_T_TAJGS_WRIB_KEI | Table | Third-party carrier discount contract table — stores third-party carrier discount contract master data including conclusion and termination dates |
| KK_T_PRG | Table | Program table — stores program configuration data (referenced via SQL key KK_SELECT_028, currently unused in execute) |
| JBSbatBusinessService | Class | Parent service class providing common batch processing infrastructure (commit, operation date, common info) |
| JKKAdChgSmtvlRnkiCC | Class | Common Component Class for smart billing linkage — mediates between BPM operations and external smart billing services |
| changeTajgswkeiTgkeiSvcKeiNo | Method | Internal method that updates third-party carrier discount target contract mappings — creates a new mapping record with the new service contract number and marks the old mapping as expired |
| selectTajgsWribKeiByTajgsWribSvcKeiNo | Method | Internal method that queries all third-party carrier discount contracts by the discount contract number |
| getSvcKei | Method | Internal method that queries service contract info by service contract number using SQL key KK_SELECT_023 |
| getIdoRsvCourseChg | Method | Internal method that queries pending migration course change records by original service contract number using SQL key KK_SELECT_080 |

---
