2014 Dec 09 11:54 AM
Hi,
I am having an item table.I wanted to know what is the best practice for using lock objects for update the table.
Let consider, say for example billing item table VBRP, where the key fields is Billing Document No. and Billing Document Item.
I want to update amount of multiple Billing Documents after locking VBRP, the information is available in internal table with the same structure as VBRP let say the internal table is it_vbrp
let's consider the internal table data as follows.
Bill Docs Bill Doc Item Amount
90000001 1 100
90000001 2 50
90000002 1 20
90000002 2 40
90000003 1 30
90000004 2 60
Kindly let me know whether we can use 'UPDATE' statement instead of 'modify' from internal table.
I cannot use loop and use update statement inside the loop, because its restricted as per the coding standards.
Please let me know the Best Practise to be Used. If anyone is having <removed by moderator> ,kindly share with me.
Regards,
Fredric
Message was edited by: Manish Kumar : Do not ask for copyrighted material. Sharing them is illegal.
2014 Dec 09 12:03 PM
Hi,
UPDATE statement will be used only to update the existing records and it cant add new records.
MODIFY statement will update the existing records if the record exist and it will create the new record also.
INSERT statement will add the new records.
use MODIFY statement to update/insert the records in VBRP table.
before udpating the table then call lock function module.
Thanks,
Sree
2014 Dec 09 12:58 PM
Your "standards" don't allow use of SQL statement in LOOP , but allow the direct update of standard tables with such Open-SQL statements ?
For, free available, documentation, read ABAP Programming (BC-ABA), The ABAP Programming Language, Data Consistency, The SAP Lock Concept.
Regards,
Raymond
2014 Dec 10 4:38 AM
Dear Raymond,
Thanks for your valuable suggestion.
As per my understanding, Update statement sets the 'Lock' implicitly without lock object.
But if we use 'MODIFY', Lock Objects needs to be called before modify statement.
Since I have multiple billing documents that needs to be updated at the same time. I just wanted to know, how to use lock objects.(Just an example,I am not going to Update standard Tables ).
Just like 'Modify Table FROM internal table' is there any way to lock multiple records at a time ?.
I just wanted to know the best practice.
Thanks & Regards,
Fredric
2014 Dec 09 1:00 PM
If your internal table it_vbrp has same structure as VBRP then you can simply use
UPDATE DBtable FROM TABLE Internal table. Hoping the itnernal table has the updated values.
Are you trying to update standard SAP table!!!!!!
Regards
2014 Dec 10 4:40 AM
Hi Abhijit,
Nope i not going to modify standard table.
Reagrds,
Fredric