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

Issue with Global variable in FM

Former Member
0 Likes
3,648

Hi experts,

I have created  two functional modules under same function group and declared the internal table (ITAB)as global variable ,

i have populated the data to to  ITAB n first function module , and  These FM are used in a program , when i debug the program , the data is populated to 1st FM and but in  2nd function module the ITAB is null only internal table structure is available.

please let me know the reason.

Thanks NK

Hi experts,

I have created  two functional modules under same function group and declared the internal table (ITAB)as global variable ,

i have populated the data to to  ITAB n first function module , and  These FM are used in a program , when i debug the program , the data is populated to 1st FM and but in  2nd function module the ITAB is null only internal table structure is available.

please let me know the reason.

Thanks NK

8 REPLIES 8
Read only

nishantbansal91
Active Contributor
0 Likes
1,900

This message was moderated.

Read only

0 Likes
1,900

Hi Nishant,

thanks for the reply, where i need to create the local variable? is it inside the 2nd FM?

Thanks

Read only

Former Member
0 Likes
1,900

Hi NK,

The itab should be declared only once, in the TOP include of the function group.

Jim

Read only

vijayanandpaul_puvvula3
Active Participant
0 Likes
1,900

Hello NK,

In your FM use GOTO (In Menu)->Global Data.

At the end of the Include add your global table. It can then be used in both the FM's if you created them in same Function Group.

Regards,

Vijay.

Read only

0 Likes
1,900

thanks all, the program ( it also an FM)  ,which is calling the 2nd FM is in background mode, i think thats the reason ITAB values are not populated.

i ts working fine with IMPORT/EXPORT but my lead says it is not advisable and they are obsolete in ECC 6.0,

---> declated iTAB as global variable.

---> call FM1 --populate itab

call function " MAIN_FM" in update task.

   ---> fm2 cllaed in side MAIN_FM,   ( here values not populated)

please suggest global variable not filled incase of background mode.


thanks

NK

Read only

0 Likes
1,900

Hi NK,

The fact that the calling program runs in background mode would not have any effect on this.

You didn't mention before that the 2nd FM is called in update task - that's the reason your itab is empty.  That starts a separate session so no shared memory from the function group.  You would need to make the itab an importing parameter to the update function module and pass it from FM1.

Read only

0 Likes
1,900

Hi Jim,

thanks for your reply. can you explain more detail.

You would need to make the itab an importing parameter to the update function module and pass it from FM1.


Thanks

NK

Read only

0 Likes
1,900

You need to define an importing parameter in FM2 that can receive the contents of your itab.  Then you have to pass those values from your calling program.  If your calling program does not have access to those values, create an additional function module in the same function group that will return the itab contents.  This is all because when you call FM2 using IN UPDATE TASK, the update task does not have the same global variables available; so you have to provide them.

Jim