on 04-28-2009 11:19 AM
HI all,
I've table control with option as "delete row".
if i create 3 rows and i want to delete the third record but first record is getting deleted.
pls have look on the code... and suggest me...
method ONACTIONA_DELETE_ROW .
Deleting a empty line from the node
DATA lo_nd_n_material TYPE REF TO if_wd_context_node.
DATA lo_el_n_material TYPE REF TO if_wd_context_element.
DATA ls_n_material TYPE wd_this->element_n_material.
DATA item_no TYPE zmatreq-zitem.
DATA lt_n_material TYPE wd_this->elements_n_material.
navigate from <CONTEXT> to <N_MATERIAL> via lead selection
lo_nd_n_material = wd_context->get_child_node( name = wd_this->wdctx_n_material ).
get element via lead selection
lo_el_n_material = lo_nd_n_material->get_element( ).
get all declared attributes
lo_nd_n_material->get_static_attributes_table(
importing
table = lt_n_material ).
loop at lt_n_material into ls_n_material.
if ls_n_material-a_req_type eq space or ls_n_material-a_matgrp eq space
or ls_n_material-a_dev_centre eq space.
item_no = ls_n_material-itemno.
DELETE TABLE lt_n_material from ls_n_material.
exit.
endif.
endloop.
lo_nd_n_material->bind_table( lt_n_material ).
Deleting a empty line from the node
endmethod.
regards
Suprith
Hi,
Try to use remove_element( ) method.
Refer the following threads:
https://forums.sdn.sap.com/click.jspa?searchID=25427895&messageID=6975756
I hope it helps.
Regards
Arjun
Edited by: Arjun Thakur on Apr 28, 2009 3:56 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suprith,
Following the way you can delete the selected row in table control. Here Node_Sumit is reference to Node bound to table control.
data:
Node_Sumit type ref to If_Wd_Context_Node,
Elem_Sumit type ref to If_Wd_Context_Element,
Stru_Sumit type If_V_Main=>Element_Sumit .
navigate from <CONTEXT> to <SUMIT> via lead selection
Node_Sumit = wd_Context->get_Child_Node( Name = IF_V_MAIN=>wdctx_Sumit ).
@TODO handle not set lead selection
if ( Node_Sumit is initial ).
endif.
get element via lead selection
Elem_Sumit = Node_Sumit->get_Element( ).
@TODO handle not set lead selection
if ( Elem_Sumit is initial ).
endif.
alternative access via index
Elem_Sumit = Node_Sumit->get_Element( Index = 1 ).
@TODO handle non existant child
if ( Elem_Sumit is initial ).
endif.
get all declared attributes
Elem_Sumit->get_Static_Attributes(
importing
Static_Attributes = Stru_Sumit ).
node_sumit->get_lead_selection( receiving element = elem_sumit ).
node_sumit->remove_element( exporting element = elem_sumit ) .
-
I hope, this will help your cause.
Regards,
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
On the click of Del button do the following :
1.Use below code to get the index of row selected in table.
2. Further delete the records from internal table before binding.
3. Bind the node with the table.
DATA: lv_index TYPE i.
lo_el_cn_node = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).
lv_index = lo_el_cn_node->get_index( ).
Thanx.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
after selected your row try as follows:
data node type ref to if_wd_context_node.
data elem_part type ref to if_wd_context_element.
data table_data type if_tab_second=>elements_part_func.
data table_line type if_tab_second=>element_part_func.
data line_index type i.
data line_index_str type string.
node = wd_context->get_child_node( 'PART_FUNC' ).
elem_part = node->get_element( ).
if ( elem_part is initial ).
exit.
endif.
call method elem_part->get_index
receiving
my_index = line_index.
Delete selected record
call method node->get_static_attributes_table
importing
table = table_data.
delete table_data index line_index.
node->bind_table(
new_items = table_data
set_initial_elements = abap_true ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.