# Business Logic — JKKAdchgCancelHakkoSODCC.kikiKeiKeepOdrCtrl() [191 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKAdchgCancelHakkoSODCC` |
| Layer | CC/Common Component (Enterprise Bean Module — EJB business component) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKAdchgCancelHakkoSODCC.kikiKeiKeepOdrCtrl()

This method implements the **equipment contract change (continuation) order control processing** (機器契約変更（継続）オーダー制御処理) as part of Fujitsu's telecom order fulfillment system for NTT East Japan (NTT東日本) broadband services. It serves as the data-fetching and agreement-stage gate within the equipment-continuation branch of the cancellation order flow.

Specifically, when a customer's service contract is being continued (kept) rather than canceled or newly added — as indicated by the `AD_CHG_CMT_KEEP` trigger — this method ensures that the system has current service agreement records before any order is issued. It acts as a **data reconciliation step** in a larger routing/dispatch pattern: the parent method (`setKikiAdchgCancelHakkoSODCtrl`) branches on the change-comment type (`jdgChgDivNet`) and the order-issuing trigger (`odr_exec_div`) to select the appropriate order-control sub-process. This method is the dedicated controller for the "equipment contract change with continuation + add" scenario.

The method handles two distinct data-fetching branches based on field presence checks: (1) retrieving the **post-change equipment-service contract agreement record** (EKK0341A010), and (2) retrieving the **post-change service contract agreement record** (EKK0081A010). Both use a pre-compute pattern — initializing hash maps with key identifiers, calling a service component (SC), and storing the results for downstream use.

After fetching the service contract agreement data, the method also reads the **pricing code** (PCRS_CD) from the result, which determines the customer's billing plan. This pricing code is stored as an instance field on the class for subsequent order-generation methods to reference when creating SOD (Service Order Data) records.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["kikiKeiKeepOdrCtrl start"])

    START --> STEP1["Step 1: Initialize statusCode=0 and hash maps"]
    STEP1 --> STEP2["Step 2: Extract 4 maps from sodMap
svc_kei_info, svc_kei_ucwk_info, opsvkei_info, kktsvkei_info"]
    STEP2 --> STEP3["Step 3: Initialize each map with shkkaMap()
(clear key-value entries for reuse)"]
    STEP3 --> STEP4["Step 4: Create inHash and resultHash for SC calls"]
    STEP4 --> STEP5["Step 5: Extract key fields
saki_svc_kei_no, chaf_svc_kei_gene_add_dtm,
chaf_kktsvkei_no, chaf_kktsvkei_gene_add_dtm"]

    STEP5 --> COND1{"Block 2: Are chaf_kktsvkei_no
and chaf_kktsvkei_gene_add_dtm
both non-blank?"}
    COND1 -->|"Yes"| BR2_SETUP["Set inHash with
kktsvkei_no + gene_add_dtm"]
    BR2_SETUP --> BR2_CALL["Call callEKK0341A010SC
(Post-change equipment service
contract agreement meeting)"]
    BR2_CALL --> BR2_CHECK{Status == 0?}
    BR2_CHECK -->|"No"| BR2_THROW["Throw CCException
(SCCallException)"]
    BR2_CHECK -->|"Yes"| BR2_STORE["Store result
chbfEKK0341A010SCHash"]
    BR2_STORE --> COND3
    BR2_THROW --> END_RETURN(["Return param"])

    COND1 -->|"No"| COND3{"Block 3: Are saki_svc_kei_no
and chaf_svc_kei_gene_add_dtm
both non-blank?"}

    COND3 -->|"Yes"| BR3_SETUP["Set inHash with
svc_kei_no + gene_add_dtm"]
    BR3_SETUP --> BR3_CALL["Call callEKK0081A010SC
(Service contract agreement meeting)"]
    BR3_CALL --> BR3_CHECK{Status == 0?}
    BR3_CHECK -->|"No"| BR3_THROW["Throw CCException
(SCCallException)"]
    BR3_CHECK -->|"Yes"| BR3_STORE["Store result
chafEKK0081A010SCHash"]
    BR3_STORE --> BR4
    BR3_THROW --> END_RETURN

    COND3 -->|"No"| BR4["Block 4: Read pricing code
from chafEKK0081A010SCHash"]
    BR4 --> BR4_STORE["Set this.pcrs_cd from
result map (PCRS_CD)"]

    BR4_STORE --> END_RETURN

    style START fill:#e1f5e1
    style END_RETURN fill:#e1f5e1
    style BR2_THROW fill:#fdd
    style BR3_THROW fill:#fdd
```

**Processing flow summary:**

1. **Initialization**: The method begins by resetting the `statusCode` to `0` and creating two hash maps — `chbfEKK0341A010SCHash` (for pre-change equipment data) and `chafEKK0081A010SCHash` (for post-change service contract data).

2. **Map extraction and initialization**: Four business maps are extracted from the incoming `sodMap` using constant keys (`SVC_KEI_INFO`, `SVC_KEI_UCWK_INFO`, `OPSVKEI_INFO`, `KKTSVKEI_INFO`), then each is cleared via `shkkaMap()` to ensure a clean working copy.

3. **Field extraction**: Key identifiers are pulled from the service contract and equipment service maps: the previous service contract number (`saki_svc_kei_no`), the post-change service contract timestamp (`chaf_svc_kei_gene_add_dtm`), the post-change equipment service contract number (`chaf_kktsvkei_no`), and the post-change equipment timestamp (`chaf_kktsvkei_gene_add_dtm`).

4. **Conditional branch 2 — Pre-change equipment data**: If the post-change equipment service contract number and timestamp are both non-blank, the method calls `callEKK0341A010SC` (post-change equipment-service contract agreement meeting SC) with the extracted identifiers. On error (non-zero status), it throws a `CCException` wrapping an `SCCallException`. On success, the result is stored in `chbfEKK0341A010SCHash`.

5. **Conditional branch 3 — Post-change service contract data**: If the previous service contract number and the post-change service contract timestamp are both non-blank, the method calls `callEKK0081A010SC` (service contract agreement meeting SC). Similarly, errors throw `CCException`, and results are stored in `chafEKK0081A010SCHash`.

6. **Pricing code extraction**: The pricing code (`PCRS_CD`) is read from the service contract agreement result and stored in the instance field `this.pcrs_cd` for downstream consumers.

7. **Return**: The method returns the `param` object unchanged. All side effects occur via the SC calls and the instance field update.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session context handle carrying session management data (e.g., connection, transaction context). Passed to SC calls to maintain session affinity during service component invocations. |
| 2 | `param` | `IRequestParameterReadWrite` | Business data retrieval/writing interface object containing the model group and control maps. Carries request parameters through the order-control chain; returned to callers for chaining. |
| 3 | `sodMap` | `HashMap<String, Object>` | Service Order Data (SOD) map — the central data container holding all service contract, service detail, option service, and equipment-service contract information. Key sub-maps include `svc_kei_info` (service contract), `svc_kei_ucwk_info` (service detail work), `opsvkei_info` (option service contract), and `kktsvkei_info` (equipment-provided service contract). |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `this.pcrs_cd` | `String` | Pricing code — stores the customer's billing plan code extracted from the service contract agreement result. Used downstream to determine cost structure. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKAdchgCancelHakkoSODCC.callEKK0081A010SC` | EKK0081A010 | Service Contract Agreement (DB table via CBS) | Reads service contract agreement data using `saki_svc_kei_no` and `gene_add_dtm` as lookup keys. Returns the post-change service contract agreement meeting record. |
| R | `JKKAdchgCancelHakkoSODCC.callEKK0341A010SC` | EKK0341A010 | Equipment Service Contract Agreement (DB table via CBS) | Reads equipment-service contract agreement data using `chaf_kktsvkei_no` and `gene_add_dtm` as lookup keys. Returns the post-change equipment-service contract agreement meeting record. |
| - | `JKKAdchgCancelHakkoSODCC.shkkaMap` | - | - | Utility method that clears and re-initializes a HashMap's key-value entries to prepare a clean working copy of business data. |
| - | `JKKAdchgCancelHakkoSODCC.isBlank` | - | - | Utility method that checks whether a String value is null or blank (empty/whitespace-only). |

### Detailed method call breakdown:

| # | CRUD | Called Method | Business Description |
|---|------|--------------|---------------------|
| 1 | R | `callEKK0341A010SC(param, handle, inHash, resultHash, FUNC_CODE_1="1")` | Retrieves the post-change equipment-provided service contract agreement meeting record. Input: equipment service contract number (`kktsvkei_no`) and generation addition timestamp (`gene_add_dtm`). Output: equipment service contract data hash map. |
| 2 | R | `callEKK0081A010SC(param, handle, inHash, resultHash, FUNC_CODE_1="1")` | Retrieves the service contract agreement meeting record. Input: service contract number (`svc_kei_no`) and generation addition timestamp (`gene_add_dtm`). Output: service contract data hash map. |
| 3 | - | `shkkaMap(map)` | Clears all key-value entries from a HashMap to prepare it for fresh data population. Applied to all four sub-maps extracted from `sodMap`. |
| 4 | - | `isBlank(str)` | Utility check to determine if a string is null, empty, or whitespace-only. Used in both conditional branches to gate SC calls. |

### SC Code references:

- **EKK0341A010**: Equipment-provided service contract agreement meeting SC. Reads equipment-service contract agreement data from the database. Referenced in the constant `TEMPLATE_ID_EKK0341A010 = "EKK0341A010"`.

- **EKK0081A010**: Service contract agreement meeting SC. Reads service contract agreement meeting data from the database. Referenced in the constant `TEMPLATE_ID_EKK0081A010 = "EKK0081A010"`.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC: `JKKAdchgCancelHakkoSODCC.setKikiAdchgCancelHakkoSODCtrl` | `setKikiAdchgCancelHakkoSODCtrl` (param, sodMap, fixedText, jdgChgDivNet, use_svc_chg_div, odr_exec_div) -> branches on `AD_CHG_CMT_KEEP="1"` && `ODR_EXEC_DIV_AD_CHG="1"` -> `kikiKeiKeepOdrCtrl` | `callEKK0081A010SC [R] Service Contract Agreement`, `callEKK0341A010SC [R] Equipment Service Contract Agreement` |
| 2 | CC (commented-out): `JKKAdchgHakkoSODCC.setKikiAdchgCancelHakkoSODCtrl` | `setKikiAdchgCancelHakkoSODCtrl` -> (commented) `kikiKeiKeepOdrCtrl` | Same terminals as caller 1 (but code path is inactive) |

**Terminal operations from this method:**

| Terminal Operation | Type | Entity / Table |
|--------------------|------|----------------|
| `callEKK0081A010SC` | R | Service Contract Agreement (DB) |
| `callEKK0341A010SC` | R | Equipment Service Contract Agreement (DB) |

## 6. Per-Branch Detail Blocks

### Block 1 — INIT (L21448–L21464)
Initialize the processing state and extract business maps from the SOD context.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `statusCode = 0` | Reset processing status code |
| 2 | SET | `chbfEKK0341A010SCHash = new HashMap<String, Object>()` | Create map for pre-change equipment service agreement results |
| 3 | SET | `chafEKK0081A010SCHash = new HashMap<String, Object>()` | Create map for post-change service contract agreement results |
| 4 | SET | `svc_kei_info_Map = (HashMap<String, Object>)sodMap.get(SVC_KEI_INFO="svc_kei_info")` | Extract service contract info map from SOD |
| 5 | SET | `svc_kei_ucwk_info_Map = (HashMap<String, Object>)sodMap.get(SVC_KEI_UCWK_INFO="svc_kei_ucwk_info")` | Extract service detail work info map from SOD |
| 6 | SET | `opsvkei_info_Map = (HashMap<String, Object>)sodMap.get(OPSVKEI_INFO="opsvkei_info")` | Extract option service contract info map from SOD |
| 7 | SET | `kktsvkei_info_Map = (HashMap<String, Object>)sodMap.get(KKTSVKEI_INFO="kktsvkei_info")` | Extract equipment-provided service contract info map from SOD |
| 8 | EXEC | `svc_kei_info_Map = shkkaMap(svc_kei_info_Map)` | Clear and reinitialize service contract map |
| 9 | EXEC | `svc_kei_ucwk_info_Map = shkkaMap(svc_kei_ucwk_info_Map)` | Clear and reinitialize service detail map |
| 10 | EXEC | `opsvkei_info_Map = shkkaMap(opsvkei_info_Map)` | Clear and reinitialize option service map |
| 11 | EXEC | `kktsvkei_info_Map = shkkaMap(kktsvkei_info_Map)` | Clear and reinitialize equipment service map |
| 12 | SET | `inHash = new HashMap<String, Object>()` | Create input parameter map for SC calls |
| 13 | SET | `resultHash = new HashMap<String, Object>()` | Create result container map for SC calls |

### Block 2 — SET (L21467–L21477)
Extract key identifiers from the service contract and equipment service maps.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `saki_svc_kei_no = svc_kei_info_Map.get(INFO_SAKI_SVC_KEI_NO="saki_svc_kei_no")` | Get previous service contract number |
| 2 | SET | `chaf_svc_kei_gene_add_dtm = svc_kei_info_Map.get(INFO_CHAF_SVC_KEI_GENE_ADD_DTM="chaf_svc_kei_gene_add_dtm")` | Get post-change service contract registration timestamp |
| 3 | SET | `chaf_kktsvkei_no = kktsvkei_info_Map.get(INFO_CHAF_KKTSVKEI_NO="chaf_kktsvkei_no")` | Get post-change equipment service contract number |
| 4 | SET | `chaf_kktsvkei_gene_add_dtm = kktsvkei_info_Map.get(INFO_CHAF_KKTSVKEI_GENE_ADD_DTM="chaf_kktsvkei_gene_add_dtm")` | Get post-change equipment service contract registration timestamp |

### Block 3 — IF [Block 2] (L21481–L21499)
> Condition: `!isBlank(chaf_kktsvkei_no) && !isBlank(chaf_kktsvkei_gene_add_dtm)` — Post-change equipment service contract data exists

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `inHash.clear()` | Clear input map for reuse |
| 2 | EXEC | `resultHash.clear()` | Clear result map for reuse |
| 3 | SET | `inHash.put(KKTK_SVC_KEI_NO="kktk_svc_kei_no", chaf_kktsvkei_no)` | Set equipment service contract number as lookup key |
| 4 | SET | `inHash.put(GENE_ADD_DTM="gene_add_dtm", chaf_kktsvkei_gene_add_dtm)` | Set equipment service contract registration timestamp |
| 5 | CALL | `statusCode = callEKK0341A010SC(param, handle, inHash, resultHash, FUNC_CODE_1="1")` | Fetch post-change equipment service contract agreement meeting data |
| 6 | IF [Block 3.1] (L21493–L21495) | `0 != statusCode` | Error handling: non-zero status indicates SC call failure |

#### Block 3.1 — IF [Error] (L21493–L21495)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `throw new CCException("", new SCCallException("", String.valueOf(statusCode), statusCode))` | Throw business exception wrapping SC call failure status code |

#### Block 3.2 — IF [Success] (L21497–L21499)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `chbfEKK0341A010SCHash = (HashMap<String, Object>)resultHash.get(TEMPLATE_ID_EKK0341A010="EKK0341A010")` | Store equipment service agreement result for downstream use |

### Block 4 — IF [Block 3] (L21503–L21521)
> Condition: `!isBlank(saki_svc_kei_no) && !isBlank(chaf_svc_kei_gene_add_dtm)` — Previous service contract data exists

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `inHash.clear()` | Clear input map for reuse |
| 2 | EXEC | `resultHash.clear()` | Clear result map for reuse |
| 3 | SET | `inHash.put(SVC_KEI_NO="svc_kei_no", saki_svc_kei_no)` | Set service contract number as lookup key |
| 4 | SET | `inHash.put(GENE_ADD_DTM="gene_add_dtm", chaf_svc_kei_gene_add_dtm)` | Set service contract registration timestamp as lookup key |
| 5 | CALL | `statusCode = callEKK0081A010SC(param, handle, inHash, resultHash, FUNC_CODE_1="1")` | Fetch service contract agreement meeting data |
| 6 | IF [Block 4.1] (L21515–L21517) | `0 != statusCode` | Error handling: non-zero status indicates SC call failure |

#### Block 4.1 — IF [Error] (L21515–L21517)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `throw new CCException("", new SCCallException("", String.valueOf(statusCode), statusCode))` | Throw business exception wrapping SC call failure status code |

#### Block 4.2 — IF [Success] (L21519–L21521)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `chafEKK0081A010SCHash = (HashMap<String, Object>)resultHash.get(TEMPLATE_ID_EKK0081A010="EKK0081A010")` | Store service contract agreement result for downstream use |

### Block 5 — SET (L21525–L21530)
> Read pricing code from service contract agreement result. Comment: "(4) Previous service contract data confirmation" (先サービス契約データ確認)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `this.pcrs_cd = (String)chafEKK0081A010SCHash.get(PCRS_CD)` | Extract pricing code from service contract agreement result and store in instance field for downstream pricing determination |

### Block 6 — RETURN (L21635)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return param` | Return the parameter object. All side effects (SC calls, instance field update) have been applied. |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kikiKeiKeepOdrCtrl` | Method | Equipment Contract Change (Continuation) Order Control — controls order issuance for equipment service contracts during a continuation (keep) scenario |
| SOD | Acronym | Service Order Data — the central data structure carrying all order-related information through the Fujiture order fulfillment system |
| SC | Acronym | Service Component — a service layer method (typically named `callXXXXXSC`) that invokes a backend CBS (Common Business Service) for database operations |
| CBS | Acronym | Common Business Service — the backend database-accessing service that a SC wraps |
| `pcrs_cd` | Field | Pricing Code — a billing plan identifier (e.g., "A47" for mansion type VDSL1, "A83" for 10G course) that determines the customer's rate structure |
| `saki_svc_kei_no` | Field | Previous Service Contract Number — the service contract number from before the change, used to fetch the pre-change agreement record |
| `chaf_svc_kei_gene_add_dtm` | Field | Post-Change Service Contract Generation Addition Timestamp — the timestamp when the new service contract was registered, used as a version key for agreement lookups |
| `chaf_kktsvkei_no` | Field | Post-Change Equipment-Provided Service Contract Number — the equipment service contract number after the change |
| `chaf_kktsvkei_gene_add_dtm` | Field | Post-Change Equipment-Provided Service Contract Generation Addition Timestamp — the equipment service contract registration timestamp |
| `kktsvkei` | Field (Japanese abbreviation) | Equipment-Provided Service (機器提供サービス) — refers to NTT's equipment-provided broadband service lines |
| `svc_kei` | Field (Japanese abbreviation) | Service Detail (サービス詳細) — internal NTT field abbreviation for service contract line items |
| `opsvkei` | Field (Japanese abbreviation) | Option Service (オプションサービス) — optional add-on services such as router functionality |
| `kktk` | Field (Japanese abbreviation) | Equipment-Provided (機器提供) — NTT's equipment-provided service category code |
| `chbf` | Prefix | Post-Change Before (変更前) — indicates data from the pre-change state |
| `chaf` | Prefix | Post-Change After (変更後) — indicates data from the post-change state |
| `saki` | Prefix | Previous/Subsequent (先) — indicates the previous or alternate service contract number |
| `gene_add_dtm` | Field | Generation Addition Timestamp (世代登録日時) — version identifier for a contract record; each change creates a new generation with a new timestamp |
| `FUNC_CODE_1="1"` | Constant | Function Code 1 — indicates primary processing mode (as opposed to check mode "2") for service component calls |
| EKK0081A010 | SC Code | Service Contract Agreement Meeting SC — retrieves service contract agreement data from the database |
| EKK0341A010 | SC Code | Equipment-Provided Service Contract Agreement Meeting SC — retrieves equipment-service contract agreement data from the database |
| `AD_CHG_CMT_KEEP="1"` | Constant | Change Comment: Keep/Continuation — indicates the customer is continuing their existing service (not canceling or adding new) |
| `ODR_EXEC_DIV_AD_CHG="1"` | Constant | Order Execution Division: Address Change — the order-issuing trigger for location/address change scenarios |
| `TEMPLATE_ID_EKK0081A010="EKK0081A010"` | Constant | Template ID key used to extract results from the SC response hash map |
| `TEMPLATE_ID_EKK0341A010="EKK0341A010"` | Constant | Template ID key used to extract results from the equipment-service SC response hash map |
| `CCException` | Class | Component Common Exception — application-level exception wrapper used throughout the EJB layer |
| `SCCallException` | Class | Service Component Call Exception — specific exception type for service component invocation failures, carries status code |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service offered by NTT East Japan |
| BBR | Business term | Broadband Router — BBR is an NTT router service code ("C014") for equipment-provided broadband routers |
| `KKTK_SVC_CD_BBR="C014"` | Constant | Equipment-Provided Service Code for BBR — identifies BBR router equipment in the system |