SAP BDL EVENT



Get Example source ABAP code based on a different SAP table
  


• EVENT ABAP_BDL_BODY
• DEEP PARAMETER ABAP_BDL_BODY , EVENT
• PARAMETER ABAP_BDL_BODY , EVENT

ABAP_RAP - event

ABAP_SYNTAX
event EventName $[$[deep$] parameter ParamName$];

What does it do?
Defines a RAP business event in the root node of a managed or unmanaged RAP BO. A RAP business event is a data record that expresses a significant change in the state of a RAP BO entity. An interested party that has subscribed to this event can consume and process it.
Currently, RAP business events can be defined only in the root node of a RAP business object.
An output parameter ParamName can optionally be defined to specify the information that is passed to the event consumers. This information is called the payload of the event.
If parameter ParamName is specified, ParamName must be a CDS abstract entity. The parameter is flat in this case. This means that the BDEF derived type for the parameter contains a component for each field of the CDS abstract entity.
If deep parameter ParamName is specified, ParamName must be an abstract BDEF with hierarchy. The parameter is deep in this case. This means that the BDEF derived type for the parameter is a hierarchy that contains all entity fields plus the components for every composition.
A RAP business event must be raised in the ABAP behavior pool of the RAP BO in question with the ABAP EML statement RAISE ENTITY EVENT. It is recommended that RAP business events are raised during the RAP saver methods save or save_modified. In managed RAP BOs, it is recommended that a RAP additional save is specified using the syntax addition with additional save and raise the RAP business event in this additional save implementation.

ABAP_AVAILABILITY
RAP business events can be defined in managed RAP BOs and in unmanaged RAP BOs.
They can also be defined in BDEF extensions for managed and unmanaged RAP BOs. This is described in topic RAP BDL - Adding Elements.
RAP events cannot be defined in BDEFs of any other implementation type.
ABAP_AVAILABILITY_END

ABAP_FURTHER_INFO
Development guide for the ABAP RESTful Application Programming Model, section about RAP Business Events.



Latest notes:

Once a RAP business event has been created and raised, an event binding must be defined to map the event to an event type.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following example shows a managed BDEF based on the CDS root view entity DEMO_RAP_EVENT. It defines two events:
myEvent defines a flat output parameter
myEvent1 defines a deep output parameter
BDEF DEMO_RAP_EVENT
The following CDS abstract entity is used as flat parameter:
DDLS DEMO_ABSTRACT_ROOT_1
The following abstract BDEF is used as deep parameter:
BDEF DEMO_ABSTRACT_ROOT
The RAP business event is raised in the RAP saver method save_modified as follows:
METH BP_DEMO_RAP_EVENT(CCIMP)=>SAVE_MODIFIED
The BDEF derived type of the flat parameter looks as follows:
IMAGE flat_para.jpg 209 36
The BDEF derived type of the deep parameter looks as follows:
IMAGE deep_para2.jpg 232 686
ABAP_EXAMPLE_END