cancel
Showing results for 
Search instead for 
Did you mean: 

How to combine two tables in BAPI to one table in Web Dynpro

Former Member
0 Kudos

Hi Everyone,

The two tables in the BAPI share an common field, I want to join the two tables with the common fields, and show/edit it in ONE table in my web dynpro view.

Is there a way to do this, thank you very much!

Regards,

Xiaoming Yang

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I think, that the simplest solution is implement new rfc function and in this function accomplish data join. Table operation in ABAP are simply to realize (furthermore separation between view and model is better)

Bogdan

Former Member
0 Kudos

Hi Bogdan,

Thanks, We think so too, so we write another BAPI to join this two table.

Thanks,

Regards,

Xiaoming Yang

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I assume your problem is like this:

You have TableA:

PK A1 A2

0 1 1

And table B:

PK B1 B2

0 2 2

Then you will display 2 rows namely:

PK A1 A2 B1 B2

0 1 1

0 2 2

Is my assumption right?

If i understand your problem correctly, you are asking for something to be available at design time to merge two tables?

Well, i guess you need to code for it!

You need to form a table via code, and then populate this table based on your logic. Form columns, attributes etc and fill and add the rows/rowelements according to your key.

I wrote a similar code which you can use for your help:

[code]

public static void wdDoModifyView(IPrivateIntDemandCompView wdThis, IPrivateIntDemandCompView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

//@@begin wdDoModifyView

IPrivateIntDemandCompView.IMergedNodeNode mergedNode = wdContext.nodeMergedNode();

IPrivateIntDemandCompView.IMergedNodeElement mergedNodeElement = null;

rootCount = wdContext.nodeResult().size();

wdContext.currentContextElement().setTemp(rootCount);

wdContext.currentContextElement().setTestStr(wdContext.nodeResult().getResultElementAt(0).getPLANID() + "");

for (int i=0; i<rootCount; i++){

wdContext.nodeResult().setLeadSelection(i);

//wdContext.nodeResult().setSelected(i, true);

rootCellPlanID = wdContext.nodeResult().getResultElementAt(i).getPLANID() + "";

rootCellUsername = wdContext.nodeResult().getResultElementAt(i).getUSERNAME() + "";

rootUUID = wdContext.nodeResult().getResultElementAt(i).getIDField() + "";

//wdContext.currentInputParameter_nElement().setIDField(rootUUID);

//planningQuery.execute();

planningCount = wdContext.nodeResult().nodePLANNINGLEVEL().size();

wdContext.currentContextElement().setTemp1(planningCount);

for (int j = 0; j<planningCount; j++){

mergedNodeElement = mergedNode.createMergedNodeElement();

//wdContext.nodeResult().nodePLANNINGLEVEL().setLeadSelection(j);

//planningCellAggLevel = wdContext.nodeResult_n().getResult_nElementAt(j).getAGGREGATIONLEVEL() + "";

//planningCellAggLevel = wdContext.nodeResult().nodePLANNINGLEVEL().currentPLANNINGLEVELElement().getAGGREGATIONLEVEL() + "";

planningCellAggLevel = wdContext.nodeResult().nodePLANNINGLEVEL().getPLANNINGLEVELElementAt(j).getAGGREGATIONLEVEL() + "";

mergedNodeElement.setPLANID(rootCellPlanID);

mergedNodeElement.setUSERNAME(rootCellUsername);

mergedNodeElement.setAGGREGATIONLEVEL(planningCellAggLevel);

mergedNode.addElement(mergedNodeElement);

}

}

//My experiment - Begins

/*IWDTable table = (IWDTable) view.createElement(IWDTable.class, null);

table.bindDataSource("Root$ROOTQUERY");

IWDTextView editor = null;

IWDTableColumn column1 = (IWDTableColumn)view.createElement(IWDTableColumn.class, null);

table.addGroupedColumn(column1);

IWDTableColumn column2 = (IWDTableColumn)view.createElement(IWDTableColumn.class, null);

table.addGroupedColumn(column2);

IWDTableColumn column3 = (IWDTableColumn)view.createElement(IWDTableColumn.class, null);

table.addGroupedColumn(column3);

//for (int i = 0; i<rootCount; i++){

IWDTextView editor1 = (IWDTextView) view.createElement(IWDTextView.class, null);

editor1.bindText("Root$ROOTQUERY.result.PLANID");

column1.setTableCellEditor(editor1);

IWDTextView editor2 = (IWDTextView) view.createElement(IWDTextView.class, null);

editor2.bindText("Root$ROOTQUERY.result.USERNAME");

column2.setTableCellEditor(editor2);

IWDTextView editor3 = (IWDTextView) view.createElement(IWDTextView.class, null);

editor3.bindText("Root$ROOTQUERY.result.PLANNINGLEVEL.AGGREGATIONLEVEL");

column3.setTableCellEditor(editor3);

IWDUIElementContainer root = (IWDUIElementContainer) view.getRootElement();

root.addChild(table);*/

//}

// My experiment - Ends

//@@end

[/code]

Regards,

Dev

Former Member
0 Kudos

Hi Devashish,

Thank you very much!

You have TableA:

PK A1 A2

0 1 1

And table B:

PK B1 B2

0 2 2

What I want is to display:

Then you will display 2 rows namely:

PK A1 A2 B1 B2

0 1 1 2 2

and not just display, I want input these value to certain table in BAPI correctly.

Thank you very much for your code, I will have a detail study.

Regards,

Xiaoming Yang

Former Member
0 Kudos

Hello xiaoming yang,

you can use supply function for the node in which you want to combine two nodes.

1. Create a new VALUE NODE in the view's context.

2. Write a Supply Function and get the values from both the BAPI nodes which ruturns the values

3. Bind the VALUE NODE to the table

Balakrishnan

Former Member
0 Kudos

Hi Bala,

Thank you very much for your reply,

Can you explain to me what's Supply Function and how to write this one? It will be very grateful.

Thanks again!

Regards,

Xiaoming Yang

Former Member
0 Kudos

Hello,

Check out this link:

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/86/7fcf3d4f902d10e10000000a114084/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/86/7fcf3d4f902d10e10000000a114084/content.htm</a>

Balakrishnan