01-23-2008 10:16 AM
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
01-23-2008 10:27 AM
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
01-23-2008 12:17 PM
01-24-2008 8:52 AM
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.
01-29-2008 6:04 AM
hi,
i also created a function module with same parameters and did not get any error.
what error are you getting?
01-29-2008 6:55 AM
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...
01-29-2008 9:10 AM
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
01-29-2008 9:18 AM
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