ABAP - Keyword Documentation → ABAP RAP Business Objects → RAP - Behavior Definitions → RAP - BDL for Behavior Definitions → RAP - Managed and Unmanaged Behavior Definitions → RAP - EntityBehaviorDefinition → RAP - EntityBehaviorBody → RAP - Events → 

    RAP - managed event

    Syntax


    managed event DerivedEventName on RefEvent parameter ViewEntityName;

    Description


    Defines a RAP derived event DerivedEventName in a managed or unmanaged RAP BO. A derived event is defined with reference to an already implemented event RefEvent and allows the definition of a payload that deviates from the payload of the referenced event. When the referenced event is raised, the derived event is raised as well with its custom payload. No implementation in an ABAP behavior pool is required for the derived event.

    • The name DerivedEventName defines the name of the derived event. It must comply with the naming rules for CDS BDL that are described in the topic RAP BDL - General Syntax Rules.
    • After the keyword ON, the referenced event RefEvent is specified. The referenced event must be an event from the current behavior definition. In case of an extension, the referenced event must be specified in the original BDEF that is currently being extended.
    • An input parameter ViewEntityName must be defined. It redefines the payload of the event RefEvent. The following rules apply:
      • The input parameter ViewEntityName must be a CDS view entity without any associations.
      • The key fields of the view entity used as the input parameter ViewEntityName must match the key fields of the entity the referenced event is defined for.

    Availability


    Hint

    The payload of a managed event is defined using a CDS view entity. By default, the RAP framework accesses this view entity with PRIVILEGED access rights. This means that no authorization checks are performed when reading the payload data.

    Further Information


    Development guide for the ABAP RESTful Application Programming Model, section about Derived Events.

    Example


    The following example shows an unmanaged BDEF based on the CDS root view entity DEMO_RAP_DERIVED_EVENT. It defines the event MyEvent.

    unmanaged implementation in class bp_demo_rap_derived_event unique;
    strict ( 2 );
    extensible;

    define behavior for DEMO_RAP_DERIVED_EVENT

    lock master
    authorization master ( instance )
    extensible
    {
      create;
      update;
      delete;

      field(readonly:update) keyfield;

      event MyEvent;
    }

    The following CDS view entity is used as an input parameter of the derived event. Its key fields match the key fields of the root view entity DEMO_RAP_DERIVED_EVENT.

    @AccessControl.authorizationCheck: #NOT_REQUIRED
    @EndUserText.label: 'CDS view entity, demo for derived event'
    define root view entity DEMO_RAP_DERIVED_EVENT_PARAM
      as select from demo_dbtab_root
    {
      key key_field    as KeyField,
          data_field   as DataField
    }

    The following BDEF extension redefines the event MyEvent from the base BDEF. The derived event has the name MyDerivedEvent.

    extension using interface DEMO_RAP_DERIVED_EVENT_PV;

    extend behavior for RootInterface
    {

      managed event MyDerivedEvent on MyEvent
        parameter DEMO_RAP_DERIVED_EVENT_PARAM;
    }