Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Help with a BW Start Routine

Former Member
0 Likes
1,172

Hi Experts,

I need a help with one BW Start Routine.

I´m extracting 52 weeks for a report.

In this report I have the stock for each week, and the stock cost for each week.

But, I may have more than one week with zero stock and zero stock cost, and I need to create an average stock for this 52 weeks, BUT excluding the weeks with zero stock.

So for an example, if I have 42 weeks with stock and 10 weeks without stock, I´ll have to add all the stock per week and than split by 42.

Can anyone help me, please?

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,102

Insure that all the weeks are always transmitted in the same packet. Then, if required SORT the package, loop at the package and  sum values and increment a counter when stock not zero, at end divide sum by counter and use a MODIFY itab lines statement.

Regards,

Raymond

Hi Experts,

I need a help with one BW Start Routine.

I´m extracting 52 weeks for a report.

In this report I have the stock for each week, and the stock cost for each week.

But, I may have more than one week with zero stock and zero stock cost, and I need to create an average stock for this 52 weeks, BUT excluding the weeks with zero stock.

So for an example, if I have 42 weeks with stock and 10 weeks without stock, I´ll have to add all the stock per week and than split by 42.

Can anyone help me, please?

Thanks in advance.

8 REPLIES 8
Read only

Former Member
0 Likes
1,102

Hello,

Eduardo Carreira Martins Gonçalves wrote:

So for an example, if I have 42 weeks with stock and 10 weeks without stock, I´ll have to add all the stock per week and than split by 42.

can you describe this above line ???

Thanks

Sabyasachi

Read only

0 Likes
1,102

Ok, let´s make an example.

WeekStockStock Value
14324 $                       432.445,00
25050 $                            9.876,00
34354 $                               987,00
476476 $                            9.876,00
564 $                                  88,00
6764674 $                               987,00
77645 $                       567.654,00
80 $ -  
9467764 $                            9.876,00
100 $ -  
117647654 $                       987.654,00
126457457 $                         98.765,00
130 $ -  
140 $ -  
150 $ -  
160 $ -  
170 $ -  
180 $ -  
190 $ -  
206543 $                            5.467,00
21653 $                            4.567,00
22653 $                               644,00
23653 $                         67.546,00
24653 $                               456,00
25653 $                            5.467,00
26653 $                         87.654,00
27653 $                            7.654,00
28653 $                            7.654,00
290 $ -  
300 $ -  
310 $ -  
320 $ -  
339857654 $               876.556.789,00
3498765 $                       876.543,00
3534567 $                 54.387.564,00
368765 $                   4.566.543,00
373456 $                       546.765,00
380 $ -  
390 $ -  
400 $ -  
410 $ -  
420 $ -  
439876 $                   7.654.654,00
4487634 $               367.989.876,00
453456 $               435.678.765,00
461234 $                 45.677.654,00
475764 $                       456.754,00
48345 $                   4.323.456,00
490 $ -  
500 $ -  
510 $ -  
520 $ -  

So in this case we have 30 weeks with stock and 22 weeks without stock.

And I need to add all the stock of this 30 weeks and split by the number of weeks with stock to have an average stock.

Total Stock:

25558745

Average Stock:

851958,2
Read only

0 Likes
1,102

Hello,

you have to use LOOP.......ENDLOOP statement.

if stock ne 0.

sum = stock + sum.  sum is a variable.

endif.

at last, sum value is total stock 25558745.

for average : use: sum / 52.     

Thanks

Sabyasachi

Read only

0 Likes
1,102

Hello,

at 1st try to enhance total stock and avg stock  in datasource (rsa6) on selective datasource in ecc site, i think loading performence will be better then start routine execute in bi site. if it is not possible then try to use the code in start routine.


that means customizing datasource.

for loading pourpose in bw site use end routine for better perfomence.

Thanks

Sabyasachi

Message was edited by: Sabyasachi Karforma

Read only

0 Likes
1,102

Hi,

In the above code, you can include a statement after the line '

sum = stock + sum' as below.

sum = stock + sum

counter = counter + 1

average = sum / counter.

Dont forget to Initialize the variables in the beginning.

Hope this will help you better.

Thank you.

Read only

Former Member
0 Likes
1,102

Hello,

start routine is mandatory or not for your case?

if not then we can try to solve this problem in different way

like in query design.

Thanks

Sabyasachi

Read only

0 Likes
1,102

Hi Sabyasachi Karforma,

Unfortunately, I have to do this loading data, because we are facing a very bad performance issue with this report.

It´s a sale and stock report, with one year of data. This report will be used in a universe for BO 3.1.

So, I have to do every calculation in loading time.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,103

Insure that all the weeks are always transmitted in the same packet. Then, if required SORT the package, loop at the package and  sum values and increment a counter when stock not zero, at end divide sum by counter and use a MODIFY itab lines statement.

Regards,

Raymond