cancel
Showing results for 
Search instead for 
Did you mean: 

how to add an empty row in a table ?

Former Member
0 Kudos

hii, i want to add a row at top of table in which already data is diaplayed....

the scenario is ..

    first I displayed some records in table ..

  then when i pressed a button like filter , a row is added as first record which is empty where i can add some data...

(this is not in alv i want it in normal table)

Thanks in advance ..

    LOKESH

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi chengalarayulu urs is right by keeping index value we it allows to add a row ..

but for adding i need to do some action ,in the action method what can we  write ?

Former Member
0 Kudos

Hi Lokesh,

DATA lo_nd_table TYPE REF TO if_wd_context_node.
DATA lo_el_table TYPE REF TO if_wd_context_element.
  DATA stru TYPE wd_this->element_NODE_NAME.

  lo_nd_table = wd_context->get_child_node( name = 'NODE_NAME' ).


  CALL METHOD lo_nd_table->bind_structure
    EXPORTING
      new_item             = stru

     set_initial_elements = abap_false
      index                = 1.

Just write this code and run. Change the NODE_NAME with the name of the node you bound for the table.

Regards,

Fareez

Former Member
0 Kudos

Thanks a lot fareez ... but it is not not editing i want to write in the empty row how can i edit?

Former Member
0 Kudos

While binding the table make the Element used for each column as TextEdit. By default it will be in TextView.

Regards,

Fareez

Answers (3)

Answers (3)

Former Member
0 Kudos

hi thanks for ur reply...

but for adding a row im creating a button as filter ..

when i click on it a new row will be added ...then in the action method of button what can i write im not getting pls help me..

chengalarayulu
Active Contributor
0 Kudos

Hi Lokesh,

you can do like below.

    DATA lo_nd_table TYPE REF TO if_wd_context_node.
  DATA lo_el_table TYPE REF TO if_wd_context_element.
  DATA ls_table TYPE wd_this->element_table.

* navigate from <CONTEXT> to <TABLE> via lead selection
  lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).

  CALL METHOD lo_nd_table->bind_structure
    EXPORTING
      new_item             = ls_table
      set_initial_elements = abap_false
*    index                =
      .

Former Member
0 Kudos

Hi Chengalarayulu,

Your code does create a new row at the end of the table, but i think you did not notice that the requirement is for adding a line at the top of the table.

Regards,

Fareez

chengalarayulu
Active Contributor
0 Kudos

we can provide INDEX also, it is already there in called method(BIND_STRUCTURE). it inserts wherevre we want in the table.

chengalarayulu
Active Contributor
0 Kudos

we can provide INDEX also, it is already there in called method(BIND_STRUCTURE). it inserts wherevre we want in the table.

Former Member
0 Kudos

Hi fareez and chengalarayulu... thanks for ur valuable reply..

im not getting how to add a row for a table having data ie... my output is a table initially displayed a data ..

when i clicked on a button(filter) an empty row will append ..

then i can type a field record name (fert ) below it will show all records related to that name..

this is my actual requirement..

fareez : what is the insert command to insert arow ..at starting ?

Former Member
0 Kudos

Hi , chengalarayulu im not getting can brief this point of adding index..

Former Member
0 Kudos

Hi lokesh,

As chengalarayulu says, bind_structure or bind_element will insert a new row to an existing table without affecting the data already present in the table.

If you use any of these methods then no need to use the insert command to insert on an itab and then doing bind_table. Just do as chengalarayulu said and don't forget to give the index as 1 to make the row appear on the top.

Regards,

Fareez

Former Member
0 Kudos

Hi Lokeshwar,

As you say you want to enter data, use TextEdit element to show the data. Now on the action of the button do as follows,

1. get the data on the table using get_static_attributes_table from the context node.

2. now add an empty row at the top using insert command

3. Now bind the table to the context node

This will make a new row appear on the table and you can enter data.

Regards,

Fareez