Ansicht
Dokumentation

ABENEML_RESPONSES_2_ABEXA - EML RESPONSES 2 ABEXA

ABENEML_RESPONSES_2_ABEXA - EML RESPONSES 2 ABEXA

PERFORM Short Reference   Vendor Master (General Section)  
This documentation is copyright by SAP AG.
SAP E-Book

- TYPE RESPONSE FOR

This example demonstrates the response parameters FAILED, MAPPED and REPORTED with a simple managed RAP BO. To show content for the responses, errors are intentionally produced in the context of a MODIFY statement trying to create new instances.

Data model

The CDS data model consists of the root entity DEMO_MANAGED_ROOT and its child entity DEMO_MANAGED_CHILD. Furthermore, it contains an association to an entity (DEMO_MANAGED_ASSOC) that is not part of the composition tree. Both associated entities are not used in the example.

Behavior definition

The CDS behavior definition DEMO_MANAGED_ROOT is defined in CDS BDL as follows:

Behavior implementation

For the above CDS behavior definition, there is no ABAP behavior pool (ABP) available.

Source Code

Execute

Description

The above source code uses EML to access the RAP business object from an ABAP program:

An modify operation is meant to trigger the creation of instances using the keyword CREATE. It includes the response structures ls_fail, ls_map and ls_report following the respective keywords FAILED, MAPPED and REPORTED for getting those responses. The structures are declared externally with TYPE RESPONSE FOR. The EML modify operation is preceded by an modify operation that creates some entries in the database table directly. In doing so, the subsequent EML operation runs into errors regarding those entries because the same keys are used. Therefore, the instances with those keys cannot be created and finally not being saved to the database. The saving is triggered by the COMMIT ENTITIES. statement.

The instances that cannot be created are reflected in the response structures ls_fail and ls_report. The mapping information for the successfully created instances is available in ls_map. To display all the responses in the output screen, the display_responses method comprises the construction and filling of internal tables to hold the returned information for the entity demo_managed_root. The information provided in those internal tables is intentionally kept simple and limited. The table for FAILED includes the fail cause, content ID and key of the affected instance as well as the affected operation or association (which is indicated by the entry 01). The table for REPORTED comprises information about the severity of the incident, content ID and key as well as a message. The table for MAPPED includes the content ID and the corresponding key of the instance.

After displaying the responses, the output screen shows an internal table that is filled with the current entries of the database (using a SELECT statement in the display_dbtabs method). It includes those entries whose creation has successfully been triggered by the EML modify operation as well as those entries having been created by the statement.






Vendor Master (General Section)   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 4068 Date: 20240426 Time: 220721     sap01-206 ( 85 ms )