‎2005 Oct 18 3:37 AM
Hi
Im using VB.Net, SAP .Net to do data entry, updates to
SAP R/3.
Now, I need to lock the data during user changes on
particular documents.
What I done is I created a lock object in SE11. Then
it produce 2 functions which are the ENQUEUE and
DEQUEUE.
Since the data reading from Non-SAP, I check for Allow
RFC and my lock mode is Exclusive and Cumulative.
After that, I also created a remote-enabled RFCs to be
call from VB.Net. These RFCs is calling the ENQUEUE
and DEQUEUE.
When I tested in SAP itself, the locking data is
working perfectly. I checked in SM12, it does shows
the locking entry.
But when I try in VB.Net and call the function
modules, it does not shows any entry in SM12. It is
like nothing happen at all.
After that, I do little test. Firstly I lock the data
from SAP then I run VB.Net, and it does shows the
message who is currently locking the data.
Anybody could help me on this?
Thank you.
Regards.
‎2005 Oct 18 3:47 AM
See the following extract from documentation. Check if your lock object definition is satisfying all of them.
<i>Reference Fields for RFC-Enabled Lock Objects
The type of an RFC-enabled function module must be completely defined. The parameters of the generated function module therefore have the following reference fields for RFC-enabled lock objects:
Parameters Reference fields
X_<field name> DDENQ_LIKE-XPARFLAG
_WAIT DDENQ_LIKE-WAITFLAG
_SCOPE DDENQ_LIKE-SCOPE
_SYNCHRON DDENQ_LIKE-SYNCHRON
</i>
Here is the link to the documentation
http://help.sap.com/saphelp_46c/helpdata/en/4f/991f82446d11d189700000e8322d00/frameset.htm
Srinivas
‎2005 Oct 18 3:47 AM
See the following extract from documentation. Check if your lock object definition is satisfying all of them.
<i>Reference Fields for RFC-Enabled Lock Objects
The type of an RFC-enabled function module must be completely defined. The parameters of the generated function module therefore have the following reference fields for RFC-enabled lock objects:
Parameters Reference fields
X_<field name> DDENQ_LIKE-XPARFLAG
_WAIT DDENQ_LIKE-WAITFLAG
_SCOPE DDENQ_LIKE-SCOPE
_SYNCHRON DDENQ_LIKE-SYNCHRON
</i>
Here is the link to the documentation
http://help.sap.com/saphelp_46c/helpdata/en/4f/991f82446d11d189700000e8322d00/frameset.htm
Srinivas
‎2005 Oct 18 4:02 AM
Hi Srinivas,
Thanks for replying.
Yup, I did try the parameters.
CALL FUNCTION 'ENQUEUE_EZCOL05'
EXPORTING
ZBUKRS = '1000'
ZCENT = code1
ZCTR = code2
X_ZBUKRS = 'X'
X_ZCENT = 'X'
X_ZCTR = 'X'
_SCOPE = '2'
_WAIT = 'X'
EXCEPTIONS
foreign_lock = 2
system_failure = 3.
It does not have any effects on the locking data. I dont know what happen. There is no entry in SM12.
Any other solution?
Thank you.
Regards.
‎2005 Oct 18 4:03 AM
Hi,
One RFC means one transaction. The moment one RFC call is over it will release the lock. You need to code your ENQUEUE/ DEQUEUE in the same function ( RFC call ) which is doing the data entry and not have a separate RFC FM for it .
Cheers
‎2005 Oct 18 4:25 AM
Hi
Could you post the RFC that you mentioned by one transaction?
My scenario: User is changing data. Meaning to say, the user would select particular Document Number and that moment , I would call the RFC ENQUEUE. Upon saving the data, I would release the lock and call the DEQUEUE.
Is there any possiblity to do that?
Thank you.
Regards.
‎2005 Oct 18 4:35 AM
SAP Lock concept is related to Logical Unit Of work -> and this is called transaction.
When you call an RFC it is similar to one dialog transaction .
When you call a RFC for locking ( separate FM ) , the lock will be released when this RFC is over. Next when you call the RFC for changing data it will be another transaction and the lock may not be there.
Between what document are you trying to change and which Function are you calling to achieve this . If its a custom FM you can put your ENQUEUE / DEQUEUE FMs in the same custom FM and call only one RFC to change the document .
Cheers.
‎2005 Oct 18 4:36 AM
I would do it like this.
Call rfc document list to present the user with a list of documents.(no locka required here).
User selects the document to be updated.(no lock required here)
Get the document details using rfc get detail.no lock required. keep a copy of this data.
Give the user VB.net gui to modify the document. Prepare the change data and here is where I need a rfc that does the following
lock the document data in R/3,
do another read of the document. compare it with the previously stored information to check if the document has changed in R/3. If changed, error handling. If not, lock the document by calling enqueue, apply the changes in R/3 and then dequeue.
Hope this helps,
Srinivas
‎2005 Oct 18 5:08 AM
Hi
I have customized module doing data entry and updates. So, when it comes to updating Document Number, i need to lock it so that other user cannot access that document number at the same time.
Thank you.
Regards.
‎2005 Oct 18 5:15 AM
You need to write a custom RFC that has the following 3 calls.
call to enqueue
call to change document
call to dequeue
Srinivas
‎2005 Oct 18 5:26 AM
Hi
The Module that you are calling for data update should have the call to ENQUEUE / DEQUEUE functions in addition to the data update . That will be sufficient to lock the number when you are updating that . In any case lock should not remain for a long period as then user will select one entry and that will be locked for all other users . So lock should be triggered only when user presses SAVE ( Commit ) button .
Cheers.
‎2005 Oct 18 5:55 AM
Hi Srinivas
Yes, I have the 3 FMs:
call to enqueue
call to change document
call to dequeue
My problem is from VB.Net (NON-SAP) cannot lock the data. There is no entry in SM12 when I call the enqueue fm from VB.Net.
For the Lock Object, I check for Allow RFC and Lock Mode = Exclusive, Cumulative.
and for the parameters, I put it below information as instructed in the SAP Library - Lock Objects.
X_<field_name>
_WAIT
_SCOPE
_SYNCHRON
I do not know which part I miss.
Thank you.
Regards.
‎2005 Oct 18 6:03 AM
Hi
I guess you are getting it worng.
You have to write a wrapper RFC function -
which will have the three ( further ) calls -
call to enqueue
call to change document
call to dequeue.
From VB you should only call the wrapper RFC FM ( and not the above indivdual FMs ) when user presses SAVE.
Cheers.
‎2005 Oct 18 6:13 AM
Hi Sanjay
I'll try your solution. But before that there is 1 question.
Why when I run the ENQUEUE from NON-SAP it does not lock the data? By logic, it should lock the data and there is entry in the SM12.
From what you're suggesting is that NON-SAP need to have wrapper function in order the Lock object to be working.
‎2005 Oct 18 6:18 AM
<b>Why when I run the ENQUEUE from NON-SAP it does not lock the data</b>?
By the time you go and check in SM12 , the RFC call has ended ( i.e. the transaction has ended ) . This releases the lock and your entry from SM12 is gone. If you really can check SM12 while your RFC is running you will see the entry . But I guess the RFC is too fast .
If you read the first post I mentioned this .
Cheers.
( Dont forget to reward if answers were helpful )
‎2005 Oct 18 7:48 AM
Hi Sanjay
I get what you mean by 'too fast'.
I did a little test. I put:
WAIT UP TO 1 seconds.
I just want to see whether it really locks the data from NON-SAP. Yup, it locks the data!
Why I kept on saying it does not lock the data from NON-SAP because when I do testing in SAP itself it shows in SM12. There is an entry. Thats why my thinking is that it would be the same logic for NON-SAP.
Another question:
1. Can a user hold/lock the data?? I dont want it automatically release the lock. Unless I call the DEQUEUE fm then I would release the lock.
Is there any possibilities to do? Or do I have to change the Lock Mode??
Thank you.
Regards.
‎2005 Oct 18 9:32 AM
Can a user hold/lock the data?? I dont want it automatically release the lock. Unless I call the DEQUEUE fm then I would release the lock.
Is there any possibilities to do?
Thank you.
Regards.
‎2005 Oct 18 6:35 PM
As you have seen in this entire discussion, you are holding the lock, but for RFC calls, SAP releases the lock automatically, and I don't think there is any way to bypass that. This is true even within R/3. Do this small experiment. Open a program in change mode using SE38. In another session, run the transaction SM12 and you will find that you are holding a lock for that program in the other session. Now, you log out of the system abruptly by entering "/nex" in the command area. Log back in and go to SM12, your lock will no longer be there. This is exactly what is happening with your RFC call. If you login, do a transaction, you are actually logging out which kills all the locks you are holding. Instead, if you have a mechanism where you keep the RFC connectin open(not recommended though), and you can make multiple calls to SAP within that connection, then you can keep your locks. I am not sure how you can achieve that, but I have seen some third party applications that can keep one connection open all the time and do their work.
Regards,
Srinivas