cancel
Showing results for 
Search instead for 
Did you mean: 

Adding rows dynamically in a table UI element

Former Member
0 Kudos

Hello Experts,

I have simple requirement yet complicated to implement within ABAP Webdynpro.

The requirement is as follows:

I have a table, with 2 columns, first one is a dropdownlist and second is an input field.

When the user enters details in inputfield, a second row must be created dynamically with the same structure (dropdown list + input field). Thus, an additional row N must be created dynamically when user enters details in row N-1.

Can someone help me in implementing the requirement in ABAP Webdynpro?

Thanks and regards,

Nitish.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Answered

Former Member
0 Kudos

Hello Draveenam. i'm a new tio webdynpro . Currently doing a requrement where i've to increase the table rows dynamically. my requirement is something close to you. so can you tell me how you achieved your requirement means adding a row dynamically?

Thank you and regards

Rajesh.J

Former Member
0 Kudos

Hi Rajesh,

To add a row dynamically to the table, follow the steps.

1. create anew element of the node using method NODE->CREATE_ELEMENT( ).

2. Now add this element to the node using NODE->BIND_ELEMENT( ). Here you should set SET_INITIAL_ELEMENTS parameter as ABAP_FALSE.

A new row would be added to your table.

Former Member
0 Kudos

Hi Khushboo,

          Thank you for your valuable points. I'll try them.  Do i need to write that piece of code under onenter() action of table column? or wddomodifyview() method?

Former Member
0 Kudos

To answer this i would want to know when you want to add a row to the table.

1. If you have a button like 'Add Row' Or 'Insert', then put this code in the event handler of the button.

2. If you want to insert empty rows in a tab;e from the very beggining, you can follow a different process.

So please let me know when do you want to add rows?

Former Member
0 Kudos

When user reaches last row of the table then if he presses enter button or any other(addrow button) then i need to add a new empty row to that table. And if user enters vlaue in first field of table then only remaining fileds shold be mandatory. Means user must enter values for remaining table fields only the first column is not initial.

Former Member
0 Kudos

Hi,

Ok. You can do the following.

1. Create a method that will have the code as mentioned in my previous post.

2. Now there are two conditions on which row shall be added

     2a. On Enter

     - Create an action in the input field say 'ONENTER'

     - For this action 'ONENTER' check the checbox 'Transfer UI parameters'

     - in the event handler

     - get the element count of the node NODE->GET_ELEMENT_COUNT

     - Get the index of the element calling the event ELEMENT->GET_INDEX( ) [ Element will be ontained as importing parameter because u marked the checkbox ]

     - If the index = element_count , call the method created in step 1

     2b. Add Row Button

     - Just call the method created in step 1

Former Member
0 Kudos

Hi Nitu,

Create a action in the on enter action of your input field.

In that action:-

1. Read the details of the particular row from the event.

DATA LO_EL_<node name> TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_<node name > TYPE WD_THIS->ELEMENT_<node name >.

LO_EL_<node name > = WDEVENT->GET_CONTEXT_ELEMENT( 'CONTEXT_ELEMENT' ).

  • get all declared attributes

LO_EL_<node name >->GET_STATIC_ATTRIBUTES(

IMPORTING

STATIC_ATTRIBUTES = LS_<node name > ).

2. Get details of index to create the new row just below

DATA INDEX_VALUE TYPE INT4.

CALL METHOD LO_EL_<node name >->GET_INDEX

RECEIVING

MY_INDEX = INDEX_VALUE.

Now get the details of the table append a new row with proper index and bind the table again with the node.

Thanks & Regards,

Monishankar C

former_member199125
Active Contributor
0 Kudos

Hi Nitish,

in your input field ONENTER action, bind blank work area to table, so that new row will added. using bind_element method.

Regards

Srinivas

Former Member
0 Kudos

I would consider using Row repeater UI in combination with eventually controlling the visibility of the UI when it is empty.