Skip to Content
avatar image
-2
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Dec 22, 2016 at 02:59 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

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

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 22, 2016 at 02:33 PM

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

    Add comment
    10|10000 characters needed characters exceeded