cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

raising error message in a programme

Former Member
0 Likes
32,669

Dear All,

I need to know a way in order to raise an error message in programme i.e when there is an error in the programme and if I run this program it should raise an error message.

With Regards,

Madhu.S.N

Accepted Solutions (0)

Answers (10)

Answers (10)

Former Member
0 Likes

Hi Madhu,

The ABAP runtime environment handles messages according to the type declared in the MESSAGE statement and the context in which the message was sent. The following message types exist:

A - Abend : Transaction terminated

E - Error : Error message

I - Info : Information

S - Status : Status message

W - Warning : Correction possible

X - Exit : Transaction terminated with short dump

The message appears in a dialog box and the program terminates. When the user has confirmed the message, control returns to the next- highest area. All the internal sessions are deleted from the stack.

1) MESSAGE E0004(Message class) WITH 'Hugo'.

2) MESSAGE 'File not found.' TYPE 'E'.

The text 'File not found.' is output as the error

message.

Regards,

Shakuntala

Message was edited by: shakuntala Negi

hymavathi_oruganti
Active Contributor
0 Likes

THE EASIEST SYNTAX IS

MESSAGE 'ERROR' TYPE 'E'.

MESSAGE 'XXXXXXXXXXXXXXX' TYPE 'W'.

.............

MESSAGE <'MESSAGE'> TYPE <'S'/'I'/'E'/'W'/'A'/'X'>

Former Member
0 Likes

Hi,

write the statement :

message E001 with text-001.

Depending on the program context, an error dialog appears

here the program stops because of the eerror message, if you correct that and reexecute then this will work.

whateer you give in the TEXT-001, that will come as a message, and this message will show in the status bar...

if you write this in the selection screen : -

Selection screen processing terminates, and the selection screen is redisplayed. The screen fields specified through the additions to the AT SELECTION-SCREEN statement are ready for input. The user must enter a new value. The system then restarts the selection screen processing using the new values. You cannot use error messages with the ON HELP-REQUEST or ON VALUE-REQUEST additions. Instead, a runtime error occurs.

Regards

Sudheer

Former Member
0 Likes

Hi Madhu,

Following program will be useful to know how to display a message whenever the program encounters a error according to cortain condition.

data: z type i.

parameters: x type i,

y type i.

if x = space or y = space.

MESSAGE E000(ZVAI).

  • enter valuse in all required fields.

endif.

z = x + y.

write:/ 'The sum is ', z.

To select a message from a message class, you have to create a message class first and then samve some messages in that class using SE91.

Then in the program, to display the message between if and endif statements, click the PATTERN button and select the MESSAGE radio button and enter the required details there.

Hope this will be useful for you.

Regards,

Vaitheeswaran

Former Member
0 Likes

Hi,

As per my understanding to your doubt,

You can use 'if sy-subrc <> 0' and raise an error message with message id including 'E'.

regards

Rakesh

Former Member
0 Likes

Hi,

Check out help on Keyword 'Message', u will get the detailed info about it's usage.

Regds,

Akshay

Former Member
0 Likes

Hi Madhu,

When do u want to raise an error? Under what conditions?

VJ

naimesh_patel
Active Contributor
0 Likes

Hello Madhu,

If you run the program with syntax error, system is giving error.

What type of checking you need. ?

Regards,

Naimesh

Former Member
0 Likes

Dear Naimesh

My question is that the program is syntatically correct and when i run the program if any run time error occurs i

have raise a message in common words.

With Regards,

Former Member
0 Likes

Hi

See the previous answers, you can use the message nr. 208 of class 00.

This message contains only & and you can replace it with your message:

IF ERROR

MESSAGE E208(00) WITH 'ERROR!!!'.

ENDIF.

Max

athavanraja
Active Contributor
0 Likes

runtime error can happen for different reasons. and if you dont catch them throw proper messages the system will dump.

to catch errors you have to use try catch block.

for example if you are are doing a multiplication you know it for sure that the if the parameters are not numbers you will get convert_no_number error. to catch that you have to do that within try catch block to catch the error.

check out this link for more info.

http://help.sap.com/saphelp_nw04/helpdata/en/a9/b8eef8fe9411d4b2ee0050dadfb92b/frameset.htm

Regards

Raja

Reward points to helpful answers by choosing appropriate radiobutton in the answers.

naimesh_patel
Active Contributor
0 Likes

Hello Madhu,

You can catch some runtime errors by CATCH SYSTEM-EXCEPTIONS except1 = rc1 ... exceptn = rcn.

But Not all...!!

Refer the help on CATCH..

Regards,

Naimesh

Former Member
0 Likes

Hi ,

If <some condition>

message E000 with 'error message'.

endif.

Regards,

GSR.

Former Member
0 Likes

Hi

Use message statament for a message of type E or A (if you want a abend message)

IF ERROR

MESSAGE E.....

ENDIF.

Max