Get Example source ABAP code based on a different SAP table
ID COMMIT-ENTITIES • COMMIT ENTITIES ABAP_STATEMENT_EML • RESPONSES OF COMMIT ENTITIES • RESPONSE OF COMMIT ENTITIES • BEGIN COMMIT ENTITIES • END COMMIT ENTITIES
COMMIT ENTITIES BEGIN, END>> 4 COMMIT ENTITIES BEGIN $[IN SIMULATION MODE$] $[${RESPONSE OF ... $| RESPONSES OF ... $} $[response_param >>$]$]. $[CONVERT KEY OF bdef FROM $[TEMPORARY$] pre_key TO final_key.$]
COMMIT ENTITIES END.>
What does it do? Triggers the RAP save sequence>. Within a RAP transaction> , RAP BO instances> are created or changed using ABAP_EML MODIFY> > statements. These transactional changes are stored within the transactional buffer> of a RAP BO. At the end of an ABAP session, the saving of changed or created data to the database must be triggered, which is done by COMMIT ENTITIES> statements. Otherwise, the changes are lost. COMMIT ENTITIES> terminates RAP transactions. If the RAP transactions include RAP modify operations>, i. e. there were ABAP_EML MODIFY> statements before a COMMIT ENTITIES> statement, an implicit COMMIT WORK>> is triggered after processing the save sequence. Therefore, all RAP BO instances that are present in the transactional buffer are persisted to the database. However, COMMIT ENTITIES> follows an all or nothing approach, i. e. either all instances are valid and correct and all can be saved or none can be saved if at least one instance is invalid. COMMIT ENTITIES> statements can be used for RAP modify operations> by RAP BO consumers> to trigger the data persistency but they cannot be used in ABAP behavior pools> in ABAP . In case of a natively supported RAP scenario (for example, an SAP Fiori app using OData>), the COMMIT ENTITIES> call is not to be used since it is performed implicitly and automatically by the RAP transactional engine>. System Fields> COMMIT ENTITIES> statements set the system field sy-subrc>. Note that using COMMIT ENTITIES> statements, it is not guaranteed that the implicit COMMIT WORK> is carried out successfully. In case of failures during the RAP save sequence> , the RAP saver method cleanup_finalize >> is called for all involved RAP business objects> to ensure that the transactional buffer is cleared for the current RAP transaction. The RAP save sequence is then terminated without persisting the instances to the database. This is indicated by the value that is set for the system field sy-subrc > when executing COMMIT ENTITIES > statements. ABAP_NOTE The following statements are only valid for COMMIT ENTITIES> statements terminating RAP transactions that include RAP modify operations>. sy-subrc>>Meaning> 0The implicit COMMIT WORK> has been carried out successfully if a RAP transaction that is terminated by a COMMIT ENTITIES> statement includes RAP modify operations>. 4The implicit COMMIT WORK> has not been carried out successfully. An issue occurred in the early phase of the RAP save sequence (involved RAP saver methods: finalize>, check_before_save>). The value 4 for sy-subrc > means that there are responses returned by the failed>> parameter because of failures in the RAP save sequence. Transactional changes successfully executed in the RAP interaction phase> remain in the transactional buffer. 8The implicit COMMIT WORK> has not been carried out successfully. An issue occurred in the late phase of the RAP save sequence (involved RAP saver methods: save> or save_modified >). lbr lbr Such an issue can produce inconsistencies which triggers the clearing of the transactional buffer and a ROLLBACK WORK> internally. A subsequent RAP modify operation can then lead to a runtime error. If the RAP BO consumer is to proceed after an issue in the late phase of the RAP save sequence, an explicit ROLLBACK ENTITIES> is required. The following variants of the COMMIT ENTITIES> statement are available:
COMMIT ENTITIES>, Short Form> The short form of the COMMIT ENTITIES> statement saves all instances of RAP BOs that are changed within the RAP transaction.
COMMIT ENTITIES>, Long Form> The long form of the COMMIT ENTITIES> statement saves all RAP BO instances that are changed within the RAP transaction and provides responses for individual RAP BO entities >.
COMMIT ENTITIES OPERATIONS >, Dynamic Form> The dynamic form of the COMMIT ENTITIES> statement allows the root entities for which the commit should be executed to be specified dynamically.
COMMIT ENTITIES BEGIN, END >> This form of the COMMIT ENTITIES> statement is relevant for late numbering>> scenarios.
Latest notes:
Using a COMMIT WORK> statement also triggers the save sequence and saves RAP BO instances from the transactional buffer to the database. However, the use of COMMIT ENTITIES> statements is preferable in the context of RAP because they offer more features like the retrieval of responses information> or key conversion>.