on 03-22-2011 12:29 PM
Hi All,
I have a table with multiple line items, and i have one insert button.
If i select line items in first table i want to create new records in 2nd table that is new structure( some values are same ).
Here problem is i am getting all records in second table eventhough i select only one? check this code and help...
here code i am using..in insert button.
DATA lo_nd_it_lips TYPE REF TO if_wd_context_node.
DATA lo_el_it_lips TYPE REF TO if_wd_context_element.
DATA ls_it_lips TYPE wd_this->Element_it_lips.
DATA lt_it_lips TYPE wd_this->Elements_it_lips.
navigate from <CONTEXT> to <IT_LIPS> via lead selection
lo_nd_it_lips = wd_context->path_get_node( path = `ZRETURN_DEL_CHANGE.CHANGING_3.IT_LIPS` ).
get element via lead selection
lo_el_it_lips = lo_nd_it_lips->get_element( ).
get all declared attributes
lo_nd_it_lips->get_static_attributes_table( importing table = lt_it_lips ).
DATA lo_nd_pack_mat TYPE REF TO if_wd_context_node.
DATA lo_el_pack_mat TYPE REF TO if_wd_context_element.
DATA ls_pack_mat TYPE wd_this->Element_pack_mat.
navigate from <CONTEXT> to <PACK_MAT> via lead selection
lo_nd_pack_mat = wd_context->get_child_node( name = wd_this->wdctx_pack_mat ).
loop at lt_it_lips into ls_it_lips.
ls_pack_mat-PACK_MATERIAL = 'PACKING1'.
ls_pack_mat-packing_qty = ls_it_lips-PICK_QTY.
ls_pack_mat-material = ls_it_lips-matnr.
ls_pack_mat-plant = ls_it_lips-werks.
append ls_pack_mat to lt_pack_mat.
endloop.
lo_nd_pack_mat->bind_table( LT_PACK_MAT ).
Thanks,
venkat.
Hi Venkat.,
lo_nd_it_lips->get_static_attributes_table( importing table = lt_it_lips ). here u r getting all the records in the first table and binding it to the second table., instead use get_static_attributes( importing table = ls_it_lips ). method.. this will give the selected record details.. then append this to the second internal table and bind it..
u can also use get_selected_elements( ) method..
Reply if u need some more clarifications.,
Thanks & Regards
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Try with tis code..
DATA lo_nd_it_lips TYPE REF TO if_wd_context_node.
DATA lo_el_it_lips TYPE REF TO if_wd_context_element.
DATA ls_it_lips TYPE wd_this->Element_it_lips.
DATA lt_it_lips TYPE wd_this->Elements_it_lips.
DATA: wa_temp TYPE REF TO if_wd_context_element,
lt_temp TYPE wdr_context_element_set.
navigate from <CONTEXT> to <IT_LIPS> via lead selection
lo_nd_it_lips = wd_context->path_get_node( path = `ZRETURN_DEL_CHANGE.CHANGING_3.IT_LIPS` ).
CALL METHOD lo_nd_it_lips->get_selected_elements
RECEIVING
set = lt_temp.
DATA lo_nd_pack_mat TYPE REF TO if_wd_context_node.
DATA lo_el_pack_mat TYPE REF TO if_wd_context_element.
DATA ls_pack_mat TYPE wd_this->Element_pack_mat.
DATA lt_pack_mat TYPE wd_this->Elements_pack_mat.
get element via lead selection
lo_el_pack_mat = lo_nd_pack_mat->get_element( ).
navigate from <CONTEXT> to <PACK_MAT> via lead selection
lo_nd_pack_mat = wd_context->get_child_node( name = wd_this->wdctx_pack_mat ).
LOOP AT lt_temp INTO wa_temp.
CALL METHOD wa_temp->get_static_attributes
IMPORTING
static_attributes = ls_it_lips.
ls_pack_mat-PACK_MATERIAL = 'PACKING1'.
ls_pack_mat-packing_qty = ls_it_lips-PICK_QTY.
ls_pack_mat-material = ls_it_lips-matnr.
ls_pack_mat-plant = ls_it_lips-werks.
append ls_pack_mat to lt_pack_mat.
CLEAR ls_pack_mat.
ENDLOOP.
lo_nd_pack_mat->bind_table( new_items = LT_PACK_MAT ).
Cheers,
Kris.
problem is that you bind the whole table. If your concern is only to add one element then use appropriate method like add_element of the if_wd_context_node.
get the selected element from the source node and use this element to add_element if their structures are same otherwise use move_corresponding between structures.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
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.