SAP BDL USING INTERFACE



Get Example source ABAP code based on a different SAP table
  


• USING INTERFACE ABAP_BDL_EXTENSION
• USING ABAP_BDL_EXTENSION

ABAP_RAP - using interface, Extension

ABAP_SYNTAX_FORMS

General Specification on Header Level
... using interface InterfaceBdef;

Specification for Extension Nodes on Entity Level
... using CDSInterface;

ABAP_VARIANTS:
1 ... using interface InterfaceBdef;
2 ... using CDSInterface;

What does it do?
RAP business objects can be extended via RAP BO interfaces using the optional addition using $[interface$]. A RAP BO interface is a layer on top of the base BO that is an interface for stable consumption and is usually released as API . In a BDEF extension with the addition using interface , only entities that are part of the RAP BO interface can be extended .
In general, the RAP BO interface is specified in the BDEF extension header, directly after the keyword extension, using the syntax addition using interface. All entities that are part of the RAP BO interface can be extended then. Further details are provided under Variant 1.
In a node extensibility scenario, the extension node is not part of the RAP BO interface. An interface for the extension node can be specified using the keyword using in the RAP extension entity behavior on entity level. Further details are provided under Variant 2.
Extensions can be created directly for managed or unmanaged RAP BOs. However, SAP recommends that you always extend a RAP BO via an interface and to always use the addition using interface. In case of C0 developer extensibility, an interface is mandatory. In some other scenarios, using interface is mandatory and this is enforced by a syntax check error.

ABAP_FURTHER_INFO
Topic TITLE .
Development guide for the ABAP RESTful Application Programming Model, topic Business Object Interface.
Topic TITLE

ABAP_EXAMPLE_VX5
The following example shows two BDEF extensions:
The first one directly extends the base BDEF, without interface.
The second one extends the base BDEF via a BDEF interface.
The base BDEF is the managed BDEF DEMO_RAP_EXTENSIBLE_ROOT.
BDEF extension DEMO_RAP_EXT_WO_INT without an interface:
BDEF DEMO_RAP_EXT_WO_INT
BDEF extension DEMO_RAP_EXT_USING_INTERF using an interface.
BDEF DEMO_RAP_EXT_USING_INTERF
ABAP_EXAMPLE_END

ABAP_VARIANT_1 ... using interface InterfaceBdef

ABAP_PREREQUISITE
As a prerequisite for using interface, the RAP interface behavior definition InterfaceBdef must explicitly allow extensions. It must be declared as extensible in the behavior definition header as described in topic TITLE .
ABAP_PREREQ_END

What does it do?
Using the optional addition using interface, a RAP business object is extended via a RAP BO interface. A RAP BO interface is a layer on top of the base BO that is an interface for stable consumption and is usually released as API . In a BDEF extension with the addition using interface , only entities that are part of the RAP BO interface can be extended .
An extension using interface produces simultaneous extensions of the base RAP BO and of the interface. For example, an extension action is part of the BDEF derived types of the base RAP BO and of the interface RAP BO.
The extension BDEF must reference RAP BO entities, RAP BO fields, and other elements by their interface names, not by their base names (which may be different). The only exceptions are elements which are not reflected in the interface, such as determinations and validations.
In its implementation in the ABAP behavior pool, the extension may use any released interface existing for the base RAP BO to perform ABAP EML operations. It is an EML consumer like any other and there might be multiple released interfaces for a RAP BO. But it is most common that it uses the very same interface which it extends.



Latest notes:

An extension using interface is created for a BDEF of type managed or unmanaged. It is not created directly for the interface. In ABAP Development Tools, you select the base BDEF as basis for an extension.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Base BDEF: RAP BO with four nodes.
BDEF DEMO_RAP_EXTENSIBLE_ROOT
Interface BDEF: renames the RAP BO entities.
BDEF DEMO_RAP_EXT_USING_INTERFACE
Extension using interface: Extends the root node, which it refers to by its interface name.
BDEF DEMO_RAP_EXT_USING_INTERF
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
The executable example RAP BO Extension Using Interface explains the example above in detail.
ABAP_EXAMPLE_END

ABAP_VARIANT_2 ... using CDSInterface

What does it do?
In a node extensibility scenario, an interface for the extension node can be specified using the keyword using in the RAP extension entity behavior on entity level. CDSInterface is the name of a CDS transactional interface that projects the extension node.

ABAP_EXAMPLE_VX5
The following BDEF extension DEMO_RAP_EXTENSION_1 adds an extension node to an existing RAP business object. It uses the RAP BO interface DEMO_RAP_EXT_USING_INTERFACE and the CDS transactional interface DEMO_RAP_EXT_USING_INT_EXT.
BDEF DEMO_RAP_EXTENSION_1
ABAP_EXAMPLE_END