on 04-04-2016 8:17 PM
Dear Experts
I have a situation where my Z-Program is calling multiple synchronous ABAP Proxies/scenarios 1 after another.
My requirement is that if second/third/fourth users are also trying to call same Z program , all Proxy calls for first user should gets completed first then call for second users start.
I know queue management is not possible in synchronous communication due to which I put a lock object in start of first proxy call and releasing it once last proxy call gets completed. Other user must not able to call first proxy until lock is released.
However above locking is not working , when multiple users are executing same program at a same time without a delay of even 1 second.
Kindly help how to stop multi processing of same proxy calls by multiple users from different sessions.
Example - 1
User - 1 - Program - A , Session - 1
Lock
Call Proxy 1 - read table - Z
Call Proxy 2
Call Proxy 3 - update table - Z
Unlock
Example - 2
User - 2 - Program - A , Session - 2
Check Object is not lock
Call Proxy 1 - read table - Z
Call Proxy 2
Call Proxy 3 - update table - Z
Unlock
In above situation user -2 should not be able to call second session of proxies until work of user - 1 gets completed but unfortunately this is not happening. User - 2 is able to view same data in table z which user 1 reviewed before updating the table, i.e. User - 2 is able to execute Proxy 1 call before data gets saved in table Z by user -1.
Dear All
Issue is resolved by creating a lock over program itself instead of using tables lock.
That is program will remain lock until last proxy call gets executes successfully.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I would suggest you to create a custom table and use enque and deque to set the status field for each user run.
Verify if the table has the flag then provide a delay and execute the loop for 5 times and come out incase if the first user is still executing else you can set and clear after each run.
Handle the table updates correctly else you will have issues.
Hope might be helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Swee
Issue may not be related to locking.
I guess locking is working but the Synchronous Proxy interface at PI end is not getting completed and second user is able to read same third party table which first user is writing.
Exact Scenario.
First User is writing last number of a number range in third party table.
Second User is reading last stored number to generate next numbers but second user is able to read old number instead of number which first user is writing.
Above issue is appearing , if both users are able to execute proxy at a same time other wise working fine.
Code is attached..
DO.
CLEAR: zenq, zenq[].
SELECT SINGLE *
FROM zp6lock
INTO wa_lock
WHERE proj = '1'.
IF sy-subrc NE '0'.
lock = space.
ELSE.
lock = 'X'.
ENDIF.
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
gclient = sy-mandt
gname = 'ZP6LOCK'
TABLES
enq = zenq
EXCEPTIONS
communication_failure = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
IF zenq IS NOT INITIAL OR lock IS NOT INITIAL.
l_index = 50.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = l_index
text = 'Please wait or Try later, P6 locked by another user'.
wait up to 4 SECONDS.
ELSE.
EXIT.
ENDIF.
ENDDO.
CALL FUNCTION 'ENQUEUE_EZZP6LOCK' "
EXPORTING
* mode_zp6lock = 'E'
mandt = sy-mandt
* PROJ =
* X_PROJ = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
PERFORM check_lock.
ENDIF.
wa_lock-mandt = sy-mandt.
wa_lock-proj = '1'.
MODIFY zp6lock FROM wa.
IF sy-subrc NE '0'.
MESSAGE 'Retry! P6 is locked by anohter user' TYPE 'S'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
PERFORM get_last_wbs_id. "Proxy Call to read
PERFORM send_new_wbs_id. "Proxy Call to write
CALL FUNCTION 'DEQUEUE_EZZP6LOCK'
EXPORTING
mode_zp6lock = 'X'
mandt = sy-mandt.
wa_lock-mandt = sy-mandt.
wa_lock-proj = space.
MODIFY zp6lock FROM wa.
ENDIF.
Looking at code i think the exit statemnet might be kicking out of loop and not from your perform.
Coming out of loop it is straight going to PERFORM get_last_wbs proxy call and so.
Please debug as you are checking lock first and then going to call proxy you should be making a mistake in handlng the loop.
As only when the lock is released you should be hitting Proxy Perform else your control should not hit that part of code.
1) Open 2 session of the progra ... set the lock trigger proxy
2) In the second session try to debug and veridy where there is breaking the logic.
Cheers!!
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.