Ansicht
Dokumentation

ABAPRAISE_ENTITY_EVENT - RAISE ENTITY EVENT

ABAPRAISE_ENTITY_EVENT - RAISE ENTITY EVENT

General Material Data   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

RAISE ENTITY EVENT

RAISE ENTITY EVENT bdef~evt FROM tab.

Effect

Raises a RAP entity event.

Since RAP entity events can only be raised on the root node level, bdef must be a root entity. The event evt that is raised must be defined in a BDEF or BDEF extension. tab is an internal table of type TYPE TABLE FOR EVENT bdef~evt.

RAP entity events might be raised in an ABAP behavior pool in various contexts, however, it is recommended that they are raised during the RAP saver methods save or save_modified.

The information that is passed always includes a RAP BO instance key of the root entity. If the event is defined with parameters, the information can include more details. For example, an event is raised if a flight is canceled in a flight booking application. In addition to the key to identify the flight, further details like the cancellation reason and a description are passed (via a CDS abstract entity).

Notes

  • An event binding must exist to map an event type to a RAP entity event.
  • Events must be assigned to an outbound channel so that the events can be sent.
  • If your use case is to raise a RAP entity event outside of the behavior pool, you can create a separate local class in the behavior pool's global class. There, you might create a static method in whose implementation part the event raising is wrapped.

Example

The following code snippet demonstrates the implementation of a save_modified method in which RAP entity events are raised for RAP BO instances that are created and deleted. The event for created RAP BO instances is defined without parameters in the BDEF. The event for deleted instances is defined with parameters. Hence, the %param structure is contained in the BDEF derived type. In both cases, the internal tables contained in the deep structures create and delete are looped across using iteration expressions with FOR to make sure that events are raised for all relevant instances.

CLASS lsc_some_bdef IMPLEMENTATION.
  METHOD save_modified.
  IF create-some_bdef IS NOT INITIAL.
    READ ENTITY IN LOCAL MODE some_bdef
       ALL FIELDS WITH CORRESPONDING #( create-some_bdef )
       RESULT DATA(created_tab) FAILED DATA(failed_cr).
    ENDIF.

  IF created_tab IS NOT INITIAL.
    "Event defined in BDEF: event created;
    RAISE ENTITY EVENT some_bdef~created
      FROM VALUE #( FOR <cr> IN created_tab (
        %key = VALUE #( key_field = <cr>-key_field )  ) ).
  ENDIF.

  IF delete-some_bdef IS NOT INITIAL.
  "Event defined in BDEF: event deleted parameter some_abstract_entity;
    RAISE ENTITY EVENT some_bdef~deleted
      FROM VALUE #( FOR <del> IN delete-some_bdef (
        %key   = VALUE #( key_field   = <del>-key_field )
        %param = VALUE #( reason_code = '01'
                          description = 'Booking canceled.' ) ) ).
    ENDIF.
  ENDMETHOD.
ENDCLASS.






CL_GUI_FRONTEND_SERVICES - Frontend Services   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 5509 Date: 20240509 Time: 054242     sap01-206 ( 60 ms )