cancel
Showing results for 
Search instead for 
Did you mean: 

deleting Lines from Table UI Element

Former Member
0 Kudos

Hello guys,

ich have a Problem deleting Lines from a table UI Element.

The Situation is like this:

I have a table ui element. if i click on a line and then on a button

i want to delete the line from the table.

How can i do this ?

Thanks a lot.

René

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Rene,

I am assuming here that the Table UI would be bound to a context node mapped to a structure. The table UI would display the rows as pouplated against the context node ( implying node cardinality would be 0:n or 1:n and thus would <<node>> ->get_static_attributes would yeild an internal table ).

There are two approaches towards tackling this:

1) If the intent is to delete the line from the table UI and subsequently delete it from a table in the underlying database, then you could do the following:

When you select a line from the table UI and click on the delete button, get the lead selection element and issue a delete of the row in the Database. Subsequently read the table rows from the DB and bind the internal table to the node mapped to the tabel UI. (This action would be actually refreshing the UI with real time DB value once the delete is clicked. Thus the new set of records does not have the deleted row) . This is performance intensive and is generally used if there is a need for the most recent data to be displayed on each event)

2) If the intent is just to remove the line from the table UI, then on click of delete, just delete the lead selected elements from the context node mapped to the Table UI


  DATA: lo_node TYPE REF TO if_wd_context_node,
        lo_ele  TYPE REF TO if_wd_context_element.
  lo_node = wd_context->get_child_node( name = wd_this-><<table_ui_node>> ).
  CALL METHOD lo_node->get_lead_selection
    RECEIVING
      element = lo_ele.
  CALL METHOD lo_node->remove_element
    EXPORTING
      element          = lo_ele
    receiving
      has_been_removed = fg_has_been_removed.

Hope this was clear.

Thanks,

Rashmi.

Former Member
0 Kudos

Hello Rashimi,

that did it, thank you very much

How can i delete mulitple lines at the same time ?

It´s only neccessary to delete them in the context, not in a table.

Thanks and best regards

René

Edited by: René Hölterling on Oct 15, 2008 10:25 AM

Former Member
0 Kudos

Hi Rene,

First u can use the method, get_selected_elements to get all the selected elements from the node. loop thro that element list and use remove_element method to remove element one by one.

Regards...

Arun.

Former Member
0 Kudos

Hi Rene,

To select multiple rows from thetable you have to change selection to 0..n of the context node which is attached to table.

To get the selected rows write the below logic.

data:node_flights type ref to if_wd_context_node,

it_selected type WDR_CONTEXT_ELEMENT_SET,

wa_selected type ref to if_wd_context_elemnt.

node_flights = wd_context->get_childnode( 'FLIGHTS' ).

it_selected = node_flights->get_selected_elements( ).

loop at it_selected into wa_selected.

node_flights->remove_element

exporting

elelment = wa_selected.

endloop.

uday_gubbala2
Active Contributor
0 Kudos

Hi Rene,

Using "LeadSelection" you can select only 1 row at a time. You will have to make use of "Selection" for achieving this. First you will have to change the selection mode of the table to multiple & also change the selection property for the related context to 0..n . Use the below coding to get the multiple rows selected by the user into an internal table . You can then loop through this new internal table and delete those corresponding records from the main internal table. Hope that this helps resolve your problem.

Regards,

Uday

METHOD onactioncopy_selected_rows .
  DATA:  wd_node TYPE REF TO if_wd_context_node,
             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.

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

Former Member
0 Kudos

thanks all for your answers.

All my Problems were solved.

Best regards

René

Edited by: René Hölterling on Oct 15, 2008 11:42 AM

Answers (0)