Sunday, December 19, 2010

Deleting a row from the Web Dynpro table

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 to 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 to 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.

No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive

goodsites