Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_SALESORDER_CHANGE not handle message type W

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

8 REPLIES 8

vishal_sharda2
Participant
0 Kudos

Hi,

Please share the message you are getting. Also, do you see same message while changing SO via t-code VA02?

Thanks!

VS.

0 Kudos

Hi VS,

It is exactly the same message except message type W in userexit. BAPI interprets it as A.

Regards,

Dominic

krishnendu_laha
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

paul_dunk
Explorer

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

0 Kudos

Hi Paul,

This is working for me.I used for MV45AFZZ save_document_prepare.