Requirement: An application built using BAS on BTP for an RAP business object has a requirement of triggering an asynchronous task in the background when a button is clicked. Example: ( this example will be used to explain the implementation ) when the button is clicked, the user uploads an excel file with data and on click of OK, the data needs to be saved but as it is a large amount of data it will take some time, so the UI shouldn’t be waiting for a response from the backend.
Challenge: background processing framework has been introduced by SAP from Cloud 2311 version. Without this framework, it is not possible to trigger an asynchronous task from a stateless UI.
Solution: To simulate similar functionality we can use existing ABAP artifacts like RFC and submitting program in background job.
Overview: In this example, I have implemented the following:
- a new action with parameters is defined in the behavior definition. The key of the RAP object will hold the keys of the table that need to be changed. The new values to be updated are passed by the UI as parameters to the action
action (features : instance) upload_file parameter ZSD_ABS_CONTRACTUAL_INDATA;
- an RFC function module is created that accepts the data from the file in the form of an internal table
- Above RFC function module is called from the RAP action implementation ( with the addition destination ‘NONE’ as otherwise commit cannot be done from the FM to schedule the job ).
METHOD upload_file.
DATA: gt_return TYPE STANDARD TABLE OF zsds_soitem_message,
lt_sch_data TYPE zsdt_soschdata.
IF NOT keys[] IS INITIAL.
LOOP AT keys INTO DATA(ls_keys).
APPEND INITIAL LINE TO lt_sch_data ASSIGNING FIELD-SYMBOL(<ls_sch_data>).
<ls_sch_data>-vbeln = ls_keys-salesdocument.
<ls_sch_data>-posnr = ls_keys-salesdocumentitem.
<ls_sch_data>-del_dt = COND #( WHEN ls_keys-%param-newcontractualdt IS NOT INITIAL
THEN ls_keys-%param-newcontractualdt ).
<ls_sch_data>-email = cond #( WHEN ls_keys-%param-email IS NOT INITIAL
THEN ls_keys-%param-email ).
ENDLOOP.
CALL FUNCTION 'ZSD_DEL_DATE_UPD_FILE' DESTINATION 'NONE'
EXPORTING
it_sch_data = lt_sch_data
EXCEPTIONS
error_message = 99.
ENDIF.
ENDMETHOD.
- The function module calls the ‘JOB_OPEN’ and ‘JOB_CLOSE’ function modules to submit another program via a background job.
- The program runs asynchronously as a job and updates the data and also sends an email with the results to the email-id ( the parameter email in the previous screenshot )
- Email functionality has been implemented so the user is informed of the success or failure of the task as the UI doesn’t wait for a response and simply displays a message that the data will be updated in background.
- The button and the popup that allows the user to upload an excel file:


Conclusion: The above approach can be used to call an asynchronous task from an RAP object for OP SAP versions. With SAP Cloud 2311, it will also be possible to update the UI once the asynchronous task is completed using event driven actions.