cancel
Showing results for 
Search instead for 
Did you mean: 

ALV - get selected rows

Former Member
0 Kudos

Hi

I'm using an ALV output (SALV_WD_TABLE)

How can I get the selected lines if multiple line selection is enabled?

ON_LEAD_SELECT just return one line!

Thanks

Thomas

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

GET_SELECTED_ELEMENTS is correct, but if several lines are selected, you have to take care about the selection colors or you use a different selection method like 08

Former Member
0 Kudos

I wrote the code into my wwdoinit also,

it does not work for me

It says: WD_CPUSE_USAGE_ALV is not known, protectoed or privat.

Same for WD_CPIFC_USAGE_ALV and lr_if_controller is nit convertible to lo_cmp_usage2 which is an instance of if_wd_component_usage...

Former Member
0 Kudos

in your case I guess the WD_CPUSE_USAGE_ALV is not known

in my development the component use for the SALV_WD_TABLE component is named "USAGE_ALV"

you can use a different name, but you have to maintain it in the properties tab on the component controller.

hope it helps

Thomas

Former Member
0 Kudos

yes, I noticed

but that can't be the solution. If I would be an end-user of this WD development, I will not care about deselecting and selecting the 1st line again to the get correct color.

If I select several lines, I don't want to take care about the colors

so the solution for that is the different selection method 08

implemetned in wddoinit:

DATA: lr_comp_usage TYPE REF TO if_wd_component_usage,

lr_if_controller TYPE REF TO iwci_salv_wd_table,

lr_model TYPE REF TO cl_salv_wd_config_table,

lr_settings TYPE REF TO if_salv_wd_table_settings.

lr_comp_usage = wd_this->wd_cpuse_usage_alv( ).

IF lr_comp_usage->has_active_component( ) IS INITIAL.

lr_comp_usage->create_component( ).

ENDIF.

lr_if_controller = wd_this->wd_cpifc_usage_alv( ).

lr_model = lr_if_controller->get_model( ).

lr_settings ?= lr_model.

lr_settings->set_selection_mode( '08' ).

So problem is solved now.

Thanks for you help Gajendra.

Former Member
0 Kudos

I just saw that there's a difference in selecting the rows

the seleced ones are in light orange color, the missing one is the dark orange

That's the one I selected before I pushed the Cntl on the keyboard to mark the others

I guess there is something wrong the the selection method

Former Member
0 Kudos

Hi Thomas,

I dont know if you have noticed, one line is selected by default in your ALV table. Remove that option off. Then you see no row is selected. Then you start selecting multiple rows and see if u get all your selected rows.

Thank You,

Gajendra.

Former Member
0 Kudos

That won't work, what's wrong?

a test case from the scratch:

1. in the new component the used component SALV_WD_TABLE with use USAGE_ALV was entered

2. in the new view the context node vbak ( 0...n) was created and some VBAK fields selected

and incl. supply function

METHOD suppy_vbak .

DATA: lt_vbak TYPE TABLE OF vbak.

SELECT * up to 10 rows FROM vbak INTO TABLE lt_vbak.

node->bind_table(

new_items = lt_vbak

set_initial_elements = abap_true ).

ENDMETHOD.

4. view container UI element and a button called display created on view

5. view embedded in window and USAGE_ALV / SALV_WD_TABLE / TABLE embedded in the

view container ui element

6. component usage USAGE_ALV: DATA was linked to component controller's VBAK

so what's the coding for the button on the view now: maybe this one:

METHOD onactiondisplay .

DATA: lr_node TYPE REF TO if_wd_context_node,

lt_selected TYPE wdr_context_element_set.

lr_node = wd_context->get_child_node( name = 'VBAK' ).

lt_selected = lr_node->get_selected_elements( ).

ENDMETHOD.

this will run of error because the child VBAK is not on the view, so I linked context VBAK of the component controller to the view.

Now it runs without error, but the table lt_selected is one less than seleced

eg 5 selected, only 4 in the lt_selected or only 1 selected -> table is empty

Any ideas?

Thanks

Former Member
0 Kudos

Hi

Try using the method GET_SELECTED_ELEMENTS method for your node(IF_WD_CONTEXT_NODE).

Thank You,

Gajendra.