cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Selection INDEX

Former Member
0 Kudos

Hi,

How can i get the Index Number if an Item Selected on Webdynpro ALV Component.

Thanks and Regards,

SenthilPandi C

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

HI,

Use the following code to get the index of selected item.


   DATA lo_nd_node TYPE REF TO if_wd_context_node.
    DATA lo_el_node TYPE REF TO if_wd_context_element.
    DATA ls_node TYPE wd_this->element_node.
    DATA value type index.


*   navigate from <CONTEXT> to <NODE> via lead selection
    lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).

*   @TODO handle not set lead selection
    IF lo_nd_node IS INITIAL.
    ENDIF.

*   get element via lead selection
    lo_el_node = lo_nd_node->get_element(  ).

*   @TODO handle not set lead selection
    IF lo_el_node IS INITIAL.
    ENDIF.
    
    CALL METHOD LO_ND_NODE->GET_LEAD_SELECTION_INDEX
  RECEIVING
    INDEX  = value            " the variable value stores the index of selected element
    .
    
   

Former Member
0 Kudos

Thanks for answering.

I tried with the method GET_LEAD_SELECTION_INDEX.

But it does not returns the correct index. And it always returns a negative value....

Former Member
0 Kudos

Hi,

Where exactly have you written the code and what is your requirement actually.can you please brief it?

former_member199125
Active Contributor
0 Kudos

If table doesnt have lead selection, then get_lead_selection_index( ) will return negative value.

hope that in your node properties initialize lead selection property not checked. plz check that mark.

Regards

Srinivas

Former Member
0 Kudos

Srinivas,

Thanks for your reply.

There is no such property called lead selection for Node.

Did you mention the ALV Component Property?

Former Member
0 Kudos

I wrote this code on the Modify view method.

My requirement is to change the color and value of the Column which is selected and also some process for the selected line of ALV.

For this i need to know the index number of the selected line.

Former Member
0 Kudos

Hi,

I think you are reading the index of an empty node, Because the WDDOMODIFY method will be triggered at

start up of application after WDDINIT method and you are not filling the node in DOINIT. so you will be reading

the index of empty node which would be negative.

As you told you want to process the selected line of ALV you can get the lead selection in the

ON_LEAD_SELECT event of ALV, So remove your code from modify and write it here.

1)Create an event handler for on lead select event of ALV

2)go to methods tab and create new method with method type as event handler and click on F4 in the event

column and select ON_LEAD_SELECT event from the popup.

3) write your code into this method.

former_member199125
Active Contributor
0 Kudos
There is no such property called lead selection for Node.

Did you mention the ALV Component Property?

Check clearly for every node we have one property "initialize lead selection" . Check whether you selected this property or not.

And am talking about node which is binded to your normal table or alv table.

Regards

Srinivas

Former Member
0 Kudos

Thanks for you reply.

I will try this and let you know the result..

Former Member
0 Kudos

Hi,

Read the context node :

1. element = lonode->get_lead_selection( ), this will return the selected row content.

2. GET_LEAD_SELECTION_INDEX method of if_wd_context_node will return the index.

Thanks,

Shailaja Ainala.