Application Development 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: 

catching an error message from function module

Former Member
0 Kudos

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.

4 REPLIES 4

amit_khare
Active Contributor
0 Kudos

Check for the EXCEPTIONS and handle them.

Regards,

Amit

Reward all helpful replies.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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'.

Former Member
0 Kudos

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