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: 

How to use global variables of external program from function group?

Former Member
0 Kudos

Hey guys,

I have a program ZBR_PROGRAM and a function group ZBR_FUNCTIONGROUP. I would like to use the global variables of the ZBR_PROGRAM in the function modules of the ZBR_FUNCTIONGROUP, how could I achieve it. I tried to use the INCLUDE statement to include the top include of the ZBR_PROGRAM where the global variables are defined, but it does not work or probably I did it wrong. Remember, the ZBR_PROGRAM is not inside the ZBR_FUNCTIONGROUP.

Thank you, regards,

Róbert Birkus

4 REPLIES 4

NTeunckens
Active Contributor
0 Kudos

I think it is because of the FUNCTION-POOL in the TOP-Include, that you're unable to include this.

You might have to create a new Include in the FunctionGroup and put your "multiple-purpose" variables there.

Then you can include that one to your Custom Program without Syntax-Error while also allowing accessibilty from the FunctionGroup ...

Consider the below Example :

REPORT ztmp_testreport.

*INCLUDE lztmp_testfg_top. "TOP-INCLUDE Contains GT_RETURN
INCLUDE ztmp_testfg_multi. "ADDITIONAL INCLUDE Contains GT_MULTI_RETURN

REFRESH gt_multi_return.

Using the TOP-Include will not work to get Access to 'GT_RETURN', but the Additional Include will have Access to 'GT_MULTI_RETURN' ...

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

There is a documented trick in ABAP, but not recommended. Therefore, find it out ...

former_member182550
Active Contributor

Hmmm.

Firstly doesn't that tie your function module too closely to your program ? If you need to get at the global variables, why not make the FM a procedure in your program.

Another way round it would be to change your function group to a class and make the variables functional methods of the class so when you use them you can use them as you would variables, and yet they would still be available within the class.


Rich

0 Kudos

Yep, that would be the recommended way ...