Fake Messages [ABAP]

You can show fake messages by using “DISPLAY LIKE dtype” option of MESSAGE statement. For example you can show a S (Success) message as E (Error) message.

MESSAGE … DISPLAY LIKE dtype

When you use this addition, the icon of the message type specified in dtype is displayed instead of the associated icon. A character-type data object is expected for dtype. This data object has to contain one of the values “A”, “E”, “I”, “S” or “W” in upper-case letters.

The message short text is still displayed as a dialog window for messages that are displayed this way by default. Messages with the type “E” or “W” (except those for PBO and LOAD-OF-PROGRAM) are displayed as a dialog window if dtype contains “A” or “I”. Messages with the type “S” are always displayed in the status bar, independently of dtype. The latter also applies to messages of the type “I” for PBO and LOAD-OF-PROGRAM. Messages of the type “X” always cause a runtime error.

But the usage of this option does not affect the behavior determined by the message type, but only the type of display. For example, if you show a success message as error message, the user can skip the message by just pressing enter. Actually you cannot skip the error message.

We needed to give a an error message in one of the sales order exit MV45AFZZ - USEREXIT_SAVE_DOCUMENT_PREPARE, but if we give an error message, the sales order program SAPMV45A blocks / gray out all fields, so you cannot enter any data. So by using fake message we showed a success message as error message.

MESSAGE s024(zpcc_sd) DISPLAY LIKE zzgc_msgty_error
WITH ls_vbkd-inco1
ls_vbap-route
ls_vbap-posnr.

The user will see an error message, although it is a success message. And in this case all fields will open to enter data. But here is the problem: The user can just skip the message by pressing although the message seems an error message. Therefore how can we keep the user in the same screen until s/he fixed the error.

A simple search and here the answer:  MV45AFZZ cancel document saving process

PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
FCODE = ‘ENT1′.
SET SCREEN SYST-DYNNR.
LEAVE SCREEN.

But I commented PERFORM FOLGE_GLEICHSETZEN(SAPLV00F) and even it worked. It means even though the user can press enter to skip the fake error message, the code will work and the user will stay there again. We tell the user not to move, just fix the error.

PS: If you write this code in MV45AFZZ - USEREXIT_SAVE_DOCUMENT_PREPARE, and if you want to catch the same error in ORDER inbound IDoc processing, you cannot! You will get another error from IDoc: “No batch input data for screen SAPMV45A 4002

Why do you get this error? Because you touched the screens, you affected the movement of the screens. Bu as you know ORDER inbound IDoc processing program (function module )IDOC_INPUT_ORDERS is using batch input data to call VA01 transaction (SAPMV45A program).  So when the program sees our code (SET SCREEN, LEAVE SCREE, etc.), it doesn’t know what to do since batch input data does not have our screen movements.

So we need to skip these screen codes for IDoc processing. But how can we understand an IDoc is creating the order or a user via VA01 / VA02. All we know IDoc processing even calls VA01 to crate the order.

Trick: Run VA01 transaction, go to System - Status, double click Screen number 101, and click Layout then you will find a hidden field IDoc number (RV45A-DOCNUM). So it means when VA01/VA02 (SAPMV45A) is called by an IDoc processing RV45A-DOCNUM field will hold the IDoc number. All right, it is perfect!

So I did:

IF rv34a-docnum is not initial.

FCODE = ‘ENT1′.
SET SCREEN SYST-DYNNR.
LEAVE SCREEN.

ENDIF.

Another problem: The IDoc didn’t catch our fake error message and successfully posted the order. Why? Because it is a fake error message, it is a success message for IDoc. Success messages are just ignored! So for IDoc processing, I showed the message as a real error message:

MESSAGE e024(zpcc_sd)
WITH ls_vbkd-inco1
ls_vbap-route
ls_vbap-posnr.

And IDoc failed, because of this error as we wanted! It’s time to smile :) after a happy end!

Tags: , , , , , , , ,

One Response to “Fake Messages [ABAP]”

  1. Mati Says:

    Nice :)… Noted there’s a typo when refering to the IDoc’s number field in the code (RV34A instead of RV45A).

Leave a Reply