‎2008 Aug 14 9:50 AM
Hi,
could anybody tell me how to raise exception in RFC.If anybody can tell me with some example.
Thanks in advance.
Regards
Lalit
‎2008 Aug 14 9:52 AM
hi..
Try to set some flag in rfc and after function call checkthe flag value and raise app error message
regards
vivek
‎2008 Aug 14 9:56 AM
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
‎2008 Aug 14 9:58 AM
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
‎2008 Aug 14 9:59 AM
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
‎2008 Aug 14 9:59 AM
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