Skip to Content

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

Dec 22, 2016 at 11:06 AM


avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Richard Harper Dec 22, 2016 at 02:59 PM


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.


Show 1 Share
10 |10000 characters needed characters left characters exceeded

Yep, that would be the recommended way ...

Nic Teunckens Dec 22, 2016 at 02:00 PM

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

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' ...

10 |10000 characters needed characters left characters exceeded
Horst Keller
Dec 22, 2016 at 02:33 PM

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

10 |10000 characters needed characters left characters exceeded