SAP BDL SAVING



Get Example source ABAP code based on a different SAP table
  


• WITH ADDITIONAL SAVE ABAP_BDL_PROP
• WITH UNMANAGED SAVE ABAP_BDL_PROP
• AND CLEANUP ABAP_BDL_PROP
• WITH FULL DATA ABAP_BDL_PROP

ABAP_RAP - Saving Options

ABAP_SYNTAX
... ${with additional save $[and cleanup$]$[with full data$]$}
$| ${with unmanaged save $[and cleanup$]$[with full data$]$} ...

ABAP_VARIANTS:
1 ... with additional save $[and cleanup$]$[with full data$]
2 ... with unmanaged save $[and cleanup$]$[with full data$]

ABAP Addition
1 ... and cleanup
2 ... with full data

What does it do?
The syntax additions described in this topic are available only in a managed RAP BO.
The additions with additional save and with unmanaged save can be used to enhance or to replace the default save sequence in a managed RAP BO. Per default, the RAP framework performs a managed save. With an additional save, steps can be added to the managed save. An unmanaged save prevents the default and allows the implementation of a dedicated saving strategy. Both additions require a reimplementation of the save_modified method of the RAP saver class in the ABAP behavior pool .
When one of the additions with additional save or with unmanaged save is specified, per default, only the values of key fields and changed fields are handed over to the save_modified method of the RAP saver class. The addition with full data can be used to hand over the full instance data - that means, the values of all fields that are part of the component group %data - to the save_modified method. Further details are described below.
There are two options for notation:
In the BDEF header, directly after the keyword managed. In this case, the additional save or unmanaged save is enabled for all entities of the business object. Example: managed with additional save implementation in class ...;
As an entity behavior property. In this case, it can be specified for each entity individually.

ABAP_EXAMPLE_VX5
The following example shows a managed BDEF that defines an additional save in the BDEF header.
BDEF DEMO_MANAGED_ADDITIONAL_SAVE
In the ABAP behavior pool, the method save_modified tracks data changes in a log table. The complete implementation can be seen in the BP_DEMO_MANAGED_ADDITIONAL_SAVCCIMP.
The ABAP class CL_DEMO_RAP_MANAGED_ADD_SAVE uses EML to access the RAP business object. It performs a create, update, and delete operations. The changes are saved and tracked in internal log tables.
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
The example shown above is displayed and explained in detail in topic ABAP EML - TYPE REQUEST FOR in a Managed RAP BO with Additional Save.
ABAP_EXAMPLE_END

ABAP_VARIANT_1 ... with additional save

What does it do?
Allows additional functionality to be called during the standard save sequence, for example, change documents and an application log.
An implementation in the local saver class is required.

ABAP_FURTHER_INFO
Development guide for the ABAP RESTful Application Programming Model, section about Additional Save.

ABAP_VARIANT_2 ... with unmanaged save

What does it do?
Prevents the BO's managed runtime from saving changes and allows the implementation of a dedicated saving strategy instead. In case of an unmanaged save, a persistent table cannot be specified.
An implementation in the local saver class is required.

ABAP_EXAMPLE_ABEXA
An example for a managed RAP BO with unmanaged save is shown in topic ABAP EML - TYPE REQUEST FOR in a managed RAP BO with unmanaged save.
ABAP_EXAMPLE_END

ABAP_FURTHER_INFO
Development guide for the ABAP RESTful Application Programming Model, section about Unmanaged Save.

ABAP Addition

What does it do?
If specified, the RAP saver method cleanup must be redefined.

ABAP Addition

What does it do?
If specified, then the full instance data is handed over to the save_modified method of the RAP saver class in the ABAP behavior pool. In other words, all fields that are part of the component group %data are filled with values when the save_modified method is called.



Latest notes:

The fields of the component group %control are not affected by this. Still, only the changed fields of %control are flagged.
In scenarios where all fields, not only changed fields, are required for further processing, the addition with full data can be used. This spares the RAP BO consumer an additional READ operation.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following example shows a managed BDEF that defines an additional save with full data in the BDEF header.
BDEF DEMO_MANAGED_ADDITIONAL_SAVE
In the ABAP behavior pool, the method save_modified tracks data changes in a log table. The complete implementation can be seen in the BP_DEMO_MANAGED_ADDITIONAL_SAVCCIMP.
The ABAP class CL_DEMO_RAP_MANAGED_FULL_DATA uses EML to access the RAP business object. First, it creates two entity instances, filling values into all entity fields. Then, it updates both entity instances, changing the values of two fields, namely field1 and field2. Without the addition with full data, only the values of the changed fields are respected in the save_modified method. The fields that are not changed have their initial value. But since this example uses with full data, even the values of fields field3 and field4 are respected.
Code Snippet: Note that field3 and field4 are not updated.
ABEXA 01655
Variable lt_update in the ABAP behavior pool when the addition with full data is specified: all fields are listed with their values, even the fields which are not included in the update operation.
IMAGE with_full_data.png 567 64
Variable lt_update in the ABAP behavior pool when the addition with full data is not specified: fields that are not updated are filled with initial values.
IMAGE without_full_data.png 520 66
ABAP_NOTE In this example, fields that are not updated are filled with initial values. Note that this is not always the case. Fields which are not updated do not contain consistent values and the values must therefore not be evaluated.
ABAP_EXAMPLE_END