Skip to Content

Hi all,

I saw many people asking how to do a multi-selection on a webdynpro ALV without using ctrl key.

First of all it isn’t a straight forward method but does the job.

So if you are in a situation where you have to do multi-selection without ctrl key, this document should help you.

Before I start this document I assume that you know how to create an ALV in webdynpro.

Step 1:Create an ALV and while initializing the ALV ( In my case its in WDDOINIT method ) set the selection mode as MULTI./wp-content/uploads/2013/05/doinit_221180.jpg

Step 2:Create a global table as an attribute to the controller.

global table.jpg

GT_INDEX is of type ZINDEX_T

ZINDEX_T has the line type ZINDEX_S

and ZINDEX_S has the structure:

/wp-content/uploads/2013/05/zindex_s_221182.jpg

Step 3:Implement the event handler method on_lead_select of the ALV

/wp-content/uploads/2013/05/select_method_221204.jpg

Step 4:Write the following code in the method.


DATA: ls_index TYPE zindex_s,
         lv_index TYPE i.
   DATA lo_nd_table_node TYPE REF TO if_wd_context_node.
   lo_nd_table_node = wd_context->get_child_node( name = wd_this->wdctx_table_node ).
   READ TABLE wd_this->gt_index WITH KEY idx = r_param->index TRANSPORTING NO FIELDS.
   IF sy-subrc = 0.
     DELETE wd_this->gt_index INDEX sy-tabix.
   ELSE.
     CLEAR ls_index.
     ls_index-idx = r_param->index.
     APPEND ls_index TO wd_this->gt_index.
   ENDIF.
   LOOP AT wd_this->gt_index INTO ls_index.
     lv_index = ls_index-idx.
     lo_nd_table_node->set_selected(
       EXPORTING
         flag  = abap_true    " Value with Which Property Is to Filled
         index = lv_index    " Index of Context Element
     ).
   ENDLOOP.

/wp-content/uploads/2013/05/select_221205.jpg

Now you go and click on the rows required without pressing ctrl key to select it and click again to deselect it.

/wp-content/uploads/2013/05/explorer_221206.jpg

Thank you.

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Sinem Kavraz

    Hello,

    When i try this code on my application , i get an error like this “

    “READ TABLE dbtab” is not supported in the OO context. Use “SELECT
    SINGLE * FROM dbtab INTO wa” wa”.

    How can i solve this problem ?

    Thanks in advance.

    (0) 
  2. Upendra Tarigopula

    Hello John,

    Good Document . But in this  after selection if i use the De Select all option to  de select the records i am getting the dump. Could you please help me regarding this error.

    Regards,

    Upendra.

    (0) 
    1. Consultora Request

      Hello Upendra,

      I would really like to know if you could fix your problem because I ended up in the same situation.

      I tried to disable the “de select all/select all” button but I couldn’t.
      Any help would be great.

      Thank you.

      (0) 

Leave a Reply