cancel
Showing results for 
Search instead for 
Did you mean: 

Clear data in ALV grid

Former Member
0 Kudos

Dear Experts,

When i first click a search button. Based on selection, data get populated in the ALV grid. If i am going to press the search button once again, the new data

gets appended with the old data.

But the new data should overwrite a old data, by clearing the old data.

Can someone help me.

Thanks&Regards,

Santhosh

Accepted Solutions (1)

Accepted Solutions (1)

amy_king
Active Contributor
0 Kudos

Hi Santosh,

How are you populating the ALV? If you are using node->bind_table, you can specify set_initial_elements to true to replace the table's existing contents. Setting this parameter to false tells the method to append the new items rather than replace them.

   node->bind_table(
     new_items               = lt_data
     set_initial_elements = abap_true ).

Cheers,

Amy

Former Member
0 Kudos

Dear Amy,

Thanks for your response.

The mistake i did was i set the initial elements to abap_false.

   node->bind_table(
     new_items               = lt_data
     set_initial_elements = abap_false).

So once i set it to abap_true, the problem is resolved.

But can you help me how to clear a ALV grid completely, using some button action.

Because i have a requirement like, After Populating the ALV grid i should clear it using some button action.

amy_king
Active Contributor
0 Kudos

Hi Santhosh,

One option is to bind a table whose rows (if any) are initial...

    node->bind_table(
       new_items              = lt_initial_table
       set_initial_elements = abap_true).

Another option is to invalidate the node, causing it to be reinitialized, i.e., its supply function will be called again...

    node->invalidate( ).

Cheers,

Amy

Former Member
0 Kudos

Hi Amy,

node->invalidate( ).

Its helping me to clear the ALV grid.

Thank You.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Santhosh,

How are you binding data to your node?

Set_initial_elements attribute is by default set to abap_true in all relevant methods.

Have you created static mapping between DATA node of ALV and the node of your component controller?