
RAP entity events are defined through Behavior Definition on root node level for both managed and unmanaged scenario. Entity events can have a parameter ( Abstract CDS Entity ) which acts as the event payload and is optional. If no parameter is defined the keys for the root BO is used as the event payload. The RAP Event created will be then mapped to a event type using "Event Binding" which will allow the event to be configured as an Outbound Topic in our event mesh Channel. This topic is then subscribed by an event mesh queue for further processing, messages can be consumed by 3rd party systems from the queue directly.
The event can also be triggered from outside the RAP Business object by wrapping the "Raise Event" in a local class in the behavior pool class and calling the same by creating static method in the global class pool of the behavior implementation class. This static method can be then used to raise the events from outside the RAP BO by passing the payload as an importing parameter.
For this use case a simple RAP BO is created which will send an event for every new instance created using the RAP BO , a parameter is defined for the event using an abstract entity that acts as payload structure to send additional Contact Details along with the partner number created. Keyword "RAISE ENTITY EVENT" is then used to raise the event when a new instance is created , this is implemented within its own behavior pool using an additional save.
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Interface View for Contact Info'
define root view entity ZI_CONINFO
as select from ztabconinfo
{
key bpno as Bpno,
firstname as Firstname,
lastname as Lastname,
@Semantics.eMail.address: true
email as Email,
@Semantics.user.createdBy: true
local_created_by as LocalCreatedBy,
@Semantics.systemDateTime.createdAt: true
local_created_at as LocalCreatedAt,
@Semantics.user.lastChangedBy: true
local_last_changed_by as LocalLastChangedBy,
//local ETag field --> OData ETag
@Semantics.systemDateTime.localInstanceLastChangedAt: true
local_last_changed_at as LocalLastChangedAt,
//total ETag field
@Semantics.systemDateTime.lastChangedAt: true
last_changed_at as LastChangedAt
}
@EndUserText.label: 'Consumption View for Contact Info'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.allowExtensions: true
@Metadata.ignorePropagatedAnnotations: true
define root view entity ZC_CONINFO
provider contract transactional_query
as projection on ZI_CONINFO
{
key Bpno,
Firstname,
Lastname,
Email,
LocalLastChangedAt
}
@Metadata.layer: #CORE
@UI: { headerInfo: {
typeName: 'User',
typeNamePlural: 'Users',
title: { type: #STANDARD, value: 'Bpno' } },
presentationVariant: [{
sortOrder: [{ by: 'Bpno', direction: #DESC }],
visualizations: [{type: #AS_LINEITEM}] }] }
annotate view ZC_CONINFO with
{
@UI.facet: [ {
label: 'General Information',
id: 'GeneralInfo',
type: #COLLECTION,
position: 10
},
{ id: 'Userdetails',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
label: 'User Details',
parentId: 'GeneralInfo',
position: 10 } ]
@UI: { lineItem: [ { position: 10, importance: #HIGH , label: 'User Number'} ] ,
identification: [ { position: 10 , label: 'User Number' } ] }
Bpno;
@UI: { lineItem: [ { position: 20, importance: #HIGH , label: 'First Name'} ] ,
identification: [ { position: 20 , label: 'First Name' } ] }
Firstname;
@UI: { lineItem: [ { position: 30, importance: #HIGH , label: 'Last Name'} ] ,
identification: [ { position: 30 , label: 'Last Name' } ] }
Lastname;
@UI: { lineItem: [ { position: 40, importance: #HIGH , label: 'Email Address'} ] ,
identification: [ { position: 40 , label: 'Email Address' } ] }
Email;
}
managed implementation in class zbp_i_coninfo unique;
strict ( 2 );
with draft;
define behavior for ZI_CONINFO alias Userdetails
persistent table ztabconinfo
draft table ztabconinfod
lock master
total etag LocalLastChangedAt
authorization master ( instance )
with additional save
{
create;
update;
delete;
field ( readonly ) LastChangedAt, LocalLastChangedBy, LocalLastChangedAt, LocalCreatedBy,
LocalCreatedAt;
event SendContact parameter ZABS_EVENTSTRUC;
draft action Edit;
draft action Activate;
draft action Discard;
draft action Resume;
draft determine action Prepare;
}
@EndUserText.label: 'Event Structure'
define abstract entity ZABS_EVENTSTRUC
{
firstname : abap.char(20);
lastname : abap.char(20);
email : abap.char(20);
created_by : abp_creation_user;
created_at : abp_creation_tstmpl;
}
method save_modified.
if create-userdetails is not initial.
raise entity event zi_coninfo~SendContact
from value #(
for userdet in create-userdetails (
Bpno = userdet-Bpno
firstname = userdet-Firstname
lastname = userdet-Lastname
email = userdet-Email
)
).
endif.
endmethod.
Event Binding
Available under Outbound Topic
RAP Event configured as outbound Topic
Topic Subscribed in the EM Queue
New Instance Created
Message Received in Queue
Event payload
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
24 | |
21 | |
20 | |
18 | |
14 | |
13 | |
12 | |
10 | |
8 | |
7 |