Skip to Content

Try run an abap in background fail

I have a program which has a checkbox and if the user enable it runs the program in background with the below code:

 data: jobname1 type tbtcjob-jobname,
 jobcount1 type tbtcjob-jobcount.

 jobname1 = 'ZFOR_GET_BKRF_BSEG'.

 call function 'JOB_OPEN'
 exporting
 jobname = jobname1
 importing
 jobcount = jobcount1
 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 zfor_get_bkrf_bseg
 with so_bukrs = so_bukrs
 with so_budat = so_budat
 with p_bckgr = space
 with p_path = p_path
 via job jobname1
 number jobcount1
 and return.

 call function 'JOB_CLOSE'
 exporting
 jobcount = jobcount1
 jobname = jobname1
 strtimmed = 'X' " Start immediately
 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.

Unfortunately the background job always canceling with the following error:

Enter date in the format __.__.____ This is the default setup for the user.

Can anyone know what cause the problem and how to fix it?

Thanks in advance Elias

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 06, 2017 at 12:48 PM

    The problem is with so_budat. If your so_budat is a select option try using "in" instead of "=". See below.

    so_budat in so_budat
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 06, 2017 at 12:25 PM

    Hi,

    Try to fill the sdlstrtdt and sdlstrttm parameters.

    call function 'JOB_OPEN'
        exporting
          delanfrep        = ' '
          jobgroup         = ' '
          jobname          = jobname1
          sdlstrtdt        = sy-datum
          sdlstrttm        = sy-uzeit
        importing
          jobcount         = jobcount1
        exceptions
          cant_create_job  = 01
          invalid_job_data = 02
          jobname_missing  = 03.
      if sy-subrc ne 0.
        "error processing
      endif.
    
    Add comment
    10|10000 characters needed characters exceeded