cancel
Showing results for 
Search instead for 
Did you mean: 

delete a selected row from a table using ALV

Former Member
0 Kudos

Hi,

I have created this simpleaction to capture a selected row using ALV and here is the code I used

to do that.

  • Get access to the desired context node

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

  • Get the lead selection of the ALV

lr_element = wd_node->get_lead_selection( ).

  • call delete_sname_complete function module

Z_WDT_NAME_MODEL=>delete_sname_complete( EXPORTING element = lr_element ).

this the empty method to delete the actual data from the database

method DELETE_SNAME_COMPLETE.

***

***

endmethod.

what is the correct syntax to delete a selected row when I pass the parameter

lr_element?

Accepted Solutions (1)

Accepted Solutions (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

This is more of ABAP general question,

You can implement your own logic to delete a record from the database.. if it is custom table, you can use Delete command, if it is standard table then call the related BAPI if provided.

Abhi

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks for the replays guys,

it was a lot simpler than I thought.

All what I have to do is write a delete a statement after get_lead_select

And it removed the selected row from the database

Thanks,

Abdul

Former Member
0 Kudos

Hi,

After you get the selected row index and its context element.

Use the REMOVE_ELEMENT of the if_wd-context_node to delete a row from the table.

But this deletes the record in the context only.

As per Abhi's reply you can delete the same from the database table.

Regards,

Lekha.

arjun_thakur
Active Contributor
0 Kudos

Hi Abdul,

Please refer the code given by Uday in the thread: .

After removing the selected line, just read the node to get all the values in an internal table and then use ABAP modify statement to modify the database table according to the data present in the internal table.

I hope it helps.

Regards

Arjun