Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Check The Job Status

Hi SAPsimhas,

My requirement is as below.

I will loop through an internal table and create some files with background processing method.(JOB_OPEN,SUBMIT & JOB_CLOSE)

Now once this job is triggered I need to check the status for that job after maximum 10 mins. Its not neccessary that each job will take 10 mins. only,It can be finished in 2 mins also.

Once the job is finished then I will XCOM that file.

So my question is how to code such timer which will check the job status for that job? I have a FM BP_JOB_READ which returns the job status.

Reply is highly appriciated.

Tags:
replied

Try this way

  do.
    call function 'SHOW_JOBSTATE'
      exporting
        jobcount         = p_jobc
        jobname          = p_jobn
      importing
        aborted          = v_aborted
        finished         = v_finished
        ready            = v_ready
        running          = v_running
        scheduled        = v_scheduled
      exceptions
        jobcount_missing = 1
        jobname_missing  = 2
        job_notex        = 3
        others           = 4.
    if v_aborted eq 'X'.
      exit.
    endif.
    if v_finished eq 'X'.
      select single * from tbtcp into wa_tbtcp1
                 where jobname eq p_jobn
                   and jobcount eq p_jobc.

      if sy-subrc eq 0.
        move wa_tbtcp1-listident to p_spono.
      endif.
      exit.
    endif.
    if v_count le 10.
      call function 'ENQUE_SLEEP'
        exporting
          seconds = 60.
      v_count = v_count + 1.
    endif.
  enddo.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question