Deleting a row from the WebDynpro table (Web Dynpro for ABAP)

By Shaik Shadulla, Cognizant  

1.        Create a view with context as follows make sure the cardinality 0..n.

2.        Create a button with event DELETE_ROW  with event delete_row

3.        Create a table in the view and bind it to the context as shown below:

4.        In the WDDOINIT write the following code

data lo_nd_kna1 type ref to if_wd_context_node.
  
data lo_el_kna1 type ref to if_wd_context_element.
  
data ls_kna1 type wd_this->element_kna1.

*   navigate from <CONTEXT> to <KNA1> via lead selection
  lo_nd_kna1 = wd_context->get_child_node( name = wd_this->wdctx_kna1 ).
  
data : it_kna1 type table of wd_this->element_kna1.

  
select kunnr land1 from kna1 into corresponding fields of table it_kna1 up to 10 rows.
  lo_nd_kna1->bind_table( it_kna1 ).

5.       In onactiondelete_row METHOD WRITE THE FOLLOWING CODE

DATA lo_nd_kna1 TYPE REF TO if_wd_context_node.
   
DATA lo_el_kna1 TYPE REF TO if_wd_context_element.
   
DATA ls_kna1 TYPE wd_this->element_kna1.
   
data: it_tab type table of wd_this->element_kna1.
*  navigate from <CONTEXT> to <KNA1> via lead selection
   lo_nd_kna1 = wd_context->get_child_node( name = wd_this->wdctx_kna1 ).

*  get element via lead selection
   lo_el_kna1 = lo_nd_kna1->get_element(  ).

   lo_el_kna1->get_static_attributes(
     
IMPORTING
       static_attributes = ls_kna1 ).

lo_nd_kna1->get_static_attributes_table(
      
importing
        
table = it_tab ).
DELETE it_tab where kunnr eq ls_kna1-kunnr.
lo_nd_kna1->bind_table(  it_tab[] ).

6.        Create a webdynpro application and execute the following result will appear

After pressing delete button result will be as follows:

Similarly you can also create one more button for add row and populate it with one more row.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image