cancel
Showing results for 
Search instead for 
Did you mean: 

How do I imitate the Master/Detail Viewer app?

Former Member
0 Kudos

Hi,

In the context tutorials there is the Master/Detail tutorial which lists customer "orders" in a table depending on the customer selected in another table. The tutorial uses SomeBOL class to generate and populate the data into the tables. I'm trying to achieve the same results by calling a Bapi and bringing the data into the context. I have two tables which are returned, both tables have a "key" (PK in one and FK in the other). What I want to do is to select the PK the first table and the associated FK data is displayed in the second table. The context model is bound in the custom controller, and my view uses this controller as a 'required controller' for its context. Because I am doing this it won't let me create the <i>supply function</i> in the view but it will let me in the custom controller. I also need help with some of the Java code as I'm not generating the data in a <i>SomeBOL</i> class like the example. Your suggestions and help will be greatly appreciated.

Thanks,

KG

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

From what i understand, i guess you dont want to use the BOL class as described in the tutorial to populate data. You are using some BAPI.

In that case say your bapi returns 2 tables

table1 and table2.

You have done the appropriate context binding from Model to controller and then from controller to view.

Let table1 be the master, and table2 be the detail.

When you execute the bapi all the data will be populated in the respective nodes.

Now populate table1 with the data. On click of a row in table1 loop through the contents of table2 node and then accordingly display the relevant details for table1 in table2.

Something like

for(i=0;i<table2node.size;i++)

{

wdContext.nodeTable2node().getelementat(i).getTableData();

//the table2 data you can get based on the FK

}

Anyway just let me know if that helps. The above is just a sample. If you require the exact logic let me know.

regards

Ravi

Former Member
0 Kudos

Hi Ravi,

Thanks for your reply. I have created a method called <i>onActionItemSelected</i>. In this method I plan to display node2 data in table2 where the PK in node1 is equal to the FK in node2.

Can you help me out with a bit of the logic and code for this? Your help is much appreciated.

Thanks

KG

Former Member
0 Kudos

Hi,

This is the code I wrote to try and get this thing to work. It isn't working please please help me and tell me what I'm doing wrong. These are the steps I took before writing the code. My custom controller context has all the data from the bapi call. In my view context I created a Value node node2 as a child node to node1. The node2 children are value attributes which I'm going to assign data to from the custom controller context. Here is the code:

[code]

public void supplyNode2(IPrivateDisplayNCRView.INode2Node node, IPrivateDisplayNCRView.INode1Element parentElement)

{

IPrivateMyView.INode2Element newNode2Node;

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

{

newNode2Node = wdContext.createNode2Element();

if(parentElement.getItem_Key() ==

wdContext.nodeNode2FromCustCont().getElementAt(10).toString())

{

newNode2Node.setcolumn1(wdContext.nodeNotiftask().getElementAt(22).toString());

newNode2Node.setcolumn2(wdContext.nodeNotiftask().getElementAt(24).toString());

newNode2Node.setcolumn3(wdContext.nodeNotiftask().getElementAt(25).toString());

newNode2Node.setcolumn4(wdContext.nodeNotiftask().getElementAt(29).toString());

newNode2Node.setcolumn5(wdContext.nodeNotiftask().getElementAt(30).toString());

node.addElement(newNode2Node);

}

}

}

[/code]

Basically, what I'm trying to do with the above code is when the ItemSelected action is triggered; check if the item_key (PK) in the parentElement matches the item_key (FK) in the Custom Controller node2 table. If it does then I'm trying to copy the fields that I need from the custom controller node2 to the view controller node2. This is the exception thrown:

[code]

java.lang.IndexOutOfBoundsException: Index: 10, Size: 8

at java.util.ArrayList.RangeCheck(ArrayList.java:507)

at java.util.ArrayList.get(ArrayList.java:324)

at com.sap.aii.proxy.framework.core.JcoBaseList.get(JcoBaseList.java:268)

at com.sap.aii.proxy.framework.core.AbstractList.get(AbstractList.java:230)

at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCList.get(DynamicRFCList.java:281)

at com.sap.tc.webdynpro.progmodel.context.Node$ModelElementList.getElement(Node.java:2600)

at com.sap.tc.webdynpro.progmodel.context.Node$MappedElementList.getElement(Node.java:2450)

at com.sap.tc.webdynpro.progmodel.context.Node.getElementAtInternal(Node.java:672)

at com.sap.tc.webdynpro.progmodel.context.Node.getElementAt(Node.java:679)

at com.eac.vendorportal.DisplayNCRView.supplyNotifTasks(DisplayNCRView.java:164)

at com.eac.vendorportal.wdp.InternalDisplayNCRView.supplyNotifTasks(InternalDisplayNCRView.java:738)

at com.eac.vendorportal.wdp.IPrivateDisplayNCRView$INotifTasksNode.doSupplyElements(IPrivateDisplayNCRView.java:10891)

at com.sap.tc.webdynpro.progmodel.context.Node.supplyElements(Node.java:461)

at com.sap.tc.webdynpro.progmodel.context.Node.getElementList(Node.java:425)

at com.sap.tc.webdynpro.progmodel.context.Node.getElements(Node.java:404)

at com.sap.tc.webdynpro.progmodel.context.Node.size(Node.java:772)

[/code]

All suggestions welcome! Thanks in advance.

KG

Answers (0)