cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Table generation-Urgent. Please reply!

Former Member
0 Kudos

Hi all

I've a scenario. I want to display a table in a view. But the no of columns in that table depends on the number of columns in the corresponding database table. I'm fetching data from an R/3 system.

Can i use a static table for this by controlling the visibility of the columns or do i have to use dynamic table. If dynamic how i'll do that? How i'll get the no of columns?

Hi

Christophe Benoit

I'm fetching data from a table with fixed no of columns. But the thing there is a chance that it's number of columns may increase. I've to consider that also. I cannot say how many columns will be added later. This is my problem

Hi Monalisa Biswal

Thank u very much for your help. My problem is half-solved.

Hi Dipankar Saha

I found your reply very helpful. I haven't tried dynamic content creation before. You provided all the helpful links.

OfCourse I'll give u points! Hoping that you'll be answering all my questions.

I think I'm the first one to do so.(Treat is required )

Hi Monalisa Biswal

I'm not using a structure binding for the value node.

In this case how i'll get the no of fields in the node as well as the fieldnames?

Thanks & Regards

Aparnna

Message was edited by:

aparnna prasad

Accepted Solutions (1)

Accepted Solutions (1)

former_member4529
Active Contributor
0 Kudos

Hi Aparnna,

You can use dynamic context binding to achive this. You can add the table control to the view at design time, but bind the context at run-time. See the following articles for more details:

1) Dynamic Programming in Java Webdynpro :

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6fdae690-0201-0010-a580-d104b459...

2) Table handing in Webdynpro :

/people/harsh.chawla/blog/2005/03/08/table-handling-in-webdynpro

3) Dynamic Table

4) Dynamic table Creation

Also if yoy are fetching data from a R/3 system you can use the Adaptive RFC model in Java webdynpro, which will automatically define the model structure and from whcih you can specify the table columns at design-time as well.

Thanks & Regards,

Dipankar

[P.S. Award points if you feel this is helpful]

Answers (4)

Answers (4)

Former Member
0 Kudos

Thank u Abhilash for your help

I got my problem solved

Regards

Aparnna

Former Member
0 Kudos

Hi Monalisa Biswal

I'm not using a structure binding for the value node.

In this case how i'll get the no of fields in the node as well as the fieldnames?

former_member182294
Active Contributor
0 Kudos

Hi Aparna,

In order to get all the attributes in a node, use the following code:

IWDNodeInfo nodeInfo = wdContext.node<Nanme>().getNodeInfo();

java.util.Iterator iterator = nodeInfo.iterateAttributes() ;

while(iterator.hasNext())

{

IWDAttributeInfo attribInfo = (IWDAttributeInfo)iterator.next();

if(attribInfo != null)

{

String name = attribInfo.getName();

//do whatever u want...

}

}

See the API for more details..

<a href="https://media.sdn.sap.com/javadocs/NW04/SPS15/wd/com/sap/tc/webdynpro/progmodel/api/IWDAttributeInfo.html">IWDAttributeInfo</a>

Regards

Abhilash

Former Member
0 Kudos

Hi Aparnna,

My thoughts:

If you are fetching data from one table with a fixed number of columns and you want to hide empty columns. Use a static table.

If you are fetching data from different tables with all different columns. Use a dynamic table.

Regards,

Christophe

monalisa_biswal
Contributor
0 Kudos

Hi Archana,

If your BAPI is returing a table parameter you can fetch attribute list dynamically using the following method:


IWDNodeInfo nodeInfo = wdContext.nodeName().getNodeInfo(); 
IStructure structure = nodeInfo.getStructureType();

int NoOfFlds =structure.getNumberOfFields();
 
for (int count = 0; count < NoOfFlds; count++) {
   IField field =structure.getField(count);
    if (field != null) 
    {
            String fieldName = field.getName();

    }
}

Hope it helps!