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: 

Messages in abap program

Former Member
0 Kudos

Hi All,

When iam using a message type as 'W' (Warning) in my program , the output is not showing the warning message , instead it showing the error message . Can any one solve my doubt . Plz tell me the explanations for my problem .

My Sample Code :

DATA: BEGIN OF structure,

name(10) TYPE c,

age TYPE i,

place(10) TYPE c,

END OF structure.

DATA : wa LIKE structure,

itab LIKE structure OCCURS 0.

DATA : v_var TYPE i .

*BREAK-POINT.

wa-name = 'raj'.

wa-age = 26.

wa-place = 'bangalore'.

APPEND wa TO itab.

CLEAR wa.

wa-name = 'praveen'.

wa-age = 23.

wa-place = 'chennai'.

APPEND wa TO itab.

CLEAR wa.

READ TABLE itab INTO wa WITH KEY name = 'TAJ'.

IF sy-subrc = 0.

WRITE : / wa-name,

wa-age,

wa-place.

ELSEIF sy-subrc = 4.

MESSAGE text-001 TYPE 'W'.

ENDIF.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

Warning message can be used at AT SELECTION-SCREEN event, not in START-OF-SELECTION: here you should use a message I.

Max

5 REPLIES 5

Former Member
0 Kudos

Hi

Warning message can be used at AT SELECTION-SCREEN event, not in START-OF-SELECTION: here you should use a message I.

Max

0 Kudos

Thank you. I got the idea . Its right that warning message will work only in selection-screen .

Former Member
0 Kudos

HI,

have you activated you code properly?

if yes try this

message w001.

double click on 001 and maintain the msg in this case you will get the desired.

or else use msg type I ie information message

thanks

vivekanand

Former Member
0 Kudos

hi,

Plz dont specify sy-subrc = 4 in elseif.

simply do it like

IF sy-subrc = 0.

WRITE : / wa-name,

wa-age,

wa-place.

ELSE.

MESSAGE text-001 TYPE 'W'.

ENDIF.

Reward if useful

Thanks,

Gaurav

former_member404244
Active Contributor
0 Kudos

Hi,

Warning messages can be used at only at (AT SELECTION-SCREEN) event.I ahve modified ur code and checked it worked.

DATA: BEGIN OF structure,

name(10) TYPE c,

age TYPE i,

place(10) TYPE c,

END OF structure.

DATA : wa LIKE structure,

itab LIKE structure OCCURS 0.

DATA : v_var TYPE i .

parameters : p_raj like mara-matnr.

*BREAK-POINT.

wa-name = 'raj'.

wa-age = 26.

wa-place = 'bangalore'.

APPEND wa TO itab.

CLEAR wa.

wa-name = 'praveen'.

wa-age = 23.

wa-place = 'chennai'.

APPEND wa TO itab.

CLEAR wa.

at selection-screen.

READ TABLE itab INTO wa WITH KEY name = p_raj.

IF sy-subrc = 0.

WRITE : / wa-name,

wa-age,

wa-place.

ELSEIF sy-subrc = 4.

MESSAGE text-001 TYPE 'W'.

ENDIF.

Regards,

Nagaraj