cancel
Showing results for 
Search instead for 
Did you mean: 

ALV and WDDOBEFOREACTION

Former Member
0 Kudos

Hi all,

in my component I have a view with many buttons (buttonview) and a view usage with ALV_TABLE view (tableview) embedded.

Users can select different rows from table and then select one of the button.

Each button should perform an action on the selected rows.

My requirement is to perform some check about the action and the rows selected (to check compatibility) and I thought the right place to do this is in WDDOBEFOREACTION of buttonview. However using method get_selected_elements for the node binded with table returns only lead selection.

Any suggestion?

Thanks,

Stefano

Accepted Solutions (1)

Accepted Solutions (1)

Madhu2004
Active Contributor
0 Kudos

HI Stefan,

I replicated the same and it is working for me.When you select multiple rows in the ALV table using the CTRL key are they getting selected.If not please check the selection cardinality property of the node you have binded to DATA node of ALV.It should have 0..n.

Regards,

Madhu.

Former Member
0 Kudos

>

> HI Stefan,

>

> I replicated the same and it is working for me.When you select multiple rows in the ALV table using the CTRL key are they getting selected.If not please check the selection cardinality property of the node you have binded to DATA node of ALV.It should have 0..n.

>

> Regards,

> Madhu.

Hi Madhu,

node cardinality and node selection is set to 0:n and Initialize lead selection is checked.

In on a ECC6.0 with SAP_ABA SP17 and SAP_BASIS SP17... what about you?

Thanks,

Stefano

Former Member
0 Kudos

In order to get all the row selected you can do either in the button action (which I think is better because in the beforeAction it will gets trigger before any action in your view not only the action that you want)

You need to loop your context node selection including your lead selection, please see the following code please note that my context node name is ALV_PREAWARD_WL:

TYPES: BEGIN OF ty_object_id,

object_id TYPE wd_this->element_alv_preaward_wl-object_id,

END OF ty_object_id.

DATA: ty_object_id_confirm TYPE STANDARD TABLE OF ty_object_id.

DATA lo_nd_alv_preaward_wl TYPE REF TO if_wd_context_node.

DATA lo_el_alv_preaward_wl TYPE REF TO if_wd_context_element.

DATA ls_alv_preaward_wl TYPE wd_this->element_alv_preaward_wl.

DATA lv_object_id TYPE wd_this->element_alv_preaward_wl-object_id.

DATA: lv_preaward_sel_set TYPE wdr_context_element_set,

lv_preaward_element TYPE REF TO if_wd_context_element.

*************************************************************************

    • Processing Section *

*************************************************************************

  • GET ALL THE SELECTED ALV LINE

lo_nd_alv_preaward_wl = wd_context->get_child_node( name = wd_this->wdctx_alv_preaward_wl ).

  • @TODO handle non existant child

IF lo_nd_alv_preaward_wl IS NOT INITIAL.

lv_preaward_sel_set = lo_nd_alv_preaward_wl->get_selected_elements( including_lead_selection = abap_true ).

ENDIF.

  • loop at each selected SC ALV line

LOOP AT lv_preaward_sel_set INTO lv_preaward_element.

lv_preaward_element->get_static_attributes( IMPORTING static_attributes = ls_alv_preaward_wl ).

CLEAR lv_object_id.

lv_object_id = ls_alv_preaward_wl-object_id.

APPEND lv_object_id TO ty_object_id_confirm.

ENDLOOP.

hope this helps!

Jason PV

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi all,

it seems that the problem is caused by a wrong application design.

In fact I have the same context element exposed on the window in 2 separate views, the first (ALV) in display mode and the second (normal view) in edit mode.

When I change a value in the second view it seems that also ALV view catch the modification and so triggers its own methods. this is not the expected behavior.

conclusion: no way out. I need to change my aplication design.

Thanks to all

Stefano

Madhu2004
Active Contributor
0 Kudos

HI Stefano,

My system is on Netweaver 2004s.

However I replicated the same a system which ECC6.0 .It has a weird problem.First time when I click the button,In BEFOREACTION method it is not returning any values,but If I click the button again GET_SELECTED_ELEMENTS is returning the selected elements.

Regards,

Madhu

Former Member
0 Kudos

Please check once again. GET_SELECTED_ELEMENTS method of if_wd_context_node gives all the selected rows of the Table.

Former Member
0 Kudos

>

> Please check once again. GET_SELECTED_ELEMENTS method of if_wd_context_node gives all the selected rows of the Table.

Hi Saurav,

I know that the method should give all selected elements, and in the other parts of the program where I use it, it work as designed. I think the problem is in the order of WDDOBEFOREACTION calls. Infact sap calls component view's WDDOBEFOREACTION and after calls used component view's WDDOBEFOREACTION method.

Making a little debug I found that in the WDDOBEFOREACTION of ALV_TABLE view the user input are reported to the application. This means that I can't see that user input in component view WDDOBEFOREACTION and moreover it seems that there's no way to code something inside ALV_TABLE view WDDOBEFOREACTION.

Please check it out.

Thanks,

Stefano

former_member574468
Participant
0 Kudos

Hi,

You can write the code with in the Button Click Event know?

Y u r going with DOBEFOREACTION?

Regards,

Vimal...

Former Member
0 Kudos

>

> Hi,

> You can write the code with in the Button Click Event know?

> Y u r going with DOBEFOREACTION?

>

> Regards,

>

> Vimal...

Of course I know, and that's what I've done as workaround.

But you should know that there's a right way of coding and a working way... and when possible I prefer the first one.

Since WDDOBEFOREACTION is intended to validate user input I think that is the right place to make my checks. Maybe I'm wrong...or not...

Regards,

Stefano