on 2007 Mar 14 10:15 AM
Hi All,
I am using a table in webdynpro ABAP. This table has a binding with a node (node name is ET_SAFRA). This node has a cardinality of 0:N. After creating the binding, the datasource property is set to the same node. The attributes of this node are used as "inputfield" in this table (except one attribute which is textview).
Now I have created two buttons, one for adding and one for deleting rows from the table. I have written the following codes in each of the button's action method.
***ADD BUTTON
DATA:
node_et_safra TYPE REF TO if_wd_context_node,
elem_et_safra TYPE REF TO if_wd_context_element,
stru_et_safra TYPE if_view_safranew=>element_et_safra .
navigate from <CONTEXT> to <ET_SAFRA> via lead selection
node_et_safra = wd_context->get_child_node( name = if_view_safranew=>wdctx_et_safra ).
node_et_safra->create_element( ).
*********************************************************************
**DELETE BUTTON
DATA:
node_et_safra TYPE REF TO if_wd_context_node,
elem_et_safra TYPE REF TO if_wd_context_element,
stru_et_safra TYPE if_view_safranew=>element_et_safra .
navigate from <CONTEXT> to <ET_SAFRA> via lead selection
node_et_safra = wd_context->get_child_node( name = if_view_safranew=>wdctx_et_safra ).
@TODO handle not set lead selection
IF ( node_et_safra IS INITIAL ).
ENDIF.
get element via lead selection
elem_et_safra = node_et_safra->get_element( ).
node_et_safra->remove_element( elem_et_Safra ).
*******************************************************************
Neither can i see a row being added, nor can i see a selected row being deleted from the table.
Is such a feature not possible or am I doing something majorly wrong?
I have struggled with ALV to get this functionality and failed. Now this is not working either. Please help me.
regards,
Priyank
Message was edited by:
Priyank Jain
Hi Madhusudan,
I hope you are well.
Just came across this thread and we have a similar requirement. Although it has been very long time since the last answer, trying to reach out and hope this will be answered.
The requirement is that we need to add and delete rows in a table which has a dropdown and an input field.
I followed the example provided in the link below as it matches our requirement. I am currently working on adding and deleting rows using two buttons above the table.
While I tried to do it as usual, it has created blank row but when I scroll down, it results in a short dump possibly because there are input elements involved and I haven't handled creating them before binding. I have also searched and been through several links on SDN but couldn't find a suitable solution.
I created a node with a sub node having the following fields:
Node: TRAVEL
Cardinality 0..n
Selection 0..1
Subnode: CITY_LIST
Cardinality 0..n
Selection 0..1
I worked on adding and deleting rows to regular tables previously i.e. with no input fields or dropdowns but this time it is somewhat different as it has different input elements involved.
Could you please help with how to append and delete rows in the table.
Thank you.
Regards,
Chaitanya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hai Priyank,
What you did is correct,but when crreating an element you need to add the elements to it.
<u><b>See the example code</b></u> I am adding the entering the fields and then adding them to the table.
DATA:
node_flighttab TYPE REF TO if_wd_context_node,
elem_flighttab TYPE REF TO if_wd_context_element,
stru_flighttab TYPE if_main_view=>element_flighttab,
node_flight TYPE REF TO if_wd_context_node,
elem_flight TYPE REF TO if_wd_context_element,
stru_flight TYPE if_main_view=>element_flight .
node_flighttab = wd_context->get_child_node( name = if_main_view=>wdctx_flighttab ).
elem_flighttab = node_flighttab->create_element( ).
node_flight = wd_context->get_child_node( name = if_main_view=>wdctx_flight ).
elem_flight = node_flight->get_element( ).
get all declared attributes
elem_flight->get_static_attributes(
IMPORTING
static_attributes = stru_flight ).
stru_flighttab = stru_flight.
node_flighttab->bind_structure(
EXPORTING
new_item = stru_flighttab
set_initial_elements = abap_false ).
here i am getting the data from flight node and adding it ot flighttab,As table is built based on Flightytab node, a new row will be added.
<u><b>Same is the case with DELETE:</b></u>
The sample code is as follows:
DATA:
node_flighttab TYPE REF TO if_wd_context_node,
elem_flighttab TYPE REF TO if_wd_context_element,
stru_flighttab TYPE if_main_view=>element_flighttab .
navigate from <CONTEXT> to <FLIGHTTAB> via lead selection
node_flighttab = wd_context->get_child_node( name = if_main_view=>wdctx_flighttab ).
get element via lead selection
elem_flighttab = node_flighttab->get_element( ).
node_flighttab->remove_element( element = elem_flighttab ).
check the 2 codes and i think they mat be helpful
bye.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Figured out the delete row problem. But add row still not working.
any comments on the code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
64 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.