on 03-27-2014 6:44 AM
Dear friends,
i am getting an issue while deleting a row from a table, pls check screen shots , the first screen shot is my table contents
when i delete 2 row , the second row is deleting properly like below screen shot
but i want like below screen shot , Col1 contents should be like pic 1 . could any one pls let me know how to solve this issue.
Thanks
Vijaya
Hi Vijaya,
Actually, you are not trying to delete whole entry of 2nd row, instead you are clearing other columns value and retaining the key COL1 at 2nd row
Is it internal table? if so
data ls_wa like line of lt_data.
clear ls_wa.
"Now, we need to modify data of 2 nd line
ls_wa-col1 = 2. "if col1 is numeric
modify lt_data from ls_data transporting all fields.
Hope this helps you.
Regards,
Rama
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijaya,
Let us say user has selected a row / many rows and click on delete button. To clear the data of selected row(s), write the below logic
data lo_node type ref to if_wd_context_node.
data lo_el type ref to if_wd_context_element.
data ls_data type wd_this->element_my_node.
data ls_temp like ls_data.
DATA lt_selected_el TYPE wdr_context_element_set."selected elements
lo_node = wd_context->get_child_node( name = wdctx_my_node ).
lo_nd->get_selected_elements(
RECEIVING set = lt_selected_el ).
LOOP AT lt_selected_el INTO lo_el.
lo_el->get_static_attributes(
importing
static_attributes = ls_temp ).
"clear data
clear ls_data.
ls_data-col1 = ls_temp-col1.
"set the cleared data back to context
lo_el->set_static_attributes(
Exporting
static_attributes = ls_data ).
ENDLOOP.
Replace the "my_node" with your context node name.
It works for multiple rows as well.
Hope this helps you.
Regards,
Rama
Hi Vijaya,
1. Get the selected row first.
lo_el_delete = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
lo_el_delete->get_static_attributes( importing static_attributes = ls_delete
).
2. Clear the values of all the attributes apart from column1.
ls_delete-column1 = 'Column1'.
ls_delete-column2 = ' '.
ls_delete-column3 = ' '.
ls_delete-column4 = ' '.
3. set the data to the node at the same index
Thanks & Regards,
Sankar Gelivi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi vijaya,
please try this code, it will help you.
DATA : it_rows TYPE wdr_context_element_set,
wa_rows LIKE LINE OF it_rows.
DATA lo_nd_table TYPE REF TO if_wd_context_node.
DATA lt_table TYPE wd_this->elements_table.
DATA lo_el_table TYPE REF TO if_wd_context_element.
DATA ls_vbap TYPE wd_this->element_table.
DATA: ld_index TYPE i.
data value TYPE sy-index.
* navigate from <CONTEXT> to <table> via lead selection
lo_nd_table= wd_context->get_child_node( name = wd_this->wdctx_table ).
* @TODO handle non existant child
* IF lo_nd_table IS INITIAL.
* ENDIF.
* get element via lead selection
* alternative access via index
* lo_el_table = lo_nd_table->get_element( index = 1 ).
* @TODO handle not set lead selection
IF lo_el_table IS INITIAL.
ENDIF.
* navigate from <CONTEXT> to <table> via lead selection
lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
* @TODO handle non existant child
* IF lo_nd_table IS INITIAL.
* ENDIF.
lo_nd_table->get_static_attributes_table( IMPORTING table = lt_table ).
* @TODO handle non existant child
* IF lo_nd_table IS INITIAL.
* ENDIF.
** @TODO compute values
** e.g. call a model function
*
* navigate from <CONTEXT> to <table> via lead selection
lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
* @TODO handle non existant child
* IF lo_nd_table IS INITIAL.
* ENDIF.
** @TODO compute values
** e.g. call a model function
*
it_rows = lo_nd_table>get_selected_elements( ).
CALL METHOD lo_nd_table->GET_LEAD_SELECTION_INDEX
RECEIVING
INDEX = value .
LOOP AT it_rows INTO wa_rows.
CALL METHOD wa_rows->get_static_attributes
IMPORTING
static_attributes = ls_table.
READ TABLE lt_table INTO ls_table WITH KEY col1 = ls_table-col1.
ld_index = value.
ENDLOOP.
CLEAR : ls_table-col2,
ls_table-col2.
MODIFY lt_table INDEX ld_index FROM ls_table.
lo_nd_table->bind_table( new_items = lt_table 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.
Hi vijaya laxmi,
try this.
Loop at lt_table into ls_table.
if sy-tabix ne 1.
clear : ls_table-col2,ls_table-col3.
modify lt_table from ls_table.
endif.
endloop.
Regards,
Ravikiran.K
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
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.