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: 

iNVALID OPERATOR.

Former Member
0 Kudos
119

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
61

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

5 REPLIES 5

former_member150733
Contributor
0 Kudos
61

Try to remove the comments on the exception and the 3 parameters returned by exception.

Message was edited by:

Anish Thomas

Former Member
0 Kudos
62

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

Former Member
0 Kudos
61

HI,

Remove the Commented Exceptions parametrs.

It will work.

Regards,

Nandha

0 Kudos
61

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

Former Member
0 Kudos
61

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