Monday, February 15, 2010

Last Used Log

My company has been on SAP for 2 years now and some of the programs we wrote two years ago are no longer being used. But because of one reason or another we do not have a good list of what programs are no longer being used. So I asked the basis guy if he could tell me what programs have not been used in the last year. He kindly did a Google search and came back with this link http://www.sapfans.com/forums/viewtopic.php?p=262634. So after reading this forum I deceided to create a log file with a function module that I will inject into the programs that I think are no longer being used and wait for a couple of months then get rid of them. So I decided since I have not posted anything for awhile I would post my function module.
First the Table.

Function Module.
ZPROGRAM_START
Importing Program_Name
Exporting TimeStamp
data: local_time_stamp type timestamp.
  tables zlast_run.
  zlast_run-ran_by = sy-uname.
  zlast_run-program_name = program_name.
  get time stamp field local_time_stamp.
  zlast_run-start_date = local_time_stamp.
  insert zlast_run.
  time_stamp = local_time_stamp.
endfunction.
The function module returns the time so that you can update with the closeing time.
ZPROGRAM_END
Importing Program_Name
Start_Date
data: local_time_stamp       type timestamp.
  get time stamp field local_time_stamp.
  update zlast_run set complete_date = local_time_stamp
        where program_name = program_name
          and start_date   = start_date
          and ran_by       = sy-uname.
endfunction.
At the start of your program insert the call for ZPROGRAM_START make sure you place it after your selection screen section.
Last thing in your code should be the call to ZPROGRAM_END.

If you have any questions or comments drop me a line thanks.