on 04-13-2015 3:35 PM
Hi;
I have the next problem, I have a table with the add/delete buttons, I can add and delete records to the table.
My problem is when I delete a row from the table, it's gone from the table, but, if I add one new record to the table, the deleted record is displayed again in the table.
this is my code to ADD/Button:
DATA lo_nd_tabla TYPE REF TO if_wd_context_node.
DATA ls_tabla TYPE wd_this->element_tabla.
DATA lt_tabla TYPE wd_this->elements_tabla.
DATA: w_itab TYPE wd_this->element_tabla.
w_itab-item = lv_item.
w_itab-usuario = lv_usuario.
w_itab-descripcion = lv_descripcion.
SELECT SINGLE descripcion INTO w_itab-descitem FROM zreqhardware WHERE codigo = lv_item.
APPEND w_itab TO lt_tabla.
clear w_itab.
lo_nd_tabla = wd_context->get_child_node( name = wd_this->wdctx_tabla ).
lo_nd_tabla->bind_table( new_items = lt_tabla set_initial_elements = abap_false ).
*** leemos/READ los registros de la tabla interna
lo_nd_tabla = wd_context->get_child_node( name = wd_this->wdctx_tabla ).
lo_nd_tabla->get_static_attributes_table( IMPORTING table = lt_tabla )."here is where i get all the table data, included the deleted record
*** amarramos/binding los registros de la TABLA a T_V0002
DATA: node_emp TYPE REF TO if_wd_context_node.
node_emp = wd_context->get_child_node( name = 'T_V0002' ).
node_emp->bind_table( lt_tabla ).
This is my code to DELETE/Button:
DATA lo_nd_t_v0002 TYPE REF TO if_wd_context_node.
DATA lo_el_t_v0002 TYPE REF TO if_wd_context_element.
DATA ls_t_v0002 TYPE wd_this->element_t_v0002.
lo_nd_t_v0002 = wd_context->get_child_node( name = wd_this->wdctx_t_v0002 ).
lo_el_t_v0002 = lo_nd_t_v0002->get_element( ).
IF lo_el_t_v0002 IS INITIAL.
exit.
ENDIF.
lo_nd_t_v0002->remove_element(
exporting
element = lo_el_t_v0002 ).
As I said, both codes work ok, but it seems like "delete record" is not really working or I'm doing wrong the context treatment in the ADD button code.
Thanks on advance.
David Fúnez
Solved, My Mistake
If you see my orginal post in ADD/Button i was pointing to other existing table node called "TABLA", so i corrected to T_V0002 that is the node table name that i need.
Corrected code:
DATA lo_nd_tabla TYPE REF TO if_wd_context_node.
DATA ls_tabla TYPE wd_this->element_t_v0002.
DATA lt_tabla TYPE wd_this->elements_t_v0002.
DATA: w_itab TYPE wd_this->element_t_v0002.
w_itab-item = lv_item.
w_itab-usuario = lv_usuario.
w_itab-descripcion = lv_descripcion.
SELECT SINGLE descripcion INTO w_itab-descitem FROM zreqhardware WHERE codigo = lv_item.
APPEND w_itab TO lt_tabla.
CLEAR w_itab.
lo_nd_tabla = wd_context->get_child_node( name = wd_this->wdctx_t_v0002 ).
lo_nd_tabla->bind_table( new_items = lt_tabla set_initial_elements = abap_false ).
*** leemos/READ los registros de la tabla interna
lo_nd_tabla = wd_context->get_child_node( name = wd_this->wdctx_t_v0002 ).
lo_nd_tabla->get_static_attributes_table( IMPORTING table = lt_tabla ).
*** amarramos/binding los registros de la TABLA a T_V0002
DATA: node_emp TYPE REF TO if_wd_context_node.
node_emp = wd_context->get_child_node( name = 'T_V0002' ).
node_emp->bind_table( lt_tabla ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
You need to correct your code,
1. In the add/button coding add the code first get the table using
wd_node->get_Static_attributes_Table.
it will update your internal table with the latest record/
2. In the delete method after deletion bind the TABLE.
Thanks and Regards
Nishant,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
after the remove_element....you had to do bind the table.
Regards
Jay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.