SAP APO - SNP Functions on Macros


Refer to the following table to find the function of your choice. The functions are listed in alphabetical order. You can find examples of macros that use some of these functions in the standard planning book 9ASNP94, view SNP94(1).
Function
Explanation
ACT_LOCATION _PRODUCTS or ACT_LOCATION _PRODUCTS()
ACT_LOCATION_PRODUCTS provides all the product-location combinations that are in the current selection. ‘GRID=2’ is an optional parameter. If you enter this parameter, the system returns the location products of the selection in the second grid.
COVER_CALC()
COVER_CALC(rows for stock on hand ; area for demand from the next period to the end of the time period ; area containing the number of workdays ; demand from the next period to the end of the time period) returns the days’ supply of a product by considering the current stock on hand, the total demand of subsequent time periods, and the number of workdays in this time period.
For example:
Time span         w11     w12  w13     m04    m05
Total demand:   0       20,0   0         25,0    27,5
Stock level        68,7   48,7   48,7    23,7    0
Days’ supply     70      63      57       26       0
Workdays         7       7       7         30       31

Result at the end of m04:
Total demand is 23.7
Total demand in the future is 27.5
Total number of work days in the next period is 31.
Thus, (23.7/27.5) x 31  ~ 26 (only 26 days can be covered)

Using the above value (26)
for w12: Days’ supply is 63 = 7 (from w13) + 30 (from m04) + 26 (from m05).
for w11: Days’ supply is 70 = 7 (from w12) + 30 (from m13) + 26 (from m04) + 26 (from m05).

COVERAGE_SUM()

COVERAGE_SUM (necessary days’ supply ; area containing quantity ; area containing days in the period) returns the total quantity that corresponds to the days' supply required. Instead of the area, you can also enter two sequences with the same number of entries.
For example:
COVERAGE_SUM ( 10 ;
                                  20 ; 30 ; 40 ; 50
                                    1 ; 2 ; 7 ; 10 )
provides the sum of the values 20, 30, 40 = 90, since the sum of days in the first three periods corresponds to the necessary days’ supply.

DEMAND_CALC ()
DEMAND_CALC( 'product' , ' location' , 'version' , 'period'  , key figure for demand , forecast key figure ) returns the demand of a period taking the settings in the master record for the location product (requirements strategy, forecast horizon) into account.
The arguments for the key figures can be rows or areas.
DEP_LOCATION_PRODUCTS()
DEP_LOCATION_PRODUCTS('locations’ ; 'product’ ; ‘version’ ; ‘direction’ ; ‘location type’ ;...) returns all product-location combinations that are connected to the given location product using the transportation land in the given direction (A = all, F = forwards, B = backwards). You can enter several location types.
FORWARD_CALC()
FORWARD_CALC( number of days ; area containing the values ; area containing the number of working days in a period) returns the sum of the values in the area over the number of days specified. If the number of days does not coincide with the end of the period, the value for this last period is calculated proportionally.
Period           1       2      3       4      5      6
Demand      100   120   130   120  100
Working        20     22     21    22     20
days
In the above example for period 1, FORWARD_CALC ( 63; ..) returns the value 350 (100 + 120 + 130). FORWARD_CALC ( 74;...) returns 410 (100 + 120 + 130 + 120 11*22).

INITIAL_STOCK()
INITIAL_STOCK( 'version' ) returns the initial stock for the version. The system determines the parameters (stock category group from the location master) from the current selection.
INTEGER_CALC()
INTEGER_CALC( Row(nattribute) ) provides the integral sum of values from the detailed level of a key figure. For example:
KF1     total      10.25
            Detail 1   3.75
            Detail 2   6.50
INTEGER_CALC (KF1 as attribute) provides 10.
It must be executed on the “all planning objects” level, or on “specific level(s)”, but not on detail level.
MATLOC_INC()
Syntax
MATLOC_INC( ‚Field name’ ; Product ; Location ; <Version> ; Date )
Field name: Literal in quotation marks containing the name of the field from the master data for product interchangeability. The following are valid names:
     VALIDFR: Valid from
     VALIDTO: Valid to
     USEUPDATE: Use up date
Product: Product ID
Location: Location ID
Version: Version ID (optional)
You can enter the product, the location, and the version with other operators or functions, such as ACT_PRODUCT, ACT_LOCATION and ACT_VERSION, or as a literal in quotation marks. If you do not enter a version, the system uses the active version.
Date: You can enter the date with operators or functions, such as BUCKET_EDATE() for instance.
Description
MATLOC_INC() provides the content of the numerical master data fields for product interchangeability executed above.
MATLOC_INC_C()
Syntax
MATLOC_INC_C( ‘Field name’ ; Product ; Location ; <Version> ; Date )
Field name: Literal in quotation marks containing the name of the field from the master data for product interchangeability. The following are valid names:
     PRODUCTID: Internal product ID (GUID)
     PRODUCT: External product ID
     SUCEPRODID: Internal product ID of the successor product (GUID).
     SUCEPROD: External product ID of the successor product.
     USEUPFLG: Use-up strategy
     ICTYPE: Type of interchangeability group
Product: Product ID
Location: Location ID
Version: Version ID (optional)
You can enter the product, the location, and the version with other operators or functions, such as ACT_PRODUCT, ACT_LOCATION and ACT_VERSION, or as a literal in quotation marks. If you do not enter a version, the system uses the active version.
Date: You can enter the date with other operators or functions, such as BUCKET_EDATE() for instance.
Description
MATLOC_INC_C() provides the content of the alphanumeric master data fields for product interchangeability executed above.
MAX_STOCK()
MAX_STOCK( 'version' ) returns the storage capacity for the location product. The system uses the current selection to find this information in the product master.
MULTILEVEL_DEMAND_MEAN()
MULTILEVEL_DEMAND_MEAN( forecast key figure, actual key figure, product, location, version, <period>) returns the sum of demands from all locations in the supply chain. Values for the future are taken from the forecast key figure, for the past from the actual key figure, in both cases for the given product, location (here for instance the plant or distribution center for which you are planning), and version. The entries actual key figure and period are not strictly necessary but improve performance, if you use MULTILEVEL_DEMAND_VAR in the same macro. For more information, see Multilevel Functions in the Supply Chain Network.
MULTILEVEL_DEMAND_VAR()

MULTILEVEL_DEMAND_VAR( forecast key figure, actual key figure, product, location, version, <period> ) returns the error variance between the forecast demand and actual demand for all locations in the supply chain. This value is determined for the whole historical period or the period specified. As above you also enter the product, location, and version of interest, for example ACT_PRODUCT, ACT_LOCATION, and ACT_VERSION. For more information, see Multilevel Functions in the Supply Chain Network.
MULTILEVEL_LEAD_MEAN()

MULTILEVEL_LEAD_MEAN( forecast key figure, actual key figure, product, location, version, <period>) is similar to MULTILEVEL_DEMAND_MEAN(). From a customer view it calculates the lead time for a product in a location. For more information, see Multilevel Functions in the Supply Chain Network.
MULTILEVEL_LEAD_VAR()

MULTILEVEL_LEAD_VAR( forecast key figure, actual key figure, product, location, version, <period> ) returns the error variance between the forecast lead time and actual lead time for the specified product and location. This value is determined for the whole historical period or the period specified. As above you also enter the product, location, and version of interest, for example ACT_PRODUCT, ACT_LOCATION, and ACT_VERSION. For more information, see Multilevel Functions in the Supply Chain Network.
NET_DEMAND()
Syntax
NET_DEMAND( Stock ; reorder point ; target stock level ; net demand ; ‘method’ ; ‘material’ ; ‘location’ ; ‘version’ )
Stock: Current period stock
Net demand: Net demand of previous period
Method: 1, 2, 3 or 4
Description
NET_DEMAND() calculates the net demand using various methods. For methods 1 and 2, the system cumulates the net demand. For methods 3 and 4, the system only considers theNet Demand parameter.
If you have defined the reorder point method for the productMaterial at location Location, the system calculates the net demand according to the following formula, irrespective of the method selected: Net demand = Target stock level – current stock level. The following applies: Current stock level = stock + (cumulative) Net demand (of previous periods). A negative net demand is set to 0.
If you have not defined a reorder point method in the location product master, the system calculates the net demand depending on the method selected:
     Methods 1 and 3: If the current stock level is lower than the reorder point, the system calculates the net demand using the following formula: Net demand = Target stock level – current stock level.  In other cases, the following formula is used: Net demand = Reorder point – current stock level.
     Methods 2 and 4: If the current stock level is lower than the reorder point, the system calculates the net demand using the following formula: Net demand = Target stock level – reorder point..  In other cases, the following formula is used: Net demand = Reorder point – current stock level.
ORDER_DATA_LOCPRODS()
ORDER_DATA_LOCPRODS( ‘buffering (y/n)’ ; ‘category group’ ; ‘version’ ; from-date ; to-date ; ‘location 1’ ; ‘product 1’ ; ‘location 2’ ;…)  provides the cumulated order quantities of any number of location products in the specified time series and in the specified category group.
PHYSICAL_STOCK()
PHYSICAL_STOCK( ‘product’ ; ‘location’ ; version ; ‘category’ ; ‘category’ ; …) returns the stock of a location product of one or more categories.
PHY_STOCK_LOCPRODS()
PHY_STOCK_LOCPRODS( ‘category group’ ; ‘version’ ; ‘location 1’ ; ‘product 1’ ; ‘location 2’ ;…)  returns the cumulated stock of multiple location products from the specified category group.
PRODUCTION_COST()
PRODUCTION_COST( 'product' ; 'location' ; date in period ; <'version'> ) returns the production costs for the product in the location for the period specified using the PPM.
REORDER_CALC()
REORDER_CALC( 'product' ; 'location' ; 'version' ; reorder days ; reorder point' ; offset ; key figure for planned demand ; row for number of workings days per period ) returns the reorder point for the location product referring to  the parameters saved in the location production master data. For instance if the reorder point process in the master data requires a manual entry for the reorder point, you must enter a value, otherwise enter 0.
The arguments for the key figures can be rows or areas.
REORDER_DAYS()
REORDER_DAYS('product' ; 'location' ; 'version' ; days' supply ) returns the days' supply referring to  the parameters saved in the location production master data. If these parameters require a manual entry for the days' supply, enter a value , otherwise enter 0.
SAFETY_CALC()
SAFETY_CALC( 'product' ; 'location' ; 'version' ; safety days’ supply ; '<name of key figure for safety days’ supply>’ ; 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 Structure linkaggregated planning (see SAP note 858794).
The arguments for the key figures can be rows or areas.
SAFETY_DAYS()
SAFETY_DAYS('product' ; 'location' ; 'version' ; safety days' supply ; ‘<name of key figure for safety days’ supply>’) returns the safety days’ supply for the location product while taking the parameters defined in the location production master data into account. If these parameters require a manual entry for the safety days' supply enter a value , otherwise enter 0.
You can use the optional parameter name of key figure for safety days’ supply in aggregated planning (see above).
SB_ALPHA_CYCLE()
SB_ALPHA_CYCLE( service level ; demand forecast ; forecast error demand (%) ; replenishment lead time ; forecast error replenishment lead time (%) ; days' supply ) returns the safety stock level for the Alpha service level according to the cycle method.
The demand forecast is a quantity per day. The replenishment lead time and the days’ supply are measured in seconds.
For more information, see Structure linkSafety Stock Planning.
SB_ALPHA_POINT()
SB_ALPHA_POINT( service level ; demand forecast ; forecast error demand (%) ; replenishment lead time ; forecast error replenishment lead time (%)) returns the safety stock level for the Alpha service level according to the point method.
SB_BETA_CYCLE()
SB_BETA_CYCLE( service level ; demand forecast ; forecast error demand (%) ; replenishment lead time ; forecast error replenishment lead time (%) ; days' supply ) returns the safety stock level for the Beta service level according to the cycle method.
SB_BETA_POINT()
SB_BETA_POINT( service level ; demand forecast ; forecast error demand (%) ; replenishment lead time ; forecast error replenishment lead time (%) ; days' supply ) returns the safety stock level for the Beta service level according to the point method.
SOS_CHECK_MULTI()
Syntax
SOS_CHECK_MULTI( procurement indicator ; version ; product ; location ; resource )
Procurement indicatorE (in-house production) or F(external procurement)
Description
SOS_CHECK_MULTI() provides the value X, if there are multiple sources of supply in the planning time period for the location product, or combination of location and product. In other cases the value SPACE (no value) is returned.
STOCK_BALANCE_OPT()
Syntax
STOCK_BALANCE_OPT( Version ; location ; product ; maximum delay ; return value ; demand area ; total demand area; total receipt area )
Version: Version ID
Location: Location ID
Product: Product ID
You can enter the version, the location, and the product with other operators or functions, such as ACT_PRODUCT, ACT_LOCATION and ACT_VERSION, or as a literal in quotation marks.
Maximum Delay: Maximum delay in days
Return value: Literal in quotation marks for defining the return value of the macro function. If you enter ‘S as the return value, the macro function provides the stock on hand. If you enter’P, the function provides the demand not covered due to capacity restrictions.
Demand area: The system uses the planned independent demand available in this area as the input data for the macro function.
Total demand area: The system uses the total demand available in this area as the input data for the macro function.
Total receipts area: The system uses the total receipts available in this area as the input data for the macro function.
Description
STOCK_BALANCE_OPT() calculates the stock on hand for a location product by considering a maximum delay for the demand.
For more information on using this macro function, see SAP note 701992.
STOCK_CALC()
STOCK_CALC( total demand key figure ; total receipts key figure ; stock level of the previous period ) returns the stock level.
The arguments for the key figures can be rows or areas.
TARGET_CALC()
TARGET_CALC( 'product' ; 'location' ; 'version' ; target days’ supply ; target stock level ; offset (such as safety stock); key figure for planned demand ; key figure for number of workings days per period ) returns the target stock level referring to  the parameters saved in the location production master data. If these parameters require a manual entry for the target days' supply or the target stock level, enter a value , otherwise enter 0.
TARGET_DAYS()
TARGET_DAYS( 'product' ; 'location' ; 'version' ; target days' supply ) returns the target days' supply referring to  the parameters saved in the location production master data. If these parameters require a manual entry for the target days' supply, enter a value , otherwise enter 0.
TRANSPORT_COST()
TRANSPORT_COST( 'product' ; 'source location' ; 'destination location' ; 'means of transport' ; date ; <'version'> ) returns the transport costs incurred transporting the product from source location to destination location using the means of transport on the given date. The system uses the information stored in the relevant transportation lane.
VEC_COVER_CALC()
VEC_COVER_CALC(area for stock on hand ; area for demand from the next period to the end of the time period ; area containing the number of workdays ; demand from the next period to the end of the time period) returns the days’ supply of a product by considering the current stock on hand, the total demand of subsequent time periods, and the number of workdays in this time period.
The vector functions correspond to the largest possible extent to the functions with the same names, but without the VEC prefix (in this case COVER_CALC). You are, however, working using vectors, so the operands are areas and not rows. This means that there are no loops within the step and performance is better.
VEC_GRID_PREQ_QUANTITY
VEC_GRID_PREQ_QUANTITY provides the part quantities in the distribution receipt for the SNP key figure procured externally.
VEC_REORDER_CALC()
VEC_REORDER_CALC( 'product' ; 'location' ; 'version' ; reorder days ; reorder point' ; offset ; key figure (area) for planned demand ; area for number of workings days per period ) returns the reorder point for the location product referring to the parameters saved in the location production master data. If the reorder point method in the master data requires a manual entry for the reorder point, for instance, you must enter a value, otherwise enter 0. This is the vector version of REORDER_CALC.
The result is an area.
VEC_SAFETY_CALC()
VEC_SAFETY_CALC('product' ; 'location' ; 'version' ; safety days' supply ; safety stock , key figure for planned demand ) returns the safety stock for the location product referring to the parameters saved in the location production master data. If these parameters require a manual entry for the safety days' supply or the safety stock, enter a value , otherwise enter 0.
The arguments for the key figures are areas, as for the result.
This is the vector version of SAFETY_CALC.
VEC_STOCK_CONSUMPTION()
VEC_STOCK_CONSUMPTION() is a vector function that carries out consumption using stock and demand values.        
Function arguments:
1: Strategy (Characteristics values: FIFO, BIFO, LIFO)
2: Time (days) for backwards consumption
3: Time (days) for forwards consumption
4: Number of decimal places for consumption
5: Initial stock on hand
6 - n+6  Vector with n storage values
n+7 - 2n+6   Vector with n stock values
2n+7 - 3n+6   Vector with n period lengths (days)
For example:
VEC_STOCK_CONSUMPTION( 'LIFO' ; 3  ; 999 ; 0 ; 0 ; Area: Sum of receipts (1) ; sum of receipts (n) ; area: Sum of demand (1) ; sum of demand (n) ; area: Workdays (1) ; workdays (n) ) provides a vector with n values that display the result of consumption. The resulting values can be interpreted as follows:
     Negative values: The demand of the corresponding periods cannot be covered completely. The amount indicates the quantity of demand not covered.
     Positive values: In the period concerned, stock is still available after consumption. This can then be used for covering further demand. The amount indicates the stock quantity.                                                                                     
VEC_TARGET_CALC()
VEC_TARGET_CALC( 'product' ; 'location' ; 'version' ; target days' supply ; target stock level ; offset ( safety stock) ) returns the target stock level referring to the parameters saved in the location production master data. If these parameters require a manual entry for the target days' supply or the target stock level, enter a value , otherwise enter 0.
This is the vector version of TARGET_CALC. The result and all key figures are areas.
VMI_LEADTIME()
VMI_LEADTIME( 'version' ) returns the procurement time for VMI. The system uses the information from the current selection (product and location) to find the data in the master data.

Comentários