Record level lock on SAP ABAP table editing
Hello All,
I have a requirement wherein I need to give users ability to be able to update contents of a table. Currently, there are using maintenance view on the table for adding/editing contents of this table. However, this prevents other users from being able to enter the table and edit contents of other records within the table.
Can anybody please guide me how do I go about giving record level edit lock on the table instead of entire table edit lock.
Appreciate all responses.
Thanks and Regards,
Samta.
Ok
I have had a request like yours, i.e the users could manage the same table in the same time.
The standard behavior avoids it, because a lock of entire table is set.
This was my solution:
A) I've created a maintenance view for my table, and I set the attibute S (for subset) for all fields will be the key I want to lock.
B) I've generated the maintenance table program for the view above.
In this way if it try to manage the view by SM30, it'll be possible only to indicate the values of the fields for the subset, so not all data of the table will be loaded, but only the records satisfying the key.
C) I've created a program to run SM30 for my view, using the fm VIEW_MAINTENANCE_CALL:
.CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
EXPORTING
action = 'S' "Display mode
view_name = <table name>
TABLES
dba_sellist = tb_sellist
EXCEPTIONS
OTHERS = 14.
As you can see above, the SM30 is always called for DISPLAY only, in this way no standard lock is set
D) I've use the event 19 in order to change the mode and set my lock:
DATA: BEGIN OF MY_LOCK,
MANDT TYPE ZPPTA019-MANDT,
WERKS TYPE ZPPTA019-WERKS,
/TRILOG/SE TYPE ZPPTA019-/TRILOG/SE,
COD_MOD_TAG TYPE ZPPTA019-COD_MOD_TAG,
END OF MY_LOCK.
DATA: W_SEL_LIST TYPE VIMSELLIST.
DATA: VARKEY TYPE RSTABLE-VARKEY.
FIELD-SYMBOLS: <MY_KEY> TYPE ANY.
LOOP AT DBA_SELLIST INTO W_SEL_LIST
WHERE VIEWFIELD = 'WERKS'
OR VIEWFIELD = '/TRILOG/SE'
OR VIEWFIELD = 'COD_MOD_TAG'.
ASSIGN COMPONENT W_SEL_LIST-VIEWFIELD
OF STRUCTURE MY_LOCK TO <MY_KEY>.
IF SY-SUBRC = 0.
MOVE W_SEL_LIST-VALUE TO <MY_KEY>.
ENDIF.
ENDLOOP.
IF SY-SUBRC = 0.
IF NOT MY_LOCK IS INITIAL.
MY_LOCK-MANDT = SY-MANDT.
VARKEY = MY_LOCK.
CALL FUNCTION 'ENQUEUE_E_TABLEE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = 'ZPPTA019'
VARKEY = VARKEY
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
MAINT_MODE = VIEW_ACTION = 'U'.
ENDIF.
ENDIF.
ENDIF.
CLEAR OLD_019.
I hope it can help you
Max
Similar Messages
-
Hi Experts,
I want to lock a table as per ecord level locking . How to go for it?
Actually the table is being updated with key records simultaneously through different processes.
Regards,
Jyoti ShankarHI,
SAP provides you with the ability to restrict access to data while the table is being updated. This is fairly
simple to implement via the use of a lock object . Create the Lock Object in SE11 for that table, if that already exist then use that one..
Add the following code in-order to create the table lock. This function module must be called before any
update takes place. If a lock has already been taken out it will display the appropriate message.
CALL FUNCTION 'ENQUEUE_EZ_ZTABLENAME'
EXPORTING
mode_ZTABLENAME = 'E'
mandt = sy-mandt
KEYFIELD1 = "Value
KEYFIELD2 = "Value
KEYFIELD3 = "Value
* X_KEYFIELD1 = ' '
* X_KEYFIELD2 = ' '
* X_KEYFIELD3 = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
* If exceptions are not used, message is displayed within FM
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Retrieve message displayed within Function Module
message id sy-msgid
type 'I'
number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
The following code will remove the lock for the specific table entries.
CALL FUNCTION 'DEQUEUE_EZ_ZTABLENAME'
EXPORTING
MODE_ZTABLENAME = 'E'
MANDT = SY-MANDT
mandt = sy-mandt
KEYFIELD1 = "Value
KEYFIELD2 = "Value
KEYFIELD3 = "Value
X_KEYFIELD1 = ' '
X_KEYFIELD2 = ' '
X_KEYFIELD3 = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
releasing the lock is mandatory,
See the link for more info.
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/7af4c8a79e11d1950f0000e82de14a/content.htm
Regards
Sudheer. -
KMC_DBRM_CONTENT DB level locks observed in this table
Hi ,
Please let me know the purpose of the KMC_DBRM_CONTENT standart table in SAP Netweaver Portal Version 7.0 SP13.
We are observing Locks in the table DB level eventually causing portal to go down.
We are using very minimal KM functionality
Regards
SudhirHi Sudhir,
Despite the DB is in the database of the Application Server. This specific table belongs and is controlled by the application KM. So I believe you will find a more suitable answer opening a thread, or moving this one to the Knowledge Management & Collaboration forum. There, many specialists of KM will be able to answer this question.
I hope I could help you, because the KM experts don't monitor this AS forum. So, there you will find your answer more quickly.
Thanks,
Anderson -
Hi,
I have a scenerio in which if a user data is being edited no other user should be able to perform update on the record. We can handle that using select for update but the specific requirement is that as soon as the one goes to the edit screen for the user the lock should be obatined for the data.
How can i handle the situation when:
1. User closes the browser without save/exit or system shutdown.
2. How will i use the same transaction object which has obtained the recorrd lock to update/rollback on save/exit operation.
Hope i stated the requirement clearly.Usually, a program should use optomistic concurrency when dealing with records. For instance, if your database table has 1000 records, it is unlikely two users would be viewing and then updating the same record such that the first user's changes are over written by the second user's update. Using optomistic concurrency, you would read the record, let the user alter it, then put the originial unaltered record values in the 'where' clause of the update statement. This way, whey he updates, the sql statement cannot find the record (because of values in the 'where' clause) which means its been altered by someone else. You can then notify the end user that the record was updated while he was editing it. Then present to the user the record and have him try altering it again.
You can read more on optomistic concurency at: http://msdn2.microsoft.com/en-us/library/aa0416cz(VS.71).aspx
If you still wish to lock the record, I suppose you can put the connection object that is in your transaction in the session scope. When the operation normally completes (user doesnt close the browser), you can close the transaction and remove the connection from session scope so it can be garbage collected. If the user closes the browser, in the JSP page, put a destroy() method and in it, end the transaction and destroy the connection in session scope so it can be garbage collected. Because the JSP page is compiled into a servlet, the servlet will automatically call the destroy() method (read up on servlets to determined the correct signature for the destroy() method). Make sure you use try/catch/finally to ensure connections are closed.
I don't know if the above will work as described, so you will have to try it out and verify it. I personnelly think you should avoid this approach. -
In an SAP Table is to possible to perfrom lock at the record level?
Hi All,
In an SAP Table/Ztable is to possible to perfrom lock at the record level?
Is it possible to increease the size of the sap table or z-table to insert more records.
For example I want to insert 50000 records into a z-table and the size category I have given as 0 means which can hold some 15thousand records.
then what abt the remaining recors?
how can I inser tthem?
do I need to increase the manually or it will be done automatically?
Could any one please explain this?
Thanks in Advance.
Regards.
Abhilash.hi,
u can insert no of records into table based on ur size category.
check these.
0 0 to 1,200
1 1,200 to 4,900
2 4,900 to 19,000
3 19,000 to 78,000
4 78,000 to 310,000
5 310,000 to 620,000
6 620,000 to 25,000,000
to lock records check this data.
Lock mode
Defines how to synchronize table record access by several users.
The following modes exist:
Exclusive lock
The locked data can be read or processed by one user only. A request for another exclusive lock or for a shared lock is rejected.
Shared lock
Several users can read the same data at the same time, but as soon as a user edits the data, a second user can no longer access this data. Requests for further shared locks are accepted, even if they are issued by different users, but exclusive locks are rejected.
Exclusive but not cumulative lock
Exclusive locks can be requested by the same transaction more than once and handled successively, but an exclusive but not cumulative lock can only be requested once by a given transaction. All other lock requests are rejected.
reward points if hlpful. -
Is it possible to Delete all Records of Std. SAP tables for Quality Server
Hi,
We want to delete some sensetive information from Test(Quality) Server.
For Std. SAP tables, is it possible to delete all Records?Hi, Through an ABAP program it is possible. You can develop the custom program on Development server than transfer it to QS and run the program.
Regards,
Aalok
Edited by: aalokg on May 13, 2010 12:19 PM -
Problem while fetching more records in SAP ABAP report program
Hello Frinds,
I have SAP ABAP report program which fetches data from usr02 table
Now, program is working fine with less number of records, bot in production there are more than 200000 records and either report gets timed out or there is run time error like buffer area not available.
Below is the fetch statement
SELECT bname FROM usr02 INTO TABLE lt_user
So, do I need to take records in small chunks, I do not think it is needed as I have worked on number of othere databases where there are number of records in single fetch statement and database itself take care of this.
Please provide me some approach to resolve this problem.This will be very difficult for you.....
Since you are getting a time out error....it looks like, you are runnning this report in foreground....................
Try running it in background it will work...
ELSE....you have to fetch in small chunks....but the question is how will you do it. Since the USR02 only has BNAME as primary key...
Either put the BNAME as part of selection screen and fetch the data.....it will solve your problem....
Only fetch for those BNAME which is entered in the selection screen...
Hope it helps! -
Create a table and upload data in MS ACCESS from SAP ABAP programming?
Hi All,
How to create a table in MS ACCESS database and Upload SAP database table data into MS ACCESS table using ABAP programming?
Explain: My client requirement is " If he/she runs a ABAP Program, that will create a table and upload data into MS ACCESS Database table in background. "
Could you please give the solution or code? I know the program RIACCESS and I went through the SAP Note 583698.
Is this only solution for this? Or Any other possibilities?
Please give me solution.
Thanks in advance.Hi,
It is not possible to create tables in a non SAP schema from inside SAP.
The SAP-Oracle license also does not allow you to create the table (see note 581312):
the following actions, among other things, are therefore forbidden at database level:
Creating database users
Creating database segments
Querying/changing/creating data in the database
Using ODBC or other SAP external access methods
Please refer following link,
[Ckick Here|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do]
You can also do it by LSMW,
If you are using Access 97, you can download directly into an access
database from SAP. See program RIACCESS for details. You have to establish
an RFC destination PS_ACCESS_1 and 2.
There are then a couple of function modules. Go to SE37 and put in
msaccess and hit PF4.
The following is from the readme file: sapgui/ps/readme.sap
For the MS-Access interface SAP delivers 4 files:
WDPSASTR.EXE This is an RFC server program that is called by SAP R/3
(PS module). This program creates a MS Access database. The structure
information of the tables is transferred from R/3. In addition to
these tables a table named DDIC is created. This table contains the
structure information and should in no case be modified or deleted.
WDPSATAB.EXE This is an RFC server program that is called by SAP R/3
after WDPSASTR. This program filles the tables of the database with data.
There must not be made any changes of the structure of
the tables between the calls of WDPSASTR and WDPSATAB.
WDPSAZET.EXE This is an RFC client program that triggers work/time
confirmations in the PS module of SAP R/3 (like transaction CN27 Collectiv
confirm).
WDPSAMAT.EXE This is an RFC client program that triggers material
confirmations in the PS module of SAP R/3 (like transaction MB1A - Goods
Please also refer following links,
[Click here|Upload data from MS Access tables, to SAP tables.;
Before using the program "RIACCESS", you need to install the PS utilities, which are part of SAPGUI install CD.
It is available in the "SAPGUIPS directory".
Then do the followings :
1. Select transaction code SALE -> Systems in network-> Define RFC Destination.
2. You will need two RFC destinations (TCP/IP connections for the front-end workstation).
Setup the two RFC destinations PS_ACCESS_1 and PS_ACCESS_2 and you'll have to get them to point to
wdpsastr.exe and wdpsatab.exe respectively.
3. Then execute RIACCESS and choose PS_ACCESS_1 to generate access tables.
The system must also be able to access the RFC-DLL files (librfc2.dll, librfc3.dll, librfc4.dll, librfc5.dll, librfc6.dll, vrfc.dll).
Please note that Access only supports tables with up to 255 fields. -
In which table the condition records get stored in sap crm
hi everybody any one can help me in this,
In which table the condition records get stored in sap crm.
Regards,
BabuHi Babu,
The table name depends on the condition table you have chosen while adding a condition record. Like if it is SAP001, the database table will be CNCCRMPRSAP001.
Regards,
Shalini Chauhan
Edited by: Shalini Chauhan on Jun 23, 2008 10:18 AM -
GUI error on SE80 in SAP NetWeaver 2004s ABAP trial Edition
I have SAP NetWeaver 2004s ABAP trial Edition installed on WinXP. one problem is that when I run T-code SE80 (Object Navigator) the middle section of the left part of the screen (where it would normally allows you to select object type for display) is not painted. it is just a block of white space! Other parts of the screen seems to work fine (both Top and Bottom sections). Has anyone had such problem? What can I do to fix it? Thank you for your help
HameedPatch level 22 is available at service market place, this is the link
Service Market Place -> Support Packages and Patches -> SAP Frontend Components -> SAP GUI FOR WINDOWS -> SAP GUI FOR WINDOWS 6.40 -> Win32 -> gui640_pdb_22-10001615.exe
https://smpdl.sap-ag.de/~swdc/012002523100007929292006D/gui640_pdb_22-10001615.exe?_ACTION=DL_DIRECT
You need the Service Market Place Id for that.
However, this file did not help!
Hameed -
How to pull records only for particular date range in Flex frm SAP wd table
Hi,
Can anyone help me with databing for datefield.
I am using two datefields in Flex for Start Date and End Date. When I click the Execute button, it should pull only the records for that date range from SAP wd table and display in my Flex datagrid.
Thanks,
Sri
Edited by: rmsridevi on May 17, 2011 4:38 PMHi,
Your query has mistakes as well. I corrected them.
Check this two different ways were in first you can define the period (month) you want and in second you have the option to select from the drop drown list :
SELECT T0.DocNum, T0.DocDate, T0.CardName,T0.DocTotal,T1.whsCode
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
WHERE t0.docdate >= '2011.01.01' and t0.docdate <='2011.01.31'
OR
SELECT T0.DocNum,T0.DocDate,T0.CardName,T0.DocTotal,T1.whsCode
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
WHERE t0.docdate >= [%1] and t0.docdate <= [%2]
Kind Regards,
Jitin
SAP Business One Forum Team -
Handling High Number Records in ABAP Table
Hi,
Other than creating indexes is there other option to handle in an efficient way searches in an ABAP table containing more than 30 million records?
Thanks in advance.Hi Ruben,
for me indexing would be the way to go: It totally depends on your access pattern. If you often read by a primary key and have no big volume queries around it would be ok.
mentioned physical Partitioning is a good option IF you can find a meaningful partition key that more or less evenly spreads the data over the partitions (i.e. 12 FISCPER that divides the 30 Mio. into partitions of 2- 3 Mio records) and that this key is used by all the quries you would start on that table. The index would be equi-partitioned. You have your DBA involved for this option; SE14 supports the physical partitioning of a table.
the other options mentioned (OPEN CURSOR...) are not much of help if you have to do number crunching;
(however, to write good SQL is the key to good performance so avoid the common pitfalls mentioned there).
You may consider a reliable archiving strategy that keeps your table on a certain row level while you move the "old" data in a kind of history table from time to time. If you need all data you would UNION both tables.
you can hint an SQL with a PARALLEL clause to speed up the processing (i.e. you retrieve all or a big amount of the 30 Mio rows)
bye
yk -
When will UniverseDesigner support SAP ERP Tables,InfoSets and ABAP Func. ?
Hi there,
to the SAP guys in this Forum to keep the rumour mill running: is it planned to extend the connectivity of the Universe Designer to access to SAP ERP Tables, Infosets and ABAP Functions ?! Is there any date when this will happen ?!
Thanks,
Sebastian
Edited by: smenzl on Apr 15, 2010 9:08 AMHi,
if you need an official statement i would recommend you open a SAP OSS Message for that.
Regards
-Seb. -
Row Level Locking while inserting a record.
It is a good practice to lock the whole table or do the row level locking while performing any DELETE / UPDATE / MODIFY actions on a database table. Is it necessary to do the same thing while inserting a record via INSERT statement?
One point may arise if two users are inserting same records at a same time....
Well i am little bit confused here bcos if a record doen't exist in a table what is the point of locking it.
Please help me.create a lock object using SE11 for that perticular table and include field names in Lock parameters. Then it will generate two FMs one for locking and another for unlocking.
Call the lock FM before updating the table and pass that row key value(For fields which taken in lock parameters for creating lock objects) to the exporting parameters.
Then do the updation.
Reward if useful................... -
How can I connect with SAP NetWeaver 7.01 SR1 SP3 ABAP Developer Edition
Hello together,
I downloaded and installed the SAP NetWeaver 7.01 SR1 SP3 ABAP Developer Edition on a virtual client.
I toke a long period to finish the installation.
Now some questions to use this system in the right way:
1.) How can I get a "developer license" which do not expire? Because the link http://www.sap.com/minisap seems to be not ok.
2.) How can I connect via network with the sap system? the application server is running on a vm client with a static ip i.e. 192.168.1.5. And my laptop gets a ip in the same range. I have installed the gui on my laptop and tried to connect with the system. But it does not work! I used as application server the ip of the virtual machine. I use the gui witch is installed on the same host like the application it works (with localhost as application server adress)
3.) Where can I download the newest version of the SAP Gui? I do not have a service marktplace account? Is it possible?
4.) I read in the documentation that it should be possible to reach the sap system also with web dynpro: http://localhost:8000/sap/bc/gui/sap/its/webgui?sap-client=000
But it does not work. I got an error message: Service cannot be reached
Note
The termination occurred in system NSP with error code 403 and for the reason Forbidden.
The selected virtual host was 0 .
Regards
ChristianI fixed in the meantime the second problem. It was a problem with my local firewall. But the other three points are still open.
Thank in advance for your help
Maybe you are looking for
-
PLease tell me how to reset my iCloud account email address if I can't remember the password?
-
Hello! I want to create bat script to create several VPN connection. There is powershell command to create vpn connection: add-vpnconnection -name "Test VPN" -serveraddress "vpn.example.com" -splittunneling -tunneltype "pptp" And I need to create VPN
-
My DVD drive is not working properly
Hi all, Hope you can help, I have been trying to play previously working DVDs on my iBook this evening, and it will not work. I have put in a music CD and it worked fine. I repaired my permissions, ran macjanitor and restarted the machine (also left
-
Can I stream movies from my iMac to the Apple TV? Can I add movies to the Apple TV hard drive I ripped from my DVD's?
-
Disjointed rollovers (I think)
Merrily creating rollovers where a larger image appears in a box to the right, but what I have now been asked to do is make the image larger where the original photo is. I know with normal rollovers that the images both have to be the same size, and