cancel
Showing results for 
Search instead for 
Did you mean: 

Table as input field..!

Former Member
0 Kudos

Hi Guys,            

I designed table to get input from user. But only the first row is open up as input field and other rows still stay as read only.

I can't enter data into them.  The context bind to the table is 1 to N.

Visible Row Count property set to 5.

Any one come across this issue ?

Wondering what if user enter more than 5 rows, how inserting a new row in a table can be done ?

Thanks

Sam

Accepted Solutions (0)

Answers (7)

Answers (7)

amy_king
Active Contributor
0 Kudos

Hi Sam,

You could create a supply function for your 1..n node in order to provide it blank rows ready for input.

METHOD supply_mynode .

  DATA lt_table_records TYPE wd_this->elements_mynode.

* Populate the table with empty rows ready for input
  DO 10 TIMES.
    APPEND INITIAL LINE TO lt_table_records.
  ENDDO.

  node->bind_table(
    new_items            = lt_table_records
    set_initial_elements = abap_true ).

ENDMETHOD.

You could then provide a button to append new rows to the table or you could programmatically detect that more rows are needed and automatically provide additional rows.

 METHOD wddomodifyview .

  DATA lv_total           TYPE i.
  DATA lv_diff            TYPE i.
  DATA lv_rows_populated  TYPE i.

* [1] Get the node's static attribute table, lt_table_records
* [2] Determine how many rows of the table are populated

  lv_total = LINES( lt_table_records ).
  lv_diff = lv_total - lv_rows_populated.
  CHECK lv_diff < 5. " or some other threshold for number of blank rows
  lv_diff = 5 - lv_diff. " number of blank rows to append

  DO lv_diff TIMES.
    APPEND INITIAL LINE TO lt_new_rows.
  ENDDO.

  lo_nd_mynode->bind_table(
    new_items            = lt_new_rows
    set_initial_elements = abap_false ). " append instead of replace

ENDMETHOD.

Cheers,

Amy

former_member184578
Active Contributor
0 Kudos

Hi,

Check this thread : http://scn.sap.com/thread/3158622

@SIVA thats me . you can find the same in the above thread.

hope this helps u.,

Thanks & Regards,

Kiran

Former Member
0 Kudos

Hi Sam,

Recently i faced the same issue, One of our SNC member provided below solution and its working .

If you want to show 5 empty records, append initial lines to the internal table  5 times and bind to Node of the Table UI element.

Sample:

1. Do 5 times.

Append wa to itab.

enddo.

2. Get the node

3. node->bind_table( itab ).

Thanks and regards

Siva Mandapudi.

former_member230486
Contributor
0 Kudos

Hi Sam,

You have to take one Add row button in the table toolbar.In the onaction of the Add Row button write the below code,

DATA lo_nd_importing TYPE REF TO if_wd_context_node.

   DATA lt_importing TYPE wd_this->elements_importing.

   DATA LV_INDEX TYPE I.

   DATA LT_SEL_REC TYPE WDR_CONTEXT_ELEMENT_SET.

* navigate from <CONTEXT> to <IMPORTING> via lead selection

   lo_nd_importing = wd_context->path_get_node( path = `ZTEST.IMPORTING` ).

* @TODO handle non existant child

* IF lo_nd_importing IS INITIAL.

* ENDIF.

   lo_nd_importing->get_static_attributes_table( IMPORTING table = lt_importing ).

*CALL METHOD lo_nd_importing->get_lead_selection_index

*  receiving

*    index  = LV_INDEX.

APPEND INITIAL LINE TO lt_importing.

CALL METHOD lo_nd_importing->bind_table

   EXPORTING

     new_items            = LT_IMPORTING

*    set_initial_elements = ABAP_TRUE

*    index                = LV_INDEX   .

Former Member
0 Kudos

Hi Sam,

Like Venkata Krishna said you can create one  button 'Add row' . IN the action event method you  have  to just append one blank row to internal table which is already bound to table ui element . And again bind that internal table to node which is bound to Table ui element.

Means whenever you press  button' Add row' the new  blank row is created for input.

Like this you can create button for 'Save row'.

Thanks

Santosh.

chandani_kaur
Active Participant
0 Kudos

Hello Sam,

You have binded the table to a node with cardinality 1..n, so one element is created. You have to provide one add button which will add element to the node, which will indirectly add a row in table. as the cell editor used by you is a inputfiled, so everytime a new element is added to the node an editable row will be added.

Thanks & regards,

Chandani

Former Member
0 Kudos

Hi Sam,

When ever their is no data then it displays like that only ......Means if u want to add more number of input rows then u have to insert empty records to u r internal table which is binded to this table...

Here that first record comes means u r node card  1...n  so it has to take atleast one record so first row is visible in table.....

Initially u just add 5 empty records to u r table.......After that create one button( ADD ROW) in this button action u add some more empty rows to inernal table and bind it..

Regards,

Venkat

Former Member
0 Kudos

If you use ALV you have in built Insert row option which makes your work easy.