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: 

error in function module

Former Member
0 Kudos

Hi,

I want to create a function module which adds two numbers

n1, n2 and should get the result n3 = n1 + n2. I tried creating the FM in the following way but i got error. Kindly rectify.

In the import parameters

parameter name typing associated type

N1 TYPE I

N2 TYPE I

export parameters

N3 TYPE I

Source code

FUNCTION ZY.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(N1) TYPE I

*" VALUE(N2) TYPE I

*" EXPORTING

*" REFERENCE(N3) TYPE I

*"----


N3 = N1 + N2.

ENDFUNCTION.

regards,

mahathi

7 REPLIES 7

Former Member
0 Kudos

Hi,

while cresting fm after providing importing and exporting parameters in the source code write logic n3 = n1 + n2

and then call it in executable program

regards

former_member282823
Active Participant
0 Kudos

can you tell me what error you got...

Former Member
0 Kudos

See mahati,

jus put the flag for export parameter

i.e.enable the checkbox for pass by value in export parameter

this is the sample code

REPORT ZSYAM_F1.

parameters:a1 type i,

a2 type i.

data:a3 type i.

CALL FUNCTION 'ZSYAM_FM1'

EXPORTING

N1 = a1

N2 = a2

IMPORTING

N3 = a3

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

write:/ a3.

Former Member
0 Kudos

hi,

i also created a function module with same parameters and did not get any error.

what error are you getting?

Former Member
0 Kudos

Mahathi,

I thing you might not activated your function group.

First check with your fucntion group .

To activate Function group.

tcode se37 ->on menu bar "Environment"->Inactive objects--Function groups>select your Function group> press activate (ctrl+F8).

Don't forget to reward if useful...

Former Member
0 Kudos

hi there,

do one thing activate all the object function module function group.

just double click on the errors what you are gettinmg and just activate all the inactive object.

chose ACTIVATE ANYWAYS

if you get a error.

hope this might help

i have made a F.M to check the outcome.

anuj

reward point if helpful

Former Member
0 Kudos

hi,

this is in report:

REPORT FMXXXX..

parameters:op1 type i,

op2 type i.

data: sum type i.

CALL FUNCTION ZFM1'

EXPORT

N1 = op1

N2 = op2

IMPORT

N3 = sum.

write:/ op1, '+' ,op2 , '=', sum.

in function module what u declared as same

try this

reward if its useful