定义差旅实体的 RAP 副作用
ABAP RESTful 应用程序编程模型 › 开发 › 开发应用程序 › 使用独占草稿功能开发事务应用 › 使用 UUID 键值构建被管理业务对象 › 开发事务行为 › 开发 RAP 副作用 › 定义差旅实体的 RAP 副作用
对于具有草稿的管理场景,定义对差旅实体的 RAP 负面影响,以便立即对 Fiori 元素 UI 进行反馈。
副作用在基本行为定义中定义。要为 UI 服务公开,它们必须像任何其他业务对象行为一样在映射行为定义中重用,请参阅投影草稿业务对象行为。
总价格重新计算的 RAP 副作用
RAP 副作用触发对 Total Price 每次更改 Booking Fee 的重新计算。
在行为定义的行为正文中使用字段触发器和字段目标定义 RAP 副作用。
示例代码
define behavior for /DMO/R_Travel_D alias Travel
...
side effects
{ field BookingFee affects field TotalPrice; }
无论何时更改 Booking Fee,都会重新加载 Total Price 并在 UI 上显示重新计算的总价格。后端中的重新计算由字段更改触发。
触发 AgencyID 验证的 RAP 副作用
RAP 副作用会触发检查 AgencyID 是否有效并重新加载相应消息的验证。为了能够为 RAP 副作用定义触发点,必须首先在确定操作中定义。确定操作与更新具有相同的权限。因此(权限:更新)已定义。
备注
关键字
side effects在行为定义正文中只能出现一次。必须同时为一个实体定义所有 RAP 副作用。
示例代码
define behavior for /DMO/R_Travel_D alias Travel
...
{ ...
determine action ( authorization : update ) validateAgencyID { validation validateAgency; }
side effects { field BookingFee affects field TotalPrice;
determine action ( authorization : update ) validateAgencyID executed on field AgencyID affects messages; }
… }
更改 AgencyID 时,都会触发调用验证并重新加载消息的确定操作。确定操作与更新具有相同的权限。因此(权限:更新)已定义。
触发 CustomerID 验证的 RAP 副作用
RAP 副作用会触发检查 CustomerID 是否有效并重新加载相应消息的验证。为了能够为 RAP 副作用定义触发点,必须首先在确定操作中定义。确定操作与更新具有相同的权限。因此(权限:更新)已定义。
备注
关键字
side effects在行为定义正文中只能出现一次。必须同时为一个实体定义所有副作用。
示例代码
define behavior for /DMO/R_Travel_D alias Travel
...
{ ...
determine action ( authorization : update ) validateAgencyID { validation validateAgency; }
determine action ( authorization : update ) validateCustomerID { validation validateCustomer; }
side effects { field BookingFee affects field TotalPrice;
determine action ( authorization : update ) validateAgencyID executed on field AgencyID affects messages;
determine action ( authorization : update ) validateCustomerID executed on field CustomerID affects messages;
}
… }
更改 CustomerID 时,都会触发调用验证并重新加载消息的确定操作。
触发日期验证的 RAP 副作用
RAP 副作用会触发验证,以检查 BeginDate 和 EndDate 是否有效并重新加载相应消息。为了能够为 RAP 副作用定义触发点,必须首先在确定操作中定义。
备注
关键字
side effects在行为定义正文中只能出现一次。必须同时为一个实体定义所有 RAP 副作用。
示例代码
define behavior for /DMO/R_Travel_D alias Travel
...
{ ...
determine action ( authorization : update ) validateAgencyID { validation validateAgency; }
determine action ( authorization : update ) validateCustomerID { validation validateCustomer; }
determine action ( authorization : update ) validateDateRange { validation validateDates; }
side effects { field BookingFee affects field TotalPrice;
determine action ( authorization : update ) validateAgencyID executed on field AgencyID affects messages;
determine action ( authorization : update ) validateCustomerID executed on field CustomerID affects messages;
determine action ( authorization : update ) validateDateRange executed on field BeginDate, field EndDate affects messages;
}
… }
每当更改 BeginDate 或 EndDate 时,都会触发调用验证并重新加载消息的确定操作。
触发预订费验证的 RAP 副作用
RAP 副作用会触发检查 BookingFee 是否有效并重新加载相应消息的验证。为了能够为 RAP 副作用定义触发点,必须首先在确定操作中定义。确定操作与更新具有相同的权限。因此(权限:更新)已定义。
备注
关键字
side effects在行为定义正文中只能出现一次。必须同时为一个实体定义所有 RAP 副作用。
示例代码
define behavior for /DMO/R_Travel_D alias Travel
...
{ ...
determine action ( authorization : update ) validateAgencyID { validation validateAgency; }
determine action ( authorization : update ) validateCustomerID { validation validateCustomer; }
determine action ( authorization : update ) validateDateRange { validation validateDates; }
determine action ( authorization : update ) validateBookingCharge { validation validateBookingFee; }
side effects { field BookingFee affects field TotalPrice;
determine action ( authorization : update ) validateAgencyID executed on field AgencyID affects messages;
determine action ( authorization : update ) validateCustomerID executed on field CustomerID affects messages;
determine action ( authorization : update ) validateDateRange executed on field BeginDate, field EndDate affects messages;
determine action ( authorization : update ) validateBookingCharge executed on field BookingFee affects messages;
}
… }
无论何时更改字段 BookingFee 都会触发确定操作,该操作将调用验证并重新加载消息。
来源:SAP Help Portal · 2025 FPS02 (Oct 2026) · 中文为 SAP 官方机器翻译
← 开发 RAP 副作用 · 定义预订实体的 RAP 副作用 →