07-06-2009 3:53 AM
Hi Experts,
Iam trying to change the Rejection code for SO by using BAPI_SALESORDER_CHANGE.
In my normal report it is working fine.
if i use the same bapi in user exit USEREXIT_SAVE_DOCUMENT_PREPARE then the bapi showing the message
like Please enter the Document number?
How to solve this problem?
07-06-2009 4:05 AM
Hi,
As we know, The functionality of BAPI BAPI_SALESORDER_CHANGE is almost same as t-code VA02 actually.
I don't know how this message 'Please enter the Document number' coming. However logically we don't call this bapi in user-exit USEREXIT_SAVE_DOCUMENT_PREPARE or USEREXIT_SAVE_DOCUMENT because this two user-exits will be triggered by this BAPI or we can say those two user-exits are part of this BAPI.
If you really want to change rejection code in user-exit, just change internal table XVBAP.
Hope above is helpful for you.
Regards.
07-06-2009 4:09 AM
Hello
Since SALESDOCUMENT is mandatory for this BAPI ,
xvbap-vbeln should have value inside this user exit.
Can u check in debug mode if this has the sales doc number ?
Thanks
Shivika
07-06-2009 4:10 AM
Also any modifications should be done to xvbak and xvbap-vbeln as this will be the one updating the sales order tables.
Thanks
Shivika
07-31-2009 10:40 PM
Hi,
This is because the Sales order which you try to change will already be locked/enqued by the system and when tried to export the SO number in
BAPI_SALESORDER_CHANGE ->
SD_SALESDOCUMENT_CHANGE->
SD_SALES_DOCUMENT_READ->
PERFORM BELEG_LESEN(SAPMV45A) include subroutine, it will not find.
Try keeping a break point in the function module SD_SALES_DOCUMENT_READ at statement
VBAK-VBELN = DOCUMENT_NUMBER.
PERFORM BELEG_LESEN(SAPMV45A)
and see if the SO doc value that is assigned to VBAK-VBELN in the function module is passed into the perform without clearing its value.
If it is clearing out, then there is enqueue on the SO number already set by the standard VA02 program.
So cannot be changed without unlocking it.
But in the form USEREXIT_SAVE_DOCUMENT_PREPARE if you try to unlock this might lead to incosistencies, so be careful.
Try if u can unlock the SO and then change using the BAPI and then enqueue again, but take care it should not lead to any inconsistency.
Sai
08-01-2009 8:02 AM
08-01-2009 8:13 AM
User exit Save document Prepare is triggered before the sales number is created
But Once a sales order has been created then only through this bapi u can change this .
since this Bapi is fired before a sales document is created that is why the error is coming.
try to find out some other exit point .