cancel
Showing results for 
Search instead for 
Did you mean: 

add new row after delete one row from view

Former Member
0 Kudos

Hi Abap Gururs,

when i will delete one row from view, automatically one new row should add in same view.

kindly tell how to do?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi sanasrinivas ,

Thank you for the reply. You got my issue. can i get the code for this.

Thanks,

Sagarika

former_member199125
Active Contributor
0 Kudos

hi

check this

This code will delete the selected records in table and will create the new rows.

node1 is the node name which binded to datasource of table.

data count type i.
data pos type i value 1.
lo_nd_node1 type ref to if_Wd_context_node.
lo_nd_ele1 type reft to if_Wd_context_element.
*** for single record
wa_node type WD_THIS->ELEMENT_node1.
count = lo_nd_itab1->get_element_count( ).
do count times.
*** for deleting selected records
if  lo_nd_node1->is_selected( index = pos) = abap_true.
    lo_nd_nod1->remove_element( index = pos ).
** for adding new record   
    lo_nd_node1->bind_structure( new_item = wa_node1
                           set_initial_elements = ABAP_FALSE ).

endif.

pos = pos+1.
enddo

Check in if_wd_context_node interface, there are 4 methods to add the records.

Regards

Srinvias

Edited by: sanasrinivas on Dec 30, 2011 10:33 AM

Former Member
0 Kudos

Remove and add is as equal as empty the current row right ?

In that case you can just bind new structure to the selected element. no need of removing the element and create a new element (which is too expensive for your purpose).

former_member199125
Active Contributor
0 Kudos

yes, u r right,

but if we select a second row in table and replace the second row contents with blank row... its quite inconvenience for user.

because seeing blank rows in middle of data, doesnt look good.

And am not sure about my reason, because, bind_structure will append the row in last, i think. let me check

Regards

Srinivas

Edited by: sanasrinivas on Dec 30, 2011 12:01 PM

Edited by: sanasrinivas on Dec 30, 2011 12:01 PM

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks so much Sanasrinivas.

This code resolved my problem.

Regards,

Sagarika

former_member199125
Active Contributor
0 Kudos

Are you talking about deleting row and adding new row in table?

in your button action code, i hope you will use remove_element( ) method to delete the row.

after the deletion code,

then bind the blank work area to Node. so that new row will be added.

Next time: Be precise about question, so that it will be easy to help

Regards

Srinivas