Professional Documents
Culture Documents
Version
Status
0.1
Draft
Date
Internal
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Design
Internal
Contents
1
Organization .................................................................................................. 4
1.1 Document Administration ............................................................................................... 4
1.1.1
Authors ...................................................................................................................... 4
1.1.2
History ....................................................................................................................... 4
1.2
Glossary .................................................................................................................................... 5
High-Level Design......................................................................................... 5
2.1
Assumptions ................................................................................................................... 6
2.2
Architecture..................................................................................................................... 6
2.3
Dynamic Behavior......................................................................................................... 10
4.2
Performance ................................................................................................................. 15
4.3
4.4
4.5
Globalization ................................................................................................................. 15
4.6
Portability ...................................................................................................................... 15
4.7
Appendix ..................................................................................................... 15
5.1
5.2
5.3
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Page 2 of 16
Design
Internal
6.2
Closed Points................................................................................................................ 16
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Page 3 of 16
Design
Internal
1 Organization
1.1 Document Administration
1.1.1 Authors
Name
Company
Role
Author
1.1.2 History
Date
Version
Chapter
0.1
All
Name
[Dev]: https://wiki.wdf.sap.corp/wiki/display/PTUCRM/Marketing+Generic+Object+Layer
[Dev]: https://wiki.wdf.sap.corp/wiki/display/PTUCRM/IBOM+Framework
[Dev]: https://wiki.wdf.sap.corp/wiki/display/WEBCUIF/Business+Object+Layer
[Dev]: https://wiki.wdf.sap.corp/wiki/display/WEBCUIF/Business+Object+Layer+Programming++How+to+Guide
[Dev]:
https://wiki.wdf.sap.corp/wiki/display/WEBCUIF/Business+Object+Layer+Programming+7.0++How+to+Guide
[Dev]: https://wiki.wdf.sap.corp/wiki/display/WEBCUIF/Generic+Interaction+Layer
[Dev]:
https://wiki.wdf.sap.corp/wiki/display/WEBCUIF/Implement+a+GenIL+Component+and+Simple+
Objects+-+How+to+Guide
[Dev]: https://wiki.wdf.sap.corp/wiki/display/WEBCUIF/GenIL+Model+Editor+-+How+to+Guide
[Dev]: https://wiki.wdf.sap.corp/wiki/display/WEBCUIF/GenIL+Programming+Tutorial++How+to+Guide
[Dev]: https://wiki.wdf.sap.corp/wiki/display/WEBCUIF/GenIL+Programming++Sample+Application
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Page 4 of 16
Design
Internal
Glossary
A SAP Trade Promotion Optimization 200 glossary will be provided in a central document.
2 High-Level Design
The existing design and implementation for triggering forecast is not modular and has potential to fail
in certain scenarios. In order to make it more modular, scalable, re-usable and neat and clean, we need
to redesign the way forecast calls are made to DMF system. Currently following areas needs
improvement in the way forecasting is done:
2. Forecasting in background mode: Forecasting is still taking place using online method i.e. CRM is
making RFC calls to DMF and waiting for results to be returned from DMF. It was decided earlier that
all DMF calls are triggered in background mode, so architectural changes are needed to
accommodate this feature. It has also been observed that in some scenarios the current approach to
forecasting in online and batch mode can lead to unexpected behavior. To achieve this we need to
create a new table /TPO/T_TPO_BGRUN for keeping track of the status for background job being
triggered in DMF. Details about this table are provided later in the document.
3. Parallel processing for agreement forecasting: Agreement forecasting currently makes lot of RFC
calls to DMF. In real life scenario one agreement can have more than hundred TPMs and forecasting
such agreement in current design would be challenging since each TPM forecast in agreement leads
to a RFC call, number of RFC calls in this case can be very high and will consume lot of system
resources. The parallel processing of agreement forecasting will be backward compatible for TPO
100.
In order to resolve all the issues mentioned above, we need to fine tune current design for forecasting
DMF calls. We also want the new design to be scalable so that, if in future we need new forecasting
scenarios our design is robust and scalable to meet future requirement.
In our new design approach we will be doing taking the following approach:
1. Delegating object level validation to the object class. For example if validation is required for
TPO object then the corresponding validation will be taken care by the object layer class of
TPO. Our approach will be to make use of existing method, if there is no existing method
then in that case we will create a new method to carry out necessary validation
2. Hierarchy of classes mentioned in class diagram below will be created for better handling of
forecasting in new design approach.
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Page 5 of 16
Design
Internal
A new table /TPO/T_TPO_BGRUN will be created to keep track of status of forecasting job
triggered in DMF as background job. Once the background job in DMF side is finished then
CRM table and run status will be updated.
5. For agreement forecasting the data of TPMs will be grouped in several pools and then
forecasting will be done for each of the pool, once the forecasting of each of the pool is
completed, agreement forecasting will be done. However the central entry point will still be
the class /TPO/CL_TPO_APPL_BASE.
6. The class /TPO/CL_TPO_APPL_BASE will contain a common method FORECAST which will
be called by all handler classes of TPO, TPM and AGR in this method at run time it will get
the instance of corresponding applications.
2.1 Assumptions
In order to achieve agreement forecasting by parallel forecasting of TPMs depends on the fact that
no changes are needed in DMF layer. If the assumption is not right then we may have to change our
approach.
2.2 Architecture
A high level flow using the new architecture will be as following when a user click on Predict or
Simulate or Forecast button on TPO/TPM/Agreement screen, the control will be passed to respective
method in class /TPO/CL_TPO_APPL_BASE (till now no changes in the existing approach), then we
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Page 6 of 16
Design
Internal
instantiate a new object of one of the child class /TPO/CL_TPO_FORECAST_GEN based on whether
forecasting is required for TPO or TPM or Agreement.
After object is instantiated class /TPO/CL_TPO_APPL_BASE will delegate the responsibility of
forecasting to the object.
The object will create a record in /TPO/T_TPO_RUN table for this forecasting incident/event and
then trigger forecast to DMF system background mode only. The object will keep on polling for the time
specified in TPO customizing (wait time) if the forecasting get over before that then the results is
displayed in the UI or else user is informed that forecasting has been triggered in background mode.
As new forecasting design requires changes at various layers in our new design approach we will be
doing taking the following approach:
Method
Operation to be performed
GET_NEXT_TPO_ID
HEADERCAUSAL_ASSIGN_READ
FORECAST_AND_UPDATE
2.
3.
GET_KF_VALUE
START_OBJECT_RUN
Runs forecast
START_OBJECT_RUN_BG_MODE
GET_TPO_STATUS
CANCEL_RUN
CREATE_NEW_TRADE_PROMOTION
CREATE_TRADE_PROMOTION
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Page 7 of 16
Design
Internal
CREATE_TRADE_PROMOTIONS
GET_CAUSAL_METATYPE_PATTERN
IS_VALID_META_TYPE
CHECK_CAUSALS_AGAINST_TPO_TYPE
Checks causal
CONVERT_CUSTOMER_GUIDS
GET_PREDICTION_INPUT_FROM_AGR
Move to
/TPO/CL_TPO_FORECAST_AGR
GET_PREDICTION_INPUT_FROM_TPM
Move to
/TPO/CL_TPO_FORECAST_GEN
PREDICT_AGREEMENT
Agreement forecasting
GET_TPO_KFP_SUBCOMPONENTS
PREDICT_AGREEMENT_BG
SET_AGREEMENT_TIME
Move to
/TPO/CL_TPO_FORECAST_AGR
In general the new approach will move TPO/TPM/AGR related methods to respective classes for
the sake of simplicity and modularity.
The following class diagram depicts the new class hierarchy to be realized.
a.
b.
/TPO/CL_TPO_FORECAST_TPO: TPO specific class for methods needed for TPO specific
functionality.
c.
/TPO/CL_TPO_FORECAST_TPM: TPM specific class for methods needed for TPM specific
functionality.
d.
/TPO/CL_TPO_FORECAST_AGR: TPM specific class for methods needed for TPM specific
functionality.
Page 8 of 16
Design
Internal
2. DDIC Changes: A new table /TPO/T_TPO_BGRUN will be created to store, track and update
status of background job in DMF. This table will not be part of object layer and it would be
added as external attribute.
Field Name
Data Type
Description
.include
CRMS_MKTGS_ASG_PRIMARY_KEY_INC
.include
CRMS_MKTGS_ASG_CGPL_KEY_INC
ASSIGN_GUID
CRM_MKTGS_GUID
RUN_GUID
CRM_MKTGS_GUID
DMF_JOB_ID
BTCJOBCNT
TRANSFER_STATUS
/TPO/E_RUN_STATUS
TIMESTAMP
TIMESTAMP
Other DDIC like table types, structures etc, will be created to perform create/read/update/delete
from table will also be created. Information about these DDIC objects are maintained in next section
of this document.
A new class /TPO/CL_TPO_BGRUN_DB will be created to create/update/delete/read entries
from table /TPO/T_TPO_BGRUN. It will not be part of object layer as we want it to remain
independent so that DMF processes can update this table when forecasting has finished.
A new class /TPO/CL_TPO_RUN_DB will be created to create/update/delete/read entries from
table /TPO/T_TPO_RUN.
3. Use of existing utility class /TPO/CL_TPO_UTIL: Services of utility class /TPO/CL_TPO_UTIL will
be used, in specific scenarios, a new method may be created in this utility class. The existing
utility class /TPO/CL_TPO_UTIL will provide more totalities to address the needs to the new
classes. The details of methods to be moved from /TPO/CL_TPO_APPL_BASE is provided in
next section.
4. Grouping of TPM forecasting parameters: For agreement forecasting the data of TPMs will be
grouped in several pools and then forecasting will be done for each of the pool, once the
forecasting of each of the pool is completed, agreement forecasting will be done. It will be
achieved via following flow:
a. The method predict_agreement of class /TPO/CL_TPO_APPL_BASE will instantiate an
object of class /TPO/CL_TPO_FORECAST_AGR.
b. Call the method predict of instantiated object.
c. In the method of predict of class /TPO/CL_TPO_FORECAST_AGR loop through all TPMs and for each iteration call
d.
e.
method GET_PREDICTION_INPUT_FROM_TPM , once the forecast parameter for TPM is created , insert the
prepared parameters into a table.
After the loop sort the table containing parameters
Group different parameters and for each group make a call for forecasting bases on following parameters
i.
ii.
iii.
iv.
v.
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
iv_sender
iv_fc_start_date
iv_fc_end_date
iv_time_agg
iv_ignore_prod_listing
Title: New Forecasting Design
Version: 0.1
Date: 14.09.2010
Page 9 of 16
Design
Internal
vi.
vii.
viii.
ix.
x.
xi.
xii.
xiii.
xiv.
xv.
iv_also_unagg_flag
iv_use_existing_offers_flag
iv_fc_existing_offers_flag
iv_fc_regular_sales_flag
iv_return_fc_info_tcd
iv_scale_up_shipment_factor
iv_diversion_shipment_factor
iv_forward_buy_shipment_factor
iv_fc_time_agg_day_of_week
Once the group is prepared a forecasting for each group can be triggered and results aggregated. The logic
for aggregation can be inferred from the method /TPO/IF_FORECAST_EXT~FORECAST_JOB_STATUS of
class /TPO/CL_BADI_FORECAST_IMPL lines 101 to 455.
The actual forecasting will still be performed in BADI layer so that if customer want to have his/her own forecasting
engine they can implement forecast BADI and perform forecasting and analysis.
I.
Backward Compatibility with TPO 100: The changes will be done in a way so that it can
be down ported to TPO100 systems,
II.
Switch using new and existing mechanism : Above changes will be done in a way that
even in TPO 200 system we can switch between old way of forecasting and new way. So
that results can be compared, once the new design is stabilized switch will be disabled
and only new will exist.
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Page 10 of 16
Design
Internal
3 Detailed Design
3.1 Classes Methods
3.1.1 Classes/Tables/structures
3.1.1.1
Classes
Class
Description
/TPO/CL_TPO_FORECAST_GEN
/TPO/CL_TPO_FORECAST_TPM
/TPO/CL_TPO_FORECAST_AGR
3.1.1.2
Structures
Structures
Description
/TPO/S_TPO_BGRUN
3.1.1.3
Class
/TPO/CL_TPO_FORECAST_GEN
FM /TPO/TPO_BGRUN_POST
Table types
Table types
/TPO/TT_TPO_BGRUN
3.1.1.4
Used In
Description
Function Module
/TPO/TPO_BGRUN_POST
Tables
Description
/TPO/T_TPO_RUN
3.1.1.5
Function Modules
Description
/TPO/SING_RUN_RESULTS_UPDATE
/TPO/MULTI_RUN_RESULTS_UPDATE
3.1.2 Methods
Class Name: /TPO/CL_TPO_FORECAST_GEN
Attribute
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Visibility
Data Type
Purpose
Page 11 of 16
Design
Internal
MT_APPL_BASE
Protected
/TPO/CL_TPO_APPL_BASE
Method
Visibility
Purpose
START_OBJECT_RUN
Public
Runs forecast
START_OBJECT_RUN_BG_MODE
Public
SAVE_AND_START_RUN
Public
CREATE_RUN
Public
Creates Run
FORECAST_AND_UPDATE
Public
GET_KF_VALUE
Protected
FORECAST_SINGLE_PREDICTION
Protected
FORECAST_MULTI_PREDICTION
Protected
/TPO/IF_TPO_FORECAST_GEN~FORECAST
Public
Interface
CANCEL_RUN
Public
Cancels Run
Visibility
MT_APPL_BASE
Protected
Data Type
Purpose
/TPO/CL_TPO_APPL_BASE
Method
Visibility
Purpose
HEADERCAUSAL_ASSIGN_READ
Public
CREATE_TRADE_PROMOTIONS
Public
CREATE_TRADE_PROMOTION
Public
Create TPMs
GET_PREDICTION_INPUT_FROM_TPM
Public
TPM_REF_ASSIGN_CREATE
Public
/TPO/IF_TPO_FORECAST_TPM~FORECAST
Public
Visibility
MT_APPL_BASE
Protected
Method
Data Type
/TPO/CL_TPO_APPL_BASE
Purpose
To access TPO application base class & its services
Visibility
Purpose
GET_PREDICTION_INPUT_FROM_AGR
Public
PREDICT_AGREEMENT
Public
Agreement forecasting
GET_DMF_AGG_LEVEL
Public
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Page 12 of 16
Design
Internal
/TPO/IF_TPO_FORECAST_GEN~FORECAST
Public
Attribute
Visibility
MT_APPL_BASE
Protected
Data Type
/TPO/CL_TPO_APPL_BASE
Method
Purpose
To access TPO application base class & its services
Visibility
Purpose
GET_NEXT_TPO_ID
Public
GET_TPO_STATUS
Public
GET_CAUSAL_METATYPE_PATTERN
Public
IS_VALID_META_TYPE
Public
CHECK_CAUSALS_AGAINST_TPO_TYPE
Public
Checks causal
CONVERT_CUSTOMER_GUIDS
Public
GET_TPO_KFP_SUBCOMPONENTS
Public
SET_TIMER
Public
Starts timer
Level
Purpose
CREATE_RECORD
Instance
UPDATE_RECORD
Instance
DELETE_RECORD
Instance
READ_RECORD
Instance
Attribute
Visibility
Method
Data Type
Visibility
Purpose
Purpose
CREATE_RECORD
Public
UPDATE_RECORD
Public
DELETE_RECORD
Public
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Page 13 of 16
Design
Internal
Public
READ_RECORD
Attribute
Visibility
Method
Data Type
Visibility
Purpose
Purpose
CREATE_RECORD
Public
UPDATE_RECORD
Public
DELETE_RECORD
Public
READ_RECORD
Public
3.1.3 Archiving
Not applicable.
3.1.4 BW extractors
Not applicable.
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Page 14 of 16
Design
Internal
4 Verification of Constraints
4.1 Data Volumes
Not relevant.
4.2 Performance
Not relevant.
4.5 Globalization
Not relevant.
4.6 Portability
Not relevant.
5 Appendix
5.1 Alternative Design Ideas
Not relevant.
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Modification
(components, objects)
Page 15 of 16
Design
Internal
Description
Responsible
Date/Decision
Description
Responsible
2014 SAP AG
Dietmar-Hopp-Allee 16
D-69190 Walldorf
Date/Decision
Page 16 of 16