cancel
Showing results for 
Search instead for 
Did you mean: 

Custom error message

baskaran00
Active Participant
0 Kudos

Hi Experts,

My requirement is to use custom error messages.

1.How can I define custom error messages?

2.How can I use it in the program.

Sample Code will b useful

Experts suggestion pls.

Answers will b rewarded.

Thanks,

Router

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Custom messages can be created using T100 messages.

First create a custom T100 message that you want to be displayed.

Second. in the mehod on the validation of which you want to call the error message, Call the wizard, choose messages... then choose F4, From the list choose Report T100 error messages, or messages,

Enter the message id and type that you require.

baskaran00
Active Participant
0 Kudos

Rajesh,

Thanks for ur quick reply.

Can u tell step by step procedure to do it, if u dont mind.

I'm new to creating custom messages.

Thanks....

alejandro_bindi
Active Contributor
0 Kudos

Router,

1. Call transaction SE91

2. Enter Message class: Maybe you must reuse an existing (Z) message class, instead of creating one. Check this with your development team.

3. Once you create or modify the message class, you enter your messages one by one. A good practice is to create the first message (000) as & & & & if it's a new message class.

4. Once the messages are created, you can translate them to other languages from the menu.

5. From the program you use them with the MESSAGE statement, check this link to SAP help: <a href="http://help.sap.com/saphelp_nw70/helpdata/en/9f/dbaaaf35c111d1829f0000e829fbfe/content.htm">http://help.sap.com/saphelp_nw70/helpdata/en/9f/dbaaaf35c111d1829f0000e829fbfe/content.htm</a>

Short example: If your message class is Z1 and you're using message 010 which is 'Hello user &', you can use it from the program in the following manner:


MESSAGE s010(Z1) WITH sy-uname.

Regards

Edited by: Alejandro Bindi on Mar 21, 2008 2:31 PM

baskaran00
Active Participant
0 Kudos

Bindu,

When I tried it in Web dynpro for ABAP, I didnt get my custom message.

How to get my custom message in Web Dynpro for ABAP?

alejandro_bindi
Active Contributor
0 Kudos

Because WDA is a slightly different picture than normal ABAP (i didn't notice this was the WDA forum since i've entered this thread by RSS).

You can define messages the same way (with SE91), but instead of using the MESSAGE command for displaying them, you must use a message manager. The interface IF_WD_MESSAGE_MANAGER has the method REPORT_T100_MESSAGE by which you can display the defined messages. You have a wizard for using the message manager from the workbench: Ctrl+F7 -> Generate Message.

This would be the code for showing the message from my previous example:


* get message manager
DATA lo_api_controller     TYPE REF TO if_wd_controller.
DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
DATA: l_uname type symsgv.

lo_api_controller ?= wd_this->wd_get_api( ).

lo_message_manager = lo_api_controller->get_message_manager( ).

l_uname = sy-uname.

* report message
lo_message_manager->report_t100_message(
    msgid                    = 'Z1'
    msgno                    = '010'
    msgty                    = 'S'  " Change this to 'E' for Error messages
    p1                       = l_uname
       ).

For more examples check the following component: WDR_TEST_MSG_AREA, in this the method REPORT_ATTRIBUTE_T100_MESSAGE is used which behaves similarly.

Edited by: Alejandro Bindi on Mar 21, 2008 6:32 PM

Answers (2)

Answers (2)

baskaran00
Active Participant
0 Kudos

Still can anyone tried overriding the custom message. When I try to give custom message for a field having search help my custom message is not displaying instead pre-defined system message is displaying.

Former Member
0 Kudos

Hi,

Define your own message class and use it in your code.

if you dont want to define your own message type then use it as...

Message 'Example' type 'I'.

Thanks

Yogesh