cancel
Showing results for 
Search instead for 
Did you mean: 

ALV forgets Lines

Former Member
0 Kudos

Dear Experts,

i use an ALV to display the data of one node. My Problem now is if i select a line and click on

the delete button nothing happens.

The Problem is: If i select one line only, the set "lt_elements" is empty. If i select two lines,

the set 'lt_elements' contains one element.

I don´t know whats the problem here. Please help if you can. I am a litte bit despaired 😕

Thank you very much.

Best regards

René

My code is:

DATA lo_nd_worklist_tabelle TYPE REF TO if_wd_context_node.

DATA lo_el_worklist_tabelle TYPE REF TO if_wd_context_element.

DATA lo_nd_tabelle_schreiben TYPE REF TO if_wd_context_node.

DATA lo_el_tabelle_schreiben TYPE REF TO if_wd_context_element.

data lt_elements type wdr_context_element_set.

lo_nd_worklist_tabelle = wd_context->get_child_node( name = 'worklist_tabelle' ).

CALL METHOD lo_nd_worklist_tabelle->get_selected_elements

RECEIVING

set = lt_elements.

Edited by: René Hölterling on Jan 8, 2009 10:06 AM

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Rene,

If you observe carefully you should see the first row that you select being highlighted in a different colour from the other rows that you select. This is to distinguish the lead selection from the selection.

Regards,

Uday

Former Member
0 Kudos

hi uday,

this change helped a little but didn´t solve the problem at all.

Now i can delete any line i want except the first line.

if i select the first line in the alv and then click delete the set 'lt_elements'

is still empty.

Thank you for helping me

Best regards

René

uday_gubbala2
Active Contributor
0 Kudos

Hi Rene,

Am not sure as to where you are going wrong. If you have set the selection mode to multinoLead then even selecting a single line should result in the get_selected_elements returning that row. I would try experiment with any other possible scenarios. In the meantime my coding is as below:

METHOD build_alv .
  DATA:
    lr_alv_usage       TYPE REF TO if_wd_component_usage,
    lr_if_controller   TYPE REF TO iwci_salv_wd_table,
    lr_config          TYPE REF TO cl_salv_wd_config_table,
    lr_table_settings  TYPE REF TO if_salv_wd_table_settings,

" Instantiate the ALV Component
  lr_alv_usage = wd_this->wd_cpuse_alv( ).
  IF lr_alv_usage->has_active_component( ) IS INITIAL.
    lr_alv_usage->create_component( ).
  ENDIF.

" Get reference to model
  lr_if_controller = wd_this->wd_cpifc_alv( ).
  lr_config        = lr_if_controller->get_model( ).

" Set the UI elements.
  lr_table_settings  ?= lr_config.

" Setting the ALV selection to multiple selection with no lead selection
  lr_table_settings->set_selection_mode( value = cl_wd_table=>e_selection_mode-multi_no_lead ).
endmethod.

METHOD onactiondelete_rows .
  DATA:  wd_node TYPE REF TO if_wd_context_node,
         lr_element  TYPE REF TO if_wd_context_element,
         lt_element  TYPE wdr_context_element_set.

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

  CALL METHOD wd_node->get_selected_elements
    RECEIVING
      set = lt_element.

  LOOP AT lt_element INTO lr_element.
    wd_node->remove_element( EXPORTING element = lr_element ).
  ENDLOOP.
ENDMETHOD.

Regards,

Uday

Former Member
0 Kudos

hi uday,

at the line

lr_alv_usage = wd_this->wd_cpuse_alv( ).

it tells me that 'wd_this->wd_cpuse_alv( ).' does not exists.

It suggests me 'wd_this->wd_cpuse_alv_table( ).'

Is this correct or can my error be at this point ?

regards

René

Former Member
0 Kudos

Hi,

lr_alv_usage = wd_this->wd_cpuse_alv( ).

it tells me that 'wd_this->wd_cpuse_alv( ).' does not exists.

It suggests me 'wd_this->wd_cpuse_alv_table( ).'

It should be 'wd_this->wd_cpuse_<<ALV name>>( ).' " ALV name should be the one you have given it under the component usages section of the Used components.

Regards,

Lekha.

Former Member
0 Kudos

Dear experts,

i solved the problem myself.

Here is the code. I don´t know why but it works.

CALL METHOD lo_nd_worklist_tabelle->get_selected_elements

exporting

including_lead_selection = abap_true

RECEIVING

set = lt_elements.

best regards

René

Answers (1)

Answers (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Rene,

Its a small mistake from your side. I guess that you have set the selection mode to MULTI because of which lead selection is still active. So the first row that you select counts as lead selection and get_selected_elements wouldn't capture that as a selection. Only the other selected rows would count as selection. You would just have to use the multiNoLead option for your alv.

data :  lr_table_settings  TYPE REF TO if_salv_wd_table_settings.

lr_table_settings ?= lr_config. 

lr_table_settings->set_selection_mode( value = cl_wd_table=>e_selection_mode-multi_no_lead ).

Regards,

Uday