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

restrict users with the same company code

arpita_churi3
Active Participant
0 Likes
1,245

Hi All,

  I have developed editable ALV which allows users to edit and delete records and save those changes in database.

Input is Company Code , Document Number and Fiscal Year.

Now I want to restrict multiple users trying to edit/delete records with same company code at a same time.

Example:

User A is editing records for company code 1250.

If User B tries to access for same company code 1250 at the same time, it should return an
error message saying “Table currently locked by User A”.

and also want to restrict the records if multiple users are trying to edit/delete the same record at

a same time,I should give an error message.

Thanks,

Arpita

8 REPLIES 8
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,123

I would simply populate the results in a maintenance view and use events to control editing..

Read only

0 Likes
1,123

thanks.

Can you pls explain in detail...

and  I don't have authorization to use maintenance view in this case..


Read only

nishantbansal91
Active Contributor
0 Likes
1,123

Hi,

Create one table and update the flag as per company code before update in the database check the flag is active then display error message. When user press back button deactivate the flag in table.

One drawback is there, if user explicitly close the session then we don't have event to deactivate the flag in database.

Regards,

Nishant

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,123

First perform some search on Lock Concept in online help (ABAP Programming (BC-ABA), The ABAP Programming Language, Saving Data Externally, Data Consistency, The SAP Lock Concept or The SAP Lock Concept (BC-CST-EQ), SAP Lock Concept)

Then use or create thru SE11 a lock object for your table (keys must start with mandt + Bukrs, to not interfere with standard locks, e.g. EFBKPF, you may create your own z-structure and an associated lock object) and before reading data check the company code is not yet locked with ENQUEUE FM, release the lock is either implicit at end of transaction or triggered thru DEQUEUE FM or COMMIT/ROLLBACK WORK (depends also on your choice on _SCOPE Parameter value).

Regards,

Raymond

Read only

Former Member
0 Likes
1,123

Hi Arpita,

Can you use Lock objects for restrict users for same company code.

For EX:

if(companycode = ' ' )

enable lock object .

endif.

Please refer the below links or search in SDN or google.

http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm

http://www.erpgreat.com/abap/type-and-uses-of-lock-objects-in-sap.htm

Regards,

Lokeswar Reddy Byni.

Read only

rosenberg_eitan
Active Contributor
0 Likes
1,123

Hi,

Also see program DEMO_TRANSACTION_ENQUEUE .

Regards.

Read only

Former Member
0 Likes
1,123

This message was moderated.

Read only

Former Member
0 Likes
1,123

This message was moderated.