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: 

variable problem in a function module

Former Member
0 Kudos

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?

11 REPLIES 11

hymavathi_oruganti
Active Contributor
0 Kudos

probably u might have define A in import paramers/ export parametrs

Former Member
0 Kudos

Declare A within the Function...Endfunction

Function FM1.

Data A type I.

perform x.

Endfunction.

Form x.

....

Endform.

0 Kudos

You might have declared A globally in your Function Group. Hence you cant redeclare it.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

jayanthi_jayaraman
Active Contributor
0 Kudos

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.

0 Kudos

Hi,

you can declare it , i checked it fine.

data: a type i.

FUNCTION ZTESSTTT.
a = 10.

write  a.

ENDFUNCTION.

Regards

Vijay

0 Kudos

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

jayanthi_jayaraman
Active Contributor
0 Kudos

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.