Get Example source ABAP code based on a different SAP table
• PERSISTENT TABLE ABAP_BDL_PROP
ABAP_RAP - persistent table>
ABAP_SYNTAX ... persistent table TableName ...>
What does it do? DDIC database table> a RAP BO> is based on. The data> on the persistent table> is processed by RAP BO operations >. Available only in managed RAP BOs> and in these, it is mandatory to specify a persistent table>. An exception is raised when the option unmanaged save >> is chosen. In case of an unmanaged save>, a persistent table must not be defined. In a projection business object>, the persistent table is automatically inherited. Requirements:
If the BDEF> specifies an ETag field>, the persistent table requires a field that is used to describe the state of the database table. This can be, for example, a time stamp field. If this field is annotated in CDS with the relevant annotation, such as @Semantics.systemDateTime.localInstanceLastChangedAt: true>, then it is automatically updated by the RAP framework>.
If the RAP BO is draft-enabled> and has a total ETag field>, the persistent table requires a field that is updated whenever the BO instance is changed. This must be a separate field from the ETag master field. The total ETag field is necessary on the lock master entity>. If the total ETag field is a time stamp field and if it is annotated in the CDS data model with the annotation @Semantics.systemDateTime.lastChangedAt>, then this field is updated automatically by the RAP framework.
If the primary key field is of type raw(16)>> (UUID)>, then it can be filled by the RAP framework using (numbering:managed)> (early internal numbering)>.
If you decide to use UUIDs as primary keys, the following rules apply:
Every entity needs a field for the UUID key.
Child entities must have a field for their parent's UUID. This is required to define associations for the composition relationship.
Any child entity that has no parent-child relationship with the lock master entity must have a field with the lock master's UUID. This is important to define associations to the lock master entity, which is required for ETag handling.
Latest notes:
If the field names of the persistent database table differ from the field names of the CDS views, then a type mapping> is required in the entity behavior body. This can be the case for example, if the fields of the CDS data model have alias names>.
The RAP framework manages writing changes to the persistent database table, including database LUWs>, COMMIT ENTITIES>>, and AB_SQL >. 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_MANAGED_ASSOC_ROOT>>. It specifies persistent database tables for the parent and the child entity. Since the field names of the database tables have alias names in the CDS views, a type mapping> is specified that maps the fields of the persistent database table to the field names of the CDS views. ABAP_NOTE This example does not fully meet the requirements of the RAP BO contract>. It is intentionally kept short and simple and serves demonstration purposes only. See more information on the RAP BO contract in the Development guide for the ABAP RESTful Application Programming Model>. BDEF DEMO_RAP_MANAGED_ASSOC_ROOT ABAP_EXAMPLE_END