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: 

Determine last program execution

Former Member
0 Kudos

Hi,

I am looking for a method to investigate when a program last have been executed in the SAP system.

I have not found a good solution for that yet.

Is the solution to use <b>TC</b>: <b>STAD</b> with some program logging switch on? (How do I switch on program execution log?)

I need this to investigate if a program still is in use or not.

And I thought that the way is to do this, is using the date for that last time the program had been executed.

Thanks in advance

Leif

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos

Hi Leif,

You can use transaction code <b>STAT</b>.

For writer/painter reports you can view stats via SE16 in table T803J. For all reports and transactions execution info is stored in table MONI. This is the same info available via ST03 and to some extent STAT. Info for MONI is collected from the UNIX servers and totalled on MONI by day, week, month, year. Retention periods are set by the Basis group. We have a custom table where this information is stored by period for historical and licensing purposes. Be sure to use the SAP function modules to retrieve data from MONI.

Also check this sample code from other thread.

* internal tables for use counterdata: 
begin of list occurs 5.        
include structure sapwlserv.
data: end of list.

data: begin of applicat occurs 0.        
include structure sapwlustcx.
data: end of applicat.

data: begin of applica_ occurs 0.        
include structure sapwlustcx.
data: end of applica_.

data: begin of applicau occurs 0,        
entry_id like sapwlustcx-entry_id,        
account  like sapwlustcx-account,        
count    like sapwlustcx-count,    
: end of applicau.
data: wa_applicau like applicau.

*&---------------------------------------------------------------------*
*&      Form  MONI
*&---------------------------------------------------------------------*
form moni.  
data: l_host like  sapwlserv-hostshort.  
m_start = p_usedt.
*** get server  
call function 'SAPWL_SERVLIST_GET_LIST'       
  tables            
    list = list.  

do.    
  loop at list.
*** loop on server      
   check not list-instshort is initial.         
   l_host = list-instshort.
*** get statistics per month and server      
   perform workload using m_start l_host.    
  endloop.    

  add 31 to m_start.    

  if m_start > sy-datum.      
    exit.    
  endif.  

enddo.  

sort applica_ by entry_id.  
sort applicau by entry_id count descending.
endform.                               " MONI

*&---------------------------------------------------------------------*
*&      Form  WORKLOAD
*&---------------------------------------------------------------------*
form workload using    p_start like sy-datum                         

p_host  like  sapwlserv-hostshort.  
refresh: applica_.

*** read application statistic from MONI  
call function 'SAPWL_WORKLOAD_GET_STATISTIC'       
  exporting            
    periodtype                 = 'M'            
    hostid                     = p_host            
    startdate                  = p_start            
    only_application_statistic = 'X'       
  tables            
    application_statistic      = applica_       
  exceptions            
    unknown_periodtype         = 1            
    no_data_found              = 2            
    others                     = 3.  

sort applica_ by entry_id account.  

loop at applica_  where entry_id(1) ge 'Y'.             "#EC PORTABLE    
  clear wa_applicau-entry_id.    
  wa_applicau-entry_id(25) = applica_-entry_id.    
  wa_applicau-account      = applica_-account.    
  wa_applicau-count        = applica_-count.    
  collect wa_applicau into applicau.  
endloop.  

sort applicau by entry_id count descending.  
applica_-ttype    = space.  
applica_-account  = space.  
modify applica_ transporting ttype account where ttype ne space.

*** collect only enhancements statistic  
if p_temp = 'X'.    
 loop at applica_.      
   applica_-entry_id+25(48) = space.      
   collect applica_ into applicat.    
  endloop.  

else.    
  loop at applica_ where entry_id(1) ge 'Y'.            "#EC PORTABLE      
    applica_-entry_id+25(48) = space.      
    collect applica_ into applicat.    
  endloop.  
endif.
endform.                               " WORKLOAD

Hope this will help.

Regards,

Ferry Lianto

2 REPLIES 2

ferry_lianto
Active Contributor
0 Kudos

Hi Leif,

You can use transaction code <b>STAT</b>.

For writer/painter reports you can view stats via SE16 in table T803J. For all reports and transactions execution info is stored in table MONI. This is the same info available via ST03 and to some extent STAT. Info for MONI is collected from the UNIX servers and totalled on MONI by day, week, month, year. Retention periods are set by the Basis group. We have a custom table where this information is stored by period for historical and licensing purposes. Be sure to use the SAP function modules to retrieve data from MONI.

Also check this sample code from other thread.

* internal tables for use counterdata: 
begin of list occurs 5.        
include structure sapwlserv.
data: end of list.

data: begin of applicat occurs 0.        
include structure sapwlustcx.
data: end of applicat.

data: begin of applica_ occurs 0.        
include structure sapwlustcx.
data: end of applica_.

data: begin of applicau occurs 0,        
entry_id like sapwlustcx-entry_id,        
account  like sapwlustcx-account,        
count    like sapwlustcx-count,    
: end of applicau.
data: wa_applicau like applicau.

*&---------------------------------------------------------------------*
*&      Form  MONI
*&---------------------------------------------------------------------*
form moni.  
data: l_host like  sapwlserv-hostshort.  
m_start = p_usedt.
*** get server  
call function 'SAPWL_SERVLIST_GET_LIST'       
  tables            
    list = list.  

do.    
  loop at list.
*** loop on server      
   check not list-instshort is initial.         
   l_host = list-instshort.
*** get statistics per month and server      
   perform workload using m_start l_host.    
  endloop.    

  add 31 to m_start.    

  if m_start > sy-datum.      
    exit.    
  endif.  

enddo.  

sort applica_ by entry_id.  
sort applicau by entry_id count descending.
endform.                               " MONI

*&---------------------------------------------------------------------*
*&      Form  WORKLOAD
*&---------------------------------------------------------------------*
form workload using    p_start like sy-datum                         

p_host  like  sapwlserv-hostshort.  
refresh: applica_.

*** read application statistic from MONI  
call function 'SAPWL_WORKLOAD_GET_STATISTIC'       
  exporting            
    periodtype                 = 'M'            
    hostid                     = p_host            
    startdate                  = p_start            
    only_application_statistic = 'X'       
  tables            
    application_statistic      = applica_       
  exceptions            
    unknown_periodtype         = 1            
    no_data_found              = 2            
    others                     = 3.  

sort applica_ by entry_id account.  

loop at applica_  where entry_id(1) ge 'Y'.             "#EC PORTABLE    
  clear wa_applicau-entry_id.    
  wa_applicau-entry_id(25) = applica_-entry_id.    
  wa_applicau-account      = applica_-account.    
  wa_applicau-count        = applica_-count.    
  collect wa_applicau into applicau.  
endloop.  

sort applicau by entry_id count descending.  
applica_-ttype    = space.  
applica_-account  = space.  
modify applica_ transporting ttype account where ttype ne space.

*** collect only enhancements statistic  
if p_temp = 'X'.    
 loop at applica_.      
   applica_-entry_id+25(48) = space.      
   collect applica_ into applicat.    
  endloop.  

else.    
  loop at applica_ where entry_id(1) ge 'Y'.            "#EC PORTABLE      
    applica_-entry_id+25(48) = space.      
    collect applica_ into applicat.    
  endloop.  
endif.
endform.                               " WORKLOAD

Hope this will help.

Regards,

Ferry Lianto

hymavathi_oruganti
Active Contributor
0 Kudos

i think SPAU /SPAD may help u