cancel
Showing results for 
Search instead for 
Did you mean: 

WenDynpro jave problem

Former Member
0 Kudos

I'm doing one of the example from tech ed 2008 java web dynpro in SAP Netweavre CE system. In that I cretaed two table one with slaes order and another with item line details. In the jave code when I write the code as follows the system is showing an error

public void wdDoInit()

{

//@@begin wdDoInit()

// Get a reference to the SalesOrders context node

ISalesOrderNode soNode = wdContext.nodeSalesOrder();

//Create two new Sales Order elements and immediately add them

//to the node collection

ISalesOrderElement soE11 = soNode.createAndAddSalesOrderElement();

ISalesOrderElement soE12 = soNode.createAndAddSalesOrderElement();

soE11.setLongtext("Printer Supplier");

soE11.setOrderNo(1000);

soE11.setSalesDate(new Date(System.currentTimeMillis()));

soE11.setSalesRep("Dinesh Ghanta");

soE12.setLongtext("Network Equipment");

soE12.setOrderNo(1001);

soE12.setSalesDate(new Date(System.currentTimeMillis()));

soE12.setSalesRep("Ned Seagoon");

// Create the LineItems node instances for each SalesOrders element

** ILineItemsNode liNode1 = soE11.nodeLineItems();**

** ILineItemsNode liNode2 = soE12.nodeLineItems();**

// Create new elements for each LineItems node,

// set the attribute values and add them to the nodes

//@@end

}

//@@begin javadoc:wdDoExit()

The system is saying that there is a type mismatch error on both the lines where I'm creating the items. Can you please help me here...am I msising something.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Dinesh,

Where have you defined the context structure? In component Controller or View Controller? If you have mapped the context beetween Comp Controller and View and you are writing this code in the view, then you need to refer to the ILineItemsNode that corresponds to the controller/view based on what the other side of the assignment refers to. Rest your cursor on nodeLineItems in the code soE11.nodeLineItems() to know what type it returns.

Hope this helps!!

Cheers,

Arafat

Former Member
0 Kudos

Hi Arafat,

Thanks for offering to help. I followed the instructions given in the Tech Ed 2008 Manual. I created the context in the Component controller, then created two tables one for sales order and other for item details. Then with the help of datalink I created link between component view and component controller using data link. Then I wrote the following code in the wdDoInit() function.

// Get a reference to the SalesOrders context node

ISalesOrderNode soNode = wdContext.nodeSalesOrder();

//Create two new Sales Order elements and immediately add them

//to the node collection

ISalesOrderElement soE11 = soNode.createAndAddSalesOrderElement();

ISalesOrderElement soE12 = soNode.createAndAddSalesOrderElement();

soE11.setLongtext("Printer Supplier");

soE11.setOrderNo(1000);

soE11.setSalesDate(new Date(System.currentTimeMillis()));

soE11.setSalesRep("Dinesh Ghanta");

soE12.setLongtext("Network Equipment");

soE12.setOrderNo(1001);

soE12.setSalesDate(new Date(System.currentTimeMillis()));

soE12.setSalesRep("Ned Seagoon");

// Create the LineItems node instances for each SalesOrders element

ILineItemsNode liNode1 = soE11.nodeLineItems();

ILineItemsNode liNode2 = soE12.nodeLineItems();

The following is teh message I get when I put my cursor on the "soE11.nodeLineItems();" .

Type mismatch: cannot convert from IPublicEx1Comp.ILineItemsNode to

IPrivateEx1CompView.ILineItemsNode

Please let me know if you need some more info.

We can do a web ex if you ahve time.

Thanks and Regards,

Dinesh Ghanta

Former Member
0 Kudos

Hi Dinesh,

The problem is exactly what I guessed. There's a type mismatch because trying to assign a value to an object whose type is differenent from the other one. To resolve the issue you just need to put the fully qualified name for ILineItemsNode as given below:

// Create the LineItems node instances for each SalesOrders element

<package name>.<Component Name [IPublicEx1Comp]>.ILineItemsNode liNode1 = soE11.nodeLineItems();

It would look something like this:

com.wipro.app.wdp.IPublicCompName.

Hope this resolves the issue.

Cheers,

Arafat

Former Member
0 Kudos

Hi,

What i dont understand here is that inspite of teh following import statems existing at the begining of the code why do we need to refer to the class path again.

import com.sap.demo.example.sample.wdcomp.ex1comp.wdp.IPrivateEx1Comp;

import com.sap.demo.example.sample.wdcomp.ex1comp.wdp.IPrivateEx1CompView.ILineItemsElement;

import com.sap.demo.example.sample.wdcomp.ex1comp.wdp.IPrivateEx1CompView.ILineItemsNode;

import com.sap.demo.example.sample.wdcomp.ex1comp.wdp.IPublicEx1Comp.ISalesOrderElement;

import com.sap.demo.example.sample.wdcomp.ex1comp.wdp.IPublicEx1Comp.ISalesOrderNode;

import com.sap.demo.example.sample.wdcomp.ex1comp.wdp.IPublicEx1Comp;

Am I getting confused here. Can you please help.

Thanks and Regards,

Former Member
0 Kudos

Hi Dinesh,

This is happening because you have a node with same name in your view controller as well as component controller.

Since the default (the imported reference to node) is the one from the view i.e::

import com.sap.demo.example.sample.wdcomp.ex1comp.wdp.IPrivateEx1CompView.ILineItemsElement;

import com.sap.demo.example.sample.wdcomp.ex1comp.wdp.IPrivateEx1CompView.ILineItemsNode;

Instead of this it should be :

import com.sap.demo.example.sample.wdcomp.ex1comp.wdp.IPublicEx1Comp.ILineItemsElement;

import com.sap.demo.example.sample.wdcomp.ex1comp.wdp.IPublicEx1Comp.ILineItemsNode;

because the soE11.nodeLineItems() returns the a reference of IPublicEx1Comp.ILineItemsNode and not IPrivateEx1CompView.ILineItemsNode.

Hope this clarified your doubt.

Cheers,

Arafat

Former Member
0 Kudos

Hi Arafat,

Thanks a lot for taking thetiem to explain the concept.

Thanks and Regards,

Answers (0)