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 display error message

Former Member
0 Likes
10,360

hi all,

i'm new to abap, plz guide, i've one selection field on selection screen but that field is not existing in database, i declared it as data type p in my simple report , now i've to display error message using se91 if entry in that field is 0 or any invalid character , i'm not getting syntax what to write in report.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,038

Hi,

If there is already a message defined in the Message class using SE91, then u need to write the following code:

AT SELECTION-SCREEN on FIELD1.

if field1 = 0.

message e000(0k) with 'Invalid data'.

endif.

Here 000 is the message number and 0k is the message class. If u have a message defined in a message class, then u can use that.

Regards,

Himanshu

5 REPLIES 5
Read only

Former Member
0 Likes
2,039

Hi,

If there is already a message defined in the Message class using SE91, then u need to write the following code:

AT SELECTION-SCREEN on FIELD1.

if field1 = 0.

message e000(0k) with 'Invalid data'.

endif.

Here 000 is the message number and 0k is the message class. If u have a message defined in a message class, then u can use that.

Regards,

Himanshu

Read only

Former Member
0 Likes
2,038

Message <text> type 'A'.

Example:

Message 'This value not allowed' type 'A'.

Read only

Former Member
0 Likes
2,038

Hi

if you want display t he error messages then follw this procedure

use message class in ur program like this

REPORT ZNNR_REPORT NO STANDARD PAGE HEADING <b>MESSAGE-ID ZNNR</b> LINE-SIZE 100 LINE-COUNT 65(4).

diplsying messages like this

***************SCREEN VALIDATIONS *****************

at selection-screen.

SELECT SINGLE *

FROM EKKO

INTO EKKO

WHERE EBELN IN S_EBELN.

<b> IF SY-SUBRC <> 0.

SET CURSOR FIELD 'S_EBELN-LOW'.

MESSAGE E999 WITH TEXT-005.

ENDIF.</b>

********end of screen validation*****************

you can write any type eror messages here

<b>Reward if usefull</b>

Read only

Former Member
0 Likes
2,038

Hi,

Sample code

select hkont from bseg

into v_hkont

up to 1 rows

where hkont = o_hkont.

endselect.

if sy-subrc <> 0.

message e000 with 'G/L Account does not exist'(001).

endif.

Reward if useful.

Read only

dhruv_shah3
Active Contributor
0 Likes
2,038

Hi,

If you are selecting some records into internal table at that

you can check tht if there are no records then you can display like this.

IF SY-SUBRC <> 0.

MESSAGE 'NO RECORDS FOUND' TYPE 'E'.

ENDIF.

Regards,

Dhruv Shah