Application Development and Automation 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: 
Read only

Background run

Former Member
0 Likes
505

Hi experts,

I am working on an interface and I have developed my object completely and now I have been asked by my team lead to make sure that this program runs in background, so can you please guide me through how can I take care of this.

Thanks

Rajeev

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
477

You can make a small program which can submit this program via jobname and jobcount to run it in background...

You have use like:

FM JOB_OPEN

SUBMIT Z_REP

FM JOB_CLOSE.

This code can help you:

  DATA: w_job_name       TYPE btcjob,
        w_job_nr         TYPE btcjobcnt.

start-of-selection.

w_job_name = 'ZTEST_NP'.

CALL FUNCTION 'JOB_OPEN'
  EXPORTING
*   DELANFREP              = ' '
*   JOBGROUP               = ' '
    JOBNAME                = w_job_name
*   SDLSTRTDT              = NO_DATE
*   SDLSTRTTM              = NO_TIME
*   JOBCLASS               =
 IMPORTING
   JOBCOUNT               = w_job_nr
* CHANGING
*   RET                    =
* EXCEPTIONS
*   CANT_CREATE_JOB        = 1
*   INVALID_JOB_DATA       = 2
*   JOBNAME_MISSING        = 3
*   OTHERS                 = 4
          .
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 ztest_np1 and return
     USER sy-uname
     VIA JOB w_job_name NUMBER w_job_nr.

  CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
      jobcount             = w_job_nr
      jobname              = w_job_name
*      strtimmed            = co_marked
    EXCEPTIONS
      cant_start_immediate = 1
      invalid_startdate    = 2
      jobname_missing      = 3
      job_close_failed     = 4
      job_nosteps          = 5
      job_notex            = 6
      lock_failed          = 7
      invalid_target       = 8
      OTHERS               = 9.
  IF sy-subrc <> 0.
*   Internal error
  write: 'error'.
  ENDIF.
*

Regards,

Naimesh Patel

Read only

0 Likes
477

To Schedule a background job:

Run SM36

Enter a background job name and job class

Click on the step button

Click on ABAP Program

Enter the program name and variant.

Click Start Condition and enter the time and date you would like the program to run

Alternatively to run immediately in the background:

Run SE38

Enter the interface program name and execute

Enter any selection criteria

Press F9 or select Program-> Execute in Background

Read only

Former Member
0 Likes
477

Do you mean the progam or the batch input session that it creates?

Rob