SAP BDL FOREIGN



Get Example source ABAP code based on a different SAP table
  


• FOREIGN ENTITY ABAP_BDL_HEADER

ABAP_RAP - foreign entity

ABAP_SYNTAX
...
foreign entity ForeignEntityName $[alias AliasName$];
...

What does it do?
Defines a RAP BO entity which is not part of the CDS composition tree of the current RAP BO as part of the response structures, thus enabling message mapping for other BOs. An alias name AliasName can be specified. The length of this alias name can be a maximum of 30 characters.
A foreign entity is defined in the RAP behavior definition header and is therefore included in the response structures of all BO nodes of the current RAP BO. A foreign entity includes the specified entity in the response structures, not a complete foreign BO. It is possible to specify multiple foreign entities, if required.
A business object determination may trigger an operation of another business object that then returns messages. To receive and adapt the messages from a foreign business object, the foreign business object can be registered in the current BO. The messages are mapped during the save sequence.
A reimplementation of the method map_messages in the ABAP behavior pool is optional.
Available for business objects of type managed, unmanaged, projection, and interface.

ABAP_FURTHER_INFO
Development guide for the ABAP RESTful Application Programming Model, section Mapping Messages Between Business Objects.



Latest notes:

The association target of a cross-BO association in a BDEF is automatically included in the response types as a foreign entity. This default behavior can be disabled using the syntax addition without response.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following example shows a managed BDEF based on the CDS root view entity DEMO_RAP_FOREIGN_ENTITY. It establishes a connection to the foreign entity DEMO_SALES_CDS_SO_1 .
ABAP_NOTE This example is intentionally kept short and simple and serves demonstration purposes only. The RAP handler methods in the ABAP behavior pool are not implemented here.
BDEF DEMO_RAP_FOREIGN_ENTITY
The class CL_DEMO_RAP_FOREIGN_ENTITY accesses the BDEF and creates three new entity instances.
Code snippet:
ABEXA 01538
Result: The entities of the referenced foreign business object are added to the reported structure.
IMAGE ABDOC_FOREIGN_ENTITY.png 456 528
ABAP_EXAMPLE_END