Enterprise Resource Planning Portal ERPGenie.COM Enterprise Resource Planning Portal

   Advertise | BLOG

Web ERPGenie.COM

Home | Vote for us |

ERPGenie.COM -> SAP Technical -> ABAP -> Example code -> Prevent a background job from being submitted more than once

* Written by :
* SAP Hints and Tips on Configuration and ABAP/4 Programming
* http://sapr3.tripod.com 
*
* For some background update jobs, you might want to stop the
* user from submitting the jobs twice.
*
* Do this checks to prevent the users from submitting the
* same background job twice.
*
* Perform the checks before starting your programs.
*
* Create a MESSAGE-ID, the program will issue an error message
* in the Job logs.

tables: tbtco. "Job status overview table

data: t_jobcnt(1) type n,
t_sdluname like tbtco-sdluname,
t_strtdate like tbtco-strtdate,
t_strttime like tbtco-strttime.

select * from tbtco where jobname = 'ZXXX'
  and strtdate = sy-datum
  and status = 'R'.

  t_jobcnt = t_jobcnt + 1.
  if t_jobcnt = 1.
    t_sdluname = tbtco-sdluname.
    t_strtdate = tbtco-strtdate.
    t_strttime = tbtco-strttime.
  endif.
endselect.

if sy-subrc = 0.
  if t_jobcnt < 1.
    message e899 with t_sdluname 'have execute the program on'
   t_strtdate t_strttime.
  endif.
endif.

Contact Us | Polls | Add URL | Contribute | About | Privacy | Terms | Feedback | Help!

Message Board | Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job