Application Development and Automation 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: 
Read only

How to write Error messge in selection screen

Former Member
0 Likes
1,771

Hi,

Suppose I enter a wrong matnr in selection-screen say 1000.

I need to write a message like, Matnr '000 does not exists. please check entries.

Here how do i populate the 1000 in message

Pls help.

Thanks.

Hi,

Suppose I enter a wrong matnr in selection-screen say 1000.

I need to write a message like, Matnr '000 does not exists. please check entries.

Here how do i populate the 1000 in message

Pls help.

Thanks.

7 REPLIES 7
Read only

Former Member
0 Likes
1,190

Hei

If your question was about how to write an error message...I can help you.

Go to SE91 and create a message class. And give all the messages that you want to use by specifying the message id.

You can call this message in your program using this

message-id. Can also use in other programs.

I guess you know the message types as Error, Abort, Warning, information etc.

Use them. Some won't let you to continue...check those

But retrieving the wrong matnr number dynamically..........am not sure how to do it.

I never did it.......Can we do that....I don't think so.

I hope it helps.

thanks

Edited by: Alchemi on Mar 5, 2008 3:04 PM

Read only

Former Member
0 Likes
1,190

TABLES: mara.

SELECTION-SCREEN BEGIN OF BLOCK test.
PARAMETERS: p_matnr LIKE mara-matnr.
SELECTION-SCREEN END OF BLOCK test.

AT SELECTION-SCREEN.
  SELECT SINGLE matnr
  INTO mara-matnr
  FROM mara
  WHERE matnr EQ p_matnr.
  IF sy-subrc NE 0.
    MESSAGE e208 WITH 'Wrong material number'.
  ENDIF.

START-OF-SELECTION.

Greetings,

Blag.

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,190

HI,

Create ur message in message class like this.

Se91->Give message class-> Message number(Give new number which does not exist in the message class)->press create.

There fill the message text like this.

Material & does not exists. please check entries. Save and go to ur program.

in the AT SELECTION-SCREEN event do like this.

AT SELECTION-SCREEN ON po_matnr.

CLEAR l_matnr.

SELECT SINGLE matnr FROM mara INTO l_matnr

WHERE matnr EQ po_matnr.

CHECK NOT sy-subrc IS INITIAL.

MESSAGE e123 WITH po_matnr.

If u enter material number 1000 and it does not exist the u will be getting message like this.

Material 1000 does not exists. please check entries.

Thanks,

Vinod.

Read only

Former Member
0 Likes
1,190

Hi,

SELECTION-SCREEN BEGIN OF BLOCK test.

PARAMETERS: p_matnr LIKE mara-matnr.

SELECTION-SCREEN END OF BLOCK test.

AT SELECTION-SCREEN.

SELECT SINGLE matnr

INTO mara-matnr

FROM mara

WHERE matnr EQ p_matnr.

IF sy-subrc NE 0.

MESSAGE e208 WITH 'Wrong material number : ' , p_matnr .

ENDIF.

Read only

Former Member
0 Likes
1,190

Hi,

Message Classes are container of user-defined messages. We can create our own messages to be displayed in the screen and we can create these messages in a message pool inside the message class.

SE91 is the Tcode to create a message class.

The created messages can be called from programs using the statement 'MESSAGE'.

SYNTAX:

MESSAGE <type_of_message><message id>(message_class).

TYPES OF MESSAGES:

-


S - Status message.

I - Information message.

E - Error message.

W - Warning message.

A - Abort message.

T - Terminate message.

You can create up to 1000 messages in a single message class. The message id ranges from 0 - 999.

Sample Code:

SELECTION-SCREEN BEGIN OF BLOCK WITH FRAME TITLE 'MESSAGE'.

Select-Options: so_matnr for mara-matnr.

SELECTION-SCREEN END OF BLOCK 'MESSAGE'.

AT SELECTION-SCREEN.

SELECT matnr

INTO mara-matnr

FROM mara

WHERE matnr in p_matnr.

IF sy-subrc NE 0.

MESSAGE e000(Zmessageclass) WITH ' Material number does not exists'.

ENDIF.

Regards,

kavitha.

Read only

Former Member
0 Likes
1,190

Hi

declare it like this.

MESSAGE text-004 TYPE 'E'

IF v_field = 'WA_KNA1-KUNNR'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING "first_list

input = v_kunnr

IMPORTING

output = v_kunnr.

SELECT kkunnr vvbeln verdat vernam vauart vaudat

INTO TABLE it_vbak

FROM vbak AS v INNER JOIN kna1 AS k ON vkunnr = kkunnr

WHERE v~kunnr = v_kunnr.

PERFORM disp_header.

ELSE.

MESSAGE 'CLICK ON CUSTOMER NO FIELD' TYPE 'E'.

ENDIF.

Read only

Former Member
0 Likes
1,190

Hi

i am sending a sample code.

table:mara.

types:begin of st_mara,

matnr type matnr,

ernam type ernam,

end of st_mara.

data:wa_mara type st_mara,

it_mara type standard table of st_mara.

select-options:so_matnr for mara-matnr.

AT SELECTION-SCREEN ON so_matnr.

SELECT matnr

FROM mara

INTO wa_mara-matnr

WHERE matnr IN so_matnr.

ENDSELECT.

IF sy-subrc <> 0.

MESSAGE i002."here give message as this is not valid number and check the entries.

ENDIF.

Thnaks&Regards,

Chaithanya.