cancel
Showing results for 
Search instead for 
Did you mean: 

click event on ALV

Former Member
0 Kudos

hi everyone

I have an ALV, where data is displayed

now if i select a row in this ALV, another ALV shd be displayed based on that row key field

can somebody plz tell me the steps as how i shd proceed

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Anjali,

Write a method subscribing to event 'ON_LEAD_SELECT' of first ALV.

You get two parameters for that method (WDEVENT, R_PARAM)

Now use the below code to read the lead selected row contents.

* get element via lead selection
  elem_search_results = node_search_results->get_element( r_param->index ).

* get all declared attributes
  elem_search_results->get_static_attributes(
    IMPORTING
      static_attributes = stru_search_results ).

  if stru_search_results-key_field = requred value  "your condition
      "populate the table of other alv and bind it to context.
  endif.

Regards,

Manne.

Former Member
0 Kudos

can both ALV be on a single view?

Former Member
0 Kudos

Hi,

Yes, it can be on a single view but your should have different VIEWUIELEMENT CONTAINERS for both.

You can also have it in diff views but you have to use plugs for navigation in this case.

Regards,

manne.

Former Member
0 Kudos

yes ive created 2 different viewUIElement

i have created an event handler ONCLICK in the COMPONENTCONTROLLER to deal with the on click event

but then i dnt know how to say on click event of ALV 1, display content in ALV2?

can u help?

Former Member
0 Kudos

Hi,

As i said in my above reply, create a method for EVENT ON_LEAD_SELECT of alv1.

This will be triggered by framework when any entry is selected in the first alv.

In that method write the below code to read the contents of selected row. That is in your case, you have to read primary key and then bind the second alv table in the same method.

* get element via lead selection
  elem_search_results = node_search_results->get_element( r_param->index ).

  elem_search_results->get_static_attributes(
    IMPORTING
      static_attributes = stru_search_results ). "reading the selected row

 " Now check your condition here 
if stru_search_results-key is satisfied.
   "prepare the second table data
   "bind it to context node mapped to second alv.
endif.

In the window, embed view into these two UI ELEMENT CONTAINERS

Former Member
0 Kudos

When im embedding both View UI Element in the Windows component

its giving me the error :

View table is already displayed in Window ZZ_00_test

its because both are ALV?

Former Member
0 Kudos

Hi,

How are you creating ALVs.

Don't use the same ALV. Give the names as ALV_FIRST and ALV_SECOND.

Map the DATA nodes of these 2 ALVs to the Node(table that you want to bind).

In the view create 2 VCU(view container elemetns).

In the Window Controller->context->Embed the views(table of each) ALV in respective VCU.

Now you have got 2ALvs and there could be no problem.

You can embed any number of ALVs but the names( or instances) should be different.

I think same ALV cant be embeded in the Window context more than once.

Try this.

Regards,

Lekha.

Former Member
0 Kudos

thanks Lekha

working now

Answers (4)

Answers (4)

uday_gubbala2
Active Contributor
0 Kudos

So now I have satisfied the first condition of data from MARA being displayed in the 1st ALV. I now need to be able to fetch & display the corresponding data from MAKT for ever row being selected in the first ALV. For this I go to the "methods" tab of my view & create an eventhandler method for the event ON_LEAD_SELECT of my ALV1. I then place the below coding within my eventhandler method:

METHOD on_alv1_select .
  DATA: lv_index TYPE i VALUE 0,
        lt_makt TYPE wd_this->elements_makt,
        ls_mara TYPE wd_this->element_mara,
        wd_node TYPE REF TO if_wd_context_node.

  wd_node = wd_context->get_child_node( name = 'MARA' ).

  CALL METHOD wd_node->get_static_attributes
    EXPORTING
      index             = r_param->index
    IMPORTING
      static_attributes = ls_mara.

  SELECT * FROM makt INTO CORRESPONDING FIELDS OF TABLE lt_makt WHERE matnr = ls_mara-matnr.

  wd_node = wd_context->get_child_node( name = 'MAKT' ).

  wd_node->bind_table( new_items = lt_makt ).
ENDMETHOD.

Thats it! Your component is all done. Hope that this helps resolve your problem.

Regards,

Uday

uday_gubbala2
Active Contributor
0 Kudos

Hi Anjali,

I will try to explain your scenario using an example. Suppose I am displaying the data from MARA in 1 ALV & when I select a row (LeadSelection) from the ALV I want the corresponding information from MAKT to be displayed in a 2nd ALV below.

So for this first of all I would need to create 2 component usages:

So I go to the, "Used web Dynpro Components" of my component and create 2 entries of SALV_WD_TABLE: ALV1 & ALV2.

Next I create 2 context nodes MARA & MAKT with a few attributes under each.

1) I go to the "properties" tab of my view & add the used components ALV1 & ALV2.

2) I go to my view layout and place 2 viewcontainer ui elements over it.

3) Next I embed my MAIN view within my WINDOW. I then embed the TABLE view of ALV1 within my first viewcontainer & the TABLE view of ALV2 within my 2nd viewcontainer.

4) I create interface controller usages & map the MARA node to the DATA node of ALV1 & similarly i map the MAKT node with the DATA node of ALV2.

I fill the data for my first ALV within my WDDOINIT method as shown below:

METHOD wddoinit .
  DATA: wd_node TYPE REF TO if_wd_context_node,
        lt_mara TYPE wd_this->elements_mara.

  wd_node = wd_context->get_child_node( name = 'MARA' ).
  SELECT * FROM mara INTO CORRESPONDING FIELDS OF TABLE lt_mara.
  wd_node->bind_table( new_items = lt_mara ).
ENDMETHOD.

Former Member
0 Kudos

Hi,

Implement the ON_LEAD_SELECT event for the ALV and write the required code to populate the second ALV in that method.

Regards,

Radhika.

former_member230839
Participant
0 Kudos

Hi Anjali,

The same way you are displaying the first ALV do the calucaltion of child records from the child table based on the selected record in the first alv. Bind it to the second ALV so that on lead selection of FIrst ALV you have to write the code for binding the second ALV.

REgards,

Anil kumar G