03-06-2012 3:57 AM
Hi,
I tried to update custom field in Additional Data B of sales order with BAPI_SALESORDER_CHANGE. BAPI calls USEREXIT_CHECK_VBAP. This user exit does a validation on custom field and return message type W when validation failed. BAPI immediately errored out and program was terminated (as if message type A).
Why BAPI not handle message type W?
Any help is appreciated. Thanks.
Best Regards,
Dominic
03-06-2012 12:05 PM
You can change the error handling in the function module by specifying an ERROR_MESSAGE in the EXCEPTIONS list. Normally, you should only call messages in function modules using the exception handling method (using the MESSAGE... RAISING or RAISE statements within the function module).
When you use ERROR_MESSAGE, the system treats the message that are called without explicit handling as follows:
Messages with type S, I and W are ignored (but entered in the log if you are running the program in the background).
Messages with type E and A cause the function module to terminate as though the ERROR_MESSAGE exception had been triggered (SY-SUBRC is set to r E ).
Put the the following in your BAPI:
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
......
EXCEPTIONS
error_message = 1. " This will catch the error message.
03-06-2012 4:56 AM
Hi,
Please share the message you are getting. Also, do you see same message while changing SO via t-code VA02?
Thanks!
VS.
03-06-2012 10:16 PM
Hi VS,
It is exactly the same message except message type W in userexit. BAPI interprets it as A.
Regards,
Dominic
03-06-2012 6:53 AM
Hello,
I think it is a standard behavior of SAP...if you raise a manual message type W / E it converts into an error message when it is called in background / another program
Please change the logic in user exit and suppress the message when SY-BATCH = 'X'
Thanks
Krish
03-06-2012 6:55 AM
Hi Dominic,
I faced a similar issue when trying to update the Reason for Rejection. The problem was because of upgrade.
As before upgrading to EHP5, warning messages were ignored by BAPI. but after upgrade the warning messages were causing an issue.
For time being the warning messages were ignored and the problem was solved and BAPI is successfully updating the sales order.
Hope this helps.
Regards,
Gaurav
03-06-2012 7:30 AM
Hi Dominic,
The way user exit works is, it reads data from your screen.For an example, if it is VA02, data from the screen fields are passed to the user exit and then it does validation.
But, when it comes to the BAPI, it does not linked with the screens or user exits. So it has no idea how the validations are done.
So the solution is, do not try to change the user exit. But you have to handle the same before passing data to the BAPI.
You need to do the same validation before passing data to BAPI.
TDW.
03-06-2012 12:05 PM
You can change the error handling in the function module by specifying an ERROR_MESSAGE in the EXCEPTIONS list. Normally, you should only call messages in function modules using the exception handling method (using the MESSAGE... RAISING or RAISE statements within the function module).
When you use ERROR_MESSAGE, the system treats the message that are called without explicit handling as follows:
Messages with type S, I and W are ignored (but entered in the log if you are running the program in the background).
Messages with type E and A cause the function module to terminate as though the ERROR_MESSAGE exception had been triggered (SY-SUBRC is set to r E ).
Put the the following in your BAPI:
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
......
EXCEPTIONS
error_message = 1. " This will catch the error message.
05-23-2014 2:58 PM
Hi Dominic,
Try something like the following. Replace the message ID, number and variables with your own:
IF call_bapi EQ charx.
* Push message to BAPI return table
PERFORM message_vbfs_aufbauen(sapfv45l) USING 'ZSD'
'150'
'W'
space
space
space
space.
ELSE.
MESSAGE w150(zsd).
ENDIF.
Cheers,
Paul
05-21-2020 9:23 AM
Hi Paul,
This is working for me.I used for MV45AFZZ save_document_prepare.