2007 Jul 20 3:15 PM
2007 Jul 20 4:42 PM
Hi,
<b>Here is an exemple.</b>
FUNCTION FM_EXEMPLE.
*"----
*" TABLES
*" TI_EX STRUCTURE ZRTEROU OPTIONAL
*" EXCEPTIONS
*" NOT_FOUND
*"----
IF TI_EX[] IS INITIAL.
RAISE not_found.
ENDIF.
ENDFUNCTION.
<b>The Calling.</b>
CALL FUNCTION 'FM_EXEMPLE'
TABLES
ti_ex = <table>
EXCEPTIONS
not_found = 1
OTHERS = 2.
CASE sy-subrc.
WHEN 1.
...
WHEN 2.
...
ENDCASE.
2007 Jul 20 3:17 PM
Hi,
You can use the Exceptions to handle the errors
There are two ABAP statements for raising exceptions. They can only be used in function modules:
RAISE <except>.
and
MESSAGE..... RAISING <except>.
The effect of these statements depends on whether the calling program handles the exception or not. If the name <except> 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.
Regards
Sudheer
2007 Jul 20 3:18 PM
Hi, you can define exception and throw the exception with the command 'RAISE'.
2007 Jul 20 4:42 PM
Hi,
<b>Here is an exemple.</b>
FUNCTION FM_EXEMPLE.
*"----
*" TABLES
*" TI_EX STRUCTURE ZRTEROU OPTIONAL
*" EXCEPTIONS
*" NOT_FOUND
*"----
IF TI_EX[] IS INITIAL.
RAISE not_found.
ENDIF.
ENDFUNCTION.
<b>The Calling.</b>
CALL FUNCTION 'FM_EXEMPLE'
TABLES
ti_ex = <table>
EXCEPTIONS
not_found = 1
OTHERS = 2.
CASE sy-subrc.
WHEN 1.
...
WHEN 2.
...
ENDCASE.