on 07-08-2013 9:36 PM
Hi all,
i am displaying alv in a view and with buttons create , change and delete.
when i click on delete button popup window will appear when i say yes to delete record, the record should get deleted from alv and get refreshed with new records.
i am not able to delete the record and display the alv with in the same view after deletng the row.
can you please help me..
Thansk & Regards,
Nagalakshmi.
Hi nagalakshmi,
Follow the below process it may help you.
In the event handler method of the delete, follow the below steps:
DATA lo_nd_sflight TYPE REF TO if_wd_context_node.
DATA lt_sflight TYPE wd_this->elements_sflight.
DATA ls_sflight TYPE wd_this->element_sflight.
lo_nd_sflight = wd_context->get_child_node( name = wd_this->wdctx_sflight ).
lo_nd_sflight->get_static_attributes_table( IMPORTING table = lt_sflight ).
CALL METHOD wd_context->get_child_node
EXPORTING
name = 'SFLIGHT'
RECEIVING
child_node = lo_nd_sflight.
DATA:t_data TYPE wdr_context_element_set.
DATA:w_data LIKE LINE OF t_data.
CALL METHOD lo_nd_sflight->get_selected_elements
RECEIVING
set = t_data.
LOOP AT t_data INTO w_data.
CALL METHOD w_data->get_static_attributes
IMPORTING
static_attributes = ls_sflight."<fs>."w_field.
DELETE TABLE lt_sflight FROM ls_sflight.
ENDLOOP.
lo_nd_sflight = wd_context->get_child_node( name = wd_this->wdctx_sflight ).
lo_nd_sflight->bind_table( new_items = lt_sflight 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 Laxmi,
Just follow the code under the delete button.
1. get the table data to internal table via context node like get_static_table method
2. get the table lead selection value like get_lead_selection method
3. delete the record from the internal table with above value as record index.
4. again bind the internal table to context node after delete the record.
regards,
Kishroekumar SVS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nagalakshmi,
What I understood is, as soon as you are deleting record from your database table, data in ALV is not getting refreshed.
If it is so, then put your select query and code to bind data with node in one separate method. and call that method again after deleting record from database i.e. on the action of Delete button. It will work.
Or kindly explain your problem little more.
Happy Coding,
Keshav.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Bind the context node with modified data inetrnal table data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
for call view as popup, and add event to that.
LO_API_COMPONENT = WD_COMP_CONTROLLER->WD_GET_API( ).
LO_WINDOW_MANAGER = LO_API_COMPONENT->GET_WINDOW_MANAGER( ).
LO_WINDOW = LO_WINDOW_MANAGER->CREATE_WINDOW(
WINDOW_NAME = 'TEST'
TITLE = 'Test Delete'
CLOSE_IN_ANY_CASE = ABAP_FALSE
MESSAGE_DISPLAY_MODE = IF_WD_WINDOW=>CO_MSG_DISPLAY_MODE_SELECTED
* close_button = abap_true
BUTTON_KIND = IF_WD_WINDOW=>CO_BUTTONS_YESNO
MESSAGE_TYPE = IF_WD_WINDOW=>CO_MSG_TYPE_NONE
DEFAULT_BUTTON = IF_WD_WINDOW=>CO_BUTTON_YES
).
LO_WINDOW->OPEN( ).
LR_VIEW_CONTROLLER = WD_THIS->WD_GET_API( ).
LO_WINDOW->SUBSCRIBE_TO_BUTTON_EVENT(
BUTTON = IF_WD_WINDOW=>CO_BUTTON_YES
BUTTON_TEXT = 'Delete'
ACTION_NAME = 'ON_Delete'
ACTION_VIEW = LR_VIEW_CONTROLLER ).
on action of delete button, get the index of selected row using GET_LEAD_SELECTION_INDEX of IF_WD_CONTEXT_NODE (if one at a time). then delete that index row from your internal table.
and set your ALV again.
************
if selecting multiple rows, then get all selected rows elements using GET_SELECTED_ELEMENTS of IF_WD_CONTEXT_NODE,
CALL METHOD LO_ND_ALV_LIST->GET_SELECTED_ELEMENTS
EXPORTING
INCLUDING_LEAD_SELECTION = ABAP_TRUE
RECEIVING
SET = LT_SELECTED.
then,
LO_EL_ALV_LIST TYPE REF TO IF_WD_CONTEXT_ELEMENT,
Loop on LT_SELECTED into LO_EL_ALV_LIST.
CALL METHOD LO_EL_ALV_LIST->GET_STATIC_ATTRIBUTES
IMPORTING
STATIC_ATTRIBUTES = LS_ALV_LIST.
look for your specific value/condition, and delete that row based on that from internal table
endloop.
set your alv again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.