cancel
Showing results for 
Search instead for 
Did you mean: 

Adding/delete/copy a row in table in web dynpro

mahesh_jagnani
Participant
0 Kudos

Hi Expers,

We have arequirement where on screen of view there is a "ADD" button,"DELETE" button and a ":COPY" button. once the user click on "ADD" button , a new row must add in the existing table,once the user select a row from table and click on "DELETE" button , that row must delete .once the user click "COPY" button a new row must added with the data of the selected row.

Can you plz help me how to do this.

Thanks

Mahesh

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>Can you plz help me how to do this.

It sounds like you need to just manipulate the context when these events occur.

For the Add, use the context node BIND_ELEMENT to bind a new empty context:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/fd/be5b4150b38147e10000000a1550b0/frameset.htm

For delete and copy you will need to read the leadSelection of the node. That will give you the element of selected record. For copy just call GET_STATIC_ATTRIBUTES on this this element. Then call BIND_ELEMENT with the structure returned from the previous method to bind the same data back into the context node as a new element.

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/32/bf5b4150b38147e10000000a1550b0/frameset.htm

Delete is easy. Once you have the element reference from the leadSelection, call REMOVE_ELEMENTof the context node object:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/fd/be5b4150b38147e10000000a1550b0/frameset.htm

But basically you probably want to study these two help links and get familiar with the context APIs for such operations.

Answers (1)

Answers (1)

former_member1151507
Participant
0 Kudos

Hi Mahesh,

-> To add a new row to the table, you need to create and bind a new element to the node.

DATA: lo_nd_test TYPE REF TO if_wd_context_node,

lo_el_test TYPE REF TO if_wd_context_element,

ls_test TYPE wd_this->element_test.

lo_nd_test= wd_context->get_child_node( name = wd_this->wdctx_test ).

lo_el_test= lo_nd_test->create_element( ).

lo_nd_test->bind_element( new_item = lo_el_test set_initial_elements = abap_false ).

lo_nd_test->set_lead_selection( lo_el_test ). " to select the new row added

-> To delete the exisiting row, get the selected row element and call remove_element method.

lo_el_test= lo_nd_test->get_lead_selection( ).

lo_nd_test->remove_element( lo_el_test ).

-> To copy the existing row, get the values of the selected row using get_static_attributes( ) method and set the values to the new row added.

lo_nd_test= wd_context->get_child_node( name = wd_this->wdctx_test ).

lo_el_test= lo_nd_test->get_lead_selection( ).

check lo_el_test is not initial.

lo_el_test->get_Static_attributes( importing static_attributes = ls_test ).

clear lo_el_test.

lo_el_test= lo_nd_test->create_element( ).

lo_nd_test->bind_element( new_item = lo_el_test set_initial_elements = abap_false ).

lo_el_test->set_Static_attributes(EXPORTING static_attributes = ls_test ).

Regards,

Manogna