How to schedule application jobs from a RAP-based business object
Beside the option to start and schedule application jobs from within the Application Job App there might be the need to start an application job from within an application based on a RAP business object.
Scheduling an application job using the API’s provided by the underlying ABAP platform framework can be tricky when doing so from within a RAP business object. This is because during it can happen that during the interaction phase implict commits are performed by the underlying frameworks. As a result the application job should only be scheduled within the save sequence to avoid that a job is scheduled unintentionally.
Therefore I have built working sample code that allows you to start an application job via an action of the RAP business object. The sample code shows in addition what needs to be implemented to display the job status in nice way in the Fiori UI using virtual fields. This way it is possible to always reflect the current status highlighting the criticality (aborted, running, finished and others statuses) and the job status text in the Fioir list report using different colours.
The technical information and the source code can be downloaded from GitHub.