cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a table row in a table.Please help!

0 Kudos
1,128

Hi Experts,

My requirement is,when the page is load then only one row should be generate in the Webdynpro ABAP table.There have a button "Add Row",after clicking on that button another row will be created and also there have a "Delete Row" button,after click on that the present will be deleted.Please refer the image.

This is done by in Webdynpro JAVA.Is there any way to create in ABAP. If possible please help me.

Thanks and Regards,

Amit Basak

Accepted Solutions (0)

Answers (2)

Answers (2)

ramakrishnappa
Active Contributor
0 Kudos

Hi Amit,

There are many threads available on SCN similar to your requirement.

To add an empty row initially, you need write logic in WDDOINIT( ) method of VIEW i.e

Sample:


DATA lt_material TYPE wd_this->Elements_material.

DATA lo_nd_material TYPE REF TO if_wd_context_node.

  lo_nd_material = wd_context->get_child_node( name = wd_this->wdctx_material ).


append initial line to lt_material.


lo_nd_material->bind_table( new_items = lt_material

  set_initial_elements = abap_true ).

Please refer the below document for add row & delete row functionality.

Hope this helps you.

Regards,

Rama

former_member229034
Participant
0 Kudos

Hi Ramakrishna,

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.

https://archive.sap.com/kmuuid2/c03227f9-e48f-2c10-4bad-8ebdec704f3d/Using%20Drop%20Down%20By%20Inde...

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

bustamantejt
Explorer
0 Kudos

You can create an ALV and set the "read only mode" to false and the buttons "Append row", "Insert row" and "Delete row" will show up automatically in the toolbar of the ALV.

Check this document or this wiki for more information.

0 Kudos

Hi Tomas,

Thanks for you reply,But I do not want to create a ALV table,I want to create simple table and in that table have two button that i mentioned above.

Thanks and Regards,

Amit