cancel
Showing results for 
Search instead for 
Did you mean: 

Add row to table control

Former Member
0 Kudos

Hi,

Give me sample coding to add a row to the table control when add row button is pressed.

Regards,

Charumathi.B

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Charumathi Balachandran ,

On the event of the button, read the node thats binded to the table ctrl, using wizard.

lets say the itab be itab1

append a blank row to the itab.

now bind the itab1 back to the node.

OR

create a new element of the same type of the node which i mapped to tablectrl.

insert blank values to the new element.

add the element to the node.

Regards

Sarath

Former Member
0 Kudos

Hi Sarath,

In my scenario a table has to be displayed initially with 5 editable rows. When the user presses the add row button the sixth row has to be appended to the table.

I have done the following things

In the WDDOINIT method I have written the following code.

data: itab like standard table of wa_tab,

wa_itab like line of itab.

Do 5 times.

wa_tab-slno = " " .

wa_tab-kostl = " " .

wa_tab-PS_POSNR = " " .

wa_tab-saknr = " " .

wa_tab-txt20 = " " .

wa_tab-netwr = space .

append wa_tab to itab.

enddo.

lo_node_items = wd_context->get_child_node( name = 'TAB1' ).

lo_node_items->bind_elements( itab ).

CALL METHOD LO_NODE_ITEMS->BIND_TABLE

EXPORTING

NEW_ITEMS = itab.

So initially 5 rows are editable .

In the onaddrow button I have written the following code.

wa_tab-slno = space.

wa_tab-kostl = space.

wa_tab-PS_POSNR = space.

wa_tab-saknr = space.

wa_tab-txt20 = space.

wa_tab-netwr = space.

append wa_tab to itab.

lo_node_items = wd_context->get_child_node( name = 'TAB1' ).

lo_node_items->bind_elements( itab ).

Then all the five rows are disappearing and only one row is displayed and editable .

Please help me to get the solution.

Regards,

Charumathi.B

Former Member
0 Kudos

hi charumathi........

what you have done is right through the grace of God.

but on the action of inserting two rows....

before you append the empty row,

first read the node and then append the empty row to the internal table of that node and again bind it.

---regards,

alex b justin

Former Member
0 Kudos

yes Charumathi Balachandran ,

read the node thats binded to the table control to the itab , inside the onaddrow button.. then

wa_tab-slno = space.

wa_tab-kostl = space.

wa_tab-PS_POSNR = space.

wa_tab-saknr = space.

wa_tab-txt20 = space.

wa_tab-netwr = space.

append wa_tab to itab.

lo_node_items = wd_context->get_child_node( name = 'TAB1' ).

lo_node_items->bind_elements( itab ).

Thats all

Regards

Sarath

Former Member
0 Kudos

Hi,

I am new to webdynpro Abap, I have a table control with a button in one of the column, rest of the columns are empty.

Once the button is clicked a new row should add up to the table and those columns will have buttons in it.

Can you guys let me know how to do this ? I am not very familiar with Objects.

Tus

Former Member
0 Kudos

Firstly, no need to call BIND_ELEMENTS and BIND_TABLE both the methods. One is enough.

Everything you are doing is correct.

Just, in the method call BIND_ELEMENTS, there is a parameter SET_INITIAL_ELEMENTS which is ABAP_TRUE by default. Pass it also and set it to ABAP_FALSE when you are appending a new row to the table.