Skip to Content
avatar image
Former Member

Creating a background job that runs once per execution and cancel previous ones if needed

Hi everyone:

I have a performance issue with SAP ECC in my company. My leader states that there's a way to enforce that a background job can run once and, if there's any running instances running at the time the new program starts, they'll cancelled.

I talked with my BASIS guy and told me that there's no such option in SAP ECC. Also investigated inside the application

Can you help me giving some light regarding this feature? I read several documentation regarding the background jobs creation and didn't found something helpful.

My current version is SAP ECC 6.0 SP 29. If you need more information please let me know.

I appreciate you help in advance. Warm regards

Lorenzo Martín Olmos

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Dec 07, 2016 at 06:17 AM

    Your Basis guy is right. There is no built in way of doing this, you have to do it programmatically. If your leader says there's a way, to why not asking him what the way is?

    This is, in fact, a FAQ. You should search on how to ensure only one instance of a program runs at a time. The usual way is to check if another instance is running, and then abort - rather than start a new instance. You seem to want to do it the other way - at the start of the program, cancel any other running instances. That can also be done using similar techniques, but is a bit more unusual. It depends what the program actually does.

    The clue in reaching an answer is to think about how you would like, logically, such a program to work. The figure out mechanisms that will allow this. Hint: in SM37, you can cancel jobs, so it must be possible programmatically...

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 07, 2016 at 04:34 PM


    More than looking at the "SM37 mechanism", check out the function modules that create, launch and delete jobs.

    ...And how do you make sure that only one user is modifying a record? A lock. Put a lock when the job (or program) is running. Test it everytime. If there is already a lock, don't run. I think there is even a lock object for this. Else just create one...

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 07, 2016 at 03:27 PM

    Hi Matthew and thanks for you comments

    I asked my leader about this before, but didn't know how to accomplish that. The functionality was made by another programmer, but he doesn't work here anymore.

    You're right, my approach is to ensure one instance of a program before the start of the program.

    Let me dive a little about the SM37 mechanism to cancel jobs. I'll update as soon as I have any updates.

    Thanks again for your comments.

    Lorenzo Martin Olmos

    Add comment
    10|10000 characters needed characters exceeded