on 02-22-2011 5:40 PM
Hello Gurus,
I want to create a method to insert a row into a table wich works for any table, like the insert fuction in ALV for example.
Does anybody have a sample code or knows wich class/method ALV uses to insert rows?
Regards,
Rafael
Hallo Rafael,
Table UI is binded to the Context node, if you want to insert a row, you need the line type data and Index where you would like to insert.
So for your generic usage. You could create a class with a static method with importing
io_node type ref to if_wd_context_node
io_item type data
iv_index type i
you can use if_wd_context_node->bind_element or if_wd_context_node->bind_structure
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
create a method with
three paramters
name type associted type
node changing if_wd_context_node
rslt exporting WDY_BOOLEAN
index importing i
then write the follwong code and call this method whenever you want to create element.
method INSERT_TABLE .
data el type ref to if_wd_context_element.
el = node->create_element( ).
data cnt type i.
cnt = node->get_element_count( ) + 1.
if cnt GE index.
node->bind_element(
new_item = el
index = index
set_initial_elements = abap_false
).
rslt = abap_true.
else.
rslt = abap_false.
endif.
endmethod.
thanks
sarbjeet singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rafael,
If you want to reuse any method, create assistance class and follow as baskaran said above..
And this is the general code to insert any row to a table.. change this according to your requirement..
DATA lo_nd_segment1 TYPE REF TO if_wd_context_node.
DATA lo_el_segment1 TYPE REF TO if_wd_context_element.
DATA ls_segment1 TYPE wd_this->Element_segment1.
data lt_segment1 type wd_this->Elements_segment1.
navigate from <CONTEXT> to <SEGMENT1> via lead selection
lo_nd_segment1 = wd_context->get_child_node( name = wd_this->wdctx_segment1 ).
lo_el_segment1 = lo_nd_segment1->bind_structure( new_item = ls_segment1
set_initial_elements = abap_false ).
Thanks,
Kris.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.