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

Show History of Job Execution Time



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Transport and Upgrade | Транспорт и Обновления
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Wed Aug 20, 2008 10:09 am    Post subject: Show History of Job Execution Time Reply with quote

Code:
* Source Name is  ZJOBHIST
REPORT ZJOBHIST   line-size 255
                  message-id zz
                  line-count 65
                  no standard page heading.
tables: indx, tbtco, tbtcp.
*
data: begin of export-id,
      srtfd like indx-srtfd value 'JOB_HISTORY',
      end of export-id.
data: begin of tab occurs 500,
      jobname like tbtco-jobname,
      progname like tbtcp-progname,
      variant  like tbtcp-variant,
      STRTDATE like tbtco-STRTDATE,
      STRTTIME like tbtco-STRTTIME,
      secs(10) type n,
      end of tab.
data: begin of jobtab occurs 500.
        include structure  tbtc5.
data: end of jobtab.
data: temp-stepcount like tbtcp-stepcount.
Data: temp-stepcount-lit(4) type c.
data: templit(40).
data: do_debug value 'X'.
parameters: jobsdat like sy-datum default sy-datum.
parameters: daysold(3) type p default 100.
data: purge-date like sy-datum.
data: startday like sy-datum.
data: starttim like sy-uzeit.
data: endday   like sy-datum.
data: endtime like sy-uzeit.
data: startsecs(10) type p.
data: endsecs like startsecs.
data: elapsedsec like startsecs.
data: tempdate like sy-datum.
data: tempsecs like startsecs.
clear do_debug.
purge-date = sy-datum - daysold.
import tab from database indx(AR) client sy-mandt
              id export-id.
if sy-subrc ne 0.
  refresh tab.
endif.
loop at tab where strtdate eq jobsdat.
  delete tab.
endloop.
loop at tab where strtdate lt purge-date.
  delete tab.
endloop.
move sy-datum to tempdate.
tempdate(4) = tempdate(4) - 1.
move '0101' to tempdate+4(4).
select * from tbtco where strtdate eq jobsdat
                      and authckman eq sy-mandt.
  refresh jobtab.
  call function 'BP_JOBLOG_READ'
       EXPORTING
            client    = tbtco-authckman
            jobcount  = tbtco-jobcount
            jobname   = tbtco-jobname
       TABLES
            joblogtbl = jobtab
       EXCEPTIONS
            others    = 1.
  if sy-subrc eq 0.
    if not do_debug is initial.
      loop at jobtab.
        write: / jobtab-entertime,
                 jobtab-entertime,
                 jobtab-msgno,
                 jobtab-text(80).
      endloop.
    endif.
  endif.
  select * from tbtcp where jobname eq tbtco-jobname
                        and jobcount eq tbtco-jobcount.
    move tbtco-enddate to endday.
    move tbtco-endtime to endtime.
    move tbtco-strtdate to startday.
    move tbtco-strttime to starttim.
    clear tab.
    clear startsecs.
    clear endsecs.
    move-corresponding tbtco to tab.
    temp-stepcount = tbtcp-stepcount + 1.
    move tbtcp-progname to tab-progname.
    move tbtcp-variant  to tab-variant.
    write: tbtcp-stepcount to temp-stepcount-lit.
    replace ' ' with '0' into temp-stepcount-lit(3).
    replace ' ' with '0' into temp-stepcount-lit(3).
    loop at jobtab where msgno eq '550'
                     and text cs 'Step'
                     and text cs 'started'
                     and text cs temp-stepcount-lit(3)
                     and text cs tbtcp-progname.
      move jobtab-enterdate to startday.
      move jobtab-entertime to starttim.
      exit.
    endloop.
    write: temp-stepcount to temp-stepcount-lit.
    replace ' ' with '0' into temp-stepcount-lit(3).
    replace ' ' with '0' into temp-stepcount-lit(3).
    loop at jobtab where msgno eq '550'
                     and text cs 'Step'
                     and text cs 'started'
                     and text cs temp-stepcount-lit
                     and text cs tbtcp-progname.
      move jobtab-enterdate to endday.
      move jobtab-entertime to endtime.
      exit.
    endloop.
    endsecs =  ( endday - tempdate ) * 24 * 60 * 60.
    tempsecs = ( endtime(2) * 60 * 60 )
                 + ( endtime+2(2) * 60 )
                 + ( endtime+4(2) ).
    endsecs = endsecs + tempsecs.
    startsecs =  ( startday - tempdate ) * 24 * 60 * 60.
    tempsecs = ( starttim(2) * 60 * 60 )
                 + ( starttim+2(2) * 60 )
                 + ( starttim+4(2) ).
    startsecs = startsecs + tempsecs.
    elapsedsec = endsecs - startsecs.
    move elapsedsec to tab-secs.
    if not tab-progname is initial.
      append tab.
    endif.
  endselect.
endselect.
export tab to database indx(AR) client sy-mandt
              id export-id.

sort tab by jobname progname variant strtdate strttime.
loop at tab.
  write: / tab-jobname,
         33  tab-progname,
         74  tab-variant,
        90   tab-strtdate,
        102   tab-strttime,
        115   tab-secs.
endloop.
include zconinc3.
format intensified off.
write: / 'Job Name',
        33   'Program Name',
        74   'Variant',
        90   'Strt Dat',
        102   'Time',
        115 'Processing Seconds'.
format intensified on.
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 -> Transport and Upgrade | Транспорт и Обновления 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.