Ansicht
Dokumentation

ABENDERIVED_TYPES_PRE_TMP_ABEXA - DERIVED TYPES PRE TMP ABEXA

ABENDERIVED_TYPES_PRE_TMP_ABEXA - DERIVED TYPES PRE TMP ABEXA

CPI1466 during Backup   ABAP Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

Using %pre / %tmp

This example demonstrates the use of %pre and %tmp with an unmanaged RAP BO in a late numbering scenario.

Note that this example does not cover a production business scenario for late numbering. Instead it is intended to give an idea about the use of %pre and %tmp during the RAP save sequence and also about the options of using %pid and %key when referring to RAP BO instances during the RAP interaction phase.

Data model

The CDS data model consists of the root entity DEMO_UMANAGED_ROOT_LATE_NUM3.

Root entity:

Behavior definition

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

Behavior implementation

For the above CDS behavior definition, one ABP is created. The global class of the behavior pool is BP_DEMO_UMANAGED_ROOT_LATE_NU3. The actual behavior implementation takes place in local classes that are defined and implemented in the BP_DEMO_UMANAGED_ROOT_LATE_NU3CCIMP of the behavior pool.

The following class is relevant for the example:

  • lcl_buffer: Constitutes the transactional buffer which is an internal table in this example. It contains all fields of the database table and further fields that are used in the example, for example, the internal table also contains the components %pid and %cid. Furthermore, there are components representing flags like changed and final_key_assigned. The first one is used to flag whether an instance has been created or changed and thus should be saved. The second specifies whether final keys have been assigned to the instance.

The following methods are relevant for the example:

  • create: Creates the instances and writes them to the transactional buffer. In this case, a %pid as well as a preliminary value for %key is created for the instances.
  • update: Updates instances. Although not relevant for the example, the method covers different cases for which the transactional buffer is checked against the incoming entities, i. e. whether %cid_ref is provided or not and whether the update happens on an already persisted instance or not.
  • prep_root_buffer: Prepares the transactional buffer. In case of an update request on persisted instances, these instances are read from the database table into the transactional buffer.
  • adjust_numbers: Assigns the final keys. In this simple example, the final keys are assigned integers starting with 1. Furthermore, the MAPPED LATE, which shows %pre and %tmp, and REPORTED LATE response structures are filled. For demonstration purposes, the entries for both structures are stored in two internal tables that are displayed in the output.
  • The save, cleanup and cleanup_finalize methods save the entries in the transactional buffer to the database table or clearing the entries respectively.

Source Code

Execute

Description

Access with ABAP using EML

There are two modify requests. The first creates multiple RAP BO instances and the second updates the new instances.

In the create request, %key is not specified. The create method creates %pid and %key for the instances.

The update request is implemented to show various options to refer to the instances that have not yet been persisted to the database. The reference is made using %tky, %pid and %key, which has a preliminary key value.

The save sequence is triggered using a COMMIT ENTITIES statement. The adjust_numbers method assigns the final keys to the instances. In this example, the method simply adds an integer to the key. Furthermore, the internal tables in the global class mentioned above are filled demonstrating how %pre and %tmp might be addressed. Finally, the save method saves the instances to the database table.

The output shows three tables:

  1. A table that displays the outcome of the RAP operations, i. e. the successfully saved entries in the database table.
  2. A table showing the MAPPED LATE information. Apart from the automatically generated %pid values in the pid field and the final keys %key in the key_field field, the first three instances show an initial value for the field tmp_key that represents the value for %tmp-key_field. For the final three instances, tmp_key includes the value that has been specified within the RAP create operation.
  3. A table showing the REPORTED LATE information. Both mapped and reported information were filled in the course of the adjust_numbers method.





CL_GUI_FRONTEND_SERVICES - Frontend Services   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.

Length: 7581 Date: 20240512 Time: 134951     sap01-206 ( 106 ms )