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: 

MESSAGE command

Former Member
0 Kudos
604

Hi guys,

My report writes to the screen using the WRITE command,

Any errors that occur, I trigger using a MESSAGE xyyy command that would show the message in the status bar.

I'm trying to achieve the scenario where the following happens when an error occurs:

1) Error message is displayed

2) Program terminates

3) Whatever is written to screen using the WRITE command is shown

Under normal circumstances, using the MESSAGE command under START-OF-SELECTION with type 'E' (.eg. MESSAGE e001) causes the error message to appear in the status bar but does not show what has been written to screen (it just shows blank screen).

Is there any way (or alternatives to this) to achieve this?

Thanks<

Kevin

1 ACCEPTED SOLUTION

former_member588853
Active Contributor
0 Kudos
364

HI,

You can do like this, but this is funny..

data i type c value '2'.

if i <> 3.

write 'error'.

message I001(SAPABAPDOCU).

endif.

regards,

nazeer

Message was edited by:

nazeer shaik

10 REPLIES 10

former_member588853
Active Contributor
0 Kudos
365

HI,

You can do like this, but this is funny..

data i type c value '2'.

if i <> 3.

write 'error'.

message I001(SAPABAPDOCU).

endif.

regards,

nazeer

Message was edited by:

nazeer shaik

Former Member
0 Kudos
364

these 2 options are possible

1.change the message type to I(Information message) and use the statement

leave list proceesing to come back to the selection screen

START-OF-SELECTION.

MESSAGE I000......

LEAVE LIST-PROCESSING.

2.change the message type to I(Information message) and use the STOP statement which transfers the control to the end-of-selection event, where u can use ur WRITE statement to display the error message.

START-OF-SELECTION.

MESSAGE I000......

STOP.

END-OF-SELECTION.

WRITE : 'Error'.

Message was edited by:

Rajesh

kiran_k8
Active Contributor
0 Kudos
364

Kevin,

RSSNAPDL.

May be this SAP standard report can give you some lead.

K.Kiran.

Former Member
0 Kudos
364

You can't first display the message and then display the list.

It's because once the error message is called the program stops executing.

So, it's better to first use WRITE statement to write whatever you want to write and then trigger the message.

if 1 <> 2.

write : 'error'.

message 'error' type 'E'.

else.

write 'correct'.

endif.

You can check the code by debugging the program, first the list is displayed and then the message is displayed.

regards,

Pavan P.

Former Member
0 Kudos
364

Hi Kevin,

Try to write before error message and then only it may be possible.

Regards,

Atish

Former Member
0 Kudos
364

Hi Kevin,

Use this message command

MESSAGE I000(ZKEVIN).

ZKEVIN is the message class name, you can create it by SE91 T-code

IF USEFULL REWARD

Former Member
0 Kudos
364

Well you can display a message, and you can exit your program after that.

But how would you expect your program, which you terminated after the message, still to run and doing write statements?

Either you exit OR you can do additional stuff like write statements.

WHat you can do is:

make yourself an internal Table in which you put in line for line the same things you put out to screen using your write statements.

Then you can do a message Type I, which has the big pro that programm will continue once you clicked the ok button.

After that you can do a loop at your itab and writing all the reocords to screen.

Then Exit Program.

former_member235056
Active Contributor
0 Kudos
364

Hi,

U can double click on the messsage code e001 and write the description that u want to display and then u can terminate program using exit statement but do not forget to write these whole in if-else condition.

Pls do reward points.

Regards,

Ameet

Former Member
0 Kudos
364

Hi guys, wonderful 6 replies in 5 minutes!

I"ll award points accordingly.

Actually I AM already doing WRITEs before I call MESSAGE.

The following shows the <b>status bar warning</b> message, does not execute RETURN and does not show what has been written so screen.

WRITE ' ERROR'.
MESSAGE 'Directory not found.' TYPE 'W'.
RETURN.

The following shows the <b>status bar error</b> message, does not execute RETURN and does not show what has been written so screen.

WRITE ' ERROR'.
MESSAGE 'Directory not found.' TYPE 'E'.
RETURN.

The following shows the <b>pop up information</b> message, <b>executes</b> RETURN and <b>will show</b> what has been written so screen.

WRITE ' ERROR'.
MESSAGE 'Directory not found.' TYPE 'I'.
RETURN.

The only sad thing about the last option is that it shows up as an information message (green tick) and not a red cross sign. I guess thats what I trying to achieve.

Note: I use RETURN and not STOP.

0 Kudos
364

If you can work with the last option and you are running on Rel 6.10 or higher then you can use the following:

WRITE ' ERROR'.

MESSAGE 'Directory not found.' TYPE 'S' DISPLAY LIKE 'E'.

This will display what looks like an Error message with a red cross on the status bar, but behaves like a success message.