07-11-2007 7:02 AM
hi,
iam calling a function module into a pogram.the functionmodule generating a error message and it is coming out.
how to catch that error message into our program.
importing
return =
.
the above is the importing parameters from the function module.
please provide the necessary solution for this.
it is very urgent.............
thanks in advance.
07-11-2007 7:19 AM
Check for the EXCEPTIONS and handle them.
Regards,
Amit
Reward all helpful replies.
07-11-2007 7:22 AM
if u want to raise exceptuion u have to declare in Exceptions tab of the function module..
or if u want to get the error messages as oputput from the function module use Importing or Tables.
07-11-2007 7:22 AM
Check out this sample code
CALL FUNCTION 'ZAC_CALCULATE'
EXPORTING
IM_NUM1 = P_NUM1
IM_NUM2 = P_NUM2
IM_OPER = P_OPER
IMPORTING
EX_RESULT = W_RESULT
EXCEPTIONS
INVALID_OPERATOR1 = 1
ZERO_DIVIDE1 = 2
OTHERS = 3
.
IF SY-SUBRC EQ 0.
WRITE:/ 'RESULT IS', W_RESULT.
ELSEIF SY-SUBRC EQ 1.
WRITE:/ 'INVALID OPERATION'.
ELSEIF SY-SUBRC EQ 2.
WRITE:/ 'CANNOT DIVIDE BY ZERO'.
07-11-2007 7:27 AM
Hi,
If you want to show an error message and also want to catch it raise an exception along with the message.
Ex MESSAGE e001(zisa) raising <EXCEPTION>. Declare this exception in the exception tab of the Function module.
You can also use ERROR-MESSAGE if you just want to catch the message with out raisning the exception.
<b>Reward points</b>
Regards