2021 Mar 22 4:04 PM
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 ?)
2021 Mar 22 5:00 PM
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.
2021 Mar 22 5:44 PM
You need to implement some kind of queue. I'm thinking qRFC is your friend in this instance.
2021 Mar 23 12:46 PM
What did you already try, did you try to use some lock or queue concept?