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

Function module data declaration part

naveen_inuganti2
Active Contributor
0 Likes
2,072

Hi....

I have 4 function modules in one of my function group.

Now my doubt is..

Can have All the data declarations of these 4 function modules in the TOP include of that function group, which is currently with sourse code of Fuction modules?

Now I want to go for this only to optimize my code!

Any problem with this in future?

As Iam not expert in this area, Please guide me in best way.

Thanks,

Naveen.I

1 ACCEPTED SOLUTION
Read only

vinod_vemuru2
Active Contributor
0 Likes
1,053

Hi Naveen,

Don't do all the declarations in the TOP include(As global parameters). It accupies global memory while executing!!!.

i.e When ever u execute any FM of this function group whole function group will be loaded to memory and memory will be allocated to all the declarations which is not recomended. If u r not using some data then why to allocate memory for that.

eg: If u r using itab1 in FM1 and itab2 in Fm2 then what is the need for allocating memory for itab2 when executing FM1.

Not only in function group, this applies every where.

If u r using some variable/constant/Internal table in multiple places then only declare it as global. Else better declare as local.

Hope it gave u some idea.

Thanks,

Vinod.

7 REPLIES 7
Read only

Former Member
0 Likes
1,053

Yes,you can declare all variables in TOP include of that function group.

It won't create any problem in future. But make sure that this TOP include is activated before activating any FM.

Regards,

Aparna Gaikwad

Read only

0 Likes
1,053

Hi.. Aparna, Shipli...

Thank you..very much.

Can expect Others attention on this with your valueble guidence.

Thanks,

Naveen.I

Read only

Former Member
0 Likes
1,053

There is no problem with this because this thing makes your code modularize.

But Once activate all function modules and function group.

Read only

Former Member
0 Likes
1,053

Hello Naveen,

Can have All the data declarations of these 4 function modules in the TOP include of that function group, which is currently with sourse code of Fuction modules?

You could have got an answer to this question by simply trying to put your declarations in the top include and then trying to activate your Function modules. No error would have meant the answer to your question is "Yes".

Anyways, the very purpose of having a top include for a function group is to have the common data for all the function modules declared in it.

If there is some data that could be used by more than one function modules of a group, then it makes sense to declare this in the top include. However, if there is only one function module that is going to use some data, it is always better to keep it in scope, that is to keep it local to the function module itself.

Future problems - only if tomorrow you decide to have the local data as global, you will have to make some changes. As long as the data is global, it can be used across all function modules and there will be no problems. Code optimization is secondary here, you need to decide on the scope of the data being declared and then declare it at the appropriate place.

hope that helps...

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,054

Hi Naveen,

Don't do all the declarations in the TOP include(As global parameters). It accupies global memory while executing!!!.

i.e When ever u execute any FM of this function group whole function group will be loaded to memory and memory will be allocated to all the declarations which is not recomended. If u r not using some data then why to allocate memory for that.

eg: If u r using itab1 in FM1 and itab2 in Fm2 then what is the need for allocating memory for itab2 when executing FM1.

Not only in function group, this applies every where.

If u r using some variable/constant/Internal table in multiple places then only declare it as global. Else better declare as local.

Hope it gave u some idea.

Thanks,

Vinod.

Read only

0 Likes
1,053

Hi... Vinod....

Say thanks to me... I brings you into 2000+....

Thanks alot for all of your attention.

So It must affects performance with this kind declartions as vinod said.

But, apart of this they is no issues.

And we hav to take care about data utility!

Thanks,

Naveeen Inuganti

Read only

0 Likes
1,053

Hi Naveen,

Itz gud that u r following Help the helper;):-)

Thanks,

Vinod.