cancel
Showing results for 
Search instead for 
Did you mean: 

deleting a row from the item table

Former Member
0 Kudos

Hi All,

I have a requirement where I need to put a button to delete the selected row from the item table and for this I have written the following code:

DATA lo_nd_t_bseg TYPE REF TO if_wd_context_node.
    DATA lo_el_t_bseg TYPE REF TO if_wd_context_element.
    DATA ls_t_bseg TYPE wd_this->element_t_bseg.
    data: it_tab type table of wd_this->element_t_bseg.
  lo_nd_t_bseg = wd_context->path_get_node( path = `Z.T_BSEG` ).
  lo_el_t_bseg = lo_nd_t_bseg->get_element( ).
  lo_el_t_bseg->get_static_attributes(
    IMPORTING
      static_attributes = ls_t_bseg ).
    lo_nd_t_bseg = wd_context->path_get_node( path = `Z.T_BSEG` ).

    lo_el_t_bseg = lo_nd_t_bseg->get_element( ).
    IF lo_el_t_bseg IS not INITIAL.
      lo_nd_t_bseg->remove_element( lo_el_t_bseg ).
    ENDIF.

Now the problem is although it's deleteing the selected line correctly but because of this I am losing one line on the screen for the user to enter... my form has a fixed number of lines and in my case it's 10... so everytime I am using deleting a line item I am losing one line to enter..... can you please tell me how can I avoid this?

Edited by: rajatg on Aug 4, 2011 3:12 PM

Accepted Solutions (0)

Answers (3)

Answers (3)

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

dont clear the table...clear the context_element (selected element), it will delete the row in the table

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

Use the text as 'Clear' rather than 'Delete '...

this elements has the values lo_el_t_bseg and all you have to do is to clear those...

use GET /SET static attributes methods ,

Former Member
0 Kudos

if i try to clear the table then this will not delete the entry from the internal table... the requirement is let say i have a parked document with three line items and now user opens that document and decides to delete one line item and save it back ... so now that particular document should only have 2 line tems... can you please tell me how can I do this !!!

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

lets say...

i have 1,2,3 documents

i have cleared , document 2....

1. when the user selects this record.... you can read the context_element....using the context element you can get the values and clear those values and set the blank values...

when the user click on save ...you can have only those two records in the table.

2. conitnue with your logic .... remove_element. once it is done ,,, create_element at the deleted index...

3. when clicked on delete ...remove_element ( current code).... bind the table to the node... and you will have ur values

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

clear the values and bind it..

lo_el_t_bseg >> get static attributes....>> this returns ls_str

clear the ls_str

and now use set_static_attributes

Edited by: ssm on Aug 4, 2011 6:46 PM