SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Overview of planned Batch Jobs



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Mon Feb 25, 2008 1:08 pm    Post subject: Overview of planned Batch Jobs Reply with quote

Code:
report zexp_batch no standard page heading message-id bt.title
*************************************************************
* Overview of planned Batch Jobs
*
*   This is freeware. Please read the terms of use.
*   Written by Urs Rohner, Rohner IT Consulting & Engineering
*
*   Contact Author: Urs Rohner
*
*history
*    Vers  Date                Own   Remark
*    ----  ------------------  ---   ----------------------------------
*    1.00   5th July     2000  rnr   Initial version
*    1.10  25th June     2001  rnr   Add step user as selection criteria
*************************************************************


* Includes
  include:
     lbtchdef.

* Shared mem
  tables:
    usr02,
    varit.

* Type Declarations
  types:
    begin of t_stp_e,             " Batch Job Step properties
      i like tbtcstep,            " - Step
      t like textpool-entry,      " - Abap text
      v like varit-vtext,         " - Abap variant text
    end of t_stp_e,
    t_stp type t_stp_e occurs 1,
    begin of t_job_e,             " Batch Job properties
      h  like tbtcjob,             " - Head
      t1 like btch1140-stdttext1,  " - Start def
      t2 like btch1140-stdttext2,  " - Start def
      t3 like btch1140-stdttext3,  " - Start def
      b1 like btch1140-btcprd1,    " - Period def
      b2 like btch1140-btcprd2,    " - Period def
      b3 like btch1140-btcprd3,    " - Period def
      b4 like btch1140-btcprd4,    " - Period def
      b5 like btch1140-btcprd5,    " - Period def
      s  type t_stp,               " - [] Steps
    end of t_job_e,
    t_job type t_job_e occurs 1.

* Globals
  data:
    job type t_job.

* Selection Screen
  select-options:
     bname for usr02-bname.


*
* P A I ( )
*
  start-of-selection.

    " fetch planned background jobs
    perform m_get_jobs using job[].
    " output list
    perform m_list_jobs using job[].



* Method: send job list to list-processing
  form m_list_jobs using j type t_job.
    data:
      _u type c,
      _j type t_job_e,
      _s type t_stp_e.

    if not j[] is initial.
      sort j[] by h-authckman h-jobname h-status.
      loop at j[] into _j.
        clear _u.
        loop at _j-s[] into _s.
          if _s-i-authcknam in bname.
            _u = 'X'.
          endif.
        endloop.
        if _u is initial.
          continue.
        endif.
        write: /2 'Jobname  ', 20 _j-h-jobname.
        write: /2 'JobClass ', 20 _j-h-jobclass.
        if not _j-h-execserver is initial.
          write: /2 'Server   ', 20 _j-h-execserver.
        endif.
        write: /2 'Status   '.
        case _j-h-status. " constants may be found in LBTCHDEF
          when 'R'. write 20 'running'.
          when 'Y'. write 20 'ready'.
          when 'P'. write 20 'scheduled'.
          when 'S'. write 20 'released'.
          when 'A'. write 20 'aborted'.
          when 'F'. write 20 'finished'.
          when 'Z'. write 20 'put active'.
          when 'X'. write 20 'unknown state'.
        endcase.
        write: /2 'Client   ', 20 _j-h-authckman.
        if not _j-s[] is initial.
          write: /2 'Number of steps',
            20 _j-h-stepcount left-justified.
          loop at _j-s[] into _s.
            write: /4 'Step',    20 sy-tabix left-justified.
            write: /6 'Program', 20 _s-i-program(60).
            write: /6 'Type'.
            case _s-i-typ.
              when 'A'. write 20 'Abap'.
                write: /8 'Name     ', 20 _s-i-program(60).
                if not _s-t is initial.
                  write: /8 '         ', 20  _s-t.
                endif.
                if not _s-i-parameter is initial.
                  write: /8 'Variant  ', 20 _s-i-parameter(60).
                  write: /8 '         ', 20 _s-v.
                endif.
                write: /8 'Language ', 20 _s-i-language.
              when 'C'. write 20 'ext. command'.
                write: /8 'Name     ', 20 _s-i-xpgpid.
                write: /8 'Parameter', 20 _s-i-parameter(60).
                write: /8 'OSystem  ', 20 _s-i-opsystem.
                write: /8 'Server   ', 20 _s-i-xpgtgtsys.
              when 'E'. write 20 'ext. program'.
                write: /8 'Name     ', 20 _s-i-xpgpid.
                write: /8 'Parameter', 20 _s-i-parameter(60).
                write: /8 'Server   ', 20 _s-i-xpgtgtsys.
            endcase.
            write: /6 'User      ', 20 _s-i-authcknam.
          endloop.
        else.
          write: /4 'No steps defined'.
        endif.
        uline.
      endloop.
    else.
      write / 'No planned jobs'.
    endif.
  endform.


* Method: fetch planned background jobs
  form m_get_jobs using j type t_job.
    local:
      varit.
    data:
      _s   type t_stp_e,
      _j   type t_job_e,
      _sel like btcselect,
      _stp like tbtcstep occurs 1,
      _job like tbtcjob  occurs 1 with header line.

    " set selection criterias
    _sel-jobname   = '*'.    _sel-jobcount  = '*'.
    _sel-jobgroup  = '*'.    _sel-username  = '*'.
    _sel-no_date   = 'X'.    _sel-with_pred = 'X'.
    _sel-eventid   = '*'.    _sel-eventparm = '*'.
    _sel-prelim    = 'X'.    _sel-schedul   = 'X'.
    _sel-ready     = 'X'.    _sel-running   = 'X'.
    _sel-finished  = ' '.    _sel-aborted   = ' '.
    " get jobs
    refresh j[].
    call function 'BP_JOB_SELECT'
      exporting
        jobselect_dialog    = 'N'
        jobsel_param_in     = _sel
      tables
        jobselect_joblist   = _job[]
      exceptions
        invalid_dialog_type = 1
        jobname_missing     = 2
        no_jobs_found       = 3
        selection_canceled  = 4
        username_missing    = 5
        others              = 6.
    if sy-subrc is initial.
      loop at _job[] into _job.
        clear _j.
        _j-h = _job.
        perform m_fill_1140_stdt_data using _j.
        " get steps
        refresh _stp[].
        call function 'BP_JOB_READ'
          exporting
            job_read_jobcount     = _job-jobcount
            job_read_jobname      = _job-jobname
            job_read_opcode       = '20' " read all data: LBTCHDEF
          tables
            job_read_steplist     = _stp[]
          exceptions
            invalid_opcode        = 1
            job_doesnt_exist      = 2
            job_doesnt_have_steps = 3
            others                = 4.
        if sy-subrc is initial.
          loop at _stp[] into _s-i.
            perform m_get_abaptexts using _j _s.
            append _s to _j-s[].
          endloop.
          sort _j-s[].
        endif.
        append _j to j[].
      endloop.
      sort j[].
    endif.
  endform.


* Method: read report texts (client independant)
  form m_get_abaptexts using j type t_job_e s type t_stp_e.
    data:
      _t like textpool occurs 1 with header line.

    clear: s-t, s-v.
    if s-i-typ eq 'A'.
      read textpool s-i-program into _t[] language sy-langu.
      if sy-subrc is initial.
        read table _t with key id = 'R'.
        if sy-subrc is initial.
          s-t = _t-entry.
        endif.
      endif.
      select single vtext from varit client specified into s-v
        where mandt   eq j-h-authckman
        and   langu   eq sy-langu
        and   report  eq s-i-program
        and   variant eq s-i-parameter.
      if sy-dbcnt is initial.
        if s-i-parameter(4) = 'SAP&' or s-i-parameter(4) = 'CUS&'.
          select single vtext from varit client specified into s-v
            where mandt   eq '000'
            and   langu   eq sy-langu
            and   report  eq s-i-program
            and   variant eq s-i-parameter.
        endif.
      endif.
    endif.
  endform.


* Method: prepare planning texts
  form m_fill_1140_stdt_data using _j type t_job_e.


  endform.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.