Skip to Content
avatar image
Former Member

Clear data present in ALV grid

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Dec 24, 2012 at 05:24 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Dec 24, 2012 at 07:00 AM

    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


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Dec 24, 2012 at 11:13 AM

    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"

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • avatar image
    Former Member
    Dec 26, 2012 at 11:51 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 26, 2012 at 02:32 PM

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 30, 2014 at 07:15 AM

    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

    Add comment
    10|10000 characters needed characters exceeded