# Business Logic — JKKShkaFinJiKikiStaAddCC.callIdoUpdAnsnHcsSvc() [333 LOC]

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

## 1. Role

### JKKShkaFinJiKikiStaAddCC.callIdoUpdAnsnHcsSvc()

This method performs the application date update processing for the "Anshin Hatsu Chushin Service" (あんしん発着信サービス — a peace-of-mind call notification service) movement reservation record. It is a cascading lookup-and-update method that traverses a hierarchy of service contract data starting from the caller's service contract detail work number, navigates through phone service contracts, optional service agreements, reservation history, and final application details, then calculates the correct reservation application date and writes it to the movement reservation record.

The method implements a **cascade routing/dispatch pattern**: it sequentially invokes 12 Service Component (SC) calls, each narrowing the scope of the data set. At each level, it filters by specific business criteria — the service type must be "02" (Phone), the service status must be "100" (In Service Provision), the optional service code must be "B135" (Anshin Hatsu Chushin Service), and the contract status must be "030" (Contracted). Only when all filters pass does the method proceed deeper into the call chain.

The method plays a **shared utility role** within the broader order processing pipeline. It is called by `addShkaFinJiKiStaAdd()` within the same class during the shipment/finance journal creation status addition process. It handles a single service category — the Anshin Hatsu Chushin Service — and operates across two delivery division scenarios: when no prior movement reservation exists (it creates an optional service contract start record) and when one already exists (it updates the reservation application date, but only if the delivery division is "02" Work Order Processing).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callIdoUpdAnsnHcsSvc(params)"])
    S1["SET svcKeiNoTel empty"]
    S2["IF isBlank svcKeiKaisenUcwkNo"]
    S3["CALL EKK0241B002: Circuit-target Service Contract List"]
    S4["IF outMsg null or empty"]
    S5["FOR ekk0241b002outMsg loop"]
    S6["IF svc_cd equals 02 Phone"]
    S7["IF svc_kei_stat equals 100 In Service"]
    S8["SET svcKeiNoTel svc_kei_no"]
    S9["break"]
    S10["IF isBlank svcKeiNoTel"]
    S11["RETURN Early exit no active phone service"]
    S12["CALL EKK0191B001: Service Contract Details eo Phone"]
    S13["IF outMsg null or empty"]
    S14["FOR ekk0191b001outMsg loop"]
    S15["IF svc_kei_ucwk_stat not 100"]
    S16["continue skip"]
    S17["CALL EKK0351B001: Optional Service Contract List"]
    S18["IF outMsg null or empty"]
    S19["FOR ekk0351b001outMsg loop"]
    S20["CALL EKK0351A010: Optional Service Contract Agreement"]
    S21["IF outMsg null or empty"]
    S22["continue skip"]
    S23["IF op_svc_cd not B135"]
    S24["continue skip"]
    S25["IF op_svc_kei_stat not 030"]
    S26["continue skip"]
    S27["CALL EKK0371A010: Optional Service Contract Phone Agreement"]
    S28["IF outMsg null or empty"]
    S29["continue skip"]
    S30["CALL EKK1681B001: Movement Reservation List"]
    S31["IF outMsg null or empty"]
    S32["CALL EKK0371C040: Optional Service Contract Phone Start"]
    S33["ELSE has results"]
    S34["IF haisoDiv not 02"]
    S35["continue skip"]
    S36["CALL EKK0161A010: Service Contract Details Agreement"]
    S37["IF outMsg null or empty"]
    S38["continue skip"]
    S39["CALL EKK0351B003: Optional Service Contract History"]
    S40["FOR ekk0351b003outMsg reverse"]
    S41["IF rsv_aply_cd equals 2 and isPastDate"]
    S42["SET mskmDtlNo"]
    S43["break"]
    S44["IF isBlank mskmDtlNo"]
    S45["continue skip"]
    S46["CALL EKK0021A010: Application Details Agreement"]
    S47["IF outMsg null or empty"]
    S48["continue skip"]
    S49["CALL EKK0011A010: Application Agreement"]
    S50["IF outMsg null or empty"]
    S51["continue skip"]
    S52["CALL getRsvAplyYmdRule0074"]
    S53["IF isBlank rsvAplyYmd"]
    S54["continue skip"]
    S55["CALL EKK1681C040: Reservation Date Modification"]
    S56["END"]

    START --> S1
    S1 --> S2
    S2 -->|false| S3
    S3 --> S4
    S4 -->|true| S5
    S5 --> S6
    S6 -->|false| S21
    S6 -->|true| S7
    S7 -->|false| S21
    S7 -->|true| S8
    S8 --> S9
    S9 --> S10
    S2 -->|true| S10
    S4 -->|false| S10
    S10 -->|false| S11
    S10 -->|true| S12
    S12 --> S13
    S13 -->|true| S14
    S14 --> S15
    S15 -->|true| S16
    S16 --> S17
    S17 --> S18
    S18 -->|false| S19
    S19 --> S20
    S20 --> S21
    S21 -->|false| S22
    S22 --> S19
    S23 -->|false| S28
    S23 -->|true| S24
    S24 -->|false| S25
    S25 -->|true| S26
    S26 --> S27
    S27 --> S28
    S28 -->|false| S29
    S29 --> S30
    S30 --> S31
    S31 -->|false| S32
    S31 -->|true| S33
    S32 --> S56
    S33 --> S34
    S34 -->|true| S35
    S35 --> S19
    S34 -->|false| S36
    S36 --> S37
    S37 -->|false| S38
    S38 --> S39
    S39 --> S40
    S40 --> S41
    S41 -->|false| S40
    S41 -->|true| S42
    S42 --> S44
    S44 -->|false| S45
    S45 --> S46
    S46 --> S47
    S47 -->|false| S48
    S48 --> S49
    S49 --> S50
    S50 -->|false| S51
    S51 --> S52
    S52 --> S53
    S53 -->|false| S54
    S54 --> S55
    S55 --> S56
```

**Branch Summaries:**

1. **Phase 1 — Phone Service Lookup (L11805–L11842):** If `svcKeiKaisenUcwkNo` (the caller's service contract detail work number) is non-blank, query the circuit-target service contract list. Within the results, find the first record where service code equals "02" (Phone) and service contract status equals "100" (In Service Provision). Extract the phone service contract number (`svcKeiNoTel`). If no active phone service exists, return immediately — no further processing is needed.

2. **Phase 2 — Service Contract Details (L11847–L11857):** Query the service contract details list for the identified phone service. Retrieve the service contract detail work number from the first matching record.

3. **Phase 3 — Optional Service Contract List (L11862–L11874):** For each detail record with status "100" (In Service Provision), query the optional service contract list.

4. **Phase 4 — Optional Service Contract Agreement (L11879–L11932):** For each optional service contract, query its agreement record. Filter by optional service code equals "B135" (Anshin Hatsu Chushin Service) and contract status equals "030" (Contracted). If both conditions pass, extract the optional service contract number and query the optional service contract (Phone) agreement.

5. **Phase 5 — Movement Reservation Branch (L11937–L12079):** Query the movement reservation list for the optional service contract.
   - **Branch A (No reservation found):** Create an optional service contract (Phone) start record via EKK0371C040.
   - **Branch B (Reservation found):** This is the primary update path. If delivery division is not "02" (Work Order Processing), skip. Otherwise, traverse deeper — query service contract details agreement, optional service contract history (find the minimum application detail number where reservation application code equals "2" (Confirmed) and application date is past the operation date), application details agreement, and application agreement. Calculate the reservation application date via `getRsvAplyYmdRule0074()`, then update the movement reservation application date via EKK1681C040.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transactional context for all service component calls. Carries the current database connection, user session, and transaction scope. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service Component invocation utility that dispatches requests to SC/CBS backend processes and returns responses. |
| 3 | `param` | `IRequestParameterReadWrite` | Business data read/write interface used as a parameter carrier across service component boundaries. |
| 4 | `fixedText` | `String` | User-defined string passed through to SC calls (typically used for logging or audit traceability in the backend). |
| 5 | `haisoFinYMD` | `String` | Delivery completion date in YYYYMMDD format. Used as one of the input parameters to `getRsvAplyYmdRule0074()` when calculating the reservation application date. |
| 6 | `baseYMD` | `String` | Operation date (system business date) in YYYYMMDD format. Used as the reference date for past-date comparison (`isPastDate`) and as the reservation application date in agreement search queries. |
| 7 | `haisoDiv` | `String` | Delivery division code. When the movement reservation exists, this determines whether the update path is taken. Only "02" (Work Order Processing / 修理以外 — non-repair) triggers the date update. Other values cause the iteration to skip via `continue`. |

**Instance fields read by the method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `svcKeiKaisenUcwkNo` | `String` | Service contract detail work number (caller reference) — used to look up the circuit-target service contract list. This is an instance field on `JKKShkaFinJiKikiStaAddCC`. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK0241B002) | EKK0241B002 | Service contract master (circuit-target list) | Circuit-target service contract list search — queries service contracts to find the phone service contract number by filtering on service code "02" (Phone) and status "100" (In Service Provision). |
| R | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK0191B001) | EKK0191B001 | Service contract detail master (eo optic phone list) | Service contract details (eo optic phone) list search — retrieves service contract detail work numbers for the identified phone service. |
| R | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK0351B001) | EKK0351B001 | Optional service contract master (list) | Optional service contract list search — finds optional service contracts associated with a service contract detail work number. |
| R | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK0351A010) | EKK0351A010 | Optional service contract agreement master | Optional service contract agreement search — retrieves agreement records filtered by reservation application date (`baseYMD`). Filters on optional service code "B135" and status "030" (Contracted). |
| R | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK0371A010) | EKK0371A010 | Optional service contract (phone) agreement master | Optional service contract (phone) agreement search — retrieves the phone-specific agreement record for the optional service contract. |
| R | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK1681B001) | EKK1681B001 | Movement reservation master | Movement reservation list search — searches for existing movement reservations using transfer division "00031", detail code "014", and status "00,03". |
| C | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK0371C040) | EKK0371C040 | Optional service contract (phone) master | Optional service contract (phone) start — creates a new optional service contract start record when no movement reservation exists. |
| R | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK0161A010) | EKK0161A010 | Service contract details agreement master | Service contract details agreement search — retrieves service contract detail agreement data including service start date and service charge start date. |
| R | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK0351B003) | EKK0351B003 | Optional service contract history master | Optional service contract history list search — retrieves historical records sorted by registration date descending; iterates in reverse to find the minimum (oldest confirmed) record. |
| R | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK0021A010) | EKK0021A010 | Application details master | Application details agreement search — retrieves application details including the application number. |
| R | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK0011A010) | EKK0011A010 | Application master | Application agreement search — retrieves application-level data including the application date (mskmYmd) used in date calculation. |
| U | `JKKShkaFinJiKikiStaAddCC.callSC` (EKK1681C040) | EKK1681C040 | Movement reservation master | Movement reservation application date modification — updates the reservation application date with the value calculated by `getRsvAplyYmdRule0074()`. |
| R | `JKKShkaFinJiKikiStaAddCC.getRsvAplyYmdRule0074` | (Rule logic) | — | Reservation application date calculation (RULE0074 — Start date setting for optional services). Computes the correct application date based on application date, service start date, service charge start date, desired service start date, and delivery completion date. |

### Additional helper calls (utility/validations):

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKStringUtil.isNullBlank` | — | — | Null/blank string check utility. |
| - | `JKKStrConst` references | — | — | String constant lookups (CD00130_02, CD00037_SVCTK_CHU, CD00037_CNC_ZM, OP_SVC_CD_ANSN_HCS_SVC, etc.). |
| - | `JPCUtilCommon.isPastDate` | — | — | Past-date comparison — checks if a given date is earlier than the operation date. |
| - | `HAISO_DIV_SHURI` (field) | — | — | Constant value "02" representing "Work Order Processing / non-repair" delivery division. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKShkaFinJiKikiStaAddCC.addShkaFinJiKiStaAdd` | `addShkaFinJiKiStaAdd` -> `callIdoUpdAnsnHcsSvc` | `callSC(EKK0241B002) [R] ServiceContract`, `callSC(EKK0191B001) [R] ServiceContractDetail`, `callSC(EKK0351B001) [R] OptionalServiceContract`, `callSC(EKK0351A010) [R] OptionalServiceContractAgreement`, `callSC(EKK0371A010) [R] OptionalServiceContractPhoneAgreement`, `callSC(EKK1681B001) [R] MovementReservation`, `callSC(EKK0371C040) [C] OptionalServiceContractStart`, `callSC(EKK0161A010) [R] ServiceContractDetailAgreement`, `callSC(EKK0351B003) [R] OptionalServiceContractHistory`, `callSC(EKK0021A010) [R] ApplicationDetail`, `callSC(EKK0011A010) [R] Application`, `callSC(EKK1681C040) [U] MovementReservation` |

**Terminal operations from this method:** `callSC[EKK0241B002] [R]`, `callSC[EKK0191B001] [R]`, `callSC[EKK0351B001] [R]`, `callSC[EKK0351A010] [R]`, `callSC[EKK0371A010] [R]`, `callSC[EKK1681B001] [R]`, `callSC[EKK0371C040] [C]`, `callSC[EKK0161A010] [R]`, `callSC[EKK0351B003] [R]`, `callSC[EKK0021A010] [R]`, `callSC[EKK0011A010] [R]`, `callSC[EKK1681C040] [U]`, `getRsvAplyYmdRule0074 [R]`, `isNullBlank [-]`, `isPastDate [-]`

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] (L11805)

> Initialize the phone service contract number variable.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiNoTel = ""` |

**Block 2** — [IF] `!JKKStringUtil.isNullBlank(svcKeiKaisenUcwkNo)` (L11807)

> If the caller's service contract detail work number is non-blank, proceed to look up the phone service contract number from the circuit-target service contract list.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `ekk0241b002InMsg = {TEMPLATEID -> "EKK0241B002", FUNC_CODE -> "1", KEY_SVC_KEI_KAISEN_UCWK_NO -> svcKeiKaisenUcwkNo}` | [-> TEMPLATE_ID_EKK0241B002="EKK0241B002"] [-> FUNC_CD_1="1"] |
| 2 | CALL | `ekk0241b002outMsg = callSC(handle, scCall, param, fixedText, ekk0241b002InMsg).getCAANMsgList(EKK0241B002CBSMSG1LIST)` | CallSC EKK0241B002: Circuit-target Service Contract List Search |

**Block 2.1** — [IF] `ekk0241b002outMsg != null && ekk0241b002outMsg.length > 0` (L11816)

> If the service contract list search returned results, iterate through them.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0241b002outMsg = callSC(...).getCAANMsgList(...)` |

**Block 2.1.1** — [FOR] `for (CAANMsg svcKeiMsg : ekk0241b002outMsg)` (L11820)

> Loop through each service contract record from the list search.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiMsg` iterates over `ekk0241b002outMsg` |

**Block 2.1.1.1** — [IF] `JKKStrConst.CD00130_02.equals(svcKeiMsg.getString(EKK0241B002CBSMsg1List.SVC_CD))` (L11823) `[CD00130_02="02" (Phone)]`

> Filter: Only process records where the service code is "02" (Phone).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `svcKeiMsg.getString(EKK0241B002CBSMsg1List.SVC_CD)` |

**Block 2.1.1.1.1** — [IF] `JKKStrConst.CD00037_SVCTK_CHU.equals(svcKeiMsg.getString(EKK0241B002CBSMsg1List.SVC_KEI_STAT))` (L11826) `[CD00037_SVCTK_CHU="100" (In Service Provision)]`

> Filter: Only process records where the service contract status is "100" (In Service Provision).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `svcKeiMsg.getString(EKK0241B002CBSMsg1List.SVC_KEI_STAT)` |

**Block 2.1.1.1.1.1** — [SET] (L11829)

> Extract the phone service contract number and break out of the loop.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiNoTel = svcKeiMsg.getString(EKK0241B002CBSMsg1List.SVC_KEI_NO)` |
| 2 | EXEC | `break` |

**Block 3** — [IF] `JKKStringUtil.isNullBlank(svcKeiNoTel)` (L11841)

> If no active phone service was found (either no caller work number, no results, or no phone/in-service record), exit the method early.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return;` |

**Block 4** — [SET] (L11847–L11851)

> Prepare input for EKK0191B001: Service Contract Details (eo optic phone) list search.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0191b001InMsg = {TEMPLATEID -> "EKK0191B001", FUNC_CODE -> "1", KEY_SVC_KEI_NO -> svcKeiNoTel}` | [-> TEMPLATE_ID_EKK0191B001="EKK0191B001"] [-> FUNC_CD_1="1"] |
| 2 | CALL | `ekk0191b001outMsg = callSC(handle, scCall, param, fixedText, ekk0191b001InMsg).getCAANMsgList(EKK0191B001CBSMSG1LIST)` | CallSC EKK0191B001: Service Contract Details eo Phone |

**Block 5** — [IF] `ekk0191b001outMsg != null && ekk0191b001outMsg.length > 0` (L11856)

> If service contract details were found, iterate through them.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0191b001outMsg = callSC(...).getCAANMsgList(...)` |

**Block 5.1** — [FOR] `for (CAANMsg svcKeiUcwkTelMsg : ekk0191b001outMsg)` (L11859)

> Loop through each service contract detail record.

**Block 5.1.1** — [IF] `!JKKStrConst.CD00037_SVCTK_CHU.equals(svcKeiUcwkTelMsg.getString(EKK0191B001CBSMsg1List.SVC_KEI_UCWK_STAT))` (L11862) `[CD00037_SVCTK_CHU="100" (In Service Provision)]`

> Filter: Skip records where the service contract detail work status is NOT "100" (In Service Provision).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `svcKeiUcwkTelMsg.getString(EKK0191B001CBSMsg1List.SVC_KEI_UCWK_STAT)` |
| 2 | EXEC | `continue` |

**Block 5.1.2** — [SET] (L11867–L11871)

> Prepare input for EKK0351B001: Optional Service Contract List.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0351b001InMsg = {TEMPLATEID -> "EKK0351B001", FUNC_CODE -> "1", KEY_SVC_KEI_UCWK_NO -> svcKeiUcwkTelMsg.getString(EKK0191B001CBSMsg1List.SVC_KEI_UCWK_NO)}` | [-> TEMPLATE_ID_EKK0351B001="EKK0351B001"] [-> FUNC_CD_1="1"] |
| 2 | CALL | `ekk0351b001outMsg = callSC(handle, scCall, param, fixedText, ekk0351b001InMsg).getCAANMsgList(EKK0351B001CBSMSG1LIST)` | CallSC EKK0351B001: Optional Service Contract List |

**Block 5.1.3** — [IF] `ekk0351b001outMsg != null && ekk0351b001outMsg.length > 0` (L11876)

**Block 5.1.3.1** — [FOR] `for (CAANMsg tempOpSvcKeiMsg : ekk0351b001outMsg)` (L11880)

**Block 5.1.3.1.1** — [SET] (L11882–L11887)

> Prepare input for EKK0351A010: Optional Service Contract Agreement search.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0351a010InMsg = {TEMPLATEID -> "EKK0351A010", FUNC_CODE -> "2", KEY_OP_SVC_KEI_NO -> tempOpSvcKeiMsg.getString(EKK0351B001CBSMsg1List.OP_SVC_KEI_NO), KEY_RSV_APLY_YMD -> baseYMD}` | [-> TEMPLATE_ID_EKK0351A010="EKK0351A010"] [-> FUNC_CD_2="2"] |
| 2 | CALL | `ekk0351a010outMsg = callSC(handle, scCall, param, fixedText, ekk0351a010InMsg).getCAANMsgList(EKK0351A010CBSMSG1LIST)` | CallSC EKK0351A010: Optional Service Contract Agreement |

**Block 5.1.3.1.2** — [IF] `ekk0351a010outMsg == null || ekk0351a010outMsg.length == 0` (L11892)

> If no agreement found, skip to the next optional service contract.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` |

**Block 5.1.3.1.3** — [IF] `!JKKStrConst.OP_SVC_CD_ANSN_HCS_SVC.equals(opSvcKeiMsg.getString(EKK0351A010CBSMsg1List.OP_SVC_CD))` (L11914) `[OP_SVC_CD_ANSN_HCS_SVC="B135" (Anshin Hatsu Chushin Service)]`

> Filter: Skip records that are NOT the Anshin Hatsu Chushin Service (optional service code "B135").

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `opSvcKeiMsg.getString(EKK0351A010CBSMsg1List.OP_SVC_CD)` |
| 2 | EXEC | `continue` |

**Block 5.1.3.1.4** — [IF] `!JKKStrConst.CD00037_CNC_ZM.equals(opSvcKeiMsg.getString(EKK0351A010CBSMsg1List.OP_SVC_KEI_STAT))` (L11922) `[CD00037_CNC_ZM="030" (Contracted)]`

> Filter: Skip records that are NOT "030" (Contracted) in optional service contract status.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `opSvcKeiMsg.getString(EKK0351A010CBSMsg1List.OP_SVC_KEI_STAT)` |
| 2 | EXEC | `continue` |

**Block 5.1.3.1.5** — [SET] (L11929)

> Extract the optional service contract number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `opSvcKeiNo = opSvcKeiMsg.getString(EKK0351A010CBSMsg1List.OP_SVC_KEI_NO)` |

**Block 5.1.3.1.6** — [SET] (L11932–L11936)

> Prepare input for EKK0371A010: Optional Service Contract (Phone) Agreement search.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0371a010InMsg = {TEMPLATEID -> "EKK0371A010", FUNC_CODE -> "2", KEY_OP_SVC_KEI_NO -> opSvcKeiNo, KEY_GENE_ADD_DTM -> ""}` | [-> TEMPLATE_ID_EKK0371A010="EKK0371A010"] [-> FUNC_CD_2="2"] |
| 2 | CALL | `ekk0371a010outMsg = callSC(handle, scCall, param, fixedText, ekk0371a010InMsg).getCAANMsgList(EKK0371A010CBSMSG1LIST)` | CallSC EKK0371A010: Optional Service Contract Phone Agreement |

**Block 5.1.3.1.7** — [IF] `ekk0371a010outMsg == null || ekk0371a010outMsg.length == 0` (L11944)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` |

**Block 5.1.3.1.8** — [SET] (L11951–L11952)

> Extract phone-specific data from the agreement.

| # | Type | Code |
|---|------|------|
| 1 | SET | `opSvcKeiTelMsg = ekk0371a010outMsg[0]` |
| 2 | SET | `lastUpdDtm = opSvcKeiTelMsg.getString(EKK0371A010CBSMsg1List.LAST_UPD_DTM)` |

**Block 5.1.3.1.9** — [SET] (L11955–L11965)

> Prepare input for EKK1681B001: Movement Reservation List search.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk1681B001InMsg = {TEMPLATEID -> "EKK1681B001", FUNC_CODE -> "1", KEY_IDO_DIV -> "00031", KEY_IDO_RSV_DTL_CD -> "014", KEY_IDO_RSV_STAT_CD -> "00,03", KEY_OP_SVC_KEI_NO -> opSvcKeiNo}` | [-> TEMPLATE_ID_EKK1681B001="EKK1681B001"] [-> FUNC_CD_1="1"] [-> CD00576_00031="00031"] [-> IDO_RSV_DTL_CD_OP_STA="014"] [-> CD01168_IDO_RSV_STAT_CD_00="00" + COMMA + CD01168_IDO_RSV_STAT_CD_03="03"] [-> COMMA=","] |
| 2 | CALL | `ekk1681B001outMsg = callSC(...).getCAANMsgList(EKK1681B001CBSMSG1LIST)` | CallSC EKK1681B001: Movement Reservation List |

**Block 5.1.3.1.10** — [IF] `ekk1681B001outMsg == null || ekk1681B001outMsg.length == 0` (L11968)

> Branch A: No movement reservation found — create a new optional service contract (Phone) start.

**Block 5.1.3.1.10.1** — [SET] (L11971–L11977)

> Prepare input for EKK0371C040: Optional Service Contract (Phone) Start.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0371c040InMsg = {TEMPLATEID -> "EKK0371C040", FUNC_CODE -> "1", OP_SVC_KEI_NO -> opSvcKeiNo, IDO_DIV -> "00031", N_050_OP_TELNO -> opSvcKeiTelMsg.getString(EKK0371A010CBSMsg1List.N_050_OP_TELNO), UPD_DTM_BF -> lastUpdDtm}` | [-> TEMPLATE_ID_EKK0371C040="EKK0371C040"] [-> FUNC_CD_1="1"] [-> CD00576_00031="00031"] |
| 2 | CALL | `callSC(handle, scCall, param, fixedText, ekk0371c040InMsg)` | CallSC EKK0371C040: Optional Service Contract Phone Start |

**Block 5.1.3.1.11** — [ELSE] (L11980)

> Branch B: Movement reservation found — this is the primary update path.

**Block 5.1.3.1.11.1** — [IF] `!HAISO_DIV_SHURI.equals(haisoDiv)` (L11986) `[HAISO_DIV_SHURI="02" (Work Order Processing)]`

> Filter: Only proceed if the delivery division is "02" (Work Order Processing / non-repair). This is an addition from IT2-2020-0000014.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` |

**Block 5.1.3.1.11.2** — [SET] (L11990)

> Extract the first movement reservation record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `idoRsvMsg = ekk1681B001outMsg[0]` |
| 2 | SET | `mskmDtlNo = ""` |

**Block 5.1.3.1.11.3** — [SET] (L11995–L11999)

> Prepare input for EKK0161A010: Service Contract Details Agreement search.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0161a010InMsg = {TEMPLATEID -> "EKK0161A010", FUNC_CODE -> "2", KEY_SVC_KEI_UCWK_NO -> svcKeiUcwkTelMsg.getString(EKK0191B001CBSMsg1List.SVC_KEI_UCWK_NO), KEY_RSV_APLY_YMD -> baseYMD}` | [-> TEMPLATE_ID_EKK0161A010="EKK0161A010"] [-> FUNC_CD_2="2"] |
| 2 | CALL | `ekk0161a010outMsg = callSC(...).getCAANMsgList(EKK0161A010CBSMSG1LIST)` | CallSC EKK0161A010: Service Contract Details Agreement |

**Block 5.1.3.1.11.4** — [IF] `ekk0161a010outMsg == null || ekk0161a010outMsg.length == 0` (L12004)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` |

**Block 5.1.3.1.11.5** — [SET] (L12010–L12014)

> Prepare input for EKK0351B003: Optional Service Contract History List.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0351b003InMsg = {TEMPLATEID -> "EKK0351B003", FUNC_CODE -> "1", KEY_OP_SVC_KEI_NO -> opSvcKeiNo}` | [-> TEMPLATE_ID_EKK0351B003="EKK0351B003"] [-> FUNC_CD_1="1"] |
| 2 | CALL | `ekk0351b003outMsg = callSC(...).getCAANMsgList(EKK0351B003CBSMSG1LIST)` | CallSC EKK0351B003: Optional Service Contract History |

**Block 5.1.3.1.11.6** — [IF] `ekk0351b003outMsg != null && ekk0351b003outMsg.length > 0` (L12018)

> If optional service contract history records exist, find the minimum (oldest) application detail number.

**Block 5.1.3.1.11.6.1** — [FOR] `for (int i = ekk0351b003outMsg.length - 1; i >= 0; i--)` (L12022)

> Iterate in reverse (descending) through the history records since they are returned sorted by registration date descending. The first match found from the end is the minimum.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tempOpSvcKeiRkMsg = ekk0351b003outMsg[i]` |

**Block 5.1.3.1.11.6.1.1** — [IF] `JKKStrConst.CD00343_2.equals(...) && JPCUtilCommon.isPastDate(...)` (L12027–L12028) `[CD00343_2="2" (Confirmed)]`

> Filter: Reservation application code equals "2" (Confirmed) AND the reservation application date is past the operation date (`baseYMD`).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `tempOpSvcKeiRkMsg.getString(EKK0351B003CBSMsg1List.KK0351_RSV_APLY_CD)` |
| 2 | EXEC | `JPCUtilCommon.isPastDate(tempOpSvcKeiRkMsg.getString(EKK0351B003CBSMsg1List.RSV_APLY_YMD), baseYMD, "1")` |

**Block 5.1.3.1.11.6.1.1.1** — [SET] (L12030–L12031)

> Extract the application detail number and break out of the loop.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mskmDtlNo = tempOpSvcKeiRkMsg.getString(EKK0351B003CBSMsg1List.MSKM_DTL_NO)` |
| 2 | EXEC | `break` |

**Block 5.1.3.1.11.7** — [IF] `JKKStringUtil.isNullBlank(mskmDtlNo)` (L12036)

> If no valid application detail number was found, skip.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` |

**Block 5.1.3.1.11.8** — [SET] (L12041–L12045)

> Prepare input for EKK0021A010: Application Details Agreement search.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0021a010InMsg = {TEMPLATEID -> "EKK0021A010", FUNC_CODE -> "2", KEY_MSKM_DTL_NO -> mskmDtlNo}` | [-> TEMPLATE_ID_EKK0021A010="EKK0021A010"] [-> FUNC_CD_2="2"] |
| 2 | CALL | `ekk0021a010outMsg = callSC(...).getCAANMsgList(EKK0021A010CBSMSG1LIST)` | CallSC EKK0021A010: Application Details Agreement |

**Block 5.1.3.1.11.9** — [IF] `ekk0021a010outMsg == null || ekk0021a010outMsg.length == 0` (L12050)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` |

**Block 5.1.3.1.11.10** — [SET] (L12057)

> Extract the application number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mskmNo = mskmDtlMsg.getString(EKK0021A010CBSMsg1List.MSKM_NO)` |

**Block 5.1.3.1.11.11** — [IF] `JKKStringUtil.isNullBlank(mskmNo)` (L12059)

> If the application number is blank, skip.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` |

**Block 5.1.3.1.11.12** — [SET] (L12064–L12068)

> Prepare input for EKK0011A010: Application Agreement search.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0011a010InMsg = {TEMPLATEID -> "EKK0011A010", FUNC_CODE -> "2", KEY_MSKM_NO -> mskmNo}` | [-> TEMPLATE_ID_EKK0011A010="EKK0011A010"] [-> FUNC_CD_2="2"] |
| 2 | CALL | `ekk0011a010outMsg = callSC(...).getCAANMsgList(EKK0011A010CBSMSG1LIST)` | CallSC EKK0011A010: Application Agreement |

**Block 5.1.3.1.11.13** — [IF] `ekk0011a010outMsg == null || ekk0011a010outMsg.length == 0` (L12073)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` |

**Block 5.1.3.1.11.14** — [SET] (L12081–L12089)

> Calculate the reservation application date using the rule-based method `getRsvAplyYmdRule0074()`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `rsvAplyYmd = getRsvAplyYmdRule0074(CD00130_02="02", OP_SVC_CD_ANSN_HCS_SVC="B135", mskmMsg.getString(MSKM_YMD), svcKeiUcwkMsg.getString(SVC_STA_YMD), svcKeiUcwkMsg.getString(SVC_CHRG_STAYMD), opSvcKeiMsg.getString(SVC_USE_STA_KIBO_YMD), haisoFinYMD)` |
| 2 | SET | `mskmMsg = ekk0011a010outMsg[0]` |

**Block 5.1.3.1.11.15** — [IF] `JKKStringUtil.isNullBlank(rsvAplyYmd)` (L12091)

> If the calculated date is blank, skip.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `continue` |

**Block 5.1.3.1.11.16** — [SET] (L12096–L12100)

> Prepare input for EKK1681C040: Movement Reservation Application Date Modification.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk1681c040InMsg = {TEMPLATEID -> "EKK1681C040", FUNC_CODE -> "1", IDO_RSV_NO -> idoRsvMsg.getString(IDO_RSV_NO), RSV_APLY_YMD -> rsvAplyYmd, UPD_DTM_BF -> idoRsvMsg.getString(UPD_DTM)}` | [-> TEMPLATE_ID_EKK1681C040="EKK1681C040"] [-> FUNC_CD_1="1"] |
| 2 | CALL | `callSC(handle, scCall, param, fixedText, ekk1681c040InMsg)` | CallSC EKK1681C040: Movement Reservation Application Date Modification |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `callIdoUpdAnsnHcsSvc` | Method | Movement reservation application date update for Anshin Hatsu Chushin Service — the core business method being documented. |
| `svcKeiKaisenUcwkNo` | Field | Service contract detail work number (caller reference) — internal tracking ID for the service contract line item that triggered this processing. |
| `svcKeiNoTel` | Field | Service contract number (Phone) — extracted phone service contract number used as a key for subsequent lookups. |
| `svcKeiUcwkNo` | Field | Service contract detail work number — internal ID for a specific service contract line item. |
| `svcKeiNo` | Field | Service contract number — the unique identifier for a service contract. |
| `svc_cd` | Field | Service code — classifies the type of service (e.g., "02" = Phone). |
| `svc_kei_stat` | Field | Service contract status — the current status of a service contract. |
| `svc_kei_ucwk_stat` | Field | Service contract detail work status — the operational status of a service contract line item. |
| `op_svc_cd` | Field | Optional service code — classifies optional/add-on services (e.g., "B135" = Anshin Hatsu Chushin Service). |
| `op_svc_kei_stat` | Field | Optional service contract status — the current status of an optional service contract. |
| `op_svc_kei_no` | Field | Optional service contract number — unique identifier for an optional service contract. |
| `ido_div` | Field | Transfer/movement division code — classifies the type of movement/transfer (e.g., "00031" = standard transfer). |
| `ido_rsv_dtl_cd` | Field | Movement reservation detail code — classifies the type of movement reservation detail (e.g., "014" = optional service status). |
| `ido_rsv_stat_cd` | Field | Movement reservation status code — the status of a movement reservation record. |
| `ido_rsv_no` | Field | Movement reservation number — unique identifier for a movement reservation. |
| `haisoDiv` | Field | Delivery division code — classifies the type of delivery (e.g., "02" = Work Order Processing / non-repair). |
| `haisoFinYMD` | Field | Delivery completion date in YYYYMMDD format — the date when delivery was completed. Used as input to the reservation application date calculation. |
| `baseYMD` | Field | Operation date in YYYYMMDD format — the system's current business date used as reference for date comparisons and reservation application lookups. |
| `mskmDtlNo` | Field | Application detail number — internal identifier for an application detail record. |
| `mskmNo` | Field | Application number — the unique identifier for a service application. |
| `mskmYmd` | Field | Application date in YYYYMMDD format — the date the application was submitted. |
| `rsvAplyYmd` | Field | Reservation application date in YYYYMMDD format — the calculated date that will be written to the movement reservation. |
| `lastUpdDtm` | Field | Last update datetime — the timestamp of the last modification to the optional service contract (phone) agreement, used for optimistic locking. |
| `rsv_aply_cd` | Field | Reservation application code — classifies the reservation state (e.g., "2" = Confirmed). |
| `rsv_aply_ymd` | Field | Reservation application date in YYYYMMDD format — the date the reservation was applied. |
| `svc_sta_ymd` | Field | Service start date in YYYYMMDD format — the date the service was started. |
| `svc_chrg_staymd` | Field | Service charge start date in YYYYMMDD format — the date when billing starts. |
| `svc_use_sta_kibo_ymd` | Field | Service usage start desired date in YYYYMMDD format — the customer's desired service start date. |
| CD00130_02 | Constant | Service code "02" = Phone service. |
| CD00037_SVCTK_CHU | Constant | Status "100" = In Service Provision (service is actively being provided). |
| CD00037_CNC_ZM | Constant | Status "030" = Contracted (the service contract has been finalized). |
| CD00343_2 | Constant | Reservation application code "2" = Confirmed (reservation is finalized). |
| CD00576_00031 | Constant | Transfer division "00031" — a standard transfer/movement division type. |
| CD01168_IDO_RSV_STAT_CD_00 | Constant | Movement reservation status "00" — a specific status code component. |
| CD01168_IDO_RSV_STAT_CD_03 | Constant | Movement reservation status "03" — another status code component. Combined as "00,03" for the query. |
| IDO_RSV_DTL_CD_OP_STA | Constant | Movement reservation detail code "014" = Optional service status. |
| COMMA | Constant | String "," — used as a delimiter when concatenating multiple status codes. |
| OP_SVC_CD_ANSN_HCS_SVC | Constant | Optional service code "B135" = Anshin Hatsu Chushin Service (Peace-of-Mind Call Notification Service). |
| HAISO_DIV_SHURI | Constant | Delivery division "02" = Work Order Processing / non-repair — determines whether the date update path is taken. |
| FUNC_CD_1 | Constant | Function code "1" — search/list query mode. |
| FUNC_CD_2 | Constant | Function code "2" — agreement/detail search mode. |
| EKK0241B002 | SC Code | Circuit-target service contract list search SC — retrieves service contracts for circuit-targeting customers. |
| EKK0191B001 | SC Code | Service contract details (eo optic phone) list search SC — retrieves service contract detail records for eo optic phone services. |
| EKK0351B001 | SC Code | Optional service contract list search SC — retrieves optional service contracts linked to a service contract detail. |
| EKK0351A010 | SC Code | Optional service contract agreement search SC — retrieves agreement records for optional service contracts. |
| EKK0371A010 | SC Code | Optional service contract (phone) agreement search SC — retrieves phone-specific agreement data. |
| EKK1681B001 | SC Code | Movement reservation list search SC — searches movement/transfer reservation records. |
| EKK0371C040 | SC Code | Optional service contract (phone) start SC — creates a new optional service contract start record (Branch A). |
| EKK0161A010 | SC Code | Service contract details agreement search SC — retrieves service contract detail agreement with service start and charge start dates. |
| EKK0351B003 | SC Code | Optional service contract history list search SC — retrieves the full history of an optional service contract. |
| EKK0021A010 | SC Code | Application details agreement search SC — retrieves application detail information including the application number. |
| EKK0011A010 | SC Code | Application agreement search SC — retrieves the top-level application record. |
| EKK1681C040 | SC Code | Movement reservation application date modification SC — updates the reservation application date on the movement reservation (Branch B final step). |
| Anshin Hatsu Chushin Service | Business term | "あんしん発着信サービス" — a peace-of-mind call notification service (optional add-on) for telecom subscribers. Code "B135". |
| `getRsvAplyYmdRule0074` | Method | Reservation application date calculation using RULE0074 logic — determines the correct application date by considering multiple date inputs (application date, service start, charge start, desired start, delivery completion). |
| SC | Acronym | Service Component — a backend processing unit that executes database operations. |
| CBS | Acronym | CBS (Common Business Service) — the backend service component implementation. |
| CAANMsg | Type | CAAN message object — the data exchange format used between the Java layer and SC/CBS. |
| eo optic phone | Business term | "eo光電話" — NTT's fiber-optic telephone service. |
| Work Order Processing | Business term | 修理以外 — delivery division for non-repair cases, requiring reservation date updates. |
