apo forecast split · pdf filesap community network sdn - sdn.sap.com | bpx - bpx.sap.com ......

12
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2010 SAP AG 1 APO Forecast Split Applies to: This article refers to the SAP Supply Network Collaboration (SNC) 7.0. For more information, visit the ABAP homepage . Summary This article describes the custom development done in SAP SNC 7.0 to support the scenario where the APO Forecast is compared with the SNC forecast to arrive at a consensus. In APO, the forecast is maintained at a single physical location whereas the SNC forecast has been divided into two logical locations. This custom development is to split the APO forecast into two logical locations. Author: Golda John Company: Cognizant Technology Solutions Created on: 17 November 2010 Author Bio Golda John is working with Cognizant since Feb 2005. Her experience is spread over different Net weaver Technologies like ABAP, Web Dynpro and SNC.

Upload: vuonghanh

Post on 01-Feb-2018

240 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 1

APO Forecast Split

Applies to:

This article refers to the SAP Supply Network Collaboration (SNC) 7.0. For more information, visit the ABAP homepage.

Summary

This article describes the custom development done in SAP SNC 7.0 to support the scenario where the APO Forecast is compared with the SNC forecast to arrive at a consensus. In APO, the forecast is maintained at a single physical location whereas the SNC forecast has been divided into two logical locations. This custom development is to split the APO forecast into two logical locations.

Author: Golda John

Company: Cognizant Technology Solutions

Created on: 17 November 2010

Author Bio

Golda John is working with Cognizant since Feb 2005. Her experience is spread over different Net weaver Technologies like ABAP, Web Dynpro and SNC.

Page 2: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 2

Table of Contents

Business Requirement ........................................................................................................................................ 3

Solution Overview ............................................................................................................................................... 3

Step by Step Configuration ............................................................................................................................. 3 Step 1: ......................................................................................................................................................................... 3

Step 2: ......................................................................................................................................................................... 4

Step 3: ......................................................................................................................................................................... 4

Result………………….. ...................................................................................................................................... 9

Related Content ................................................................................................................................................ 11

Disclaimer and Liability Notice .......................................................................................................................... 12

Page 3: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 3

Business Requirement

Due to tax regulations, the business requirement is to maintain two logical locations although there is only one physical location. APO is used for short to mid range forecasting. SNC Responsive Replenishment is used to support VMI. APO forecast is maintained at the physical location level and hence it has only one number however there is a need to maintain SNC forecast at two logical locations level. The requirement hence is to split the APO forecast at these logical location levels so that APO forecast can be compared with SNC forecast and also customer / market inputs to arrive at a consensus before the Final Forecast is released for Short term forecasting.

Solution Overview

The custom development aims at addressing the scenario as follows:

Create a custom table with Customer location and the split locations.

In the implementation of the BADI /SCA/BIF_I_FCST determine if the customer location has any split location associated with it by checking against the custom table.

If split locations exist, split the incoming APO forecast quantity across the locations in the same ratio that the SAP SNC Forecast quantity is split for the locations

Step by Step Configuration

Step 1:

Create a custom table with customer locations and the associated split locations.

Page 4: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 4

Step 2:

Create an implementation of BADI /SCA/BIF_I_FCST.

Step 3:

In the method BEFORE CONVERSION check whether the location has any split locations associated with it. If so, determine the SNC forecast for the all the split locations. Divide the APO forecast quantity among the split locations in the same ratio as the division of quantity of SNC forecast.

Code Snippet: The skeleton code is on the assumption that the incoming Structure has only one item and quantity details for one period.

*****************************************************************

* TYPE DECLARATION *

*****************************************************************

TYPES: BEGIN OF gty_matloc,

product TYPE /sapapo/matnr,

location TYPE /sapapo/locno,

END OF gty_matloc.

*****************************************************************

* CONSTANT DECLARATION *

*****************************************************************

CONSTANTS: gc_kprm TYPE /scmb/tsdm_kprm VALUE 'FORECAST',

gc_tstp TYPE /scmb/tstp VALUE 'VMIW1'.

*****************************************************************

* FIELD SYMBOL DECLARATION *

*****************************************************************

FIELD-SYMBOLS: <ls_tims> TYPE /sca/bif_s_quantity_time_se_it,

<ls_tims2> TYPE /sca/bif_s_quantity_time_se_it,

<ls_item> TYPE /sca/bif_s_forecast_item.

Page 5: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 5

*****************************************************************

* DATA DECLARATION *

*****************************************************************

DATA: lv_total TYPE /scmb/dm_itm_quan,

lv_quan TYPE /scmb/dm_itm_quan,

lv_date TYPE string,

lv_from TYPE /scmb/dm_validfr_datim,

lv_to TYPE /scmb/dm_validfr_datim,

lv_quantity TYPE cmquan17,

lv_locno TYPE /scmb/mdl_locno.

DATA: ls_item TYPE /sca/bif_s_forecast_item,

ls_locations TYPE zsnc_splitloc,

ls_matloc TYPE gty_matloc,

ls_prodloc TYPE gty_matloc,

ls_locno TYPE /sca/dm_locno_rstr,

ls_matnr TYPE /sca/dm_matnr_rstr,

ls_ctrl TYPE /scmb/tsdm_read_ctrl,

ls_kprm TYPE /scmb/kprm_str,

ls_sales TYPE /scmb/ts_str,

ls_period TYPE /scmb/tsdm_period_str,

ls_kval1 TYPE /scmb/kval_str,

ls_kval2 TYPE /scmb/kval_str.

DATA: lt_period TYPE /scmb/tsdm_period_tab ,

lt_locno TYPE /sca/dm_locno_rtab,

lt_matnr TYPE /sca/dm_matnr_rtab,

lt_matlocid TYPE /scmb/tsdm_matidlocid_tab,

lt_kprm TYPE /scmb/kprm_tab,

lt_sales TYPE /scmb/ts_tab,

lt_locations TYPE STANDARD TABLE OF zsnc_splitloc,

lt_matloc TYPE STANDARD TABLE OF gty_matloc,

lt_prodloc TYPE STANDARD TABLE OF gty_matloc,

lt_return TYPE STANDARD TABLE OF bapiret2.

CHECK cs_fcst_notif-product_forecast-item[] IS NOT INITIAL.

* DETERMINE THE SPLIT LOCATIONS

SELECT *

INTO TABLE lt_locations

FROM zsnc_splitloc

FOR ALL ENTRIES IN cs_fcst_notif-product_forecast-item

WHERE customer_loc = cs_fcst_notif-product_forecast-item-ship_to_location-

internal_id-value.

CHECK sy-subrc IS INITIAL.

READ TABLE lt_locations INTO ls_locations INDEX 1.

CHECK sy-subrc IS INITIAL.

UNASSIGN <ls_item>.

READ TABLE cs_fcst_notif-product_forecast-item

ASSIGNING <ls_item>

Page 6: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 6

WITH KEY ship_to_location-internal_id-value = ls_locations-customer_loc.

IF sy-subrc IS INITIAL.

IF ls_locations-splitloc1 IS NOT INITIAL.

ls_matloc-product = <ls_item>-product-internal_id-value.

ls_matloc-location = ls_locations-splitloc1.

APPEND ls_matloc to lt_matloc.

ENDIF.

IF ls_locations-splitloc2 IS NOT INITIAL.

ls_matloc-product = <ls_item>-product-internal_id-value.

ls_matloc-location = ls_locations-splitloc2.

APPEND ls_matloc to lt_matloc.

ENDIF.

IF lt_matloc[] IS NOT INITIAL.

* DETERMINE IF THE PRODUCT LOCATION COMBINATION EXISTS FOR

* THE SPLIT LOCATIONS

SELECT matnr

locno

FROM /sapapo/v_matloc

INTO TABLE lt_prodloc

FOR ALL ENTRIES IN lt_matloc

WHERE matnr = lt_matloc-product

AND locno = lt_matloc-location.

IF sy-subrc IS INITIAL.

ls_matnr-sign = 'I'.

ls_matnr-option = 'EQ'.

ls_matnr-low = <ls_item>-product-internal_id-value.

APPEND ls_matnr TO lt_matnr.

LOOP AT lt_prodloc INTO ls_prodloc.

ls_locno-sign = 'I'.

ls_locno-option = 'EQ'.

ls_locno-low = ls_prodloc-location.

APPEND ls_locno TO lt_locno.

ENDLOOP.

* GET THE GUIDS FOR THE PRODUCT LOCATION

CALL FUNCTION '/SCA/TSDM_MD_KEYS_GET'

EXPORTING

it_matnr = lt_matnr

it_locno = lt_locno

IMPORTING

et_matidlocid = lt_matlocid.

* FILL THE REQUIRED PARAMETERS TO GET THE SNC FORECAST

ls_ctrl-tstp = gc_tstp.

ls_ctrl-nobuffer = 'X'.

ls_ctrl-peridflg = 'X'.

Page 7: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 7

ls_kprm-kprm = gc_kprm.

APPEND ls_kprm TO lt_kprm.

* GET THE SNC FORECAST

CALL FUNCTION '/SCA/TDM_TSDM_TS_GET'

EXPORTING

is_ctrl = ls_ctrl

it_kprm = lt_kprm

it_matidlocid = lt_matlocid

IMPORTING

et_ts = lt_sales

CHANGING

ct_period = lt_period

ct_return = lt_return.

IF lt_return IS NOT INITIAL.

ct_return[] = lt_return[].

ENDIF.

ENDIF.

ENDIF.

UNASSIGN <ls_tims>.

READ TABLE <ls_item>-sales_forecast_time_series-item ASSIGNING <ls_tims> INDEX 1.

IF sy-subrc IS INITIAL.

* FORMAT THE START DATE

lv_date = <ls_tims>-validity_period-start_date_time.

TRANSLATE lv_date USING '- T : '.

CONDENSE lv_date NO-GAPS.

lv_from = lv_date.

CLEAR lv_date.

* FORMAT THE END DATE

lv_date = <ls_tims>-validity_period-end_date_time.

TRANSLATE lv_date USING '- T : '.

CONDENSE lv_date NO-GAPS.

lv_to = lv_date.

READ TABLE cs_fcst_notif-product_forecast-item

INTO ls_item

INDEX 1.

IF sy-subrc IS INITIAL.

ls_item-ship_to_location-internal_id-value = ls_locations-splitloc2.

UNASSIGN <ls_tims2>.

READ TABLE ls_item-sales_forecast_time_series-item

ASSIGNING <ls_tims2>

WITH KEY validity_period-start_date_time = <ls_tims>-validity_period-

start_date_time

validity_period-end_date_time = <ls_tims>-validity_period-end_date_time.

IF sy-subrc IS NOT INITIAL.

* RAISE ERROR MESSAGE

ENDIF.

ENDIF.

* READ THE PERIOD CORRESPONDING TO START DATE-END DATE

READ TABLE lt_period

Page 8: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 8

INTO ls_period

WITH KEY pertstfr = lv_from

pertstto = lv_to.

IF sy-subrc IS INITIAL.

READ TABLE lt_sales INTO ls_sales INDEX 1.

IF sy-subrc IS INITIAL.

READ TABLE ls_sales-kval

INTO ls_kval1

WITH KEY perid = ls_period-perid.

ENDIF.

CLEAR ls_sales. READ TABLE lt_sales INTO ls_sales INDEX 2.

IF sy-subrc IS INITIAL. READ TABLE ls_sales-kval

INTO ls_kval2

WITH KEY perid = ls_period-perid.

ENDIF.

CALL FUNCTION '/SCMB/MDL_KEYC_BY_LOCID_SNL'

EXPORTING

iv_locid = ls_sales-locid

IMPORTING

EV_LOCNO = lv_locno

. IF ls_kval1-kval IS INITIAL

AND ls_kval2-kval IS INITIAL.

CLEAR lv_quantity.

IF <ls_tims> IS ASSIGNED.

lv_quantity = <ls_tims>-quantity-value / 2.

<ls_tims>-quantity-value = lv_quantity.

ENDIF.

IF <ls_tims2> IS ASSIGNED.

<ls_tims2>-quantity-value = lv_quantity.

ENDIF.

ELSE.

CLEAR: lv_total,

lv_quan,

lv_quantity.

lv_total = ls_kval1-kval + ls_kval2-kval.

lv_quan = <ls_tims>-quantity-value.

IF lv_locno = ls_locations-splitloc2.

lv_quantity = ( lv_quan * ls_kval1-kval ) / lv_total.

<ls_tims>-quantity-value = lv_quantity.

lv_quantity = ( lv_quan * ls_kval2-kval ) / lv_total.

<ls_tims2>-quantity-value = lv_quantity.

ELSE.

lv_quantity = ( lv_quan * ls_kval2-kval ) / lv_total.

IF <ls_tims> IS ASSIGNED.

<ls_tims>-quantity-value = lv_quantity.

ENDIF.

CLEAR lv_quantity.

lv_quantity = ( lv_quan * ls_kval1-kval ) / lv_total.

IF <ls_tims2> IS ASSIGNED.

<ls_tims2>-quantity-value = lv_quantity.

ENDIF.

ENDIF.

APPEND ls_item TO cs_fcst_notif-product_forecast-item.

ENDIF.

Page 9: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 9

Result

The Forecast values can be viewed In the Web SNC go to the Demand Collaborative Sales Forecast Sales Forecast Details – Product View. Key figure for the same is “Customer Baseline Sales Forecast”.

The SNC Forecast for Period 09/27 - 10/03 for Location1 and Location2 are as follows:

Location1: 55

Location2: 232

Suppose the incoming APO Forecast Value for Location1 is 50 H.A check against the custom table determines that that Location1 is maintained as Location1 and Location2 at the logical level. So the Forecast quantity is split across the locations in the same ratio as that of SNC Forecast for these locations.

Scenario: Location2 and Product 43300.

Page 10: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 10

The split Forecast quantity for location2 is 50*232/287 =40.418. The corresponding value in CR is 40.418* 5 = 202.08. This value is rounded to 202 on the Sales Forecast Product View.

Scenario: Location1 and Product 43300.

The Forecast split calculated according the ratio in “TH” for location1 is 50*55/287 =9.581. The corresponding value in CR for this is 9.581* 5 = 47.91. The value is rounded to 48.

Page 11: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 11

Related Content

For more information, visit the ABAP homepage.

Page 12: APO Forecast Split · PDF fileSAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com ... APO is used for short to mid range forecasting. SNC Responsive Replenishment is

APO Forecast Split

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 12

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.