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: 

Check The Job Status

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

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.

3 REPLIES 3

Former Member
0 Kudos

Hi

You can create another job to XCOM the file. To schedule the second job, goto TCode SM36, enter relevent parameters. Under the button " Start Condition" you will find a tab after job.

There you can define the first job.

Hope this helps.

Regards,

Rajat

former_member194669
Active Contributor
0 Kudos

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.

rainer_hbenthal
Active Contributor
0 Kudos

IF the only problem is the troggering i guess you have to loop and do a polling. you can use wait 10 seconds to keep mips small during polling