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

Messages in abap program

Former Member
0 Likes
2,021

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
Read only

Former Member
0 Likes
860

Hi

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

Max

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.

5 REPLIES 5
Read only

Former Member
0 Likes
861

Hi

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

Max

Read only

0 Likes
860

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

Read only

Former Member
0 Likes
860

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

Read only

Former Member
0 Likes
860

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

Read only

former_member404244
Active Contributor
0 Likes
860

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