‎2008 May 02 11:28 AM
Can any body help me..I want locking. When I opened my report , no body can open at the same time.I am giving input 'AUFNR' and 'WERKS'.
eg. when I entered in my report with werks 1105 and aufnr 10001115 then no body can enter in report with the same plant and aufnr.
Rakesh
‎2008 May 02 11:40 AM
HI Rakesh,
You can lock the table using Lock objects. First create a lock object in SE11 and then call the below FM in your program under your condition.
Procedure for creating lock objects :
1)Go to se11 transaction.
2)Click on lock object radio button and give a lock object name starting with 'E'.For example 'ESAMPLE'.Click CREATE.
3)In the TABLE tab, you can give the table name for which you require a lock.In the LOCK PARAMETERS tab,you can give the table fields based on which the table should be locked.
4)Call a function module in your program ENQUEUE_lockobjectname to obtain a lock on the required table.In our example the FM will be ENQUEUE_ESAMPLE.
5)To release the lock on the table,call the function module DEQUEUE_lockobjectname.In our example the FM will be DEQUEUE_ESAMPLE.
Thanks.
‎2008 May 02 11:53 AM
Hi ,
there may not be direct solution ..
For this i have proposal ... Create One Z table which will hold the User name and the AUFNR and WERKS , as soon as user runs report you update the table and commit the work.
Assume that some other user is entered same values . You check the ztable for the same AUFNR and werks before report executes , if present then give the error 'USER(From z table entry) is already running with these values else continue the report .
Once report is excuted ,, Your last statement Should Delete the current record in table.
if you are not allowed to create Z table you can use table .. INDX and export the values , it will present in the same unless you delete it
Regards
Badari
‎2008 May 02 11:55 AM
Hi Rakesh,
I think u have to create one Ztable for this with keys werks and aufnr. In the START OF SELECTION event insert a record into ur Ztable with input AUFNR and WERKS. In the end of source code of ur program Delete the same record from Ztable. U have to put small piece of code in ur report also. Before inserting the record in to ztbale u have to check whether an entry exist in the table or not. If exist then give some message. Else Insert that entry and proceed.
This logic will be safe if u dont have any error messages from START OF SELECTION event. If u are giving any error messages in or after start of selection then do ROLLBACK WORK just before error message so that the record u created will not be updated to data base otherwise u can never execute for the same record with out deleting it from database. So ur Ztable has records only during the execution of the report. Check below the skeleton of code.
AT SELECTIOn SCREEN
do ur validations.
START OF SELECTION
SELECT SINGLE * from Ztab WHERE aufnr eq p_aufnr
and werks eq p_werks.
If sy-subrc IS initial.
MESSAGE i000 WITH 'User is already processing this plant and doc'.
EXIT.
ELSE.
wa_ztab-aufnr = p_aufnr.
wa_ztab-werks = p_werks.
INSER wa_ztab INTO ztab.
ENDIF.
proceed with ur logic and finally
DELETE ztab WHERE aufnr = p_aufnr and werks = p_werks
Hope this is clear.
Thanks,
Vinod.
Edited by: Vinod Kumar Vemuru on May 2, 2008 4:28 PM