on 10-02-2012 8:47 PM
Hi Friends
I need help in WD
I have situation that , on clicking delete button i need to delete the line from and that should be updated in the DB table.
I have written this code...
I am able to delete the item in the table but i need to update the ztable as well.
Any help is appreciated.than you in advance.let me know if you need more info.
*-- Local dta
DATA : lo_nd_nd_exc_item TYPE REF TO if_wd_context_node,
"Item data node.
lo_el_nd_exc_item TYPE REF TO if_wd_context_element,
"Selected line
lt_sel_elmts TYPE wdr_context_element_set.
"All selected lines.
* Get the selected lines.
lo_nd_nd_exc_item = wd_context->get_child_node(
name = wd_this->wdctx_nd_exc_item ).
lt_sel_elmts = lo_nd_nd_exc_item->get_selected_elements(
including_lead_selection = abap_true ) .
* * Remove elements from the table.
IF lt_sel_elmts IS NOT INITIAL .
LOOP AT lt_sel_elmts INTO lo_el_nd_exc_item.
CALL METHOD lo_nd_nd_exc_item->remove_element
EXPORTING
element = lo_el_nd_exc_item.
ENDLOOP.
ENDIF.
Hi Vandana,
If I understand your question, you need to update a customer database table-- a z-table-- is that right? If so, there is nothing "web dynpro" specific you need to do. You would use Open SQL keywords INSERT, UPDATE, MODIFY or DELETE to update your z-table as needed. See this link for help on changing data the database. This same information is also available in your system's keyword documentation library.
Note that it's only appropriate to directly update a customer database table. If you needed to update an SAP database table, you wouldn't want to use INSERT, UPDATE, MODIFY or DELETE since doing so violates the service contract with SAP. To update an SAP database table, you would want to look for a BAPI or function module or perhaps use BDC.
Cheers,
Amy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amy,
thanks for quick reply.
I have used remove element method, which iam able to remove the line item from the table...but is only happeing on screen
when i trying to use
delete lo_el_nd_exc_item.
it is nt wrking bcoz it is not a internal table
my problem is: i have line item in ' lo_el_nd_exc_item' nw to delete the line item from db
any sample code will be appreicated
is there any method we can use it;
IF lt_sel_elmts IS NOT INITIAL .
LOOP AT lt_sel_elmts INTO lo_el_nd_exc_item.
CALL METHOD lo_nd_nd_exc_item->remove_element
EXPORTING
element = lo_el_nd_exc_item.
ENDLOOP.
Hi Vandana.
I encourage you to read the keyword documentation for DELETE since this will help you decide how to build your DELETE statement according to your needs.
The syntax options are as follows...
Examples of deleting from a customer database table are...
DELETE FROM ztable WHERE key = my_value.
DELETE ztable FROM TABLE my_key_table.
DELETE ztable FROM my_workarea.
Cheers,
Amy
Hi Amy,
Thanks amy i new to WD,and answering my questions.
the delete command had worked..i have one more problem i have
i able to delete the row from DB but not selected one is getting deleted.
Please check the code and i am missing:how to get the selected row in it_tab?
* * *-- Local dta
DATA : lo_nd_nd_exc_item TYPE REF TO if_wd_context_node,
"Item data node.
lo_el_nd_exc_item TYPE REF TO if_wd_context_element,
"Selected line
lt_sel_elmts TYPE wdr_context_element_set,
"All selected lines.
ls_nd_exc_head TYPE wd_this->element_nd_exc_head,
lt_nd_exc_item TYPE wd_this->elements_nd_exc_item.
Data ls_nd_exc_item type wd_this->element_nd_exc_item.
* navigate from <CONTEXT> to <ND_EXC_ITEM> via lead selection
lO_nd_nd_exc_item = wd_context->get_child_node( name = wd_this->wdctx_nd_exc_item ).
* @TODO handle non existant child
IF lo_nd_nd_exc_item IS INITIAL.
ENDIF.
* get element via lead selection
lo_el_nd_exc_item = lo_nd_nd_exc_item->get_element( ).
* @TODO handle not set lead selection
IF lo_el_nd_exc_item IS INITIAL.
ENDIF.
* alternative access via index
lo_el_nd_exc_item = lo_nd_nd_exc_item->get_element( index = 1 ).
* get all declared attributes
lo_el_nd_exc_item->get_static_attributes(
IMPORTING
static_attributes = ls_nd_exc_item ).
data: i type i.
data: it_tab type table of wd_this->element_nd_exc_item,"ZTT_FQM_EXC,
wa_tab type wd_this->element_nd_exc_item . "ZTT_FQM_EXC_REQ
i = lo_el_nd_exc_item->GET_INDEX( ).
lo_nd_nd_exc_item->get_static_attributes_table(
IMPORTING
table = it_tab ).
lo_nd_nd_exc_item->get_static_attributes(
EXPORTING index = i
importing STATIC_ATTRIBUTES = wa_tab ).
DELETE table it_tab FROM wa_tab.
lo_nd_nd_exc_item->bind_table( it_tab ).
READ TABLE it_tab INTO wa_tab INDEX i.
DELETE ZTT_FQM_EXC_REQ FROM TABLE it_tab .
endmethod.
Hi,
Use this code to get the selected row :
lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
l_lead_index = lr_element->get_index( ).
lo_el_nd_exc_item = lo_nd_exc_item->get_element( l_lead_index ).
* get all declared attributes
lo_el_nd_exc_item->get_static_attributes(
IMPORTING
static_attributes = ls_nd_exc_item ).
Thanks,
Pris.
Hi Vandana,
I'm not sure if you're intending to delete one row from the database or several rows. If you're trying to delete just one row corresponding to the lead selection, then you already have read the lead selection with your line...
* get element via lead selection
lo_el_nd_exc_item = lo_nd_nd_exc_item->get_element( ).
Now you just need to get the static attributes of the lead selection...
lo_el_nd_exc_item->get_static_attributes(
IMPORTING
static_attributes = ls_nd_exc_item ).
Assuming ls_nd_exc_item has the same structure as the database table, you can delete the database record corresponding to the lead selection via...
DELETE ztt_fqm_exc_req FROM ls_nd_exc_item.
If ls_nd_exc_item does not have the same structure as the database table, you can delete the database record corresponding to the lead selection via...
DELETE FROM ztt_fqm_exc_req WHERE key_field1 = ls_nd_exc_item-field1
AND key_field2 = ls_nd_exc_item-field2.
Cheers,
Amy
Hi Amy,
I am tring to display success message in the format
'Batch xxxxx is removed from Exception id XXX'
Any help please.
I have used this logic:
CALL METHOD lo_message_manager->REPORT_SUCCESS
EXPORTING
MESSAGE_TEXT = 'Batch is removed from Exception id'
* PARAMS =
* MSG_USER_DATA =
* IS_PERMANENT = ABAP_FALSE
* SCOPE_PERMANENT_MSG = CO_MSG_SCOPE_CONTROLLER
* VIEW =
* SHOW_AS_POPUP =
* CONTROLLER_PERMANENT_MSG =
* MSG_INDEX =
* CANCEL_NAVIGATION =
* ENABLE_MESSAGE_NAVIGATION =
* COMPONENT =
* RECEIVING
* MESSAGE_ID =
.
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 | |
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.