Force your ABAP Report to Run in Background
Despite of any performance tuning you made, some reports may still take forever to execute. One of my last report did, and when i tried to execute it in foreground it gets a TIME_OUT runtime error, apparently the report hits the maximum run time parameter defined in the system.
One solution to this is by running your report in background, since there are no run time limitations of background jobs you can execute any report in any amount of time needed.
The easiest way to do this is by forcing your user to use Execute in Background (F9) menu than the usual Excecute (F8) button they usually use.

Then add these following lines to make sure they choose the right one.
IF SY-batch NE 'X'.
MESSAGE e001 WITH 'This report could only be executed in background'.
ENDIF.
Though it’s easy too implement it may took some times for users to get used to it and may cause an inconvenience.
Another option is to make your report automatically processed in background when it is being executed using JOB_OPEN, SUBMIT and JOB_CLOSE like following
DATA: d_jobcount LIKE TBTCJOB-JOBCOUNT,
d_jobname LIKE TBTCJOB-JOBNAME.
d_jobname = 'JOB1'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = d_jobname
IMPORTING
jobcount = d_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE s368(00) WITH 'Error Creating Job'
sy-subrc.
EXIT.
ENDIF.
SUBMIT <REPORT_NAME>
VIA JOB d_jobname
NUMBER d_jobcount
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = d_jobcount
jobname = d_jobname
strtimmed = 'X' " Immediate
EXCEPTIONS
invalid_startdate = 1
jobname_missing = 2
job_close_failed = 3
job_nosteps = 4
job_notex = 5
lock_failed = 6
OTHERS = 7.
IF sy-subrc > 0.
MESSAGE s368(00) WITH 'Closing Job Failed'
sy-subrc.
EXIT.
ENDIF.
Hi,
What If I need to run three variants of a report(one after the other) in the background?
Like, Z_REPORT needs to be run with 3 variants.
Use WITH addition in SUBMIT form, for example if you want to use two parameters
SUBMIT Z_REPORT WITH PAR1 = <val1> WITH PAR2 = <val2> VIA JOB d_jobname NUMBER d_jobcount AND RETURN.Very useful article..thanks
hi,
i make program for posting data and have it run on background when user execute it.the problem is sometimes the background job get “cancelled” by it self. some said that it’s because someone had put a lock on table that i was trying to access.but i’m also curious if there is some ‘limitation’ regarding the use of background job that i didn’t know of.
hatur nuhun.