SAP BDL NEW ELEM EXT



Get Example source ABAP code based on a different SAP table
  


• DETERMINATION ABAP_BDL_EXTENSION
• DETERMINATION ON SAVE ABAP_BDL_EXTENSION
• DETERMINATION ON MODIFY ABAP_BDL_EXTENSION
• VALIDATION ON SAVE ABAP_BDL_EXTENSION
• VALIDATION ABAP_BDL_EXTENSION
• READONLY ABAP_BDL_EXTENSION , FIELD
• FIELD FEATURES INSTANCE ABAP_BDL_EXTENSION , FIELD
• READONLY UPDATE ABAP_BDL_EXTENSION , FIELD
• MANDATORY ABAP_BDL_EXTENSION , FIELD
• FIELD ABAP_BDL_EXTENSION , CHARACTERISTICS
• SUPPRESS ABAP_BDL_EXTENSION , FIELD
• ACTION ABAP_BDL_EXTENSION
• STATIC ABAP_BDL_EXTENSION
• EXTERNAL ABAP_BDL_EXTENSION , action
• LOCK NONE ABAP_BDL_EXTENSION
• FACTORY ABAP_BDL_EXTENSION
• FUNCTION ABAP_BDL_EXTENSION
• EXTERNAL ABAP_BDL_EXTENSION , function
• DETERMINE ACTION ABAP_BDL_EXTENSION
• ALWAYS ABAP_BDL_EXTENSION , DETERMINE ACTION
• ASSOCIATION ABAP_BDL_EXTENSION
• ABBREVIATION ABAP_BDL_EXTENSION , ASSOCIATION
• CREATE ABAP_BDL_EXTENSION , ASSOCIATION
• WITHOUT RESPONSE ABAP_BDL_EXTENSION , ASSOCIATION
• WITH DRAFT ABAP_BDL_EXTENSION , ASSOCIATION
• MAPPING FOR ABAP_BDL_EXTENSION
• CORRESPONDING ABAP_BDL_EXTENSION
• CONTROL ABAP_BDL_EXTENSION
• EXCEPT ABAP_BDL_EXTENSION
• PARAMETER ABAP_BDL_EXTENSION , MAPPING FOR
• EVENT ABAP_BDL_EXTENSION
• DEEP PARAMETER ABAP_BDL_EXTENSION , EVENT
• PARAMETER ABAP_BDL_EXTENSION , EVENT

ABAP_RAP - Adding Elements

ABAP_SYNTAX
...
$[determination$]
$[validation$]
$[event$]
$[field characteristics$]
$[action$]
$[function$]
$[determine action$]
$[association$]
$[type mapping$]
...

ABAP_VARIANTS:
1 ... determination ...
2 ... validation ...
3 ... event ...
4 ... field characteristics ...
5 ... action ...
6 ... function ...
7 ... determine action ...
8 ... association ...
9 ... type mapping ...

What does it do?
The elements listed in this topic can be added to the body of an existing RAP BO entity. All of them are optional, and multiple elements or all elements can be specified together.
The elements can be added in a base BDEF extension with or without the addition using interface. In other words, these elements are possible in direct base extensions and also in extensions that make use of an interface layer.

ABAP_EXAMPLE_ABEXA
Executable examples:
Node extension:
A RAP BO with four nodes is extended via a RAP BO interface with one further node on the level of the great-grandchild.
Ancestor associations are defined, while lock master and authorization master entities are not explicitly defined.
An ABAP EML call creates instances of all five nodes.
Field extension
The original BO consists of one root node.
The root node is extended via a RAP BO interface with extension fields. These extension fields are created on database level and added to the CDS data model via a CDS data model extension.
Field attributes are added to the extension fields.
Dynamic feature control for the extension fields is implemented in the extension ABP.
Behavior extension:
The original BO consists of one root node.
One extension node is added to the original BO via a RAP BO interface.
The extended RAP BO implements authorization control, feature control, a validation, a determination and two actions. These implementations are distributed between original ABP and extension ABP.
An ABAP EML call performs multiple operations and logs the execution order of the handler methods.
ABAP_EXAMPLE_END

ABAP_VARIANT_1 ... determination ...

What does it do?
Adds a RAP determination to the entity behavior body of an existing RAP BO entity via a BDEF extension.
As a prerequisite, the extended BDEF must explicitly allow the particular kind of determination (see topic TITLE ).
Syntax: exactly the same as for RAP BOs, see topic TITLE .
All fields (extension fields and original fields) can be used as trigger.
Implementation in the extension ABAP behavior pool must obey the rules for extension ABPs.



Latest notes:

The execution order of determinations and validations is arbitrary, also between original and extension components.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The BDEF extension DEMO_RAP_EXT_DET_VAL extends the RAP behavior definition DEMO_RAP_BASE_DET_VAL. It adds a determination on save setStatus, which is triggered whenever a new entity instance is created.
Original BDEF: explicitly allows determinations on save in the BDEF extension header:
BDEF DEMO_RAP_BASE_DET_VAL
Extension BDEF: Defines a determination on save.
BDEF DEMO_RAP_EXT_DET_VAL
This determination is implemented in the extension ABP. It sets the field char_field automatically to status A whenever a new entity instance is created.
METH BP_DEMO_RAP_EXT_DET_VAL(CCIMP)=>SETSTATUS
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
An executable example for a BDEF extension adding a new determination is provided in topic RAP BDL - extend determine action.
ABAP_EXAMPLE_END

ABAP_VARIANT_2 ... validation ...

What does it do?
Adds a RAP validation to the entity behavior body of an existing RAP BO entity via a BDEF extension.
As a prerequisite, the extended BDEF must explicitly allow the particular kind of validation (see topic about extensibility enabling).
Syntax: exactly the same as for RAP BOs, see topic about validations.
All fields (extension fields and original fields) can be used as trigger.
Implementation in the extension ABAP behavior pool must obey the rules for extension ABPs.



Latest notes:

The execution order of determinations and validations is arbitrary, also between original and extension components.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The BDEF extension DEMO_RAP_EXT_VALIDATION extends the RAP behavior definition DEMO_RAP_BASE_DET_VAL. It adds a validation on save Limit , which is triggered when field dec_field is updated.
Original BDEF: explicitly allows validation on save in the BDEF extension header:
BDEF DEMO_RAP_BASE_DET_VAL
Extension BDEF: Defines a validation on save.
BDEF DEMO_RAP_EXT_VALIDATION
This validation is implemented in the extension ABP. It checks that the value inserted into field dec_field does not exceed 500. If it does, the validation fails and an error message is returned.
METH BP_DEMO_RAP_EXT_VALIDATION(CCIMP)=>LIMIT
ABAP_EXAMPLE_END

ABAP_VARIANT_3 ... event ...

What does it do?
Adds a RAP business event to the entity behavior body of an existing RAP BO entity via a BDEF extension.
RAP business events can only be defined in the root node of a RAP business object. As a consequence, they can only be defined in a BDEF extension to the root node.
Syntax: exactly the same as for RAP BOs, see topic about events.
An extension RAP business event must be raised in the extension ABAP behavior pool of the RAP BO in question with the ABAP EML statement RAISE ENTITY EVENT. The rules for extension ABPs must be obeyed.

ABAP_FURTHER_INFO
The development guide for the ABAP RESTful Application Programming Model provides an example for a RAP business event that is added by means of a BDEF extension. See Creating RAP Business Events.

ABAP_EXAMPLE_VX5
The BDEF extension DEMO_RAP_EVENT_EXT extends the RAP behavior definition DEMO_RAP_EXTENSIBLE. It adds the RAP business event MyEvent to the RAP BO root entity. It adds a RAP additional save , so the event can be raised in the extension ABP in the RAP handler method save_modified.
BDEF DEMO_RAP_EVENT_EXT
ABAP_EXAMPLE_END

ABAP_VARIANT_4 ... field characteristics ...

What does it do?
Adds field attributes to extension fields.
Field attributes can be added only for extension fields. Extension fields are fields which are not part of the original BO, but are added via RAP data model extension.
The following field attributes are available in BDEF extensions for extension fields:
readonly
mandatory
suppress
readonly:update
features:instance
ABAP_NOTE When implementing instance feature control for fields, the rules for extension ABPs apply.
These field attributes work as described in topic RAP BDL - field characteristics. ABAP_NOTE Internal field numbering is not available in BDEF extensions. ABAP_NOTE The field characteristic mandatory:create is not available in BDEF extensions.

ABAP_EXAMPLE_VX5
The BDEF extension DEMO_EXTENSION_RAP_BO extends the RAP behavior definition DEMO_RAP_FIELD_EXT. It behavior-enables multiple extension fields.
BDEF DEMO_EXTENSION_RAP_BO
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
The example above is described in detail in topic RAP BDL - Field Extension.
ABAP_EXAMPLE_END

ABAP_VARIANT_5 ... action ...

What does it do?
Adds a RAP action to the entity behavior body of an existing RAP BO entity.
Syntax: exactly the same as for RAP BOs, see topic RAP BDL - action. ABAP_NOTE The optional addition default to define a factory action as default factory action is not available in BDEF extensions.
Implementation in the extension ABAP behavior pool must obey the rules for extension ABPs.

ABAP_EXAMPLE_VX5
The BDEF extension DEMO_RAP_BEH_EXT_CH extends the RAP behavior definition DEMO_RAP_BEH_EXT. It adds action setValue to the behavior definition body.
BDEF DEMO_RAP_BEH_EXT_CH
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
The example above is described in detail in topic RAP BDL - Behavior Extension.
ABAP_EXAMPLE_END

ABAP_VARIANT_6 ... function ...

What does it do?
Adds a RAP function to the entity behavior body of an existing RAP BO entity.
Syntax: exactly the same as for RAP BOs, see topic RAP BDL - function.
Implementation in the extension ABAP behavior pool must obey the rules for extension ABPs.

ABAP_VARIANT_7 ... determine action ...

What does it do?
Adds a RAP BO determine action to the entity behavior body of an existing RAP BO entity.
Syntax exactly the same as for RAP BOs, see topic RAP BDL - determine actions.
Only determinations and validations from the same BDEF extension can be assigned. Determinations and validations from the original BDEF must not be assigned.

ABAP_VARIANT_8 ... association ...

What does it do?
Behavior-enables an association. The association target must be an extension node.
Syntax exactly the same as for RAP BOs, see topic Operations for Associations.

ABAP_EXAMPLE_VX5
The BDEF extension DEMO_RAP_EXTENSION_1 extends the RAP behavior definition DEMO_RAP_EXTENSIBLE_ROOT. The first section of this extension extends an existing node by behavior-enabling the association _Children4Ext. The association target is an extension node.
BDEF DEMO_RAP_EXTENSION_1
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
The example above is described in detail in topic RAP BDL - Node Extension.
ABAP_EXAMPLE_END

ABAP_VARIANT_9 ... type mapping ...

What does it do?
Adds a RAP type mapping to the entity behavior body of an existing RAP BO entity. This type mapping can only contain extension fields. It must not contain any fields from the extended BDEF.
Syntax exactly the same as for RAP BOs, see topic RAP BDL - Type Mapping.

ABAP_EXAMPLE_VX5
The BDEF extension DEMO_RAP_EXT_MAPPING extends the RAP behavior definition DEMO_RAP_BASE_MAPPING. It adds a type mapping to structure DEMO_RAP_STRUC. The fields used in this type mapping are extension fields that are added to the data model via a CDS view entity extension.
BDEF DEMO_RAP_EXT_MAPPING
ABAP_EXAMPLE_END