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

Raising exception issue

senthil_kumar29
Participant
0 Likes
2,640

Hi Guys,

I would like to know the difference between following statements

RAISE NO_BODY_FOUND

and

MESSAGE e300 RAISING NO_BODY_FOUND.

Is that the first statement produce dump error while the other log an error message ?

Thanks

Senthil

Hi Guys,

I would like to know the difference between following statements

RAISE NO_BODY_FOUND

and

MESSAGE e300 RAISING NO_BODY_FOUND.

Is that the first statement produce dump error while the other log an error message ?

Thanks

Senthil

8 REPLIES 8
Read only

former_member156446
Active Contributor
0 Likes
1,681

RAISE .

Only occurs in function modules and methods. Terminates processing and raises an exception defined in the interface.

[RAISE EXCEPTION ref. In this case, the exception object must already exist and the REF reference variable must point to it.|http://help.sap.com/saphelp_nw04/helpdata/EN/83/636d2012fc11d5991e00508b5d5211/content.htm]

Read only

0 Likes
1,681

Hi,

Thanks for the answer.

If I am calling a FM, and don't handle the exception it will through a dump right?

Here is the sample code which is throwing a dump error.

CALL FUNCTION 'Z_HR_SUPERIOR_ROLE'

EXPORTING

otype = 'P'

sobid = v_sobid

IMPORTING

supervisor = v_supervisor.

IF sy-subrc EQ 0.

PERFORM: get_email_addr USING v_supervisor v_sup_addr.

IF v_sup_addr <> space.

CLEAR i_receivers. "WIl03Y

i_receivers-rec_type = 'U'.

i_receivers-receiver = v_sup_addr.

APPEND i_receivers.

ENDIF.

In fact this FM module have the following exceptions

EXCEPTIONS

NOBODY_FOUND

UNKNOWN_DELEGTYPE

NO_ACTIVE_PLVAR

ERROR

When this FM returns exception its dumping.

Thanks

Senthil

Read only

0 Likes
1,681

Hi,

you should add the exceptions part else it will dump in case of any exceptions raised by the FM:

CALL FUNCTION 'Z_HR_SUPERIOR_ROLE'

EXPORTING

otype = 'P'

sobid = v_sobid

IMPORTING

supervisor = v_supervisor

EXCEPTIONS

NOBODY_FOUND = 1

UNKNOWN_DELEGTYPE = 2

NO_ACTIVE_PLVAR = 3

ERROR = 4

OTHERS = 5.

if sy-subrc = 0.....

Even if you do not handle the sy-subrc case for the exceptions, it does not matter. But the exceptions declarations need to be there.

Edited by: Dev Parbutteea on Apr 17, 2009 7:12 AM

Read only

0 Likes
1,681

you will use the exception like this:

i_receivers-receiver = v_sup_addr.
APPEND i_receivers.
if sy-subrc NE 0.
raise exception <exception name>.
endif.
ENDIF.

Read only

Former Member
0 Likes
1,681

Raise.

Will be used in FM's to cature the error situations. Based on the exception raised, it'll assign teh sy-subrc value.

Other one is a normal error message raising in the programs (direct).

Read only

Former Member
0 Likes
1,681

hi,

RAISE.

is used in Function modules any unexpected results occurred and in methods also used for same purpose .

message as u no it will be used in condition to display the status .

Read only

Former Member
0 Likes
1,681

There are two ABAP statements for raising exceptions. They can only be used in function modules:

RAISE .

and

MESSAGE..... RAISING .

The effect of these statements depends on whether the calling program handles the exception or not. If the name of the exception or OTHERS occurs in the EXCEPTIONS addition of the CALL FUNCTION statement, the exception is handled by the calling program.

If the calling program does not handle the exception

The RAISE statement terminates the program and switches to debugging mode.

The MESSAGE ..... RAISING statement display the specified message. How the processing continues depends on the message type.

If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE ..... RAISING statement does not display a message. Instead, it fills the system fields SY-MSGID, SY-MSGTY, SY-MSGNO, and SY-MSGV1 to SY-MSGV4.

An ABAP/4 module lets the system know that an error has occurred by issuing information,error or warning messages. you can also use success messages when a particular action is performed successfully. When the user presses ENTER, the current process is interrupted. The system returns the user to the SAP main menu using Abend message.

Message is displayed using MESSAGE Xnnn, where X is the type of the message and nnn is the number of the message.

You have to declare the Id of the message class in the program using

MESSAGE-ID cc,where cc is the message class.

Read only

senthil_kumar29
Participant
0 Likes
1,681

Thanks Guys.. Solved.