cancel
Showing results for 
Search instead for 
Did you mean: 

Logic behind macro function SAFETY_CALC()

Former Member
0 Kudos

Hi,

We are trying to extract certain key figures from SNP, including safety stock. It is calculated using default macro that utilises function SAFETY_CALC. Does anyone know what kind of calculations this function does based on the parameters?

I noticed that the BI content contains infocubes and infosources needed for reporting this key figure. However, when I activated the infosource it did not contain any of the transfer rules used for calculating values of different key figures. Do you know which transfer rules should I activate? The problem with the BI content is that we are not using the standard planning area (we copied the original and added some key figures to the copy).

Regards,

Prikka

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

A simpler way to do this would be to copy the safety stock values calculated by the standard macro into a time series keyfigure added to the planning area and then extract the data from this time series KF through the data source you have built on the planning area and then work on this extracted data.

In my opinion, There is no need to change the std macro or create a new one for this requirement.

If I am not wrong this is what Mr Pawan is trying to say as well.

Regards,

Ashok

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi everyone,

We will add a new key figure to planning area for storing the results of safety stock calculations. After this, we can extract the values through which ever aggregate we want. It would have been nice to learn about the exact logic behind the safety stock macro and replicate it in BI query, but this solution will do the trick as well. The problem is that if the calculation logic is changed for some reason, we will have to recalculate values stored in BW so that they match the new logic.

former_member187488
Active Contributor
0 Kudos

Hello,

The macro function's description is like:

"

SAFETY_CALC( 'product' ; 'location' ; 'version' ; safety daysu2019 supply ; '<name of key figure for safety daysu2019 supply>u2019 ; safety stock ; '<name of key figure for safety stock>' ; key figure for planned demand ; key figure for number of workdays per period ) returns the safety stock for the location product while taking the parameters defined in the location product master data into account. If these parameters require a manual entry for the safety days' supply or the safety stock, enter a value , otherwise enter 0.

You can use the optional parameters name of key figure for safety days' supply and name of key figure for safety stock in aggregated planning (see SAP note 858794).

The arguments for the key figures can be rows or areas.

"

But this may not be what you want.

Actually in SAP standard SNP planning book, the safety stock key figure is populated in an auxiliary key figure, the value of which is calculated by the above macro function. Each time you load any data, the default macro runs to populate safety stock value. However, this value will not be save in liveCache, thus you cannot extract it from the planning area.

I'm not quite familar with BW transfer rules. From APO point of view, if you want to put safety stock in to datasource, you can configure a time series key figure to save the calcualted safety stock.

Best Regards,

Ada

Former Member
0 Kudos

Hi,

It is true that we might be able to solve this problem by adding another key figure to planning area for actually storing safety stock value to liveCache. The problem is that the planning is done on both daily and weekly levels and I'm not sure whether we can store the key figure to the planning area so that the values are correct on both day and week levels. I'd rather use queries and infocubes provided in BI-content, since that would ensure that the key figure is calculated using standard way both on reports and in liveCache.

So, any ideas?

I just realized that the safety stock is actually a quantity, not a factor like days' supply etc. Therefore it should not matter whether the value is saved on week or day level.

Edited by: Prikka on Nov 1, 2011 11:26 AM

Despite this, I'd still be interested in utilizing BI-content in this case. Any ideas how to connect InfoSources etc. of BI content to custom planning area?

Edited by: Prikka on Nov 1, 2011 4:25 PM

former_member209769
Active Contributor
0 Kudos

Hi Prikka, I would assume that you have generated an export data source already for the APO Planning Area. The data that you would get from the datasource would be similar to the data that is stored at the Planning Area level in APO. You can check how the exported data would look like by using T-Code RSA3.

Once you have a datasource linked to the Planning Area, then you can play around with data during the extraction.

PS: Since safety stock is a standard APO Key Figure, it would be best to use the standard SNP macro for the calculation of safety stock. You can copy the standard macro from the standard SNP planning area. Then your extracted data would have this value and you don't need to do any calculations. This KF addition or the calculation wouldn't take up too much memory.