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

set_table_for_first_display

Former Member
0 Likes
1,225

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.

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,158

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

7 REPLIES 7
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,159

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

Read only

Former Member
0 Likes
1,158

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,158

>

> 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

Read only

matt
Active Contributor
0 Likes
1,158

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,158

>

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

Read only

Former Member
0 Likes
1,158

Thank you Experts for your valuable inputs.

Read only

alex_campbell
Contributor
0 Likes
1,158

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.