Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
get total/sum of numbers that are coming through seperate requests from webservice?
Arif shah
<p>Hi,</p>
<p> </p>
<p>I am trying to get some numbers from webservice wsdl url. This webservice only returns data for specific ids like 1, 2, 3 etc that are passed as parameters</p>
<p> </p>
<p>I have all these ids in a seperate dataset while the webservice dataset is seperate. I have created a table and put the ids dataset in its properties binding. Then I created another table inside the parent table and made the webservice dataset as its dataset and passed the ids as parameters from the parent table</p>
<p> </p>
<p>Now for each id, I am seeing the relevant number from the webservice but now I am facing a problem. I need to calculate some percentages of the numbers. I need to sum up some of the numbers returned as a result of passing those ids and in some cases I need to sum up the results of all ids</p>
<p> </p>
<p>My problem is that currently, each row in my table is a result of seperate request sent to the webservice by passing the id from the parent table</p>
<p> </p>
<p>Can someone please tell me how can I sum up the numbers of different rows when each row is a result of seperate request</p>
<p> </p>
<p>Do I have to first collect all the rows from each request and make a seperate dataset out of that? If that is what I need to do, how can I do that as I have no experience with writing scripted datasources so a little help will be appreciated</p>
<p> </p>
<p>Regards</p>
<p>Arif</p>
Find more posts tagged with
Comments
Arif shah
<p>After researching some more, I think I will have to write a pojo datasource that takes value from one dataset, send it as parameter to the webservice, collect the result and send another request and thus keep collecting the resultset in an array till all values have been sent as parameter</p>
<p> </p>
<p>Now my problem is that I am not a java guru and I don't know how to write such a script. Some help in this regard will be apprecaited. For a sample or practice, the below webservice can be used</p>
<p> </p>
<p><a data-ipb='nomediaparse' href='
http://www.webservicex.net/WeatherForecast.asmx?WSDL'>http://www.webservicex.net/WeatherForecast.asmx?WSDL</a></p>
;
<p> </p>
<p>Thanks</p>
<p>Arif</p>
Clement Wong
<p>You shouldn't need to write a POJO data source. While you are fetch the values in the inner/child Data Set, you can save off the values into a Java ArrayList. If you use one of my previous examples with a nested table with a scripted data source @ <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/36783-how-to-loop-through-data-set-values-for-a-yesterday-hourly-report/?p=137165'>http://developer.actuate.com/community/forum/index.php?/topic/36783-how-to-loop-through-data-set-values-for-a-yesterday-hourly-report/?p=137165</a>
; as a base, you can add code into onFetch of the "Inner Web Service Data Set" to save off values.</p>
<pre class="_prettyXprint">
array.add( row["yourRowValueColumnNameHere"] );</pre>
<p>
In the parent/outer data set, you'll need initialize a Java ArrayList to save off those values in the beforeOpen event:</p>
<pre class="_prettyXprint">
array = new java.util.ArrayList();
</pre>
<p>Also, in the Open event of the parent/outer data set, initialize a variable so that you can save the total of those values:</p>
<pre class="_prettyXprint">
theTotal = 0;</pre>
<p>In the beforeClose event of the parent/outer data set, you can compute the total of those values.</p>
<pre class="_prettyXprint">
for (i=0; i < array.size(); i++) {
theTotal += new Number(array.get(i));
}
</pre>
<p>Attached is a sample (created in OS BIRT 4.4.2). The "Combined Data Set" is the final data set that has the sum and the percentage of the sum. The results of that data set is displayed in the second table in light blue.</p>