‎2016 Mar 31 9:42 PM
Hi all,
I need to call the ENQUEUE_EVVBAKE function from RFC in order to lock an order from my web portal in certain cases.
I create a custom function module enabled for RFC and in this function module simply I call the ENQUEUE_EVVBAKE function, passing the sales document number.
If I test my custom function from SE37, the function locks correctly the sales document and I can see the lock on the sales order number from SM12 tcode.
If I call my custom function from RFC, the function doesn't return errors but it doesn't lock the sales document. From SM12 tcode I can see the lock on
$%&sdbatch object instead of my sales document number.
The user configured for the remote logon in RFC is a service user, not a dialog user: this may be a problem?
Thanks in advance,
Francesca
‎2016 Mar 31 10:15 PM
Did you place a commit after the excecution of the BAPI call?
Regards, Andreas
‎2016 Apr 01 7:56 AM
Hi Andreas,
I don't but I think is not a COMMIT problem: the function runs correctly if I call this from SE37.
I think the problem is a batch user that I'm using for RFC call ....
Thanks,
Francesca
‎2016 Apr 01 8:27 AM
Ah sorry, I did not read your question accurately. So my answer could be ignored
‎2016 Apr 01 8:34 AM
Hi Francesca,
Try to give a look at this thread
It refers to a similar problem where the OP tries to set a lock on sales order via JAVA
Meaningful part
a sales order uses lock object EVVBAKE, which is set via function module ENQUEUE_EVVBAKE. Unfortunately the (generated lock) function modules are not RFC capable. Assuming that your order means sales order, you could utilize RFC function modules ISA_LOCK_SALESDOCUMENTS for locking the order and ISA_UNLOCK_SALESDOCUMENTS for unlocking the sales order
Let us know if this solve your issue
‎2016 Apr 01 9:09 AM
A $%&sdbatch is often created in "simultation'" mode from some transaction/BAPI (or FM kie ISA_LOCK_SALESDOCUMENTS in its call of SD_SALES_DOCUMENT_ENQUEUE which wrap the final ENQUEUE_EVVBAKE), so check your code did you use one of those FM
Did you also check lifetime of the RFC connection, if connection close (explicit RfcClose or inactivity time, etc.)
Regards,
Raymond
‎2016 Apr 01 3:33 PM
Hi all,
I tried the ISA_LOCK_SALESDOCUMENTS but the results is always a lock on $%&sdbatch instead of my sales document number.
My code simply calls this function without additional code. I can't find $%&sdbatch constant in the global program.
Thanks,
Francesca
‎2016 Apr 01 9:34 PM
I'd rather suspect that maybe the document # is passed incorrectly or something completely different is off. Neither RFC or user should matter in this case. There is RFC debugging available but it's a pain in the back.
Could you post your code and SM12 screenshot (have to see it to believe it)?
‎2016 Apr 01 10:37 PM
Hello Francesca,
I believe that you are on the right track with following the suggestions of using the RFC enabled ISA_LOCK_SALESDOCUMENTS FM instead of ENQUEUE_EVVBAKE. Additionally, I understand your concern regarding the user type; however, based on your results, I do not think that is the issue either. Looking at the logic behind ISA_LOCK_SALESDOCUMENTS, the batch lock is set on ‘$%&sdbatch’ after the SD_SALES_DOCUMENT_ENQUEUE is successfully (sy-subrc = 0); see below:
CONSTANTS: con_enqueue_batch LIKE vbak-vbeln VALUE '$%&sdbatch'. "#EC NOTEXT
CALL FUNCTION 'SD_SALES_DOCUMENT_ENQUEUE'
EXPORTING mode_vbak = mode_vbak
mandt = mandt
vbeln = vbeln
x_vbeln = x_vbeln
_scope = _scope
EXCEPTIONS
foreign_lock = 1
system_failure = 2
no_change = 3
OTHERS = 4.
IF sy-subrc <> 0.
CALL FUNCTION 'BALW_BAPIRETURN_GET'
EXPORTING
type = sy-msgty
cl = sy-msgid
number = sy-msgno
par1 = sy-msgv1
par2 = sy-msgv2
par3 = sy-msgv3
par4 = sy-msgv4
IMPORTING
bapireturn = return
EXCEPTIONS
OTHERS = 1.
ELSE. *also set batch lock
CALL FUNCTION 'ENQUEUE_EVVBAKE'
EXPORTING
mode_vbak = 'S'
vbeln = con_enqueue_batch
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
CALL FUNCTION 'BALW_BAPIRETURN_GET'
EXPORTING
type = sy-msgty
cl = sy-msgid
number = sy-msgno
par1 = sy-msgv1
par2 = sy-msgv2
par3 = sy-msgv3
par4 = sy-msgv4
IMPORTING
bapireturn = return
EXCEPTIONS
OTHERS = 1.
ELSE.
CALL FUNCTION 'SD_DOCUMENT_NO_DEQUEUE_SET'.
ENDIF.
ENDIF.
Therefore, my suspicion is that something is going wrong with the way you are calling ISA_LOCK_SALESDOCUMENTS. Are you passing the sales order number in the VBELN field (not the x_vbeln)? Additionally, if you aren’t do so already, can you please include leading zeros with the Sales document number? If that still doesn’t work, please share your code and I can take another look.
‎2016 Apr 02 2:30 PM
Hi all,
thanks for your responses.
I left my custom RFC function and I tried to call directly the ISA_LOCK_SALESDOCUMENTS function from my FPM portal.
The sales document number has a lenght of 10 chars, it doesn't need of leading zero.
CALL FUNCTION 'ISA_LOCK_SALESDOCUMENTS' DESTINATION 'T02'
EXPORTING
MODE_VBAK = 'E'
MANDT = '001'
vbeln = '2005378988'
_SCOPE = '2'.
The resulting lock is here below:
BR,
Francesca
‎2016 Apr 04 10:28 PM
Well, if you look at the actual code in ISA_LOCK_SALESDOCUMENTS (trx SE37) then you can see that if the call to FM SD_SALES_DOCUMENT_ENQUEUE comes back with an error (sy-subrc <> 0) then that's the lock that will be set.
It has this constant right at the beginning:
CONSTANTS:
con_enqueue_batch LIKE vbak-vbeln VALUE '$%&sdbatch'. "#EC NOTEXT
I doubt the SCN members would be able to assist further with this. You need to check why the first lock fails in your system. As I mentioned, there is RFC debugging available. Also check with your Basis admin if they see anything in the log or can help to trace this.
‎2016 Apr 04 10:49 PM
Ok, I will investigate with my basis admin.
Thank you so much to everyone!
Francesca