Skip to end of metadata
Go to start of metadata

Author: Andrea Olivieri
Supported Releases: SAP ECC 6.0
Submitted: 20 September 2010


Processing

This simple ABAP report reads the job definitions of all jobs with the following states:

  • Scheduled
  • Released
  • Finished

After that, from the related steps, gets the following information:

  • Job name,
  • Program name,
  • Variant name
  • Package.

The output is a raw list.

Text Elements

070	Differentiation Specifications of Jobs
071	Statuses
072	Performance Optimization
073	Execution
121	Released
122	Scheduled
123	Finished
148	Test Run
152	Block Size

ABAP Source Code

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
*&---------------------------------------------------------------------*
*& Report  ZSDN_PROG_JOB_GET
*&---------------------------------------------------------------------*
*& Report Name: Get Report Name and Variant from periodic Scheduled Jobs
*& Created by: Andrea Olivieri                                         *
*& Company: Techedge SpA                                               *
*& Created on: 13.09.2010 at 13:10:12 CET                              *
*&---------------------------------------------------------------------*

report  zsdn_prog_job_get line-size 200 message-id bt.

type-pools: abap.

include lbtchdef.

tables: tbtcp, tbtco, btcoptions.
ranges: rstatus for tbtco-status.

constants:
  default_portion type int2 value '1000'.

data: begin of jobs occurs 100.
data: jobname    like tbtco-jobname,
      jobcount   like tbtco-jobcount,
end of jobs.
types: begin of report_ty,
         jobname  type tbtco-jobname,
         progname type tbtcp-progname,
         variant  type tbtcp-variant,
       end of report_ty.
data: report type sorted table of report_ty with unique key  jobname progname variant,
      wa_report like line of report.

data:
  count type i,
  tbtco_cursor type cursor.

*--------------------------------------------------------------------*
selection-screen begin of block bl3 with frame title text-070.
select-options jobname  for tbtco-jobname no intervals.
select-options jobcount for tbtco-jobcount no intervals no-display.
select-options username for tbtco-sdluname no intervals.
select-options event    for tbtco-eventid no intervals.
select-options eventpar for tbtco-eventparm no intervals.
select-options sdldt    for tbtco-sdlstrtdt.
selection-screen end of block bl3.

selection-screen begin of block bl2 with frame title text-071.
selection-screen begin of line.
selection-screen comment 2(15) text-121 for field  prelim.
parameter: prelim like btcselect-prelim as checkbox default 'X'.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 2(15) text-122 for field  sched.
parameter: sched  like btcselect-schedul as checkbox default ' '.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 2(15) text-123 for field  finish.
parameter: finish  like btcselect-finished as checkbox default ' '.
selection-screen end of line.
selection-screen end of block bl2.
selection-screen begin of block bl1 with frame title text-072.
selection-screen begin of line.
selection-screen comment 2(10) text-152 for field portion.
parameter:  portion type i default default_portion obligatory.
selection-screen end of line.
selection-screen end of block bl1.

at selection-screen on block bl2.
  if prelim is initial and finish is initial and sched is initial.
    set cursor field 'PRELIM'.
    message e333(s1) with 'Choose at least one status'(e01).
  endif.

initialization.

  data:    gjahr  like t009b-bdatj,
           fdate  type sy-datum,
           tdate  type sy-datum.

  gjahr = sy-datlo(4).

  call function 'G_POSTING_DATE_OF_YEAR_GET'
    exporting
      variant   = 'K1'
      year      = gjahr
    importing
      from_date = fdate
      to_date   = tdate.


  sdldt-sign = 'I'.
  sdldt-option = 'BT'.
  sdldt-low = fdate.
  sdldt-high = tdate.
  append sdldt.

start-of-selection.

  rstatus-sign = 'I'.
  rstatus-option = 'EQ'.
  if not sched is initial.     "Scheduled P
    rstatus-low = btc_scheduled.
    append rstatus.
  endif.
  if not prelim is initial.    "Released S
    rstatus-low = btc_released.
    append rstatus.
  endif.
  if not finish is initial.    "Finished
    rstatus-low = btc_finished.
    append rstatus.
  endif.

  open cursor with hold tbtco_cursor for select
    jobname jobcount from tbtco "INTO CORRESPONDING FIELDS OF TABLE jobs
    where jobname    in jobname    and
          jobcount   in jobcount   and
          sdluname   in username   and
          eventid    in event      and
          eventparm  in eventpar   and
          sdlstrtdt  in sdldt      and
          status in rstatus.

  do.
    fetch next cursor tbtco_cursor into table jobs
                      package size portion.
    if sy-subrc <> 0. exit. endif.

    perform append_jobs tables jobs
                        changing report.
  enddo.

  perform print_report using report.

*&---------------------------------------------------------------------*
*&      Form  print_report
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_REPORT  text
*----------------------------------------------------------------------*
form print_report
    using p_report like report.
  data: wa_tadir type tadir,
        wa_trdirt type trdirt.

  loop at report into wa_report.
    select single * from  tadir into wa_tadir
           where  pgmid     = 'R3TR'
           and    object    = 'PROG'
           and    obj_name  = wa_report-progname.
    check sy-subrc = 0.
    clear wa_trdirt.
    select single * from  trdirt into wa_trdirt
           where  name   =  wa_report-progname
           and    sprsl  = wa_tadir-masterlang.


    write:/ '|' no-gap,
            wa_report-jobname no-gap,
            '|' no-gap,
            wa_report-progname no-gap,
            '|' no-gap,
            wa_trdirt-text no-gap,
            '|' no-gap,
            wa_report-variant no-gap,
            '|' no-gap,
            wa_tadir-devclass no-gap,
            '|' no-gap.
  endloop.

endform.                    "print_report
*&--------------------------------------------------------------------*
*&      Form  append_jobs
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->P_JOBS     text
*      -->P_TESTRUN  text
*---------------------------------------------------------------------*
form append_jobs
    tables p_jobs structure jobs
           changing p_report like report.

  data:
      wa_tbtcp like tbtcp,
      lt_tbtcp type table of tbtcp,
      pred_jobname  like tbtco-jobname,
      pred_jobcount like tbtco-jobcount,
      rc type i.

  loop at p_jobs.
    select * from tbtcp into table lt_tbtcp
             where jobname  = p_jobs-jobname  and
                   jobcount = p_jobs-jobcount and
                   variant <> space           and
                   variant not like '&%'.

    if sy-subrc <> 0. continue. endif.
    loop at lt_tbtcp into wa_tbtcp.
      wa_report-jobname  = p_jobs-jobname.
      wa_report-progname = wa_tbtcp-progname.
      wa_report-variant  = wa_tbtcp-variant.
      insert wa_report into table p_report.
    endloop.
  endloop.

endform.                    " delete_selected_job

Back to Discover Report Variants with Parameters - Select Options of type BUKRS