cancel
Showing results for 
Search instead for 
Did you mean: 

Clear data present in ALV grid

Former Member
0 Kudos

Dear Experts,

I select some data in select options and based upon the data selected, i get the data populated in the ALV grid.

Then by using the standard reset button of Selection options, i should be clear data in the select options as well as the data present in the ALV grid.

Can anyone help me

Thanks&Regards,

Santhosh

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

In order to solve this problem you will need some coding like this (this piece of code assumes an inherited class of cl_gui_alv_grid):

METHOD handle_usercommand.

     FIELD-SYMBOLS <my_gridtable> TYPE STANDARD TABLE.

     ASSIGN me->mt_outtab->* to <my_gridtable>.

     CLEAR <my_gridtable>.

     APPEND INITIAL LINE OF <my_gridtable>.

     me->refresh_table_Display(

          EXPORTING

               i_soft_refresh = 'X'

     ).

ENDMETHOD.

Yes, I know, this tread old and the last post is 18 month ago, but maybe someone else might find this solution helpful.

cheers,

Markus

0 Kudos

Make your ALV context node available in selection screen view and  use the below code. In below code node MARA is displayed in ALV.

    DATA lo_nd_mara TYPE REF TO if_wd_context_node.

    lo_nd_mara = wd_context->get_child_node( name = wd_this->wdctx_mara ).
    lo_nd_mara->invalidate( ).

singhmanishekhar
Explorer
0 Kudos

Dear Santhosh,,

           Consider, You Bounded the node Flight (car. 0-n). So, You create an event handler method say 'Reset' and write following code inside that method.

DATA lo_nd_flight TYPE REF TO if_wd_context_node.
DATA lt_flight TYPE wd_this->elements_flight.
   lo_nd_flight = wd_context->get_child_node( name = wd_this->wdctx_flight ).
   CLEAR lt_flight.
   lo_nd_flight->bind_table( new_items = lt_flight set_initial_elements = abap_true ).

Press F4 against this method in event column and select "on_reset" event of Section Component.

It will work fine, because I am referring from my implemented example.

singhmanishekhar
Explorer
0 Kudos

Dear Santhosh,

          If you asking about Web Dynpro  selection Option, then you can easily receive reset Event triggered on Selection Option and Write your code (will execute for Reset Event). Only your have to create an Event handler method and assign On_reset event of Select-option. Code written in that method will also execute. Here, you can clear bounded node (with ALV  Grid).

      

Refer SAP Example "WDR_TEST_SELECT_OPTIONS"

Former Member
0 Kudos

Hi manishekar,

Thanks for your reply

I have done this, but i need the code to be written to clear the data present in the ALV grid on this ON_RESET action.

Thanks&Regards,

Santhosh

Former Member
0 Kudos

HI SANTHOSH

in order to have a button like this , you will have to add a custom button in alv toolbar, simple push button wont work .

after that you can do the code for that button.

try this in the wddoinit method of the view:

***this will create a new button in the alv tolbar with name delete all

data lr_button type ref to cl_salv_wd_fe_button.

create object lr_button.

lr_button->set_text( 'delete all' ).

data button1 TYPE REF TO cl_salv_wd_function.

button1 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON' ).

button1->set_editor( lr_button ).

**now create a method in the same view of the type event handler and in the event column press F4 and select onfunction.

write code in this method :

DATA: temp TYPE string.

   temp = r_param->id.

   if temp = 'BUTTON'.

     WD_COMP_CONTROLLER->GET_DEL( ).

     endif.

declare this get_del in the component controller aand using nagical stick set a table operation for the same desired node , donot write any additional code in this method.

regards

vaibhav


Former Member
0 Kudos

Hi Vaibhav,

Thanks for your reply.

Can you tell me how to clear data present in an ALV grid.

Thanks&Regards,

Santhosh

Former Member
0 Kudos

hi santhosh

create a method in component controller by name get_del . use magical stick to fetch the code for the same using set on table operation . do not make any changes in the code.

in the view , create another method and under event column , press f4 and choose onfunction from the f4 help.

now write this code :

DATA: temp TYPE string.

   temp = r_param->id.

   if temp = 'BUTTON'.

     WD_COMP_CONTROLLER->GET_DEL( ).

     endif.

now activate and test .

when you will press the delete all button created above , it will remove all entries from the alv.

regards

vaibhav

Former Member
0 Kudos

Hi, could you explain in clear about your requirement. Either you need a button in selection screen which would used to clear the data or else need a button in application tool bar which will clear the grids data.

Former Member
0 Kudos

Hi Sudheer,

Thanks for your reply.

I just need to clear the data in the ALV grid when i click the Reset button in the select option.

Right now, when i click the reset button, its clearing the select option data. Now what i want is the same action should also clear the ALV grid data.

Thanks&Regards,

Santhosh

Former Member
0 Kudos

One thing i want to know that whether you kept reset button in selection screen

like the example in link http://help.sap.com/saphelp_nw04s/helpdata/en/9f/dba81635c111d1829f0000e829fbfe/content.htm .

or else button at application toolbar of selection screen.

Former Member
0 Kudos

Hi sudheer,

Thanks for your reply.

i have kept the reset buttonin the selection screen.

Can you please say me the code to clear the data present in the ALV grid.

Thanks&Regards,

Santhosh