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: 

Execution at the same time results in duplicate entries

former_member355261
Participant
0 Kudos
413

Hello gurus,

We have a program used to look for batches in MCH1 and if not found create them using FM BAPI_BATCH_CREATE.

Sometimes the program is executed many times at the exact same time and this results in new batch creation instead of just finding it as it was created by another process but not yet committed to the DB.

So we end up having two batches for the same input parameters.

Is there a way to handle this properly ? (GTT? / Shared memory ? / Lock objects ?)

3 REPLIES 3

former_member736527
Active Participant
313

One approach could be that you can lock the current program instance and let the other instances wait till the first one is released. Check below link:

https://answers.sap.com/questions/6914639/how-to-check-if-abap-program-is-running-in-another.html

This can impact the user experience if this is being run in foreground.

matt
Active Contributor
0 Kudos
313

You need to implement some kind of queue. I'm thinking qRFC is your friend in this instance.

raymond_giuseppi
Active Contributor
313

What did you already try, did you try to use some lock or queue concept?

  • You can lock at a global level (some dummy object) or at lower level (batch) - lock concept
  • You can insure the process can only be executed once and not in parallel - Queued RFC (qRFC)