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

ABAP Background Job Status Report Code.

Former Member
0 Likes
4,200

Hi Experts,

My requirement is to Genarate a report that will display the background job Status.

I.e. job cancelled or job abended or job still running like that.

My selection screen will be :

Job Name.

Run Date .

Run time .

Status of Job .

Can any one please send me the report code , i searched in google in many ways but i didnt get suitable report for my above requirement.

Its very urgent ...Help me.

Thank you & Regards,

Vanky.

Hi Experts,

My requirement is to Genarate a report that will display the background job Status.

I.e. job cancelled or job abended or job still running like that.

My selection screen will be :

Job Name.

Run Date .

Run time .

Status of Job .

Can any one please send me the report code , i searched in google in many ways but i didnt get suitable report for my above requirement.

Its very urgent ...Help me.

Thank you & Regards,

Vanky.

5 REPLIES 5
Read only

former_member188827
Active Contributor
0 Likes
1,478

check tcode sm37..it has almost same functionality as required by u.

copy its program name from sytem...> status.

its SAPLBTCH.

in se38, open it and check the dictionary tables used by it..den u can create ur own from dem.

Read only

Former Member
0 Likes
1,478

data: begin of wa,

job_name type tbtco-jobname,

run_date type tbtco-strtdate,

run_time type tbtco-strttime,

job_stat type tbtco-status,

end of wa.

data: itab like table of wa.

select jobname strtdate strttime status from tbtco into table itab where

status not in ('F', 'P', 'A', 'S').

loop at itab into wa.

write:/ wa-job_name, wa-run_date, wa-run_time, wa-job_stat.

endloop.

Read only

Former Member
0 Likes
1,478

Hi,

check BDL_READ_JOB_STATUS func module

Read only

arpit_shah
Contributor
0 Likes
1,478

hi..

check SE37 it is same as per your requirement.

regards,

Arpit

Read only

Former Member
0 Likes
1,478

Hi Venkat,

here is the code that you can make use of to create a report that list the status of jobs. Here, it is assumed that you have filled the table gt_jobs with the jobs whoes status you need to check:


types: begin of gty_jobs,
           JOBCOUNT     type         TBTCO-JOBCOUNT,
           JOBNAME      type	TBTCO-JOBNAME,
           ABORTED	type	TBTCV-ABORT,
           FINISHED	type	TBTCV-FIN,
           PRELIMINARY	type	TBTCV-PRELIM,
           READY	type	TBTCV-READY,
           RUNNING	type	TBTCV-RUN,
           SCHEDULED	type	TBTCV-SCHED,
       end of gty_jobs.

types: gty_t_jobs type table of gty_jobs,

  data: gt_jobs type gty_t_jobs,
        gv_subrc type sysubrc,
        gv_aborted type i,
        gv_finished type i,
        gv_total type i.

  field-symbols: <lfs_jobs> type gty_jobs.

* Get the job status
  loop at gt_jobs assigning <lfs_jobs>.
    CALL FUNCTION 'SHOW_JOBSTATE'
      EXPORTING
        jobcount               = <lfs_jobs>-jobcount
        jobname                = <lfs_jobs>-jobname
       IMPORTING
         ABORTED                = <lfs_jobs>-ABORTED
         FINISHED               = <lfs_jobs>-FINISHED
         PRELIMINARY            = <lfs_jobs>-PRELIMINARY
         READY                  = <lfs_jobs>-READY
         RUNNING                = <lfs_jobs>-RUNNING
         SCHEDULED              = <lfs_jobs>-SCHEDULED
       EXCEPTIONS
         JOBCOUNT_MISSING       = 1
         JOBNAME_MISSING        = 2
         JOB_NOTEX              = 3
         OTHERS                 = 4
              .
  endloop.

* keep on checking the job status until it is finished or cancelled
  while gv_subrc eq 0.

    loop at gt_jobs assigning <lfs_jobs>.
      if <lfs_jobs>-finished ne 'X' and
         <lfs_jobs>-aborted ne 'X'.

**      reduce the frequency of checking the job status to *reduce the network traffic
        wait up to 60 seconds.       

        CALL FUNCTION 'SHOW_JOBSTATE'
          EXPORTING
            jobcount               = <lfs_jobs>-jobcount
            jobname                = <lfs_jobs>-jobname
           IMPORTING
             ABORTED                = <lfs_jobs>-ABORTED
             FINISHED               = <lfs_jobs>-FINISHED
             PRELIMINARY            = <lfs_jobs>-PRELIMINARY
             READY                  = <lfs_jobs>-READY
             RUNNING                = <lfs_jobs>-RUNNING
             SCHEDULED              = <lfs_jobs>-SCHEDULED
           EXCEPTIONS
             JOBCOUNT_MISSING       = 1
             JOBNAME_MISSING        = 2
             JOB_NOTEX              = 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.

        gv_subrc = 0.
        exit.

      else.
        gv_subrc = 4.
      endif.
    endloop.
  endwhile.

* Output job summary
  write: /55  'J O B   S U M M A R Y' color 4.
  write: / sy-uline(150).
  skip 2.
  describe table gt_jobs lines gv_total.


*  loop at gt_jobs assigning <lfs_jobs> where finished ne 'X'.
  loop at gt_jobs assigning <lfs_jobs>.

    if <lfs_jobs>-aborted eq 'X'.
      add 1 to gv_aborted.
      write: / 'Jobname :', <lfs_jobs>-jobname,
            50 'Job ID :', <lfs_jobs>-jobcount color 6.
      write: / sy-uline(150).

    elseif <lfs_jobs>-finished eq 'X'.
      add 1 to gv_finished.
      write: / 'Jobname :', <lfs_jobs>-jobname,
            50 'Job ID :', <lfs_jobs>-jobcount.
      write: / sy-uline(150).
    endif.
  endloop.
      write: / 'Jobs Cancelled :', 15 gv_aborted color 6.
      write: / 'Jobs Finished :', 15 gv_finished.
      write: / 'Total Jobs :', 15 gv_total.


*  clear: gv_aborted, gv_finished, gv_total, gt_jobs.
  clear: gv_aborted, gv_finished, gv_total.

Hope this helps.

Thanks

Sanjeev