‎2006 Feb 16 7:16 AM
Hi all,
I'm writing a function module FM1 via SE37.
-
Data A type I.
Function FM1.
perform x.
Endfunction.
Form x.
....
Endform.
-
The system warned me that variable A has been defined,
is that becoz I've defined variable A in another function module within the same function group?
‎2006 Feb 16 7:19 AM
probably u might have define A in import paramers/ export parametrs
‎2006 Feb 16 7:20 AM
Declare A within the Function...Endfunction
Function FM1.
Data A type I.
perform x.
Endfunction.
Form x.
....
Endform.
‎2006 Feb 16 7:27 AM
You might have declared A globally in your Function Group. Hence you cant redeclare it.
‎2006 Feb 16 7:25 AM
hi Macy,
the warning is because you have the same variable name in a different FM of the same FG , defined globally..
to avoid error try to define it within
Function.
.....
Endfunction.
regards
satesh
‎2006 Feb 16 7:26 AM
hi,
if you are using same variables in different function modules in same group, i dont think there will be any problem. whereas the exporting importing and tables parameters should be different.
moreover, once you have declared a variable in any of the exporting, importing or tables column, you cannot declare it even in perform.
cheers
‎2006 Feb 16 8:09 AM
Hi macy,
1.
Data A type I.
Function FM1.
2. Why are u declaring varible
A
Before the FM declaratrion
3. Ideally it should be like this.
Function FM1.
Data A type I.
ENDFUNCTION.
regards,
amit m.
‎2006 Feb 16 8:14 AM
Hi macy,
1. If we declare any variable
before any function defitinoin,
(just like u have done)
2. Then, it is as good as
GLOBAL VARIABLE
(which can be accessed via all fm in that group)
3. Hence, your error is coming.
4. Either give another name to your variable,
or
change the POSITION of the variable definition,
(in the other FM)
5. ie.
WRITE BELOW THE FUNCTION DEFITNIION.
FUNCTION MYFUNC.
data :a type c. <----
.
.
.
ENDFUNCTION
6. not like this.
data :a type c. <----
FUNCTION MYFUNC.
.
.
.
ENDFUNCTION
regards,
amit m.
Message was edited by: Amit Mittal
‎2006 Feb 16 8:27 AM
Hi,
If it is declared in function group,just check whether it is available in l***top include.
Then only you can access it inside your function module.Otherwise you can declare it inside the new function module.
If you want the value from that function module,check whether the variable's value is exporting parameter in that FM.If so,call that function module inside your function module.
‎2006 Feb 16 8:36 AM
Hi,
you can declare it , i checked it fine.
data: a type i.
FUNCTION ZTESSTTT.
a = 10.
write a.
ENDFUNCTION.Regards
Vijay
‎2006 Feb 16 8:41 AM
Hi Macy,
i created another one in the same group, now it is telling that a already defined,if you define outside FUNCTION ENDFUNCTIOn then that means your declaration is gloabal , through out FUNCTION GROUP.
data a type i.
FUNCTION ZTESSTTT1.
ENDFUNCTION.Regards
vijay
‎2006 Feb 16 8:31 AM
Hi,
If it is declared in function group,just check whether it is available in l***top include.
Then only you can access it inside your function module.Otherwise you can declare it inside the new function module.
If you want the value from that function module,check whether the variable's value is exporting parameter in that FM.If so,call that function module inside your function module.