How to Execute a Report Always in Background mode, even on Press of Function Key F8?


Always run the report in background mode even on the press of F8? You might feel, what’s the big deal?

Just schedule a background job and you are good. You do not need to handle it in your program. But sometimes clients have different plans. They know that scheduling the job in the background would be the smartest solution, but still, they would insist that they might run it in the foreground through the custom t-code but even then, the program should execute in background mode. Crazy clients sometimes. But, the Client is God, therefore we cannot argue much with God. 🙂

Our solution to this requirement is to create a custom report and all the option to run the program in foreground mode will be disabled. Even whenever the user would press the F8 function key or click on the execute button even then the program will show the option to run in background mode.

Layout design, Logic implemented and step by step process to produce the output

Create a report program using the Tcode SE38. Here the report created is ZR_BACKGROUNG_CHECK. To enable the execute button to work as background run, we have to write the code in the event AT SELECTION SCREEN.

We need to assign the value ‘SJOB’ which is the Function Code for the batch job to the SSCRFIELDS-UCOMM where the value is either ‘ONLI’ or ‘EXEC’.

System field SY-UCOMM will hold the value ‘ONLI’ when the user will either click on the execution button or press the function key F8.

Also Read: Write your first program in HANA ABAP.

The Function Code ‘EXEC’ is defined inside the custom PF-STATUS which is explained below.


In the INITIALIZATION event, we need to create a custom PF-STATUS. The idea behind creation of the PF-STATUS is to customize the PF-STATUS for Selection Screen.

Sample Code:

free sap training

Double click on the INITIALIZATION event and inside this create the custom PF-STATUS. Here the PF-STATUS created is ‘ZCUSTOM’.

Sample Code: PF Status

Double click on the PF-STATUS name and it will ask to create one like below screen, click on yes button.

abap program in background

Provide a short text and press enter.
GUI Status for Selection Screen

Then the below screen will appear, here we need to go to menu bar Extras->Adjust template.

Extras->Adjust template.

Choose the SelectionScreen radio button from the template list given below screen shot and then press enter.

Adjust Template Status

You can find to see the below screen shot where we need to keep only the required function codes and have to remove others.

sap application tool bar function codes

Keep only these Function Codes given in the below screen shot. Here we have changed the function code name ‘ONLI’ to ‘EXEC’ and have kept the function key same that is F8.

PF Status in SAP

Also Check: Problem faced by ABAPer while working on the first SAPUI5 Development.

Activate the PF-STATUS and the report, upon the execution of the report we can see the 3 buttons that we have given in PF-STATUS.

program in background mode

In the below screen shot you can see the from the program menu we have disabled the ‘Execute’ and ‘Execute and Print’ option.

program menu in sap

Sample code:

In the event AT SELECTION-SCREEN OUTPUT, we need to write the below logic to exclude these 2 function code from the program menu.

Activate the report, execute the report, and feed the selection criteria and then either press F8 or click on the execution button you can see the below screen that we get for background run.

Background mode in SAP

 Choose the schedule option from the below screen then press the save button.

 You can see the scheduled job and result using the Transaction code SM37.

 Point to remember: PF-STATUS must be activated before executing the report.

Also Read: Create your First OData Service in 5 minute.

You might be doing UI5 development or Fiori implementation or might be working in the in-memory database HANA. But, sometimes, the need of the customer only need plain vanilla ABAP. Those moments are special where you need to provide the innovative solution which is just right for the clients using the age old ABAP. And did anyone try to scare you, with all machine learnings(ML) and artificial intelligence(AI) and Automation, ABAPers would die?

But we at SAPYard feel, with all those automation, the need for ABAPers would grow more. Afterall, who is going to do those ML, AI and Automation programming. 🙂 . And who is going to support and sustain those crazy innovations? Long live the ABAPers. 😛

So…What Do You Think?

Now we want to hear from you.

What do you think? Are ABAPers going to be extinct in near future?

Whether you feel yes or no, in either case, please leave a quick comment below.


Leave a Reply to Steven Oldner Cancel reply

Please enter your comment!
Please enter your name here