Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to transfer our execution from online to background processing

Former Member
0 Kudos

HI

I have a report in which i have to call the same report using SUBMIT statement as a background process. can anyone help me?

Regards

Aditya

4 REPLIES 4

Jelena
Active Contributor
0 Kudos

Here is a code fragment that I used for a report to force the execution in background (even when users don't select background process). It has a selection screen and stuff but when the users attemt to run it in the foreground, it just schedules itself in a background job. When it runs in the background job (sy-batch = 'X'), then the main code is executed.

START-OF-SELECTION.

  IF sy-batch IS INITIAL.

* Open a job
    jobname = sy-repid.
    CLEAR jobcount.

    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
        jobname  = jobname
      IMPORTING
        jobcount = jobcount.

    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

    SUBMIT <your program name here>
           WITH ...
           VIA JOB jobname
           NUMBER jobcount
           AND RETURN.

* Close the job and run immediately
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount  = jobcount
        jobname   = jobname
        strtimmed = 'X'.            " Start immediately

    IF sy-subrc = 0.
      MESSAGE 'Job started' type 'I'.
    ELSE.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

  ELSE.

    " do all stuff here

  ENDIF.

Former Member
0 Kudos

I'm afraid, it might lead to a dead lock!!!?

Former Member
0 Kudos

I solved the issue but the above answer is not working

0 Kudos

What exactly did not work and how did you solve the problem then?

Thank you.