Global Data in Start Routine initialized once or per packet?

Question: I have a requirement to calculate the percent of dollars a material represents against the overall order dollar amount.

I am processing data at the order-material level and need to divide the order-material dollars key figure by the total dollar amount of the order and store the result in a percent key figure.

I plan to define an internal table to hold the order number and total dollar amount in the global declaration of the start routine as well as populate the internal table in the start routine.

Then in the individual key figure update rule, reference the internal table to retrieve the total dollar amount, do the math, and write the percent to the percent key figure.

Where I have a concern about is - is the start routine called once per entire data load or once per data packet? I believe once per data packet. If this is the case how do I make sure my internal table with order number and total dollars is filled only once instead of which each data packet?

Really that data - order and total dollars - only needs to be pulled once for the load and available to all data packets.

I have done some searches on past posts and haven't found anything definitive.

Thanks.

Answer:
Where I have a concern about is - is the start routine called once per entire data load or once per data packet? I believe once per data packet. If this is the case how do I make sure my internal table with order number and total dollars is filled only once instead of which each data packet?

I for sure have answered this at least once... anyway, it's called once per DataPackage (so possibly multiple times per InfoPackage). To avoid to load your internal table more than once, is a basic programmer's check.
Here's a little example:

data: x_first(1) type c value 'x'.

if not x_first is initial.
  <insert your coding here>
  x_first = 'n'.
endif.

cheers,

El Belgio

PS if you want to do it fancier, you'll make x_first a boolean

Answer:
Thanks El Belgio. Just a follow up... (1) is there ever a possibility with data packets being loaded concurrently that the global internal table gets filled more than once even with the check in place and (2) anything declared in the global section is available to the local update rules for the characteristics/key figures as well as the local update rules for subsequent packages - that is global declarations are global across data packages and at all levels?

I know I am probably asking the obvious I am just looking for some explicit confirmation.

Thanks again.

Answer:
Hi,
I believe the internal table and any global delarations will hold data for that info package load only. Meaning for each info package load, it fills the internal table with all order number and amount in that info package.

I am still not sure about how the first reply from El Belgio suggestions works???

Answer:
(1) is there ever a possibility with data packets being loaded concurrently that the global internal table gets filled more than once even with the check in place

anything is possible... however, such a situation should normally not occur

(2) anything declared in the global section is available to the local update rules for the characteristics/key figures as well as the local update rules for subsequent packages - that is global declarations are global across data packages and at all levels?

that is correct!

Answer:
Thanks El Belgio.
Copyright ?2007 - 2008 www.jt77.com