Get Example source ABAP code based on a different SAP table
ABAP_EML - 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 >>. Behavior definition> The RAP behavior definition> DEMO_MANAGED_ROOT>> is defined in RAP BDL> as follows: BDEF DEMO_MANAGED_ROOT_CUSTOM Behavior implementation> For the above RAP behavior definition, there is no ABAP behavior pool (ABP)> available.
ABAP_SOURCE_CODE DEMO CL_DEMO_RAP_EML_RESPONSES_2
ABAP_DESCRIPTION The above source code uses EML> to access the RAP business object from an ABAP class: An ABAP_EML 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 AB_SQL 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 AB_SQL statement.