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: 

Error Message in User Exit

Former Member
0 Kudos
1,813

Hi,

I have written an user exit (program 'MV45AFZZ') ( user exit 'FORM USEREXIT_SAVE_DOCUMENT_PREPARE'). Here I want to give an error message (before save the doc) if the user did enter the correct order reason. It is giving error message properly but during the message system is showing all the fields (VA01) in display mood.After displaying the error message when user press enter system should be able to show Order Reason field as input parameter not display parameter. Pls suggest how to handle this situation. Code is given below :

-


if xvbak-auart = 'ZFRE'.

IF XVBAK-VKORG = TVAUK-VKORG AND

XVBAK-VTWEG = TVAUK-VTWEG AND

XVBAK-SPART = TVAUK-SPART AND

XVBAK-AUDAT GT TVAUK-DATAB.

if xvbak-augru ne tvauk-augru.

SET CURSOR FIELD 'VBAK-AUGRU'.

message E000(zsd01) with

'Please select correct Order Reason'.

exit.

endif.

ELSE.

SET CURSOR FIELD 'VBAK-AUGRU'.

message e000(zsd01) with

'Please select correct Order Reason'.

ENDIF.

ELSE.

if xvbak-augru eq tvauk-augru.

SET CURSOR FIELD 'VBAK-AUGRU'.

message E000(zsd01) with

'Please select Order Reason not assigned to Cost Center'.

endif.

ENDIF.

-


Thanks,

Pradeep

5 REPLIES 5

Former Member
0 Kudos
247

Try information(type I) or warning (type W) message instead of error.

Former Member
0 Kudos
247

You can achieve this by following method.

In the user exit you can set one variable to 'N' if you don't allow the user to SAVE order.Your Variable should be avaiable at Global level.IF you dont want to use variables then you can achieve this by IMPORT EXPORT into memory also.

Change the error message to Warning message.

In Include MV45AF0B_BELEG_SICHERN

Immidiately after user exit

  • Userexit

PERFORM USEREXIT_SAVE_DOCUMENT_PREPARE.

Create new include and in the include

write the following code.

IF VARIABLE = 'N'.

CLEAR VARIABLE.

FCODE = FCODE_GLEICHE_SEITE.

PERFORM FCODE_BEARBEITEN.

CH_SUBRC = 4.

EXIT.

ELSE.

CH_SUBRC = 0.

ENDIF.

If any issues let me know.

Regards

Aman

It will not allow you to SAVE the order.

Message was edited by: Amandeep Singh

nablan_umar
Advisor
Advisor
0 Kudos
247

Instead of EXIT statement, try use LEAVE SCREEN. And off-course, do MESSAGE with 'I' or 'S', not 'E'.

0 Kudos
247

Hi aman,

I will implement this logic tomorrow since today basis guy is not there and I need the access key to implement this logic. I will let you know the status tomorrow.

Thanks for the suggestion.

Pradeep

Former Member
0 Kudos
247

Hi,

Use the user exit USEREXIT_MOVE_FIELD_TO_VBAK instead of USEREXIT_SAVE_DOCUMENT_PREPARE.

Hope this helps.

Regards,

Nagaraju Chidurupalli