on 01-21-2009 1:07 PM
How can I add or delete the row for the table dynamically at runtime. Example : I have a table, it displays table correctly, I need to add/delete one row on selecting a button. If we need to delete the row from table, selecting the row and press the delete button. To increase the row, I use to other button. Please explain me to add/delete the row of the table at runtime.
Thanks,
Prasad
hi ,
to add the row u can use following code in the onaction of the button
method onactiononadd .
node_material type ref to if_wd_context_node.
elem_material type ref to if_wd_context_element.
stru_material type sflight.
node_material = wd_context->get_child_node( name = 'ANNA' ).
elem_material = node_material->get_element( ).
if ( elem_material is initial ).
call method node_material->create_element
receiving
element = elem_material.
endif.
call method elem_material->get_static_attributes
importing
static_attributes = stru_material .
call method node_material->bind_structure
exporting
new_item = stru_material
set_initial_elements = abap_false.
endmethod.
I hope it helps.
Regards,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> Hi Prasad,
> To remove a row you can either use the method suggested by Thomas or you can refer the method suggested by Alex Justin in this [thread|].
>
> I hope it helps.
>
> Regards
> Arjun
It is far more efficient from a performance standpoint to remove the element than to adjust the internal table and redo the bind_table.
Hi prasad,
i tried to update the db table as well .How can i do that?
please check the code and let me know any changes required.
Data ls_nd_exc_item type wd_this->element_nd_exc_item.
* navigate from <CONTEXT> to <ND_EXC_ITEM> via lead selection
lO_nd_nd_exc_item = wd_context->get_child_node( name = wd_this->wdctx_nd_exc_item ).
* @TODO handle non existant child
IF lo_nd_nd_exc_item IS INITIAL.
ENDIF.
* get element via lead selection
lo_el_nd_exc_item = lo_nd_nd_exc_item->get_element( ).
* @TODO handle not set lead selection
IF lo_el_nd_exc_item IS INITIAL.
ENDIF.
* alternative access via index
lo_el_nd_exc_item = lo_nd_nd_exc_item->get_element( index = 1 ).
* get all declared attributes
lo_el_nd_exc_item->get_static_attributes(
IMPORTING
static_attributes = ls_nd_exc_item ).
data: i type i.
data: it_tab type table of wd_this->element_nd_exc_item,
wa_tab type wd_this->element_nd_exc_item .
* lo_el_nd_exc_item->GET_INDEX( i1 ).
lo_nd_nd_exc_item->get_static_attributes_table(
IMPORTING
table = it_tab ).
delete it_tab WHERE charg eq ls_nd_exc_item-charg.
lo_nd_nd_exc_item->bind_table( it_tab ).
READ TABLE it_tab INTO wa_tab INDEX i.
delete from ZTT_FQM_EXC_REQ where EXCEP_ID = wa_tab-EXCEP_ID.
endmethod.
You simply manipulate the bound context. You use the context APIs to add an element or delete an element. IF_WD_CONTENT_NODE methods BIND_ELEMENT and REMOVE_ELEMENT.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.