‎2011 Apr 08 6:18 AM
Hi Experts,
When i am trying to pass an internal table which is defined locally to the method set_table_for_first_display to the parameter it_outtab i am getting an error at the runtime displaying a pop-up message 'program errors: ALV internal table shoule be referred globally but not locally'. When i did declare the internal table globally the ALV is working good. Please explain the issue.
Thanks lot in advance.
Best Regards,
Ravi.
‎2011 Apr 08 6:37 AM
Hello Ravi,
Can you post the code which was giving the error? I am aware local internal tables give this error when passed to 'REUSE_ALV_GRID_DISPLAY'.
BR,
Suhas
‎2011 Apr 08 6:37 AM
Hello Ravi,
Can you post the code which was giving the error? I am aware local internal tables give this error when passed to 'REUSE_ALV_GRID_DISPLAY'.
BR,
Suhas
‎2011 Apr 08 6:51 AM
Hi Ravi,
have you defined the internal table locally within a form routine?
This internal table is only available while form routine is processed. ALV needs globally defined tables which are known after the generation of the report for creation of the field catalog. Locally defined tables are unknown!
Regards,
Klaus
‎2011 Apr 08 7:09 AM
>
> This internal table is only available while form routine is processed. ALV needs globally defined tables which are known after the generation of the report for creation of the field catalog. Locally defined tables are unknown!
Hello Klaus,
But we pass the fieldcatalog while calling the method SET_TABLE_FOR_FIRST_DISPLAY. I don't think displaying the ALV will pose any error if we pass a local internal table.
As a matter-of-fact i created a small test program & checked it out!
Your thoughts on this.
BR,
Suhas
‎2011 Apr 08 7:45 AM
The local table must be active in memory in same scope that the ALV is active. This seems obvious to me - for example, if you change the contents of a field in an editable ALV, the ALV must be able to refer to the internal table.
matt
‎2011 Apr 08 9:12 AM
>
> The local table must be active in memory in same scope that the ALV is active.
Yes, i too agree with you Matt. More so given the fact that the param IT_OUTTAB is a CHANGING param which is "passed by reference".
This seems obvious to me - for example, if you change the contents of a field in an editable ALV, the ALV must be able to refer to the internal table
I think even for sort & filter operations the ALV must be able to refer back to the internal table.
‎2011 Apr 11 7:51 AM
‎2011 Apr 13 10:53 PM
I believe that set_table_for_first_display only retains the reference to the table it is passed, and not the table itself. As a result, if the table is declared locally in a subroutine, when that subroutine ends, that memory will be deallocated and the reference is no longer valid.
Another thing to note is that if you pass a field-symbol to set_table_for_first_display, and later reassign that field symbol to a different table (global or otherwise), the newly assigned table will NOT be displayed in the ALV, because the reference used is to the table assigned when set_table_for_first_display is called.