Application Development and Automation 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: 
Read only

Error

Former Member
0 Likes
1,151

Hi,

i wrote the program to call the function module.

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.

EXCEPTION

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.

This is the error.

Statement "EXCEPTION" is not defined. Check your spelling . . . . . . .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
984

hi,

Remove this '.' from the code.

CALL FUNCTION 'ZAC_CALCULATE'
EXPORTING
IM_NUM1 = P_NUM1
IM_NUM2 = P_NUM2
IM_OPER = P_OPER
IMPORTING
EX_RESULT = W_RESULT.  " <-------here remove this full stop.
EXCEPTION
INVALID_OPERATOR1 = 1
ZERO_DIVIDE1 = 2
OTHERS = 3
.

Rgds

Reshma

9 REPLIES 9
Read only

Former Member
0 Likes
985

hi,

Remove this '.' from the code.

CALL FUNCTION 'ZAC_CALCULATE'
EXPORTING
IM_NUM1 = P_NUM1
IM_NUM2 = P_NUM2
IM_OPER = P_OPER
IMPORTING
EX_RESULT = W_RESULT.  " <-------here remove this full stop.
EXCEPTION
INVALID_OPERATOR1 = 1
ZERO_DIVIDE1 = 2
OTHERS = 3
.

Rgds

Reshma

Read only

0 Likes
984

Hi,

I had removed the fullstop, but it is giving the error for the nexrt line,

Unable to interpret "INVALID_OPERATOR1". Possible causes of error:Incorrect spelling or comma error.

Read only

0 Likes
984

HI,

PARAMETERS: p_test22(5) type c.

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

<b>EXCEPTIONS</b>"<----


you forgot to put the 'S' in 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.

Read only

Former Member
0 Likes
984

hi,

U closed the function module by keeping full stop after ex_result = wa_result.

Remove it and kREPORT 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

EXCEPTION

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.

Message was edited by:

Roja Velagapudi

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
984

HI,

Problem resolved.

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

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
984

Hi,

Use pattern(ctrl+F6) in ABAP Editor to call the function module 'ZAC_CALCULATE' and then pass the necessary parameters.

Read only

0 Likes
984

Hi,

I had used pattern to call the function module.

Read only

Former Member
0 Likes
984

hi,

how u wrote the code in ur function module.

u need to write like below.

define oper.

EX_RESULT = &1 &2 &3.

end-of-definition.

oper IM_NUM1 IM_OPER IM_NUM2.

rgds,

bharat.

Read only

0 Likes
984

Hi,

This is my source code in the function module and it is working fine.

CASE IM_OPER.

WHEN '+'.

EX_RESULT = IM_NUM1 + IM_NUM2.

WHEN '-'.

EX_RESULT = IM_NUM1 - IM_NUM2.

WHEN '*'.

EX_RESULT = IM_NUM1 * IM_NUM2.

WHEN '/'.

EX_RESULT = IM_NUM1 / IM_NUM2.

WHEN '%'.

EX_RESULT = IM_NUM1 MOD IM_NUM2.

WHEN OTHERS.

ENDCASE.

IF IM_NUM2 = 0.

WRITE:/ 'CANNOT DIVIDE BY ZERO'.

ENDIF.

ENDFUNCTION.