on 01-31-2011 11:02 AM
hi,
I have added the separate column "delete" to the table uielement and so for each record or row of the table the appropriate "delete" link to action will be there................the code below works when the particular row is selected through lead selection only.......
help me how to delete without using lead selection.....
DATA:
NODE_MODULE TYPE REF TO IF_WD_CONTEXT_NODE,
ELEM_MODULE TYPE REF TO IF_WD_CONTEXT_ELEMENT,
STRU_MODULE TYPE IF_V_MODULE=>ELEMENT_MODULE .
data itab TYPE TABLE OF zac_modules.
navigate from <CONTEXT> to <MODULE> via lead selection
NODE_MODULE = WD_CONTEXT->GET_CHILD_NODE( NAME = `MODULE` ).
get element via lead selection
ELEM_MODULE = NODE_MODULE->GET_ELEMENT( ).
get all declared attributes
ELEM_MODULE->GET_STATIC_ATTRIBUTES(
IMPORTING
STATIC_ATTRIBUTES = STRU_MODULE ).
NODE_MODULE->GET_STATIC_ATTRIBUTES_TABLE(
IMPORTING
TABLE = itab )
.
DELETE itab WHERE zmodule_id = STRU_MODULE-zmodule_id.
CALL METHOD NODE_MODULE->BIND_TABLE
EXPORTING
NEW_ITEMS = itab
SET_INITIAL_ELEMENTS = ABAP_TRUE
INDEX =
.
ENDMETHOD.
Alagappen,
i think onbutton action send you the standard parameters id and context_element. If you do not have them already, you can delete the action and create a action with event-parameters checkbox selected or you can insert these parameters on your own.
if_wd_context_node has parameter remove_element and it accepts a context_element as importing parameter.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
In the eventhandler of the delete button .
write the code to get the element from which the button has been clicked by using the following code and then delete it.
DATA lo_el TYPE REF TO if_wd_context_element.
lo_el = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
then delete
DATA lo_nd TYPE REF TO if_wd_context_node.
lo_nd = wd_context->get_child_node( name = '<node name>' ).
lo_nd->remove_element( lo_el ).
Regards,
Sarb
>
> hi baskaran,
>
> But i have delete button for each and every record for the table.....................and i have to delete the record without using lead selection........
>
> Edited by: Alagappan.S on Jan 31, 2011 4:49 PM
Right, on every button click you get the corresponding context_element along with the wdevent object.
If your event handler has this parameter (importing) then data transport happens automatically. You do not need any lead selection.
Hi ,
The onclick event provides you with a standard paramater "CONTEXT_ELEMENT" which has the element from which the event is triggered.
so you can declare this in the handler(if it is not there) and use it as follows.
CONTEXT_ELEMENT TYPE REF TO IF_WD_CONTEXT_ELEMENT an importing paramater.
DATA:
NODE_MODULE TYPE REF TO IF_WD_CONTEXT_NODE,
ELEM_MODULE TYPE REF TO IF_WD_CONTEXT_ELEMENT,
STRU_MODULE TYPE IF_V_MODULE=>ELEMENT_MODULE .
data itab TYPE TABLE OF zac_modules.
CONTEXT_ELEMENT->GET_STATIC_ATTRIBUTES(
IMPORTING
STATIC_ATTRIBUTES = STRU_MODULE ). "Using the context_element paramater to get the static attributes.
NODE_MODULE->GET_STATIC_ATTRIBUTES_TABLE(
IMPORTING
TABLE = itab ) "getting all the data.
.
DELETE itab WHERE zmodule_id = STRU_MODULE-zmodule_id. "deleting the particular row from the table and binding it.
CALL METHOD NODE_MODULE->BIND_TABLE
EXPORTING
NEW_ITEMS = itab
* SET_INITIAL_ELEMENTS = ABAP_TRUE
* INDEX =
.
thanks,
Aditya.
>
> @sarbjeet
>
> plz edit me in the above code which i have written bcoz i dont know where the prob. occurs exactly......
You just need to write this code as it is with node name in the place mentioned below in the code.
DATA lo_el TYPE REF TO if_wd_context_element.
lo_el = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
DATA lo_nd TYPE REF TO if_wd_context_node.
lo_nd = wd_context->get_child_node( name = '<node name>' ). " here <node name> give your node's name which is
"bound to data source of the table.
lo_nd->remove_element( lo_el ).
Thanks
sarbjeet singh
@sarbjeet,
but it is working with lead selection only.............if there are 10 records inside the table,i also have 10 delete buttons inside the table for each and every row................I have inserted the delete button into the table by right clicking on the table uielement and i have selected tablecolumn option to insert the seperate column and iside that i have inserted the button............
Here is what i am writing in my delete eventhandler top delete the record from backend as well as from table.
my table is zdealer and i am deleting after checking the id of the selected row.
DATA lo_el TYPE REF TO if_wd_context_element.
lo_el = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
DATA lo_nd_zdealer TYPE REF TO if_wd_context_node.
lo_nd_zdealer = wd_context->get_child_node( name = 'DEALER' ).
lo_nd_zdealer->remove_element( lo_el ).
data lv_id type ZDEALER-ID.
lo_el->get_attribute(
EXPORTING
name = `ID`
IMPORTING
value = lv_id ).
delete from zdealer where id = lv_id.
Regards,
Sarbjeet singh
@sarbjeet: I too tried the same thing just now and Wrote the code exactly u told . I am also getting the same error as ALAGAPPAN (he is working with me )
The error(runtime) which I am getting is "ACCESS VIA NULL OBJJECT " when we call the function GET_ATTRIBUTE at the end through ELEMENT. UPon debugging i found out that the line when we write
ELEM_TABLE_EMP = WDEVENT->GET_CONTEXT_ELEMENT( 'CONTEXT ELEMENT' ).
is not storing anything in ELEM_TABLE_EMP. ITs value after this statement remains . Thats why later when we try to call GET_ATTRIBUTE from this object , since its containing NULL VALUE , we get the runtime error.
So dont know why nothing is stored in ELEM_TABLE_EMP.
THANKS
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.