cancel
Showing results for 
Search instead for 
Did you mean: 

Table column Total

Former Member
0 Kudos

Hi,

I am trying to implement utility class(Calculating total for 1 column) in my application.

I have 2 views and one custom controller.

1) TableUtilities.java class imported to src/packages.

2) Created a value attribute say ‘tableutility” in ResultView Context ,and assigned the properties of the attribute type Java Native Type "TableUtilities".

Do I need to create anything other than this?.

Below code is added to the ResultView wdDoModifyView

-


if(firstTime) {

IWDTextView tv = (IWDTextView)view.getElement("total");

wdContext.currentContextElement().setTableutility(new TableUtilities(wdContext.nodeDepartments()));

//Returns attribute info of a dynamically created attribute which can be bound to the UI element need.

tv.bindText(wdContext.currentContextElement().getTableutility().CalculateSum("Departments","NoOfPeople"));

}

If I implement this code in my Resultview wdDoModifyView, it is throwing run time errors.........

.at sd.salesorderslist.SalesResultView.wdDoModifyView(SalesResultView.java:146)

at sd.salesorderslist.wdp.InternalSalesResultView.wdDoModifyView(InternalSalesResultView.java:301)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doModifyView(DelegatingView.java:78)

at com.sap.tc.webdynpro.progmodel.view.View.modifyView(View.java:337)

at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.doModifyView(ClientComponent.java:481)

Please advice.

Accepted Solutions (1)

Accepted Solutions (1)

nikhil_bose
Active Contributor
0 Kudos

jai,

1. you need to put correct package for TableUtilities.java once you place it to src folder.

replace first line

package .........*; with your package

2. Make sure that "Departments" is your node "NoOfPeople" is the column for that you need to calculate sum are existing.

nikhiL

Former Member
0 Kudos

Hi,

This is my code.....

if(firstTime) {

IWDTextView tv = (IWDTextView)view.getElement("total");

wdContext.currentContextElement().setTableutility(new TableUtilities(wdContext.nodeSales_Orders()));

tv.bindText(wdContext.currentContextElement().getTableutility().CalculateSum("Sales_Orders","Req_Qt"));

Hope those 2 are correct......, I am not getting build time errors, I am getting runtime errors..

Only above part of code and tableutility context variable created in ResultView.

Do I need to create any text view to show this total or runtime it will create the textview?.

Former Member
0 Kudos

Hi,

Everything seems to be fine. The runtime error clearly shows that the error is at SalesResultView.java:146 (line no). Could you post the exact runtime error and the code at line 146.

thanks & regards,

Manoj

nikhil_bose
Active Contributor
0 Kudos

yes.

IWDTextView tv = (IWDTextView)view.getElement("total");

will retrieves the reference of an existing TextView with name total.

Create a TextView in your view and name it as "total" that will work

nikhiL

Former Member
0 Kudos

Hi Nikil,

I have created the Java class, calculating sum is working fine. For export to Excel I have created context element(Excelfile) and LinkToURL(url).

If there is any mistake, can you please correct this code,....

public void wdDoInit()

{

//@@begin wdDoInit()

ArrayList al = new ArrayList();

al.add(IPrivateResults.ISalesOrdersElement.MATERIAL);

al.add(IPrivateResults.ISalesOrdersElement.REQ__QTY);

wdContext.currentContextElement().setExcelfile((String)wdContext.currentContextElement().getTableutility().DownloadToExcel(al).get("url"));

//@@end

}

I am getting follwoing error...

-


java.lang.NullPointerException

at .sd.salesorderslist.Results.wdDoInit(Results.java:106)

at .sd.salesorderslist.wdp.InternalResults.wdDoInit(InternalResults.java:171)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)

at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)

at com.sap.tc.webdynpro.progmodel.view.View.initController(View.java:445)

-


Thanks in advance,

Former Member
0 Kudos

If I am not wrong.... this piece of code is for setting the column header right???

Former Member
0 Kudos

Hi,

I did some debugging(Commented the complete functionality in Java Utility and tried, just to induct error is from java utility class or farm my program)...

I figured out that, when I call the method it is thorwing exception....

ArrayList al = new ArrayList();

al.add(IPrivateResult.ISalesOrdersElement.MATERIAL);

al.add(IPrivateResult.ISalesOrdersElement.REQ__QTY);

Map m = wdContext.currentContextElement().getTableutility().DownloadToExcel(al);

java.lang.NullPointerException

at .componenets.Result.wdDoInit(Result.java:111)

at .componenets.wdp.InternalResult.wdDoInit(InternalResult.java:124)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)

at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)

at com.sap.tc.webdynpro.progmodel.view.View.initController(View.java:445)

Doing anything wrong in the Arrylist?...Please advice..this is bit urgent!!!.

Answers (0)