Comments on the article
@wridgeu:
Still one of the hardest tasks to face. It is important to create one point of access to your data object that takes care of all the interaction. Everyone then has to use this layer if they want to interact with your data. You can't really intercept the rest. Even in the standard version, I can change the data using Modify, bypassing the BAPI, without anyone noticing or me having to worry about locks. In the end, it all comes down to clean integration by the developer.
Locks - Data Model
When it comes to locks (especially SAP locks) I have always wondered what the "best" approach would be when you have a simple Header/Item relationship scenario (non RAP, non Cloud, pure on-prem ABAP). What do you think, or what'd be your approach, especially in regards to locking?
Context:
Sure you can implement a DAO and do all the handling in there and of course you can create a lock object for the Header Table and make use of this but still, without also creating one for the Item Table or explicitly implementing checks on the header lock (within the DAO) or maybe using actual DB locks you'd never be able to properly restrict access to the Item Table and thus ensure consistency yourself without implementing it yourself, right? In classic ABAP (i.e. also no BOPF etc.) there is just nothing SAP does for you out of the box when you have a more complex data model or simple relations. You'd always have to take care about it all.
Either way, there will always be the possibility of someone simply throwing modification statements against your Item table (if no locking was added), I guess (so either it works for Items or you have taken care of locking those too explicitly). Am I missing something fundamental here? ^^
Check Lock
Hey!
Thanks for the blog.
Do you know by any chance a way to check if a lock exists? (without trying to set the lock)
Like ENQUEUE_READ.
I know the use-cases are rare, as technically 1ms after you checked, it could be locked, as you didnt set a lock yourself, but still...
Thanks!
@Neldrak:
I had a look, but there is nothing there at the moment. Usually it only becomes interesting when I try to lock and change the data myself. The API could perhaps be used if you want to build a feature for this in an app.