---

# Business Logic — JKKAdchgTelInfoChgCC.appendSvcKeiUcwk() [110 LOC]

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

## 1. Role

### JKKAdchgTelInfoChgCC.appendSvcKeiUcwk()

This method is responsible for **adding service detail lines** (内訳 — ukiwae) during a **telecom service contract change operation** triggered by a customer address relocation (転居 — tsumugi). Specifically, it appends new line-item records to the existing service contract when a customer is changing their phone number as part of the relocation process.

The method handles **two distinct service types** (defined by the `use_svc_chg_div` service change classification): **「追加」(Add, value "3")** and **「継続」/「変更」(Continue/Change, value other than "3")**. For the Add branch, it may perform a pre-service-number-addition workflow that includes number addition (`addTelnoInfo`), number portability work registration (`addBmpo`), SOD issuance for number addition (`hakkoSODhtelNoAdd`), and value attachment update (`updateSvcKeiUcwkVaHimoduke`) to handle multi-function router exchange scenarios. For the Continue/Modify branch, it either performs number addition (when no original phone number exists) or updates existing phone number information by invoking `JKKTelnoInfoChgCC.appendTelSvcKeiUcwk` with the necessary parameters.

The method implements a **guard-and-dispatch design pattern**: it first applies five early-return guards (lines 1665, 1672, 1678, 1709, 1722) to determine whether any service detail needs to be added, then dispatches to one of two processing paths based on the service change classification. It acts as a **shared utility method** called from the parent processing method `telInfoChg()` after the existing contract details are cleared, meaning it participates in a larger contract change pipeline.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["appendSvcKeiUcwk"])
    START --> GET_PARAM["Get parameter map"]
    GET_PARAM --> EXTRACT["Extract adchgTelNo, modifyTelNo, dslFlg, baseTelNo, useSvcChgDiv"]
    EXTRACT --> DSL_CHECK{dslFlg equals 1?}
    DSL_CHECK -->|Yes| RETURN_EARLY["Return - no details to add"]
    DSL_CHECK -->|No| PHONE_EQUAL{adchgTelNo equals modifyTelNo?}
    PHONE_EQUAL -->|Yes| RETURN_EARLY
    PHONE_EQUAL -->|No| PORT_BACK{baseTelNo not empty AND equals modifyTelNo?}
    PORT_BACK -->|Yes| RETURN_EARLY
    PORT_BACK -->|No| USE_SVC_CHECK{useSvcChgDiv equals CD00849_ADD?}
    USE_SVC_CHECK -->|Yes| ADD_BRANCH["Add branch"]
    USE_SVC_CHECK -->|No| CONT_BRANCH["Continue/Modify branch"]

    ADD_BRANCH --> NO_ADTELNO{adchgTelNo empty?}
    NO_ADTELNO -->|Yes| NUMBER_ADD["Number addition path"]
    NO_ADTELNO -->|No| SKIP_ADD["Skip - no number addition"]

    NUMBER_ADD --> CALL_ADDTEL["Call addTelnoInfo"]
    CALL_ADDTEL --> CALL_ADDBMPO1["Call addBmpo"]
    CALL_ADDBMPO1 --> GET_SVCNUM["Get svcKeNo from param"]
    GET_SVCNUM --> GET_UCWKNO["Call getSvcKeiUcwkNo"]
    GET_UCWKNO --> GET_KIKI["Call getKiki"]
    GET_KIKI --> KIKI_CHECK{kk0341Map not null?}
    KIKI_CHECK -->|Yes| UPDATE_FLG["Call updateSvcKeiUcwkVaHimoduke"]
    UPDATE_FLG --> SOD_ADD["Call hakkoSODhtelNoAdd"]
    SOD_ADD --> ADD_END["End of Add branch"]
    KIKI_CHECK -->|No| ADD_END
    ADD_END --> FINAL_END(["Return"])

    CONT_BRANCH --> NO_BASETEL{baseTelNo empty?}
    NO_BASETEL -->|Yes| ADDTEL_BMPO["Call addTelnoInfo and addBmpo"]
    NO_BASETEL -->|No| TELNO_UPDATE["Phone number update path"]

    ADDTEL_BMPO --> CALL_ADDTEL2["Call addTelnoInfo"]
    CALL_ADDTEL2 --> CALL_ADDBMPO2["Call addBmpo"]
    CALL_ADDBMPO2 --> FINAL_END

    TELNO_UPDATE --> GET_USERDATA["Get telno_info_chg map"]
    GET_USERDATA --> GET_MSKM["Get mskm_dtl_no"]
    GET_MSKM --> GET_SVC["Get svcKeiNo"]
    GET_SVC --> SVC_CHECK{svcKeiNo not empty?}
    SVC_CHECK -->|Yes| CALL_EKK0081["Call getEKK0081A010"]
    SVC_CHECK -->|No| PUT_MSKM["Put mskm_dtl_no into userData"]
    CALL_EKK0081 --> GET_LASTUPD["Get last_upd_dtm from result"]
    GET_LASTUPD --> PUT_LASTUPD["Put kk0081UpdDtm into userData"]
    PUT_LASTUPD --> PUT_MSKM
    PUT_MSKM --> PUT_MSKM2["Put mskm_dtl_no into userData"]
    PUT_MSKM2 --> CREATE_TELNOCC["Create JKKTelnoInfoChgCC"]
    CREATE_TELNOCC --> CALL_APPEND["Call appendTelSvcKeiUcwk"]
    CALL_APPEND --> CALL_ADDBMPO3["Call addBmpo"]
    CALL_ADDBMPO3 --> FINAL_END
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (implicit: request parameter map) | `HashMap<String, Object>` via `getRequestParameter()` | The method reads a parameter map extracted from the HTTP request containing all customer-provided and system-managed fields for the phone number change operation. |
| - | `adchg_tel_no` | `String` | The phone number directly entered by the user for the relocation destination (直近に入力された転居先の電話番号). This represents the most recently input phone number at the new address. Empty string means a new number is being added (number addition = 番号追加). |
| - | `modify_tel_no` | `String` | The phone number being corrected/updated in this transaction (今回訂正した転居先の電話番号). This is the target phone number for the relocation. |
| - | `dsl_flg` | `String` | DSL cancellation flag — indicates whether a cancellation has occurred (解約有無). Value "1" means a cancellation exists, and the method returns early without adding any service details (追加する内訳なし). |
| - | `base_tel_no` | `String` | The original phone number before relocation (転居元). Used to detect number port-back scenarios (同番復帰 — dobangukufuku) where the new number matches the old one. |
| - | `use_svc_chg_div` | `String` | Service change classification for phone (利用サービス変更区分（電話）). Determines which processing branch to execute. Value `"3"` (CD00849_ADD) means "Add" (追加). Other values mean "Continue" (継続) or "Change" (変更). |
| - | `svc_kei_no` | `String` | Service contract number (サービス契約番号) retrieved from the parameter map. Used in the Add branch to look up the service detail work number and in the Continue/Modify branch for the service contract agreement inquiry. |
| - | `after_svc_kei_kaisen_ucwk_no` | `String` | After service contract improvement work number. Passed to `getKiki()` to determine the system configuration for value attachment updates. |
| - | `before_svc_kei_kaisen_ucwk_no` | `String` | Before service contract improvement work number. Passed to `getKiki()` for comparison with the after number. |
| - | `telno_info_chg` | `HashMap<String, Object>` | Phone number information change data map (電話番号情報変更). Carries the parameters needed for the phone number change SCCC. |
| - | `mskm_dtl_no` | `String` | Application detail number (申請明細番号). Business application reference number for the contract change request. |

### External State

| Source | Field | Business Description |
|--------|-------|---------------------|
| Instance | `keepSesHandle` | Thread-local session handle, accessed in the Continue/Modify branch when creating `JKKTelnoInfoChgCC` |
| Instance | `keepReqParam` | Thread-local request parameter, accessed in the Continue/Modify branch |
| Instance | `keepFixedText` | Thread-local fixed text, accessed in the Continue/Modify branch |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `getRequestParameter` | JKKAdchgTelInfoChgCC | - | Retrieves the request parameter map from the current request context |
| C | `addTelnoInfo` | JKKAdchgTelInfoChgCC | KK_T_TELNO_INFO (inferred) | Registers a new telephone number record during the number addition workflow |
| C | `addBmpo` | JKKAdchgTelInfoChgCC | KK_T_BMPO (inferred) | Registers a number portability work (番号ポ工事) record for the porting process |
| R | `getSvcKeiUcwkNo` | JKKAdchgTelInfoChgCC | - | Retrieves the service detail work number (サービス契約内訳番号) based on service contract number and phone number |
| R | `getKiki` | JKKAdchgTelInfoChgCC | - | Retrieves system configuration info (機器) by comparing before/after service contract improvement work numbers |
| U | `updateSvcKeiUcwkVaHimoduke` | JKKAdchgTelInfoChgCC | KK_T_OPSVKEI_ISP (inferred) | Updates the service detail value attachment flag (値付替え更新) to handle multi-function router exchange during new service addition |
| C | `hakkoSODhtelNoAdd` | JKKAdchgTelInfoChgCC | KK_T_ODR_HAKKO_JOKEN (inferred) | Issues a Service Order Data (SOD) record for phone number addition, executed before service start |
| R | `getEKK0081A010` | EKK0081A010SC | KK_T_OPSVKEI_CONTRACT (inferred) | Queries the service contract agreement (サービス契約同意会) to retrieve the last update timestamp for locking |
| C | `JKKTelnoInfoChgCC.appendTelSvcKeiUcwk` | JKKTelnoInfoChgCC | KK_T_OPSVKEI_ISP (inferred) | Appends a new telephone service detail line item through a separate CC component |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `addBmpo` [C], `appendTelSvcKeiUcwk` [-], `getEKK0081A010` [R], `addBmpo` [C], `addTelnoInfo` [C], `hakkoSODhtelNoAdd` [-], `updateSvcKeiUcwkVaHimoduke` [U], `getKiki` [R], `getSvcKeiUcwkNo` [R], `addBmpo` [C], `addTelnoInfo` [C], `getRequestParameter` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKAdchgTelInfoChgCC.telInfoChg` | `telInfoChg(handle, param, fixedText)` -> checks `addAndDslFlg` -> `appendSvcKeiUcwk()` | `addTelnoInfo [C] KK_T_TELNO_INFO`, `addBmpo [C] KK_T_BMPO`, `getSvcKeiUcwkNo [R] -`, `getKiki [R] -`, `updateSvcKeiUcwkVaHimoduke [U] KK_T_OPSVKEI_ISP`, `hakkoSODhtelNoAdd [C] KK_T_ODR_HAKKO_JOKEN`, `getEKK0081A010 [R] KK_T_OPSVKEI_CONTRACT`, `appendTelSvcKeiUcwk [C] KK_T_OPSVKEI_ISP` |

**Call chain details:**
- `telInfoChg()` is the public entry point of the `JKKAdchgTelInfoChgCC` class. It is called by screens or CBS that handle telecom contract changes (e.g., phone number changes during address relocation).
- When `addAndDslFlg` is "1" (add then cancel), `appendSvcKeiUcwk()` is called first, followed by `clearSvcKeiUcwk()`.
- In the normal case, `clearSvcKeiUcwk()` is called first to clear existing details, then `modifySvcKeiUcwk()` for modifications, then `appendSvcKeiUcwk()` for additions.

## 6. Per-Branch Detail Blocks

### Block 1 — IF `[dslFlg equals "1"]` (L1664-L1667)

> Returns early when a DSL cancellation exists. This prevents adding service details when the service is being cancelled (解約 — kaiyaku). The rationale is that a cancelled service has no service details to append (追加する内訳なし — details to add: none).

| # | Type | Code |
|---|------|------|
| 1 | SET | `dslFlg = param.get("dsl_flg")` // Cancellation flag (解約有無) [-> CONSTANT="1"] |
| 2 | COND | `"1".equals(dslFlg)` |
| 3 | RETURN | `return;` // No details to add (追加する内訳なし) |

### Block 2 — IF `[adchgTelNo equals modifyTelNo]` (L1671-L1674)

> Returns early when the directly entered phone number matches the corrected phone number. This means the relocation destination phone number was not actually changed, so no new detail needs to be added (追加する内訳なし — details to add: none).

| # | Type | Code |
|---|------|------|
| 1 | SET | `adchgTelNo = param.get("adchg_tel_no")` // Phone number entered for relocation destination (直近に入力された転居先の電話番号) |
| 2 | SET | `modifyTelNo = param.get("modify_tel_no")` // Corrected phone number for this transaction (今回訂正した転居先の電話番号) |
| 3 | COND | `adchgTelNo.equals(modifyTelNo)` |
| 4 | RETURN | `return;` // No details to add (追加する内訳なし) |

### Block 3 — IF `[baseTelNo not empty AND baseTelNo equals modifyTelNo]` (L1676-L1681)

> Detected during IT2-2014-0000089 response. Returns early when this is a number change avoidance case (番号変更やめ — number change cancellation) where the customer is returning to the original number via number port-back (同番復帰 — dobangukufuku). No detail addition is needed in this port-back scenario.

| # | Type | Code |
|---|------|------|
| 1 | SET | `baseTelNo = param.get("base_tel_no")` // Original phone number before relocation (転居元) |
| 2 | COND | `!StringUtils.isEmpty(baseTelNo)` |
| 3 | COND | `baseTelNo.equals(modifyTelNo)` |
| 4 | RETURN | `return;` // Port-back detected, no detail addition needed |

### Block 4 — IF/ELSE `[useSvcChgDiv equals CD00849_ADD]` (L1685-L1756)

> **CD00849_ADD = "3"** (defined in `JKKAdchgConstCC.java`). This is the service change classification for "Add" (追加 — tsuika). The method branches into two sub-paths: number addition (番号追加, when `adchgTelNo` is empty) and skip (when `adchgTelNo` has a value).

#### Block 4.1 — IF `[CD00849_ADD = "3" (追加)]` (L1685-L1719)

> When the service change classification is "Add", the method first performs pre-service operations: adding a telephone number and registering a portability work. Then, if no original phone number exists (= number addition), it performs SOD issuance and value attachment updates for handling multi-function router exchange.

| # | Type | Code |
|---|------|------|
| 1 | SET | `useSvcChgDiv = param.get("use_svc_chg_div")` // Service change classification for phone (利用サービス変更区分（電話）) |
| 2 | COND | `JKKAdchgConstCC.CD00849_ADD.equals(useSvcChgDiv)` | [-> CD00849_ADD="3"] |
| 3 | SET | `// サービス開始前の番号追加` // Number addition before service start |
| 4 | SET | `// または サービス開始前の番号変更（変更後番号の追加）` // Or number change before service start (adding post-change number) |
| 5 | CALL | `addTelnoInfo()` // Register new telephone number [-> C KK_T_TELNO_INFO] |
| 6 | CALL | `addBmpo()` // Register number portability work (番号ポ工事の登録) [-> C KK_T_BMPO] |

##### Block 4.1.1 — IF `[adchgTelNo empty = 番号追加]` (L1696-L1715)

> When the directly entered phone number is empty (= new number addition, 直近の電話番号なし = 番号追加), the method performs a full pre-service number addition workflow. This includes retrieving the service detail work number, getting system configuration, performing value attachment update for multi-function router exchange (多機能ルータ交換), and issuing an SOD for phone number addition before service start.

| # | Type | Code |
|---|------|------|
| 1 | COND | `StringUtils.isEmpty(adchgTelNo)` // No direct phone number = number addition (直近の電話番号なし = 番号追加) |
| 2 | SET | `svcKeiNo = param.get("svc_kei_no")` // Service contract number (サービス契約番号) |
| 3 | CALL | `svcKeiUcwkNo = getSvcKeiUcwkNo(svcKeiNo, modifyTelNo)` // Get service detail work number (払出されたサービス契約内訳番号の取得) |
| 4 | CALL | `kk0341Map = getKiki(after_svc_kei_kaisen_ucwk_no, before_svc_kei_kaisen_ucwk_no, svcKeiNo)` // Get system configuration info (機器) |
| 5 | COND | `kk0341Map != null` |
| 6 | SET | `// サービス追加時の番号追加は、多機能ルータ交換の可能性があるため妥当性更新が必要` // Number addition during service addition may involve multi-function router exchange, so validity update is required |
| 7 | SET | `// SOD発行前に妥当性更新を実施` // Perform validity update before SOD issuance |
| 8 | CALL | `himodukeUpdateFlg = updateSvcKeiUcwkVaHimoduke(svcKeiNo, kk0341Map)` // Update service detail value attachment flag (値付替え更新) [-> U KK_T_OPSVKEI_ISP] |
| 9 | CALL | `hakkoSODhtelNoAdd(param, svcKeiNo, svcKeiUcwkNo, kk0341Map, himodukeUpdateFlg)` // Issue SOD for pre-service number addition (サービス開始前番号追加のためのSOD発行) [-> C KK_T_ODR_HAKKO_JOKEN] |

#### Block 4.2 — ELSE `[CD00849_ADD not equals "3" (継続/変更)]` (L1721-L1756)

> When the service change classification is "Continue" (継続) or "Change" (変更), the method checks whether the original phone number exists. If no original number exists, it performs number addition. Otherwise, it performs a phone number information update through a dedicated CC.

##### Block 4.2.1 — IF `[baseTelNo empty = 電話番号なし]` (L1725-L1733)

> When no original phone number exists at the relocation source (転居元に電話がない場合), the method performs number addition: it registers a new telephone number and registers a portability work. This is the same sequence as the Add branch's pre-service operations.

| # | Type | Code |
|---|------|------|
| 1 | COND | `StringUtils.isEmpty(baseTelNo)` // No phone at relocation source (転居元に電話がない場合) |
| 2 | SET | `// 番号追加` // Number addition |
| 3 | CALL | `addTelnoInfo()` // Register new telephone number [-> C KK_T_TELNO_INFO] |
| 4 | SET | `// 番号ポ工事の登録` // Register number portability work |
| 5 | CALL | `addBmpo()` // Register number portability work [-> C KK_T_BMPO] |

##### Block 4.2.2 — ELSE `[baseTelNo not empty = 電話番号情報変更]` (L1736-L1755)

> When an original phone number exists, the method performs a phone number information update SC process. It retrieves the phone number change parameter map and prepares it with the application detail number and service contract agreement update timestamp before delegating to `JKKTelnoInfoChgCC.appendTelSvcKeiUcwk()`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `// 電話番号情報変更SCのパラメータ取得` // Retrieve parameters for phone number change SC |
| 2 | SET | `userData = param.get("telno_info_chg")` // Phone number information change data map |
| 3 | SET | `// 申請明細番号` // Application detail number |
| 4 | SET | `mskm_dtl_no = param.get("mskm_dtl_no")` |
| 5 | SET | `// サービス契約番号` // Service contract number |
| 6 | SET | `svcKeiNo = param.get("svc_kei_no")` |
| 7 | COND | `!StringUtils.isEmpty(svcKeiNo)` |
| 8 | SET | `// EKK0081A010 サービス契約同意会` // Service contract agreement inquiry |
| 9 | CALL | `map = getEKK0081A010(svcKeiNo)` // Query service contract agreement [-> R EKK0081A010SC KK_T_OPSVKEI_CONTRACT] |
| 10 | SET | `lastUpdDtm = map.get(EKK0081A010CBSMsg1List.LAST_UPD_DTM)` // Last update datetime (最終更新年月日时分秒) [-> LAST_UPD_DTM="last_upd_dtm"] |
| 11 | SET | `userData.put("kk0081UpdDtm", lastUpdDtm)` // Store update timestamp |
| 12 | SET | `userData.put("mskm_dtl_no", mskm_dtl_no)` // Store application detail number |
| 13 | SET | `// 電話番号情報変更SC` // Phone number change SC |
| 14 | SET | `telnoInfoChgCc = new JKKTelnoInfoChgCC()` |
| 15 | SET | `// 電話番号の内訳追加` // Append telephone service detail |
| 16 | CALL | `telnoInfoChgCc.appendTelSvcKeiUcwk(keepSesHandle.get(), keepReqParam.get(), keepFixedText.get(), userData)` // Append service detail [-> C KK_T_OPSVKEI_ISP] |
| 17 | SET | `// 番号ポ工事の登録` // Register number portability work |
| 18 | CALL | `addBmpo()` // Register portability work [-> C KK_T_BMPO] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `adchg_tel_no` | Field | The phone number directly entered by the user for the relocation destination (直近に入力された転居先の電話番号) |
| `modify_tel_no` | Field | The phone number being corrected/updated in this transaction (今回訂正した転居先の電話番号) |
| `dsl_flg` | Field | DSL cancellation flag — indicates whether a cancellation has occurred (解約有無). "1" means cancellation exists |
| `base_tel_no` | Field | The original phone number before relocation (転居元) |
| `use_svc_chg_div` | Field | Service change classification for phone (利用サービス変更区分（電話）). Determines processing branch: "3" = Add (追加), other values = Continue (継続) or Change (変更) |
| `svc_kei_no` | Field | Service contract number (サービス契約番号) |
| `svc_kei_ucwk_no` | Field | Service detail work number (サービス契約内訳番号) — internal tracking ID for service contract line items |
| `mskm_dtl_no` | Field | Application detail number (申請明細番号) — business application reference number |
| `telno_info_chg` | Field | Phone number information change data map (電話番号情報変更) |
| `kk0081UpdDtm` | Field | Last update datetime from EKK0081A010 — used as a locking mechanism to ensure consistency during phone number changes (更新年月日时分秒) |
| `CD00849_ADD` | Constant | Service change classification code "3" — "Add" (追加). Defined in `JKKAdchgConstCC` |
| `LAST_UPD_DTM` | Constant | Field name "last_upd_dtm" in `EKK0081A010CBSMsg1List` — last update timestamp |
| `addAndDslFlg` | Field | Add-then-cancel flag — "1" means add first then cancel (追加後解約) |
| SOD | Acronym | Service Order Data — telecom order fulfillment record issued before service activation. Used for number addition before service start |
| Bmpo | Acronym | Number portability work (番号ポ工事) — registration record for number portability (MNP) processing |
| 転居 (Tsumugi) | Business term | Address relocation — the business context in which phone numbers are changed |
| 内訳 (Ukiwae) | Business term | Service detail / line item — individual service entries within a contract |
| 解約 (Kaiyaku) | Business term | Contract cancellation — termination of a telecom service |
| 番号追加 (Bangou Tsuika) | Business term | Number addition — adding a new phone number during relocation |
| 同番復帰 (Doban Fukku) | Business term | Number port-back — returning to the original phone number via number portability |
| 多機能ルータ交換 (Takinou Router Koukan) | Business term | Multi-function router exchange — a hardware change scenario that requires value attachment update before SOD issuance |
| EKK0081A010 | CBS | Service contract agreement inquiry SC Code — queries the service contract agreement (サービス契約同意会) |
| KK_T_TELNO_INFO | DB Table | Telephone number information table (inferred) — stores phone number records |
| KK_T_BMPO | DB Table | Number portability work table (inferred) — stores portability work registration records |
| KK_T_OPSVKEI_ISP | DB Table | Service detail ISP table (inferred) — stores service contract detail/line item records |
| KK_T_ODR_HAKKO_JOKEN | DB Table | Order issuance conditions table (inferred) — stores SOD issuance records |
| KK_T_OPSVKEI_CONTRACT | DB Table | Service contract agreement table (inferred) — stores service contract agreement records queried by EKK0081A010 |

---