Application Development and Automation 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: 
Read only

What is the Best Practise to use Lock objects ..?

fredericbasilius
Participant
0 Kudos
770

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.

5 REPLIES 5
Read only

Former Member
0 Kudos
349

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

Read only

RaymondGiuseppi
Active Contributor
0 Kudos
349

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

Read only

0 Kudos
349

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

Read only

Former Member
0 Kudos
349

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

Read only

0 Kudos
349

Hi Abhijit,

Nope i not going to modify standard table.

Reagrds,

Fredric