# Business Logic — JKKUsePlaceAdInfUpdCC.createPrgTokkiMapEmgAd() [88 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKUsePlaceAdInfUpdCC` |
| Layer | Common Component (CC) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKUsePlaceAdInfUpdCC.createPrgTokkiMapEmgAd()

This method generates the "progress special remarks" (進捗特記事項 — `prg_tkjk`) for an emergency contact address change (`緊急通報先住所変更`) within the Fujitsu Futurity telecom order fulfillment system. It operates as a string-builder utility that compares old values from `kk0191_a010_map` against new values from `updateMap` and constructs human-readable, comma-delimited before/after description strings documenting which address fields changed. Specifically, it handles two categories of address data: (1) the emergency contact postal code (緊急通報用補正郵便番号) and (2) the full seven-field postal address (都道府県名 → 大字通名称 → 建物名/部屋番号). If any address field changed, all seven address fields are rendered in full. The output strings are trimmed of trailing Japanese commas and truncated to a maximum of 128 characters to comply with system constraints (スキーマの制限). This method is a private builder called by `updateEmgContactAd()` during the emergency contact address update loop.

## 2. Processing Pattern (Detailed Business Logic)

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

    START --> INIT["Initialize: prgMap, prg_tkjk_e040, prg_tkjk2_e040 as empty strings"]

    INIT --> CHK_PCD["Compare old vs new Postal Code<br/>(EMG_HOSEI_PCD vs ad_pcd)"]

    CHK_PCD -->|Different| PCD_BUILD["Append postal code label + old value + comma<br/>and new value + comma to prg_tkjk_e040/prg_tkjk2_e040"]
    CHK_PCD -->|Same| CHK_ADDR["Check address fields"]

    PCD_BUILD --> CHK_ADDR

    CHK_ADDR -->|Any of 7 fields differ| ADDR_BUILD["Append full address label + all 7 old values + comma<br/>and new label + all 7 new values + comma<br/>to prg_tkjk_e040/prg_tkjk2_e040"]
    CHK_ADDR -->|All 7 fields same| TRIM_PCD["Trim trailing delimiter from prg_tkjk_e040"]

    ADDR_BUILD --> TRIM_PCD

    TRIM_PCD --> CHK_PCD_LEN["Length of prg_tkjk_e040 > 0?"]

    CHK_PCD_LEN -->|Yes| STRIP_END["Remove last character (trailing comma)"]
    CHK_PCD_LEN -->|No| SKIP_PCD

    STRIP_END --> CHK_PCD_MAX["Length > PRG_TKJK_MAX_VALUE (128)?"]

    CHK_PCD_MAX -->|Yes| TRUNCATE["Truncate prg_tkjk_e040 to 128 characters"]
    CHK_PCD_MAX -->|No| TRIM_PCD2["Trim trailing delimiter from prg_tkjk2_e040"]

    TRUNCATE --> TRIM_PCD2

    TRIM_PCD2 --> CHK_PCD2_LEN["Length of prg_tkjk2_e040 > 0?"]

    CHK_PCD2_LEN -->|Yes| STRIP_END2["Remove last character (trailing comma)"]
    CHK_PCD2_LEN -->|No| SKIP_PCD2

    STRIP_END2 --> CHK_PCD2_MAX["Length > 128?"]

    CHK_PCD2_MAX -->|Yes| TRUNCATE2["Truncate prg_tkjk2_e040 to 128 characters"]
    CHK_PCD2_MAX -->|No| PRG_MAP_SET

    TRUNCATE2 --> PRG_MAP_SET

    SKIP_PCD["Skip trimming prg_tkjk_e040"] --> TRIM_PCD2

    SKIP_PCD2["Skip trimming prg_tkjk2_e040"] --> PRG_MAP_SET

    PRG_MAP_SET["Set PRG_TKJK_1 and PRG_TKJK_2 in prgMap<br/>then return prgMap"] --> END(["Return prgMap"])
```

**Constant Resolution Reference:**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `PCG_RIYOBASHO_PCD_TEXT` | `"変更前郵便番号:"` | Label: "Before change postal code" |
| `PCG_RIYOBASHO_PCD_TEXT_AF` | `"変更後郵便番号:"` | Label: "After change postal code" |
| `PCG_RIYOBASHO_AD_TEXT` | `"変更前住所:"` | Label: "Before change address" |
| `PCG_RIYOBASHO_AD_TEXT_AF` | `"変更後住所:"` | Label: "After change address" |
| `PCG_KUTEN_CANMA` | `"、"` | Japanese comma — field separator |
| `PRG_TKJK_MAX_VALUE` | `128` | Maximum character limit for special remarks |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `kk0191_a010_map` | `HashMap<String, Object>` | The **old** emergency contact address data — contains previously stored values from the `EKK0191A010` CBS (Service Contract - EO Fiber Optic Telephone) agreement. Key entries include `EMG_HOSEI_PCD` (postal code), `EMG_STATE_NM` (prefecture), `EMG_CITY_NM` (city), `EMG_OAZTSU_NM` (district), `EMG_AZCHO_NM` (block), `EMG_BNCHIGO` (land number), `EMG_ADRTTM` (building supplementary info), and `EMG_ADRRM` (room number). Used for the "before" snapshot in the progress remarks. |
| 2 | `updateMap` | `HashMap<String, Object>` | The **new** address change data — contains the updated values the user or system is submitting. Uses parameter keys like `PARAM_AD_PCD` ("ad_pcd"), `PARAM_AD_STATE_NM` ("ad_state"), `PARAM_AD_CITY_NM` ("ad_city"), etc. Used for the "after" snapshot. |

**Instance fields and static constants read by this method:**

| Field | Type | Business Meaning |
|-------|------|-----------------|
| `PRG_TKJK_MAX_VALUE` | `static final int = 128` | Schema-enforced maximum length for special remarks strings |
| `PCG_RIYOBASHO_PCD_TEXT` | `static final String = "変更前郵便番号:"` | Display label prefix for "before" postal code |
| `PCG_RIYOBASHO_PCD_TEXT_AF` | `static final String = "変更後郵便番号:"` | Display label prefix for "after" postal code |
| `PCG_RIYOBASHO_AD_TEXT` | `static final String = "変更前住所:"` | Display label prefix for "before" address |
| `PCG_RIYOBASHO_AD_TEXT_AF` | `static final String = "変更後住所:"` | Display label prefix for "after" address |
| `PCG_KUTEN_CANMA` | `static final String = "、"` | Japanese comma used as field separator |
| `PARAM_AD_PCD` | `static final String = "ad_pcd"` | Key for postal code in updateMap |
| `PARAM_AD_STATE_NM` | `static final String = "ad_state"` | Key for prefecture name in updateMap |
| `PARAM_AD_CITY_NM` | `static final String = "ad_city"` | Key for city name in updateMap |
| `PARAM_AD_OAZTSU_NM` | `static final String = "ad_oaztsu"` | Key for district name in updateMap |
| `PARAM_AD_AZCHO_NM` | `static final String = "ad_azcho"` | Key for block name in updateMap |
| `PARAM_AD_BNCHIGO` | `static final String = "ad_bnchigo"` | Key for land/lot number in updateMap |
| `PARAM_AD_ADRTTM` | `static final String = "ad_adrttm"` | Key for building supplementary info in updateMap |
| `PARAM_AD_ADRRM` | `static final String = "ad_adrrm"` | Key for room number in updateMap |
| `EKK1091D010CBSMsg.PRG_TKJK_1` | `static final String = "prg_tkjk_1"` | Output key for "before" progress remarks |
| `EKK1091D010CBSMsg.PRG_TKJK_2` | `static final String = "prg_tkjk_2"` | Output key for "after" progress remarks |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKUsePlaceAdInfUpdCC.isSameObj` | JKKUsePlaceAdInfUpdCC | - | Utility method that compares two objects for equality (handles null safely). Called 8 times — once for postal code and once for each of the 7 address fields — to detect whether values differ between old and new maps. No database interaction. |
| - | `String.substring` | String | - | Standard Java `String.substring(0, n)` used to truncate progress remarks strings to 128 characters when they exceed the schema limit. Called 4 times total. |
| - | `String.length` | String | - | Standard Java `String.length()` used to check string lengths for empty-string and overflow conditions. Called 4 times total. |

**Notes:** This method performs **no database or CBS operations**. It is a pure data-transformation utility that compares maps in memory and builds formatted strings. All "CRUD" entries are method calls on parameters and local objects (EXEC type), not service-component invocations.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC:JKKUsePlaceAdInfUpdCC | `updateEmgContactAd(handle, param, fixedText, scCall, paramMap)` → `createPrgTokkiMapEmgAd(kk0191_a010_map, paramMap)` | `isSameObj [EXEC] in-memory comparison`, `substring [EXEC] String truncation` |

**Context:** `createPrgTokkiMapEmgAd` is a `private` method called from within `updateEmgContactAd()` at approximately line 1329 of `JKKUsePlaceAdInfUpdCC.java`. `updateEmgContactAd()` is invoked as part of the emergency contact address change loop, iterating over service contract details (`kk0191_b001_list`) and comparing old vs. new values. The entire call chain originates from higher-level CBS or OPOperation entry points (e.g., screen processing classes such as `KKSVxxxxOPOperation`) that trigger the address update flow. This method itself is the terminal leaf in the call chain — it performs no downstream service calls, only in-memory string building.

## 6. Per-Branch Detail Blocks

**Block 1** — [INITIALIZATION] (L2826-L2830)

Initialize working variables. The method starts by creating an empty result map and two empty string builders for the "before" and "after" progress remarks.

| # | Type | Code |
|---|------|------|
| 1 | SET | `prgMap = new HashMap<String, Object>()` |
| 2 | SET | `prg_tkjk_e040 = ""` |
| 3 | SET | `prg_tkjk2_e040 = ""` |

---

**Block 2** — [IF] `!isSameObj(old postal code, new postal code)` — EMG_HOSEI_PCD vs ad_pcd (L2837-L2842)

Compare the emergency contact postal code before and after the change. If the values differ, append labeled entries to both progress remark strings. The comment indicates this is under the service contract category "EO Fiber Optic Telephone" (サービス契約内詳：eo光電話).

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `prg_tkjk_e040 = prg_tkjk_e040 + PCG_RIYOBASHO_PCD_TEXT + old_pcd + PCG_KUTEN_CANMA` | Append "Before: postal code = [value]、" to the before-string |
| 2 | SET | `prg_tkjk2_e040 = prg_tkjk2_e040 + PCG_RIYOBASHO_PCD_TEXT_AF + new_pcd + PCG_KUTEN_CANMA` | Append "After: postal code = [value]、" to the after-string |

**Constant Resolution:**
- `PCG_RIYOBASHO_PCD_TEXT` = `"変更前郵便番号:"` (Label: "Before change postal code:")
- `PCG_RIYOBASHO_PCD_TEXT_AF` = `"変更後郵便番号:"` (Label: "After change postal code:")
- `PCG_KUTEN_CANMA` = `"、"` (Japanese comma — field separator)
- `EMG_HOSEI_PCD` = `"emg_hosei_pcd"` (Key: Emergency contact corrected postal code)
- `PARAM_AD_PCD` = `"ad_pcd"` (Key: Postal code in update map)

---

**Block 3** — [IF] Any of 7 address fields differ (L2845-L2876)

If any one of the seven address components changed (prefecture, city, district, block, lot number, building supplementary info, or room number), build the full address description for both old and new values. The method does a bulk comparison — if even one field differs, all seven fields are rendered.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `prg_tkjk_e040 = prg_tkjk_e040 + PCG_RIYOBASHO_AD_TEXT + old_state + old_city + old_oaztsu + old_azcho + old_bnchigo + old_adrttm + old_adrrm + PCG_KUTEN_CANMA` | Build before-address string: "Before: address = [prefecture][city][district][block][lot][building info][room]、" |
| 2 | SET | `prg_tkjk2_e040 = prg_tkjk2_e040 + PCG_RIYOBASHO_AD_TEXT_AF + new_state + new_city + new_oaztsu + new_azcho + new_bnchigo + new_adrttm + new_adrrm + PCG_KUTEN_CANMA` | Build after-address string with the same structure using new values |

**Constant Resolution:**
- `PCG_RIYOBASHO_AD_TEXT` = `"変更前住所:"` (Label: "Before change address:")
- `PCG_RIYOBASHO_AD_TEXT_AF` = `"変更後住所:"` (Label: "After change address:")
- `EMG_STATE_NM` = `"emg_state_nm"` → Key: Prefecture name
- `EMG_CITY_NM` = `"emg_city_nm"` → Key: City name
- `EMG_OAZTSU_NM` = `"emg_oaztsu_nm"` → Key: District name (大字通)
- `EMG_AZCHO_NM` = `"emg_azcho_nm"` → Key: Block name (字丁目)
- `EMG_BNCHIGO` = `"emg_bnchigo"` → Key: Lot/land number
- `EMG_ADRTTM` = `"emg_adrttm"` → Key: Building supplementary info
- `EMG_ADRRM` = `"emg_adrrm"` → Key: Room number
- `PARAM_AD_STATE_NM` = `"ad_state"`
- `PARAM_AD_CITY_NM` = `"ad_city"`
- `PARAM_AD_OAZTSU_NM` = `"ad_oaztsu"`
- `PARAM_AD_AZCHO_NM` = `"ad_azcho"`
- `PARAM_AD_BNCHIGO` = `"ad_bnchigo"`
- `PARAM_AD_ADRTTM` = `"ad_adrttm"`
- `PARAM_AD_ADRRM` = `"ad_adrrm"`

---

**Block 4** — [IF] `prg_tkjk_e040` has content → Trim trailing comma and truncate (L2879-L2895)

Apply final formatting to the before-remarks string. First remove the trailing Japanese comma delimiter, then truncate to 128 characters if needed.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `prg_tkjk_length = prg_tkjk_e040.length()` | Get the string length |
| 2 | IF | `prg_tkjk_e040 != null && !"".equals(prg_tkjk_e040) && prg_tkjk_length > 0` | Guard against empty strings |
| 2.1 | SET | `prg_tkjk_getalue = prg_tkjk_e040.substring(0, prg_tkjk_length - 1)` | Remove trailing character (Japanese comma) |
| 2.2 | SET | `prg_tkjk_e040 = prg_tkjk_getalue` | Reassign trimmed string |
| 2.3 | IF | `prg_tkjk_length - 1 > PRG_TKJK_MAX_VALUE` (`128`) | Check if exceeded schema limit |
| 2.3.1 | SET | `prg_tkjk_select = prg_tkjk_e040.substring(0, PRG_TKJK_MAX_VALUE)` | Extract first 128 characters |
| 2.3.2 | SET | `prg_tkjk_e040 = prg_tkjk_select` | Reassign truncated string |

**Constant Resolution:**
- `PRG_TKJK_MAX_VALUE` = `128` (Maximum allowed characters for progress special remarks)

**Comment from source (translated):** "Due to schema constraints, the character count of the special remarks is limited to 256 characters. Remove the final comma from the special remarks (extract the portion excluding the final character)."

Note: The code comment mentions 256 characters as the limit, but the actual constant `PRG_TKJK_MAX_VALUE` is 128. This is the effective runtime limit.

---

**Block 5** — [IF] `prg_tkjk2_e040` has content → Trim trailing comma and truncate (L2896-L2912)

Apply the same formatting to the after-remarks string: remove trailing comma and truncate to 128 characters if needed. This mirrors Block 4 for the second string.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `prg_tkjk2_length = prg_tkjk2_e040.length()` | Get the string length |
| 2 | IF | `prg_tkjk2_e040 != null && !"".equals(prg_tkjk2_e040) && prg_tkjk2_length > 0` | Guard against empty strings |
| 2.1 | SET | `prg_tkjk2_getalue = prg_tkjk2_e040.substring(0, prg_tkjk2_length - 1)` | Remove trailing character (Japanese comma) |
| 2.2 | SET | `prg_tkjk2_e040 = prg_tkjk2_getalue` | Reassign trimmed string |
| 2.3 | IF | `prg_tkjk2_length - 1 > PRG_TKJK_MAX_VALUE` (`128`) | Check if exceeded schema limit |
| 2.3.1 | SET | `prg_tkjk2_select = prg_tkjk2_e040.substring(0, PRG_TKJK_MAX_VALUE)` | Extract first 128 characters |
| 2.3.2 | SET | `prg_tkjk2_e040 = prg_tkjk2_select` | Reassign truncated string |

---

**Block 6** — [SET] + [RETURN] Set result map and return (L2913-L2915)

Place both formatted progress remark strings into the result map with their designated keys and return.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `prgMap.put(EKK1091D010CBSMsg.PRG_TKJK_1, prg_tkjk_e040)` | Map "before" progress remarks under key `"prg_tkjk_1"` |
| 2 | SET | `prgMap.put(EKK1091D010CBSMsg.PRG_TKJK_2, prg_tkjk2_e040)` | Map "after" progress remarks under key `"prg_tkjk_2"` |
| 3 | RETURN | `return prgMap` | Return the populated map |

**Constant Resolution:**
- `EKK1091D010CBSMsg.PRG_TKJK_1` = `"prg_tkjk_1"` (Progress special remarks 1 — before state)
- `EKK1091D010CBSMsg.PRG_TKJK_2` = `"prg_tkjk_2"` (Progress special remarks 2 — after state)

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|-----------------|
| `prg_tkjk` | Field | Progress special remarks (進捗特記事項) — human-readable text describing what changed during a service order operation |
| `EMG_HOSEI_PCD` | Field | Emergency contact corrected postal code (緊急通報用補正郵便番号) — the postal code for the emergency contact address |
| `EMG_STATE_NM` | Field | Emergency contact prefecture name (緊急通報先都道府県名) |
| `EMG_CITY_NM` | Field | Emergency contact city name (緊急通報先市区町村名) |
| `EMG_OAZTSU_NM` | Field | Emergency contact district name (緊急通報先大字通名称) — large district / thoroughfare name in Japanese addresses |
| `EMG_AZCHO_NM` | Field | Emergency contact block name (緊急通報先字丁目名) — block/chome name in Japanese addresses |
| `EMG_BNCHIGO` | Field | Emergency contact lot/land number (緊急通報先住所番地号) |
| `EMG_ADRTTM` | Field | Emergency contact building supplementary info (緊急通報先住所補記・建物名) — building name or address notes |
| `EMG_ADRRM` | Field | Emergency contact room number (緊急通報先住所補記・部屋番号) |
| `PARAM_AD_PCD` | Field | Address postal code parameter key — the "ad_pcd" entry in the update map |
| `PARAM_AD_STATE_NM` | Field | Address prefecture name parameter key — "ad_state" |
| `PARAM_AD_CITY_NM` | Field | Address city name parameter key — "ad_city" |
| `PARAM_AD_OAZTSU_NM` | Field | Address district name parameter key — "ad_oaztsu" |
| `PARAM_AD_AZCHO_NM` | Field | Address block name parameter key — "ad_azcho" |
| `PARAM_AD_BNCHIGO` | Field | Address lot number parameter key — "ad_bnchigo" |
| `PARAM_AD_ADRTTM` | Field | Address building info parameter key — "ad_adrttm" |
| `PARAM_AD_ADRRM` | Field | Address room number parameter key — "ad_adrrm" |
| `EKK0191A010` | CBS Code | Service Contract - EO Fiber Optic Telephone agreement (サービス契約内詳：eo光電話) — CBS for emergency contact address data |
| `EKK1091D010CBSMsg` | CBS Msg | Progress special remarks message class — defines keys PRG_TKJK_1 and PRG_TKJK_2 for before/after remarks |
| EO Fiber | Business term | EO (Enoki Optical) Fiber — NTT's fiber-to-the-home optical internet service |
| CBS | Acronym | Component Business Service — the service component layer that handles data access and business logic execution |
| CC | Acronym | Common Component — shared business logic class, used here for address update operations |
| 進捗特記事項 | Business term | Progress special remarks — formatted text documenting what changed during a service order lifecycle step |
| 緊急通報先住所 | Business term | Emergency contact address — the address used for emergency notification purposes (e.g., emergency dispatch) |
| 郵便番号 | Business term | Postal code — Japanese 7-digit postal code (〒 format) |
| 都道府県 | Business term | Prefecture — Japan's primary administrative division (e.g., Tokyo, Osaka) |
| 市区町村 | Business term | City/town/village — secondary administrative division within a prefecture |
| 大字通 | Business term | Large district / thoroughfare — primary street or area designation in Japanese addresses |
| 字丁目 | Business term | Block/chome — neighborhood subdivision within a district |
| PCG_KUTEN_CANMA | Constant | Japanese comma "、" — used as a delimiter between address fields in the remarks string |
