cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic rows in ABAP webdynpro table

AntonPierhagen
Active Participant
0 Kudos

hi all

I've got a question. I have a webdynpro with a table.

This table is feed by a node. The number of rows of this node is dynamic.

I had seen in the properties of the table object that the number of visible rows can be set.

But is there also a method to set this number of rows dynamicly? So when the node has 20 rows

the table object is also set to show 20 rows and when there are none, the table

only shows the header of the table.

Currently the table always shows 5 rows, without checking how many rows there actually are.

Does any of you know how to do this?

kind regards,

Anton Pierhagen

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Anton ,

You can use the method SET_VISIBLE_ROW_COUNT() of the class cl_wd_table for setting the visible row count dynamically.

In the WDDOMODIFY view , you can get the reference of the table UI element used and proceed.

DATA lo_table TYPE cl_wd_table.

lo_table ?= view->get_element( ID = 'name_of_table_in_the_view').
lo_table->SET_VISIBLE_ROW_COUNT(value = 5)."Here the value you can decide based on your data.

But this method is not recommended as it directly deals with the view's elements and will be very difficult for the person maintaining the code.

Instead create a attribute which can store a number and bind the visible row count property to this attribute.

set this attribute with the values based on the data.(as in number of visible rows you would want to see.)

Thanks,

Aditya

AntonPierhagen
Active Participant
0 Kudos

Thank you both for your answers!

I really appriciate it!

Kind regards,

Anton Pierhagen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

There is a much easier solution. Just set the number of visible rows properties to -1. This is an alias value that means you want all rows displayed. No reason to go through the dynamic programming that has been suggested here.

Warning: regardless of your approach for doing so, showing all visible rows can lead to performance problems. Depending upon the number of rows this can grealy increase both the network traffic and the page size on the client.

AntonPierhagen
Active Participant
0 Kudos

Thanks! I will keep it in mind. I have chosen for the dynamic programming. So, when there are more then 25 rows, it won't show anymore then that. And there aren't any performance problems

But thanks anyhow for your answer!

kind regards

Anton Pierhagen

Answers (1)

Answers (1)

gill367
Active Contributor
0 Kudos

HI

It is possible to do .

create an attribute of type i in the context of the view.

then bind this attribute to the property visiblerowcount of the table.

then check the number of elements in the node and set this attribute.

you can write the code in wddoinit or domodify.

hers is the sample code. my attribute name is 'VISROW' and node name of the table is ZDEALER

data nd type ref to if_wd_context_node.
nd = wd_context->get_child_node( 'ZDEALER' ).

data n type i.
n =  ND->GET_ELEMENT_COUNT( ).

WD_CONTEXT->SET_ATTRIBUTE(

NAME = 'VISROW'
VALUE = N

).

thanks