Skip to Content
avatar image
Former Member

Add new row in table

Hi,

I have a table UI element with data in it.

When i click on Add Row button, an empty row should get added in to the table UI element.

Can anybody help me out as to how to do this?

Regards,

Kanakaraj V A

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Mar 09, 2009 at 08:06 AM

    Hi Kanakaraj,

    In order to realise this functionality you would just have to bind an empty work area to your context node.

    For example: I have a node by name SFLIGHT which am using to bind to a table on my layout. Try check the code snippet below for my button's action handler:

    method ONACTIONADD_ROW .
      data: wd_node type ref to if_wd_context_node,
            wa_data type wd_this->element_sflight.
      wd_node = wd_context->get_child_node( name = 'SFLIGHT' ).
      wd_node->bind_structure( new_item             = wa_data
                               SET_INITIAL_ELEMENTS = ABAP_FALSE ).
    endmethod.

    Its important to set SET_INITIAL_ELEMENTS to ABAP_FALSE otherwise all the rows of the table would get deleted & it would just contain the newly added row.

    Regards,

    Uday

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 09, 2009 at 07:59 AM

    Hi kanakaraj,

    Try out this...

    Data : node_table type ref to if_wd_context_node,
           elem_table type ref to if_wd_context_element.
    node_table = wd_context->get_child_node( 'TABLE' ).
    elem_table = node_table->create_element( ).
    node_table->bind_element(  new_item = elem_table set_initial_elements = abap_false ).
    

    Hope this helps..

    Thanks,

    Mugundhan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 09, 2009 at 09:21 AM

    Hi,

    Step1: read the Table properties (Table name) by using if_wd_view try it in wdDoModifyView.

    Step2: by using class cl_wd_table you can add new row to your table. (in SE24 you can check class properties)

    • Put this code in your conditions for example when you click the button a new row has to add to the table

    Best Regards

    Ravi

    Add comment
    10|10000 characters needed characters exceeded