cancel
Showing results for 
Search instead for 
Did you mean: 

to delete record from database table

0 Kudos

Hi,

I'm new to SAP.

In my Application View when im clicking delete button by selecting the row the value is deleted only in view but not in table when I'm refreshing the view again I'm getting the record which i deleted can anyone assist me how to delete from table through view

here by im ataching the code which i have implemented for Delete Button


METHOD onactionremove .
  DATA lo_nd_main TYPE REF TO if_wd_context_node.

  DATA lo_el_main TYPE REF TO if_wd_context_element.
  DATA ls_main TYPE wd_this->element_main.

  lo_nd_main = wd_context->get_child_node( name = wd_this->wdctx_main ).

* @TODO handle not set lead selection
  IF lo_nd_main IS NOT INITIAL.

* get element via lead selection
    lo_el_main = lo_nd_main->get_element(  ).

* @TODO handle not set lead selection
    IF lo_el_main IS NOT INITIAL.
      lo_nd_main->remove_element( lo_el_main ).
    ENDIF.
  ENDIF.

ENDMETHOD.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Madhu

DATA lo_nd_main TYPE REF TO if_wd_context_node.

DATA lo_el_main TYPE REF TO if_wd_context_element.

DATA lt_itab type if_main=>elements_main.

DATA ls_main type if_main=>element_main.

lo_nd_main = wd_context->get_child_node( name = wd_this->wdctx_main ).

lo_el_main = lo_nd_main->get_element( ).

lo_el_main->get_static_attributes(

IMPORTING

static_attributes = ls_main ).

lo_nd_main->get_static_attributes_table(

importing

table = lt_tab ).

DELETE it_tab where <key> eq ls_main-<key value>.

lo_nd_main1->bind_table( it_tab[] ).

Try to check with this code

Thanks

Tulasi Palnati

0 Kudos

thanks each and every one

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Madhu,

In the attached code, you are just deleting from the view. When you delete from the view, you should also write code for deleting from the database table.

Refer the below link for that.

[Deleting from Database Table|http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb3aef358411d1829f0000e829fbfe/content.htm]