cancel
Showing results for 
Search instead for 
Did you mean: 

Merging data from multiple BAPI tables

Former Member
0 Kudos

Hello,

I'm executing a BAPI_XX_GETLIST with multiple "Tables" selected with the REQUESTEDTABLESX import parameter. What is the best way to combine/merge data from multiple "Tables" and bind them into a single webdynpro UI Table?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Yakima

If your requirement is that some columns in table1 and some columns in table2 then

1. create a table ui element.

2. Add columns manually and bind them to the RFC table columns you like.

Kishore

Former Member
0 Kudos

Hi Kishore,

Can you give me some code sample?

If I bind all columns from table 1 and add one column from table 2, the result UI table will have repeating value of the column from table 2.

I might need to tie the primary key of each BAPI tables and create a new structured context with merged columns to fill the UI table.

Thanks.

Former Member
0 Kudos

Hi Yakima,

To elabrate on this, add a value node to ur first table structure with cardinality 1:1. And add a value attribute. Create a supply function for the value node. Set the value attribute with the data based on the primark key.

In the UI table add another column and bind it to the new value attribute.

IPrivateCO_Component.IValueNodeElement nodeX = node.createValueNodeElement();

nodeX.setValuAttributeValue(parentElement.getValueFromSecondTable());

node.bind(nodeX);

Refer the blog "Supply functions in WebDynpro"

/people/sap.user72/blog/2005/03/15/supply-functions-in-webdynpro

Hope this helps. If you require more info on this send a reply.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Yakima

You will not have any repeating values.

Let me know your table structures and the way you want the values to be displayed.

Kishore

Former Member
0 Kudos

Hi Santhosh,

How do I set the value attribute with the data based on the primary key?

Can you show me how you would implement the getValueFromSecondTable() method?

Thanks much.

Former Member
0 Kudos

Hi,

Lets say the BAPI name is BAPI_XX_GETLIST and the table names are ET_TABLE1(Field1, Field2, Field3) and ET_TABLE2 (FieldA, FieldB). You have display the fields of ET_TABLE1 (Field1, Field2, Field3) and one field from ET_TABLE2 (FieldB). "FieldA" id the key field.

Create a value node (vnField) under the model node table ET_TABLE1 with cardinality 1:1. Create a value attribute (vaFieldB). For "vnField" create a supply function (supplyfunction). If you goto the implementation you can see a method "supplyVnField(IPrivateCO_ComponentName.IVnFieldNode node, IPrivateCO_ComponentName.IET_Table1Element parentElement)".

Write the following code in the implementation.

IPrivateCO_ComponentName.IVnFieldNode nodeX = node.createValueFieldElement();

for(int i=0;i<wdContext.nodeET_Table2().size();i++){

if(parentElement.getField3Value().equals(wdContext.nodeET_Table2().getET_Table2ElementAt(i).getFieldA())){

nodeX.setValuAttributeValue(wdContext.nodeET_Table2().getET_Table2ElementAt(i).getFieldB());

}

}

node.bind(nodeX);

Hope this solves your problem.

Regards,

Santhosh.C

Former Member
0 Kudos

Hello Santhosh,

Thanks so much for your help. If this is the easiest way to solve this problem in WebDynpro, it sure is awfully cumbersome compare to other development environments such as .NET.

Former Member
0 Kudos

How would it be done there?

Armin

Former Member
0 Kudos

Armin,

In .NET, data from different SAP tables can be merged into a "DataSet" object, and the UI Table(datagrid in .NET) datasource set to the dataset. Similar to a new contextNode without the nodevalues/attributes and the supply functions. IMHO, much easier.

Regards.

Former Member
0 Kudos

Hi Yakim

Taking the santhosh example you can combine the data much easier as follows with out any coding.

Sort the values in both the tables by the key field ie Field A in SAP.

Create a table in webdynpro and bind the table to ET_table1. Add a column in the table and bind this column to field b of ET_table2 manually.

Kishore

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You have to create Value node and value attributes (as per your display requirements bind the node to the Table UI element), read the data from the model and set the data to the value attributes.

Or you can do another thing,

If it is a custom built BAPI/RFC, add/modify the table strcuture you want and send it as a export table. If it is standard BAPI, write a wrapper BAP/RFC to send the data as per your requirements.

So you can directly bind it to your table UI element.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Santhosh,

Do you suggest that I create a local dictionary of structure datatype with which to create the value node and value attributes?

Would you have some code sample to illustrate the solution?

Your help is much appreciated.