cancel
Showing results for 
Search instead for 
Did you mean: 

Delete a row

Pramanan
Active Participant
0 Kudos

Hi Experts,

i am using table ui element to show the uploaded files details like name of the file , user name and date on which the file was uploaded. Bind a node to the table with lead selection intialization and selection mode as multinode.

I have a delete button in table tool bar. i need to delete the selected row.But always the table header is pointing to the first uploaded record and it deletes first then the second file becomes first. So in my next attempt it delete the second record though i have selected 4th or 5th record.

The lead selection doesnot pointing to the selected record.

please help to solve this problem.

Thanks,

Ramanan

Accepted Solutions (0)

Answers (5)

Answers (5)

Pramanan
Active Participant
0 Kudos

answered

baskaran00
Active Participant
0 Kudos

Hi Ramanan,

Try below code, below code is used to delete multiple selection in a table. Sure this will resolved ur problem.

DATA : lo_node TYPE REF TO if_wd_context_node,

lo_element TYPE REF TO if_wd_context_element,

index type i.

DATA : sets type WDR_CONTEXT_ELEMENT_SET,

wa_sets like LINE OF it_sets.

CALL METHOD LO_NODE->GET_SELECTED_ELEMENTS

EXPORTING

INCLUDING_LEAD_SELECTION = ABAP_TRUE

RECEIVING

SET = sets.

loop at sets into wa_sets.

CALL METHOD WA_SETS->GET_INDEX( RECEIVING MY_INDEX = index ).

lo_element = lo_node->get_element( index = index ).

call method lo_node->remove_element

EXPORTING

element = lo_element.

  • receiving

  • has_been_removed =

.

endloop.

Thanks...

Former Member
0 Kudos

Hi,

First of all, uncheck 'initialize lead selection' of the node which you bound to table from context.

Then change the selections '1..n', and at the end use

remove_element method of if_wd_context_node to delete the elements from the table. You can use this in loop.

Thanks,

uday_gubbala2
Active Contributor
0 Kudos

Hi Ramanan,

1) Get the references of all the selected table rows into an internal table.

2) Loop through the above table & delete the rows from the context

3) Get all the present context node data into 1 internal table

4) Re-bind the new internal table to the context

Regards,

Uday

Below is the coding to do the deletion task that you intend to do.

METHOD onactiondelete_selected_rows .
  DATA:  wd_node TYPE REF TO if_wd_context_node,
         lt_node1 TYPE ig_componentcontroller=>elements_node1,
         wa_temp  TYPE REF TO if_wd_context_element,
         lt_temp  TYPE wdr_context_element_set,
         row_number TYPE i VALUE 0.


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

  CALL METHOD wd_node->get_selected_elements
    RECEIVING
      set = lt_temp.

  LOOP AT lt_temp INTO wa_temp.
    wd_node->remove_element( EXPORTING element = wa_temp ).
  ENDLOOP.

  CALL METHOD wd_node->get_static_attributes_table
    EXPORTING
      from  = 1
      to    = 2147483647
    IMPORTING
      table = lt_node1.

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

uday_gubbala2
Active Contributor
0 Kudos

Hi Ramanan,

If you want to work with multiple row selection in a table then you will have to make use of "Selection" concept. LeadSelection allows you to select only 1 row at a time. Try setting the SelectionMode to "Auto". Also uncheck the, "Initialization Lead Selection" checkbox of the node which you are using to bind to your table. (This helps make the first row as not selected by default.) The below coding helps copy data in between 2 tables. The user first selects multiple records from 1 table using the Selection concept and presses on a toolbar button COPY. I hope this coding would help make you understand the concept.

Regards,

Uday

METHOD onactioncopy_selected_rows .
  DATA:  wd_node TYPE REF TO if_wd_context_node,
         ls_node1 TYPE ig_componentcontroller=>element_node1,
         lt_node1 TYPE ig_componentcontroller=>elements_node1,
         lt_node2 TYPE ig_componentcontroller=>elements_node2,
         wa_temp  TYPE REF TO if_wd_context_element,
         lt_temp  TYPE wdr_context_element_set.


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

  CALL METHOD wd_node->get_selected_elements
    RECEIVING
      set = lt_temp.

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

  LOOP AT lt_temp INTO wa_temp.
    CALL METHOD wa_temp->get_static_attributes
      IMPORTING
        static_attributes = ls_node1.
    APPEND ls_node1 TO lt_node1.
    CLEAR ls_node1.
  ENDLOOP.

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

Former Member
0 Kudos

Hi Ramanan,

Please check your node again.

It will be good if u can share the screenshot of your context node with us.

Regards,

Sumit Oberoi