# Business Logic — JBSbatKKAdHenkoHoyuDataChstuMan.execute() [623 LOC]

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

## 1. Role

### JBSbatKKAdHenkoHoyuDataChstuMan.execute()

This method is the main batch processing routine for **extracting changed address data from address master tables and inserting them into a work queue table** (`KK_T_CHGTGAD_CD_WK`). The class-level javadoc states in Japanese: 「変更対象住所コードワークより対象テーブルから変更保住所データ抽出クラスです。」(Translation: "This is a class that extracts changed-preserved address data from target tables via the change-target address code work table."). The method follows a **repetitive extract-transform-load (ETL) pattern**: for each of 8 distinct service/customer domains, it queries the appropriate source table for address records matching the input `AD_CD` (address code), transforms the data by joining old/new address fields, generates a unique work sequence number, and inserts a new record into the change-tracking table `KK_T_CHG_AD_JGRTWK`.

The method handles **7 active service domains** (the 8th — phone application contents — uses two sub-queries): Customer Contract Address, Customer Designated Delivery Address, Individual Customer, Equipment Provider Service, Optional Service Contract (TV), Billing Contract, and Phone Application Contents (Postal Code + Installation Site). Each domain queries a different source table and sets a distinct `CHG_TG_SCHEMA_ID` to indicate the data schema origin. For every inserted row, the batch populates both the current (new) address fields and the historical (old) address fields, along with audit constants: `AD_TOHAIGO_TRN_STAT_CD = "4"` (not-yet-processed transfer status) and `AD_TOHAIGO_UPD_FAIL_RSN_CD = "03"` (manual input flag). After completing all insert batches, the method updates the `KK_T_CHGTGAD_CD_WK` work table to mark the address code transformation as processed (setting status to `"9"`), then commits the transaction and returns `null`.

Design pattern: **Batch ETL router** — the method sequentially dispatches to domain-specific SQL query/insert cycles without branching logic (no if/else on input parameters), making it a linear pipeline.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute(inMap)"])
    START --> INIT_DB["Initialize DB access classes in initial()"]
    INIT_DB --> GET_AD["Get AD_CD from inMap"]
    GET_AD --> PROCESS_1["Process 1: NTT Customer Contract Address"]
    PROCESS_1 --> QRY1["Query KK_SELECT_043 from CK_T_CUST"]
    QRY1 --> LOOP1{"More rows?"}
    LOOP1 -->|Yes| SET1["Set CHG_AD_JGRTWK fields with CHG_TG_SCHEMA_ID=CK0011"]
    SET1 --> SEQ1["Generate sequence SEQ_CHG_AD_JGRTWK_NO"]
    SEQ1 --> INS1["INSERT into KK_T_CHG_AD_JGRTWK"]
    INS1 --> LOOP1
    LOOP1 -->|No| PROCESS_2["Process 2: Customer Designated Delivery Address"]
    PROCESS_2 --> QRY2["Query KK_SELECT_044 from CK_T_CUST"]
    QRY2 --> LOOP2{"More rows?"}
    LOOP2 -->|Yes| SET2["Set CHG_AD_JGRTWK fields with CHG_TG_SCHEMA_ID=CK0011"]
    SET2 --> SEQ2["Generate sequence"]
    SEQ2 --> INS2["INSERT into KK_T_CHG_AD_JGRTWK"]
    INS2 --> LOOP2
    LOOP2 -->|No| PROCESS_3["Process 3: Individual Customer"]
    PROCESS_3 --> QRY3["Query KK_SELECT_007 from CK_T_CUST_KOJIN"]
    QRY3 --> LOOP3{"More rows?"}
    LOOP3 -->|Yes| SET3["Set CHG_AD_JGRTWK fields with CHG_TG_SCHEMA_ID=CK0021"]
    SET3 --> SEQ3["Generate sequence"]
    SEQ3 --> INS3["INSERT into KK_T_CHG_AD_JGRTWK"]
    INS3 --> LOOP3
    LOOP3 -->|No| PROCESS_4["Process 4: Equipment Provider Service"]
    PROCESS_4 --> QRY4["Query KK_SELECT_108 from KK_T_KKTK_SVC_KEI"]
    QRY4 --> LOOP4{"More rows?"}
    LOOP4 -->|Yes| SET4["Set CHG_AD_JGRTWK fields with CHG_TG_SCHEMA_ID=KK0341"]
    SET4 --> SEQ4["Generate sequence"]
    SEQ4 --> INS4["INSERT into KK_T_CHG_AD_JGRTWK"]
    INS4 --> LOOP4
    LOOP4 -->|No| PROCESS_5["Process 5: Optional Service Contract TV"]
    PROCESS_5 --> QRY5["Query KK_SELECT_007 from KK_T_OPSVKEI_TV"]
    QRY5 --> LOOP5{"More rows?"}
    LOOP5 -->|Yes| SET5["Set CHG_AD_JGRTWK fields with CHG_TG_SCHEMA_ID=KK0381"]
    SET5 --> SEQ5["Generate sequence"]
    SEQ5 --> INS5["INSERT into KK_T_CHG_AD_JGRTWK"]
    INS5 --> LOOP5
    LOOP5 -->|No| PROCESS_6["Process 6: Billing Contract"]
    PROCESS_6 --> QRY6["Query KK_SELECT_056 from KK_T_SEIKY_KEI"]
    QRY6 --> LOOP6{"More rows?"}
    LOOP6 -->|Yes| SET6["Set CHG_AD_JGRTWK fields with CHG_TG_SCHEMA_ID=KK0491"]
    SET6 --> SEQ6["Generate sequence"]
    SEQ6 --> INS6["INSERT into KK_T_CHG_AD_JGRTWK"]
    INS6 --> LOOP6
    LOOP6 -->|No| PROCESS_7["Process 7: Phone App Contents (Postal Code)"]
    PROCESS_7 --> QRY7A["Query KK_SELECT_004 from TU_T_DNWACHOMSK_NYO"]
    QRY7A --> LOOP7A{"More rows?"}
    LOOP7A -->|Yes| SET7A["Set CHG_AD_JGRTWK fields with CHG_TG_SCHEMA_ID=TU0091"]
    SET7A --> SEQ7A["Generate sequence"]
    SEQ7A --> INS7A["INSERT into KK_T_CHG_AD_JGRTWK"]
    INS7A --> LOOP7A
    LOOP7A -->|No| QRY7B["Query KK_SELECT_005 from TU_T_DNWACHOMSK_NYO"]
    QRY7B --> LOOP7B{"More rows?"}
    LOOP7B -->|Yes| SET7B["Set CHG_AD_JGRTWK fields with CHG_TG_SCHEMA_ID=TU0091"]
    SET7B --> SEQ7B["Generate sequence"]
    SEQ7B --> INS7B["INSERT into KK_T_CHG_AD_JGRTWK"]
    INS7B --> LOOP7B
    LOOP7B -->|No| UPDATE_WK["Update KK_T_CHGTGAD_CD_WK AD_TOHAIGO_TRN_STAT_CD=HENKO_ADD_CD_ZM(9)"]
    UPDATE_WK --> COMMIT["Commit transaction via JBSbatBusinessService.commit()"]
    COMMIT --> END_NODE(["Return null"])
```

**Active vs. Disabled Domains:** The method contains two commented-out blocks (delimited by `ANK-4494-00-00 DEL` markers from a 2024/03/06 changelog entry for "bi-directional Doban [number port] support"). These were:
- Process 8: Work Project — 3 sub-blocks (NTT Customer Address, Installation Site Address, Ownership Transfer Address) — querying `KU_T_KOJIAK` and `TU_T_BMP_KOJI`
- Process 9: Number Port Transfer — querying `TU_T_DOBANITEN`

These are **not currently active**. The 7 active blocks described above constitute the complete execution path.

**Constants Resolved:**
| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `JKKBatConst.HENKO_ADD_CD_FUKA` | `"4"` | Change/addition code "unattached" — indicates the address transfer has not yet been processed |
| `JKKBatConst.UPD_FAIL_RSN_MANINPFLG` | `"03"` | Update failure reason "manual input flag" — the record was created via manual input (not an automated failure) |
| `JKKBatConst.HENKO_ADD_CD_ZM` | `"9"` | Change/addition code "ZM" — indicates the address transformation work has been completed/processed |
| `SEQ_NAME` | `"SEQ_CHG_AD_JGRTWK_NO"` | Oracle sequence name for generating unique change-address-work-numbers |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `inMap` | `JBSbatServiceInterfaceMap` | Input message map containing batch processing parameters. Specifically, it provides the `AD_CD` (Address Code) string value via `JZMBatCommon.getInMapData(inMap, "AD_CD")`. This address code is the primary search key used in all 8 source queries — every domain-specific SQL query filters rows where the address code matches the provided `AD_CD`. |

**Instance fields / external state read during execution:**

| Field | Type | Usage |
|-------|------|-------|
| `commonItem.getConnection()` | `Connection` | Database connection used for sequence number generation (`SEQ_CHG_AD_JGRTWK_NO`) |
| `db_CK_T_CUST` | `JBSbatSQLAccess` | SQL access to `CK_T_CUST` (Customer contract address table) |
| `db_CK_T_CUST_KOJIN` | `JBSbatSQLAccess` | SQL access to `CK_T_CUST_KOJIN` (Individual customer address table) |
| `db_KK_T_KKTK_SVC_KEI` | `JBSbatSQLAccess` | SQL access to `KK_T_KKTK_SVC_KEI` (Equipment provider service contract table) |
| `db_KK_T_OPSVKEI_TV` | `JBSbatSQLAccess` | SQL access to `KK_T_OPSVKEI_TV` (Optional service TV contract table) |
| `db_KK_T_SEIKY_KEI` | `JBSbatSQLAccess` | SQL access to `KK_T_SEIKY_KEI` (Billing contract table) |
| `db_TU_T_DNWACHOMSK_NYO` | `JBSbatSQLAccess` | SQL access to `TU_T_DNWACHOMSK_NYO` (Phone application contents table) |
| `db_CHG_AD_JGRTWK` | `JBSbatSQLAccess` | SQL access to `KK_T_CHG_AD_JGRTWK` (Change address judgment work table — insert target) |
| `db_CHGTGAD_CD_WK` | `JBSbatSQLAccess` | SQL access to `KK_T_CHGTGAD_CD_WK` (Change target address code work table — final update target) |
| `super` (extends `JBSbatBusinessService`) | — | Provides `commit()` for transaction commitment |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JZMBatCommon.getInMapData` | — | — | Reads `AD_CD` (Address Code) string from the input message map |
| R | `db_CK_T_CUST.selectBySqlDefine` | — | CK_T_CUST | Executes SQL define `KK_SELECT_043` to query customer contract address records matching the input address code |
| R | `db_CK_T_CUST.selectNext` | — | CK_T_CUST | Iterates result set — fetches the next row from the customer contract address query |
| R | `JCCOracleSeqUtil.getFormatedNextSeq` | — | — | Generates a formatted next sequence value from Oracle sequence `SEQ_CHG_AD_JGRTWK_NO` for unique work record numbering |
| R | `map.getString` | — | — | Extracts string column values (SYSID, SVC_KEI_NO, AD_CD, PCD, STATE_NM, CITY_NM, OAZTSU_NM, AZCHO_NM, AD_SHUSEI_CD, NEW_*, OLD_*) from each query result row |
| C | `db_CHG_AD_JGRTWK.insertByPrimaryKeys` | — | KK_T_CHG_AD_JGRTWK | Inserts a new address change judgment work record with all current and historical address fields, schema ID, and audit constants |
| R | `db_CK_T_CUST_KOJIN.selectBySqlDefine` | — | CK_T_CUST_KOJIN | Executes SQL define `KK_SELECT_007` to query individual customer address records |
| R | `db_CK_T_CUST_KOJIN.selectNext` | — | CK_T_CUST_KOJIN | Iterates result set from individual customer query |
| R | `db_KK_T_KKTK_SVC_KEI.selectBySqlDefine` | — | KK_T_KKTK_SVC_KEI | Executes SQL define `KK_SELECT_108` to query equipment provider service contract address records |
| R | `db_KK_T_KKTK_SVC_KEI.selectNext` | — | KK_T_KKTK_SVC_KEI | Iterates result set from equipment provider query |
| R | `db_KK_T_OPSVKEI_TV.selectBySqlDefine` | — | KK_T_OPSVKEI_TV | Executes SQL define `KK_SELECT_007` to query optional service TV contract address records |
| R | `db_KK_T_OPSVKEI_TV.selectNext` | — | KK_T_OPSVKEI_TV | Iterates result set from optional service TV query |
| R | `db_KK_T_SEIKY_KEI.selectBySqlDefine` | — | KK_T_SEIKY_KEI | Executes SQL define `KK_SELECT_056` to query billing contract address records |
| R | `db_KK_T_SEIKY_KEI.selectNext` | — | KK_T_SEIKY_KEI | Iterates result set from billing contract query |
| R | `db_TU_T_DNWACHOMSK_NYO.selectBySqlDefine` | — | TU_T_DNWACHOMSK_NYO | Executes SQL defines `KK_SELECT_004` and `KK_SELECT_005` to query phone application contents records (postal code and installation site variants) |
| R | `db_TU_T_DNWACHOMSK_NYO.selectNext` | — | TU_T_DNWACHOMSK_NYO | Iterates result set from phone application contents query |
| U | `db_CHGTGAD_CD_WK.updateByPrimaryKeys` | — | KK_T_CHGTGAD_CD_WK | Updates the work table to set `AD_TOHAIGO_TRN_STAT_CD = "9"` (HENKO_ADD_CD_ZM), marking the address code transformation as completed |
| - | `JBSbatBusinessService.commit` | — | — | Commits the current database transaction, persisting all inserts and the final work table update |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKAdHenkoHoyuDataChstuMan | `JBSbatBusinessServiceFramework.execute` -> `JBSbatKKAdHenkoHoyuDataChstuMan.execute(inMap)` | `db_CHG_AD_JGRTWK.insertByPrimaryKeys [C] KK_T_CHG_AD_JGRTWK` (×7 domains), `db_CHGTGAD_CD_WK.updateByPrimaryKeys [U] KK_T_CHGTGAD_CD_WK` |
| 2 | Batch: JBSbatKKAdHenkoHoyuDataChstuMan | `JBSbatBusinessServiceFramework.execute` -> `JBSbatKKAdHenkoHoyuDataChstuMan.execute(inMap)` | `db_CK_T_CUST.selectBySqlDefine [R] CK_T_CUST` (×2 queries: KK_SELECT_043, KK_SELECT_044) |
| 3 | Batch: JBSbatKKAdHenkoHoyuDataChstuMan | `JBSbatBusinessServiceFramework.execute` -> `JBSbatKKAdHenkoHoyuDataChstuMan.execute(inMap)` | `db_CK_T_CUST_KOJIN.selectBySqlDefine [R] CK_T_CUST_KOJIN` |
| 4 | Batch: JBSbatKKAdHenkoHoyuDataChstuMan | `JBSbatBusinessServiceFramework.execute` -> `JBSbatKKAdHenkoHoyuDataChstuMan.execute(inMap)` | `db_KK_T_KKTK_SVC_KEI.selectBySqlDefine [R] KK_T_KKTK_SVC_KEI` |
| 5 | Batch: JBSbatKKAdHenkoHoyuDataChstuMan | `JBSbatBusinessServiceFramework.execute` -> `JBSbatKKAdHenkoHoyuDataChstuMan.execute(inMap)` | `db_KK_T_OPSVKEI_TV.selectBySqlDefine [R] KK_T_OPSVKEI_TV` |
| 6 | Batch: JBSbatKKAdHenkoHoyuDataChstuMan | `JBSbatBusinessServiceFramework.execute` -> `JBSbatKKAdHenkoHoyuDataChstuMan.execute(inMap)` | `db_KK_T_SEIKY_KEI.selectBySqlDefine [R] KK_T_SEIKY_KEI` |
| 7 | Batch: JBSbatKKAdHenkoHoyuDataChstuMan | `JBSbatBusinessServiceFramework.execute` -> `JBSbatKKAdHenkoHoyuDataChstuMan.execute(inMap)` | `db_TU_T_DNWACHOMSK_NYO.selectBySqlDefine [R] TU_T_DNWACHOMSK_NYO` (×2 queries) |

**Notes:** No direct Java-level callers were found for `execute()` on this class. As a `JBSbatBusinessService` subclass, it is invoked through the batch processing framework infrastructure (typically via XML-based batch configuration that maps batch names to service classes). The method operates independently — it does not delegate to other custom service methods but uses only the injected `JBSbatSQLAccess` database handles and common utility classes.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `strAdCd = JZMBatCommon.getInMapData(inMap, "AD_CD")` (L96)

> Retrieves the address code from the input message map. This code is the primary key used across all subsequent queries to filter records belonging to the target address.

| # | Type | Code |
|---|------|------|
| 1 | SET | `strAdCd = JZMBatCommon.getInMapData(inMap, "AD_CD")` |

**Block 2** — [WHILE LOOP] Process 1: NTT Customer Contract Address (Customer (NTT Contract Holder Address Code)) (L100–L143)

> Queries the customer contract address table (`CK_T_CUST`) using SQL define `KK_SELECT_043`. For each matching row, generates a sequence-based work number, populates 23 fields (including schema ID `CK0011`, customer name `KEISHA_AD_CD`, current/new address fields, and historical/old address fields from `KEISHA_*` columns), and inserts into `KK_T_CHG_AD_JGRTWK`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbList = new JBSbatCommonDBInterface()` [L102] |
| 2 | EXEC | `dbList.setValue(strAdCd)` — binds address code as query parameter [L103] |
| 3 | CALL | `db_CK_T_CUST.selectBySqlDefine(dbList, "KK_SELECT_043")` — executes customer contract query [L105] |
| 4 | SET | `map = new JBSbatCommonDBInterface()` [L108] |
| 5 | WHILE | `while((map=db_CK_T_CUST.selectNext())!=null)` — iterates each matching row [L109] |
| 6 | BLOCK 2.1 — [WITHIN LOOP] For each customer contract row |
| 7 | SET | `inDbMap = new JBSbatCommonDBInterface()` [L111] |
| 8 | SET | `seqNo = JCCOracleSeqUtil.getFormatedNextSeq(commonItem.getConnection(), SEQ_NAME, "", JKKBatConst.SEQ_KETA)` — generates unique work number [L113] |
| 9 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.CHG_AD_JGRTWK_NO, seqNo)` [L114] |
| 10 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.CHG_TG_SCHEMA_ID, "CK0011")` — schema ID for customer contract [L115] |
| 11 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.CHG_TG_KMK_NM_EINM, "KEISHA_AD_CD")` — customer name label: 企業住所コード (Company Address Code) [L116] |
| 12 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.SYSID, map.getString("SYSID"))` [L117] |
| 13 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.SVC_KEI_NO, map.getString("SVC_KEI_NO"))` [L118] |
| 14 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.AD_CD, map.getString("AD_CD"))` [L119] |
| 15 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.PCD, map.getString("PCD"))` — Postal Code [L120] |
| 16 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.STATE_NM, map.getString("STATE_NM"))` — State/Province Name [L121] |
| 17 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.CITY_NM, map.getString("CITY_NM"))` — City Name [L122] |
| 18 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.OAZTSU_NM, map.getString("OAZTSU_NM"))` — District/Neighborhood Name [L123] |
| 19 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.AZCHO_NM, map.getString("AZCHO_NM"))` — Block/Lot Name [L124] |
| 20 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.AD_SHUSEI_CD, map.getString("AD_SHUSEI_CD"))` — Address Consolidation Code [L125] |
| 21 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.NEW_AD_CD, map.getString("NEW_AD_CD"))` — New Address Code [L126] |
| 22 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.NEW_PCD, map.getString("NEW_PCD"))` — New Postal Code [L127] |
| 23 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.NEW_STATE_NM, map.getString("NEW_STATE_NM"))` [L128] |
| 24 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.NEW_CITY_NM, map.getString("NEW_CITY_NM"))` [L129] |
| 25 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.NEW_OAZTSU_NM, map.getString("NEW_OAZTSU_NM"))` [L130] |
| 26 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.NEW_AZCHO_NM, map.getString("NEW_AZCHO_NM"))` [L131] |
| 27 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.AD_CHG_SBT_CD, map.getString("AD_CHG_SBT_CD"))` — Address Change Sub-type Code [L132] |
| 28 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.OLD_AD_CD, map.getString("KEISHA_AD_CD"))` [L133] |
| 29 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.OLD_PCD, map.getString("KEISHA_PCD"))` [L134] |
| 30 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.OLD_STATE_NM, map.getString("KEISHA_STATE_NM"))` [L135] |
| 31 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.OLD_CITY_NM, map.getString("KEISHA_CITY_NM"))` [L136] |
| 32 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.OLD_OAZTSU_NM, map.getString("KEISHA_OAZTSU_NM"))` [L137] |
| 33 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.OLD_AZCHO_NM, map.getString("KEISHA_AZCHO_NM"))` [L138] |
| 34 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.AD_TOHAIGO_TRN_STAT_CD, JKKBatConst.HENKO_ADD_CD_FUKA)` `[-> HENKO_ADD_CD_FUKA="4"]` — Not yet processed [L139] |
| 35 | SET | `inDbMap.setValue(JBSbatKK_T_CHG_AD_JGRTWK.AD_TOHAIGO_UPD_FAIL_RSN_CD, JKKBatConst.UPD_FAIL_RSN_MANINPFLG)` `[-> UPD_FAIL_RSN_MANINPFLG="03"]` — Manual input flag [L140] |
| 36 | CALL | `count = db_CHG_AD_JGRTWK.insertByPrimaryKeys(inDbMap)` — INSERT文実行 (Execute INSERT statement) [L142] |

**Block 3** — [WHILE LOOP] Process 2: Customer Designated Delivery Address (Customer (Designated Delivery Address Code)) (L148–L193)

> Queries `CK_T_CUST` using SQL define `KK_SELECT_044`. This differs from Process 1 in that it reads `CSSTI_SHS_*` (Customer-Designated-Ship-to-Address) columns instead of `KEISHA_*` (Company) columns. The schema ID remains `CK0011`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbList = new JBSbatCommonDBInterface()` [L149] |
| 2 | EXEC | `dbList.setValue(strAdCd)` [L150] |
| 3 | CALL | `db_CK_T_CUST.selectBySqlDefine(dbList, "KK_SELECT_044")` — selects designated delivery addresses [L152] |
| 4 | SET | `map = new JBSbatCommonDBInterface()` [L155] |
| 5 | WHILE | `while((map=db_CK_T_CUST.selectNext())!=null)` [L156] |
| 6 | BLOCK 3.1 — [WITHIN LOOP] For each designated delivery row |
| 7 | SET | `inDbMap = new JBSbatCommonDBInterface()` [L158] |
| 8 | SET | `seqNo = JCCOracleSeqUtil.getFormatedNextSeq(...)` [L160] |
| 9 | SET | `inDbMap.setValue(CHG_AD_JGRTWK_NO, seqNo)` [L161] |
| 10 | SET | `inDbMap.setValue(CHG_TG_SCHEMA_ID, "CK0011")` — same schema as Process 1 [L162] |
| 11 | SET | `inDbMap.setValue(CHG_TG_KMK_NM_EINM, "CSSTI_SHS_AD_CD")` — Customer-designated ship-to address code [L163] |
| 12–36 | SET | Remaining 25 field assignments identical structure to Block 2, but read `CSSTI_SHS_*` columns instead of `KEISHA_*` columns for OLD_AD_CD through OLD_AZCHO_NM fields. Then sets the same audit constants (HENKO_ADD_CD_FUKA="4", UPD_FAIL_RSN_MANINPFLG="03") and calls `insertByPrimaryKeys`. |

**Block 4** — [WHILE LOOP] Process 3: Individual Customer (Customer (Individual)) (L198–L243)

> Queries `CK_T_CUST_KOJIN` (Individual Customer table) using SQL define `KK_SELECT_007`. Uses schema ID `CK0021` and reads `SKSHA_*` (Individual Customer Address) columns for historical data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbList = new JBSbatCommonDBInterface()` [L199] |
| 2 | EXEC | `dbList.setValue(strAdCd)` [L200] |
| 3 | CALL | `db_CK_T_CUST_KOJIN.selectBySqlDefine(dbList, "KK_SELECT_007")` [L202] |
| 4 | SET | `map = new JBSbatCommonDBInterface()` [L205] |
| 5 | WHILE | `while((map=db_CK_T_CUST_KOJIN.selectNext())!=null)` [L206] |
| 6 | BLOCK 4.1 — [WITHIN LOOP] For each individual customer row |
| 7 | SET | `inDbMap = new JBSbatCommonDBInterface()` [L208] |
| 8 | SET | `seqNo = JCCOracleSeqUtil.getFormatedNextSeq(...)` [L210] |
| 9 | SET | `inDbMap.setValue(CHG_AD_JGRTWK_NO, seqNo)` [L211] |
| 10 | SET | `inDbMap.setValue(CHG_TG_SCHEMA_ID, "CK0021")` — Individual customer schema [L212] |
| 11 | SET | `inDbMap.setValue(CHG_TG_KMK_NM_EINM, "SKSHA_AD_CD")` — 個人住所コード (Individual Address Code) [L213] |
| 12–36 | SET | 25 field assignments reading `SKSHA_*` columns for OLD_*, with same audit constants ("4" and "03"), followed by `insertByPrimaryKeys`. |

**Block 5** — [WHILE LOOP] Process 4: Equipment Provider Service Contract (Equipment Delivery Address Code) (L248–L293)

> Queries `KK_T_KKTK_SVC_KEI` (Equipment Provider Service Contract table) using SQL define `KK_SELECT_108`. Uses schema ID `KK0341` and reads `KIKI_SOHUS_*` (Equipment Subscription) columns.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbList = new JBSbatCommonDBInterface()` [L249] |
| 2 | EXEC | `dbList.setValue(strAdCd)` [L250] |
| 3 | CALL | `db_KK_T_KKTK_SVC_KEI.selectBySqlDefine(dbList, "KK_SELECT_108")` [L252] |
| 4 | SET | `map = new JBSbatCommonDBInterface()` [L255] |
| 5 | WHILE | `while((map=db_KK_T_KKTK_SVC_KEI.selectNext())!=null)` [L256] |
| 6 | BLOCK 5.1 — [WITHIN LOOP] For each equipment provider row |
| 7–11 | SET | Same structure: seqNo, schema ID `KK0341`, KMK_NM `KIKI_SOHUS_AD_CD`, then 25 field assignments reading `KIKI_SOHUS_*` columns. |
| 12 | CALL | `insertByPrimaryKeys(inDbMap)` [L292] |

**Block 6** — [WHILE LOOP] Process 5: Optional Service Contract — TV (TV Guide Subscription Address Code) (L298–L343)

> Queries `KK_T_OPSVKEI_TV` (Optional Service TV table) using SQL define `KK_SELECT_007`. Uses schema ID `KK0381` and reads `GUIDEMG_SOHUS_*` (Guide Management Subscription) columns.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbList = new JBSbatCommonDBInterface()` [L299] |
| 2 | EXEC | `dbList.setValue(strAdCd)` [L300] |
| 3 | CALL | `db_KK_T_OPSVKEI_TV.selectBySqlDefine(dbList, "KK_SELECT_007")` [L302] |
| 4 | SET | `map = new JBSbatCommonDBInterface()` [L305] |
| 5 | WHILE | `while((map=db_KK_T_OPSVKEI_TV.selectNext())!=null)` [L306] |
| 6 | BLOCK 6.1 — [WITHIN LOOP] |
| 7–11 | SET | seqNo, schema ID `KK0381`, KMK_NM `GUIDEMG_SOHUS_AD_CD` (TV Guide Subscription Address Code), 25 field assignments reading `GUIDEMG_SOHUS_*`columns. |
| 12 | CALL | `insertByPrimaryKeys(inDbMap)` [L342] |

**Block 7** — [WHILE LOOP] Process 6: Billing Contract (Billing Address Code) (L348–L393)

> Queries `KK_T_SEIKY_KEI` (Billing Contract table) using SQL define `KK_SELECT_056`. Uses schema ID `KK0491` and reads `SOHUS_*` (Subscription) columns.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbList = new JBSbatCommonDBInterface()` [L349] |
| 2 | EXEC | `dbList.setValue(strAdCd)` [L350] |
| 3 | CALL | `db_KK_T_SEIKY_KEI.selectBySqlDefine(dbList, "KK_SELECT_056")` [L352] |
| 4 | SET | `map = new JBSbatCommonDBInterface()` [L355] |
| 5 | WHILE | `while((map=db_KK_T_SEIKY_KEI.selectNext())!=null)` [L356] |
| 6 | BLOCK 7.1 — [WITHIN LOOP] |
| 7–11 | SET | seqNo, schema ID `KK0491`, KMK_NM `SOHUS_AD_CD` (Subscription Address Code), 25 field assignments reading `SOHUS_*` columns. |
| 12 | CALL | `insertByPrimaryKeys(inDbMap)` [L392] |

**Block 8** — [COMMENTED OUT — DISABLED] ANK-4494-00-00 DEL START/END (L396–L560)

> Three disabled work project sub-blocks (NTT Customer Address → `KK_SELECT_020`/`KU_T_KOJIAK`, Schema `KU0011`; Doban [Number Port] → `KK_SELECT_003`/`TU_T_DOBANITEN`, Schema `TU0021`). Disabled as part of 2024/03/06 bidirectional Doban [number port] support change.

| # | Type | Code |
|---|------|------|
| 1 | COMMENT | `ANK-4494-00-00 DEL START` — All code between here and DEL END is commented out |

**Block 9** — [WHILE LOOP] Process 7A: Phone Application Contents — Postal Code (Postal Code Address Code) (L565–L610)

> Queries `TU_T_DNWACHOMSK_NYO` (Phone Application Contents table) using SQL define `KK_SELECT_004`. Uses schema ID `TU0091` and reads `KEISAI_*` (Posting/Listing — Postal Code) columns.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbList = new JBSbatCommonDBInterface()` [L566] |
| 2 | EXEC | `dbList.setValue(strAdCd)` [L567] |
| 3 | CALL | `db_TU_T_DNWACHOMSK_NYO.selectBySqlDefine(dbList, "KK_SELECT_004")` [L569] |
| 4 | SET | `map = new JBSbatCommonDBInterface()` [L572] |
| 5 | WHILE | `while((map=db_TU_T_DNWACHOMSK_NYO.selectNext())!=null)` [L573] |
| 6 | BLOCK 9.1 — [WITHIN LOOP] |
| 7–11 | SET | seqNo, schema ID `TU0091`, KMK_NM `KEISAI_AD_CD` (Postal Code Address Code), 25 field assignments reading `KEISAI_*` columns. |
| 12 | CALL | `insertByPrimaryKeys(inDbMap)` [L609] |

**Block 10** — [WHILE LOOP] Process 7B: Phone Application Contents — Installation Site (Installation Site Address Code) (L615–L660)

> Queries the same table `TU_T_DNWACHOMSK_NYO` but with SQL define `KK_SELECT_005` (a different query for installation site addresses). Schema ID remains `TU0091`. Reads `SETPLACE_*` (Installation Site) columns for historical data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dbList = new JBSbatCommonDBInterface()` [L616] |
| 2 | EXEC | `dbList.setValue(strAdCd)` [L617] |
| 3 | CALL | `db_TU_T_DNWACHOMSK_NYO.selectBySqlDefine(dbList, "KK_SELECT_005")` [L619] |
| 4 | SET | `map = new JBSbatCommonDBInterface()` [L622] |
| 5 | WHILE | `while((map=db_TU_T_DNWACHOMSK_NYO.selectNext())!=null)` [L623] |
| 6 | BLOCK 10.1 — [WITHIN LOOP] |
| 7–11 | SET | seqNo, schema ID `TU0091`, KMK_NM `SETPLACE_AD_CD` (Installation Site Address Code), 25 field assignments reading `SETPLACE_*` columns. |
| 12 | CALL | `insertByPrimaryKeys(inDbMap)` [L659] |

**Block 11** — [SET] Work table update parameters (Change Target Address Code Work processing status update) (L666–L668)

> Prepares the UPDATE statement to mark the address code transformation work as completed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `valueMap = new JBSbatCommonDBInterface()` [L667] |
| 2 | SET | `valueMap.setValue(JBSbatKK_T_CHGTGAD_CD_WK.MANIPT_CHG_AD_TRN_STAT_CD, JKKBatConst.HENKO_ADD_CD_ZM)` `[-> HENKO_ADD_CD_ZM="9"]` — Set status to "processed" [L668] |

**Block 12** — [SET] WHERE clause parameters for work table update (L671–L672)

| # | Type | Code |
|---|------|------|
| 1 | SET | `whereMap = new JBSbatCommonDBInterface()` [L671] |
| 2 | SET | `whereMap.setValue(JBSbatKK_T_CHGTGAD_CD_WK.AD_CD, strAdCd)` — WHERE AD_CD = input address code [L672] |

**Block 13** — [CALL] Update work table and commit (L675–L679)

> Updates the work table to mark the address code as processed, commits all changes, and returns.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `db_CHGTGAD_CD_WK.updateByPrimaryKeys(whereMap, valueMap)` — UPDATE文を実行する (Execute UPDATE statement) [L675] |
| 2 | CALL | `super.commit()` — Commit the transaction [L678] |
| 3 | RETURN | `return null` [L680] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `AD_CD` | Field | Address Code — internal numeric/string identifier for a geographic address, used as the primary filtering key across all source queries |
| `PCD` | Field | Postal Code — Japanese postal addressing code |
| `SVC_KEI_NO` | Field | Service Category Number — internal tracking identifier for a service line item / contract category |
| `AD_SHUSEI_CD` | Field | Address Consolidation Code — code indicating whether the address has undergone municipal consolidation (Japan's address reform) |
| `SYSID` | Field | System ID — system-level unique identifier for a customer or service entity |
| `CHG_AD_JGRTWK_NO` | Field | Change Address Judgment Work Number — unique sequence-generated identifier for each address change record in `KK_T_CHG_AD_JGRTWK` |
| `CHG_TG_SCHEMA_ID` | Field | Change Target Schema ID — a domain-specific code (e.g., `CK0011`, `CK0021`, `KK0341`, `KK0381`, `KK0491`, `TU0091`) identifying which data schema/domain the record belongs to |
| `CHG_TG_KMK_NM_EINM` | Field | Change Target Customer Name (English Name) — the English short name for the address type (e.g., `KEISHA_AD_CD`, `CSSTI_SHS_AD_CD`, `SKSHA_AD_CD`) |
| `AD_TOHAIGO_TRN_STAT_CD` | Field | Address Post-Change Transfer Status Code — indicates processing status of the address change record |
| `AD_TOHAIGO_UPD_FAIL_RSN_CD` | Field | Address Post-Change Update Failure Reason Code — reason code for any update failure |
| `AD_CHG_SBT_CD` | Field | Address Change Sub-type Code — further classifies the type of address change |
| `NEW_AD_CD` / `NEW_PCD` / etc. | Field | New Address fields — the updated/current address values from the source table |
| `OLD_AD_CD` / `OLD_PCD` / etc. | Field | Old/Historical Address fields — the previous address values, sourced from domain-specific columns (KEISHA_*, CSSTI_SHS_*, SKSHA_*, etc.) |
| `HENKO_ADD_CD_FUKA` | Constant | Value `"4"` — 変更追加コード:付加 (Change Addition Code: Unattached) — indicates the address transfer has not yet been processed; used as initial status for all new records |
| `HENKO_ADD_CD_ZM` | Constant | Value `"9"` — 変更追加コード:済 (Change Addition Code: Completed) — indicates the address transformation work has been completed; used to mark the work table after processing |
| `UPD_FAIL_RSN_MANINPFLG` | Constant | Value `"03"` — 更新失敗理由: manual input flag — indicates the record originated from manual input rather than being an automated processing failure |
| SEQ_CHG_AD_JGRTWK_NO | Constant | Oracle database sequence name used to generate unique work numbers for each address change record |
| KEISHA_AD_CD | Field | 企業住所コード (Company Address Code) — the address code associated with a corporate/enterprise NTT customer contract |
| CSSTI_SHS_AD_CD | Field | Customer-Designated Ship-to Address Code — an alternate delivery address specified by the customer |
| SKSHA_AD_CD | Field | 個人住所コード (Individual Address Code) — the residential address of an individual (non-enterprise) customer |
| KIKI_SOHUS_AD_CD | Field | 機器契約住所コード (Equipment Contract Address Code) — address associated with an equipment provider service contract |
| GUIDEMG_SOHUS_AD_CD | Field | TV Guide Management Subscription Address Code — address for optional TV guide service subscription |
| SOHUS_AD_CD | Field | 契約住所コード (Contract Subscription Address Code) — address associated with the primary billing contract |
| KEISAI_AD_CD | Field | 掲示住所コード (Posting/Listing Address Code) — address for phone application content (postal code variant) |
| SETPLACE_AD_CD | Field | 設置場所住所コード (Installation Site Address Code) — address where equipment/service is physically installed |
| KK_T_CUST | Table | Customer Contract Address Master Table — stores address data for NTT enterprise customer contracts |
| CK_T_CUST_KOJIN | Table | Individual Customer Address Table — stores address data for individual (non-enterprise) customers |
| KK_T_KKTK_SVC_KEI | Table | Equipment Provider Service Contract Table — stores data for equipment-related service contracts |
| KK_T_OPSVKEI_TV | Table | Optional Service TV Contract Table — stores data for TV-related optional service subscriptions |
| KK_T_SEIKY_KEI | Table | Billing Contract Table — stores data for billing/subscription contract records |
| KK_T_CHG_AD_JGRTWK | Table | Change Address Judgment Work Table — the target table where all extracted address change records are inserted for downstream processing |
| KK_T_CHGTGAD_CD_WK | Table | Change Target Address Code Work Table — a work table that tracks which address codes have been processed; updated at the end of execute() |
| TU_T_DNWACHOMSK_NYO | Table | Phone Application Contents Application Table — stores phone application (dial-down/machine) service content with address data |
| CK_T_CUST | Table | Customer Master Address Table (CK prefix) — contains address data for both contract and designated delivery addresses |
| KK_SELECT_043 | SQL Define | SQL template identifier for querying NTT customer contract addresses |
| KK_SELECT_044 | SQL Define | SQL template identifier for querying customer designated delivery addresses |
| KK_SELECT_007 | SQL Define | SQL template identifier used across multiple tables for individual customer and optional service queries |
| KK_SELECT_108 | SQL Define | SQL template identifier for querying equipment provider service contract addresses |
| KK_SELECT_056 | SQL Define | SQL template identifier for querying billing contract addresses |
| KK_SELECT_004 | SQL Define | SQL template identifier for querying phone application contents (postal code variant) |
| KK_SELECT_005 | SQL Define | SQL template identifier for querying phone application contents (installation site variant) |
| CK0011 | Schema ID | Change target schema identifier for customer contract address domain |
| CK0021 | Schema ID | Change target schema identifier for individual customer address domain |
| KK0341 | Schema ID | Change target schema identifier for equipment provider service domain |
| KK0381 | Schema ID | Change target schema identifier for optional service TV domain |
| KK0491 | Schema ID | Change target schema identifier for billing contract domain |
| TU0091 | Schema ID | Change target schema identifier for phone application contents domain |
| KU0011 | Schema ID | Change target schema identifier for work project domain (currently disabled) |
| TU0011 | Schema ID | Change target schema identifier for Doban/Number Port work domains (currently disabled) |
| TU0021 | Schema ID | Change target schema identifier for number port transfer domain (currently disabled) |
| NTT | Business term | Nippon Telegraph and Telephone — Japan's primary telecommunications provider; "NTT Contract Holder" refers to enterprise customers |
| Doban | Business term | 番ポート — Number Portability — the ability to retain an existing phone number when switching service providers |
| ANK-4494 | Jira/Ticket | Internal change tracking ticket for bidirectional Doban [number port] support (2024/03/06) |
