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

Exception in RFC

Former Member
0 Likes
2,635

Hi,

could anybody tell me how to raise exception in RFC.If anybody can tell me with some example.

Thanks in advance.

Regards

Lalit

5 REPLIES 5
Read only

Former Member
0 Likes
1,583

hi..

Try to set some flag in rfc and after function call checkthe flag value and raise app error message

regards

vivek

Read only

Former Member
0 Likes
1,583

you can use the RAISE statement to raise an exception in a function module. the exception should be first defined in the exceptions tab in the function module.

after the fm is called, if the exception is raised, the value will be available in sy-subrc.

Example..

define an exception DATA_NOT_FOUND in the exceptions tab.

write a select query in the function module, if it returns sy-subrc as non-zero, then raise this exception.

select............<your select query>

if sy-subrc ne 0.

raise data_not_found.

endif.

in the calling program...

call function <function name>

exporting.....

importing....

EXCEPTIONS

DATA_NOT_FOUND = 1 (this number will depend on the order in which you have defined exceptions in exceptions tab...1 means it is defined first, 2 will stand

for the second exception)

in case the exception is raised, the value of

Edited by: Priyank Jain on Aug 14, 2008 4:56 AM

Read only

Former Member
0 Likes
1,583

I have written th exception in the exception tab..but when i run the function module its giving me dump.do I need to do something extra means write some code.

I have written the raise exception in the source code.

Regards

Lalit

Read only

0 Likes
1,583

you need to catch the exception also when calling your fm...

this is done through the EXCEPTIONS addition in the call function statement

....and i hope your raise exception statement is in the source code of FM and not in the calling program

Edited by: Priyank Jain on Aug 14, 2008 4:59 AM

Read only

Former Member
0 Likes
1,583

Hi,

Go to the exceptions tab and maintain some exception with short text.Suppose exception is exception1

Now in the source code,

write :

if sy-uname <> ' ABCD'.

raise exception1.

endif.

Thanks

Papiya