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 - RAP BO Operations → 

    RAP - Operations for Associations

    Syntax


    ... [internal] association _Assoc
                  [abbreviation newName] 
                  [without response] 
                   {[ 
                  [internal] create
                 [{(features:instance | features:global}] 
                  [,precheck] 
                  [,authorization:none] 
                  [,authorization:update];)
                  [{default function GetDefaultsFor_Assoc [external 'GetDefaultsForCBA'];}] 
                  [with draft];
                   ]}

    Description


    Enables read-by-association and create-by-association operations for associations:

    The following rules apply:

    • The read-by-association and create-by-association operations can be defined for intra BO associations and for cross-BO associations.
    • The association target entity must be behavior enabled, in other words, the association target entity must have its own behavior definition.
    • In the case of intra-BO associations, it is mandatory to define at least read access to the associations to RAP BO entities that are also behavior-enabled.

    The syntax for enabling read-access to an association target entity is as follows:

    association _Assoc { }

    Alternative spelling option: association _Assoc;

    • This is allowed in both directions, from parent to child and vice versa. As this syntax enables only read access to an association target, the create-by-association is explicitly not allowed.

    The syntax for enabling read access and create access to an association target entity is as follows:

    association _Assoc { create; }

    • Create-by-association is only available for to-child associations. It is not allowed for to-parent associations. In other words, child nodes can be created via their parent node, but parents cannot be created via their child nodes.

    RAP BDL Operation Additions

    The following RAP BDL operation additions are possible:

    • internal: Can be used in two places:
      • in front of the association:
      • in front of create within the curly brackets:

    The following additions are only possible in combination with { create; } and therefore, in case of a composition relationship, can only be declared for the parent entity.

    Example: association _Assoc { create(addition);}

    Restriction


    In a managed RAP BO, create-by-association works only on direct child entities. Entities that are part of the same composition tree, but more than one level below the RAP BO root entity, can be read enabled, but not create enabled. In an unmanaged RAP BO, this limitation does not apply.

    Availability


    Hints

    Further Information


    Development guide for the ABAP RESTful Application Programming Model, topic Create by Association Operation.

    Addition 1


    ... abbreviation newName

    Description


    Defines an alternative name for an association. The abbreviation newName can have a maximum of 16 characters. Associations are in the namespace of their root entity and can have up to 30 characters. This is under certain circumstances too long to be processed in ABAP RAP. Whenever a shorter name is required, you are prompted to assign an abbreviation to the association with no more that 16 characters. The abbreviation should start with a character, not with an underscore.

    Addition 2


    ... without response

    Description


    The optional addition without response is for cross-BO associations that have an association target from another BO. The association target entity of cross-BO associations is automatically included in the response types of the current RAP BO as foreign entity. In this way, issues with the target entity can become part of the response types during read-by-association or create-by-association operations. without response prevents the default behavior. It excludes the foreign entity from the response types.

    Notation: association _ext without response { create; }

    Addition


    ... with draft; ...

    Description


    Draft-enables an association. A draft-enabled association retrieves active data if it is followed from an active instance and draft data if it is followed from a draft instance (for details about RAP draft handling, see RAP BDL - managed, with draft).

    If a BO is draft-enabled, then all associations should be draft-enabled, so that the associations always lead to the target instance with the same state (draft or active).

    As soon as you draft-enable a BO by adding with draft, all BO-internal associations are automatically draft-enabled. To make this behavior explicit, the behavior prompts you to specify the to-child associations within a draft BO with with draft.