2007 Jul 10 12:30 PM
hI,
This is my program.
REPORT ZAC_TAB25.
PARAMETERS:
P_NUM1 TYPE I,
P_NUM2 TYPE I,
P_OPER TYPE C.
DATA:
W_RESULT TYPE I.
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'.
ELSE.
WRITE:/ 'UNKNOWN EXCEPTION'.
ENDIF.
Here when i am giving Invalid operator, it is giving result as zero instead of getting message as Invalid operator.
2007 Jul 10 12:33 PM
when zero , it will print the w_result value , so it will be 0
when it is 1 , it will give output as INVALID OPERATOR, chk in debugging
2007 Jul 10 12:33 PM
Try to remove the comments on the exception and the 3 parameters returned by exception.
Message was edited by:
Anish Thomas
2007 Jul 10 12:33 PM
when zero , it will print the w_result value , so it will be 0
when it is 1 , it will give output as INVALID OPERATOR, chk in debugging
2007 Jul 10 12:43 PM
HI,
Remove the Commented Exceptions parametrs.
It will work.
Regards,
Nandha
2007 Jul 10 12:47 PM
Hi,
Try now
REPORT ZAC_TAB25.
PARAMETERS:
P_NUM1 TYPE I,
P_NUM2 TYPE I,
P_OPER TYPE C.
DATA:
W_RESULT TYPE I.
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'.
ELSE.
WRITE:/ 'UNKNOWN EXCEPTION'.
ENDIF.
Regards,
Sesh
2007 Jul 10 1:27 PM
Hello Ram,
Always when you use FM ,then try to uncomment exceptions,so that you will have sy-subrc value.
some times based on exception we write the code ...
Thanks
Seshu