You are on page 1of 9

APD: How to Get Delta if Created

On/Changed On Date Field


Available

Applies to:
SAP BW 3.x & SAP BI NetWeaver 2004s (BI7.0). For more information, visit the Business Intelligence
homepage.

Summary
Many times there are situations where your APD needs to extract delta records to flat file. If you have fields
like Created on or Changed on dates in your data source objects, then the delta can be possible using
Customer exit and SAP delivered TVARVC table.
Author:

Yogesh Patil

Company: Accenture India Pvt. Ltd.


Created on: 17 April 2010

Author Bio
Yogesh Patil is working as Analyst Programmer with Accenture India Pvt. Ltd. He has got rich
experience on various BW Implementation/Support Projects in both SAP BW 3.5 and SAP BW
7.0.

SAP COMMUNITY NETWORK


2010 SAP AG

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


1

APD: How to Get Delta if Created On/Changed On Date Field Available

Table of Contents
Introduction ................................................................................................................................................... 3
Business Scenario ........................................................................................................................................ 3
Step by Step Guide ....................................................................................................................................... 3
1. Create Variable on Created On InfoObject ............................................................................................. 3
2. Create Entry in TVARVC table ............................................................................................................... 4
3. Create Filter in APD ............................................................................................................................. 5
4. Create customer exit for your varible to populate Delta date parameters ................................................ 5
5. Create Custom ABAP program to maintain Delta date parameters ......................................................... 6
6. Process Chain ....................................................................................................................................... 7
Related Content ............................................................................................................................................ 8
Disclaimer and Liability Notice ....................................................................................................................... 9

SAP COMMUNITY NETWORK


2010 SAP AG

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


2

APD: How to Get Delta if Created On/Changed On Date Field Available

Introduction
In SAP BW/BI, data from various databases from systems available in the company are collected,
consolidated, managed and prepared for evaluation purposes. There is often further, valuable potential in
this data.
It deals with completely new information that is displayed in the form of meaningful connectivity between data
but that is too well hidden or complex to be discovered by simple observation or intuition.
The Analysis Process Designer (APD) makes it possible to find and identify these hidden or complex
relationships between data in a simple way. Various data transformations are provided for this purpose, such
as statistical and mathematical calculations, and data cleansing or structuring processes.
The analysis results are saved in BW data targets or in a CRM system. They are available for all decision
and application processes and thus can be decisive (strategically, tactically, operatively).
One of the problem with the APD is it always do full extract from the data sources (DSOs, Master Data
InfoObjects) and there is not delta functionality provided.
But if you have Created On/Changed On Date fields populated in your data sources, then we can get delta
using TVARVC table and Customer Exit. Lets explore!

Business Scenario
Lets take an example- Suppose you are fetching data from DSO where Created On date is populated. This
data is used for calculating complex scenarios using other data and then send the output to the Flat file
which will be input file to some legacy system. As APD extract always all data from DSO which Customer
feels unnecessary and demand is SAP BI should be intelligent enough to send only delta records.
Below is the step by step process how to achieve delta based on Created On date available.

Step by Step Guide


1. Create Variable on Created On InfoObject
The DSO from which you are extracting delta records
based on Created On date, you will need to create
Variable of type Customer Exit.
-

So, go to BEx Query Designer.

Click on New Query.

Go to InfoArea

Select your DSO. Double Click on it.

Screen will appear with Key Figures and


Dimensions.

Find your Created On InfoObject and Expand.

Right Click on Characteristic Value Variable

Click on New Variable (as shown in fig. 1)

SAP COMMUNITY NETWORK


2010 SAP AG

Fig.1

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


3

APD: How to Get Delta if Created On/Changed On Date Field Available

For this new variable, provide valid description,


technical name.

Use Processing By as Customer Exit (As shown in


fig. 2)

In Detail Tab, make variable as Interval and


Optional. Also, uncheck Variable is ready for Input.
(As shown in fig. 3)

Save the variable.

Fig.2

Fig.3

2. Create Entry in TVARVC table


-

Go to SM30 transaction

Provide table name as TVARV and click


on Maintain button

Go to tab- Selection Options

Press CTRL+F1

Press F5

Provide Name of variable and Option and


High and Low values for date (example19000101 for both Low and High Value)

SAP COMMUNITY NETWORK


2010 SAP AG

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


4

APD: How to Get Delta if Created On/Changed On Date Field Available

3. Create Filter in APD


-

Go to transaction RSANWB

Open your APD in Edit mode

Insert filter (Restrict Amount of Data) in your APD to get delta


records from your DSO

Go to Properties of this filter -> Field Selection and select Created on Date

Go to Filter Conditions tab

Restrict Created Date field by your Variable created in step 1

Save and Activate your APD.

4. Create customer exit for your varible to populate Delta date parameters
Go to CMOD and navigate to Function exit EXIT_SAPLRRS0_001.
Implement below code in INCLUDE ZXRSRU01************************************************************************
* Author:
Yogesh Patil
*
* Variable : ZDELTA_DATE - Get Delta date range
*
* Description: This variable is used in APD processes in
*
*
filters. It contains Delta date range
.
*
************************************************************************
*
PLEASE DO NOT USE THIS VARIBLE for any other Object
*
*
It should be used by APD - XXXXXXXX
*
************************************************************************
WHEN 'ZDELTA_DATE'.
DATA: ls_tvrv TYPE STANDARD TABLE OF tvarvc WITH HEADER LINE.
DATA: lv_date TYPE sy-datum.
**********************************************************************
* Please note that the Variables are determined in program - ZGET_DELTA_DATE
* And this program should be run before APD XXXXXXXX run to set delta parameters
**********************************************************************
IF i_step = 1.
CLEAR l_s_range.
SELECT SINGLE * FROM tvarvc INTO CORRESPONDING FIELDS OF ls_tvrv
WHERE name = 'ZDELTA_DATE_APD1'.
IF sy-subrc = 0.
l_s_range-low = ls_tvrv-low. "Last Run
l_s_range-high = ls_tvrv-high. "Current Run
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDIF.

SAP COMMUNITY NETWORK


2010 SAP AG

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


5

APD: How to Get Delta if Created On/Changed On Date Field Available

5. Create Custom ABAP program to maintain Delta date parameters


The need of ABAP program is to set delta date parameters accurately. The logic to set parameters can be
implemented in Customer Exit itself but had disadvantage as whenever you run APD for test purpose (or to
see intermediate result), the Customer Exit will set the delta date parameters which should not happen.
So to avoid it create custom ABAP program and run it in process chain before APD run.

*&---------------------------------------------------------------------*
*& Report ZGET_DELTA_DATE
*&
*&---------------------------------------------------------------------*
************************************************************************
* Author:
Yogesh Patil
*
* Variable : ZDELTA_DATE - Get Delta date range
*
* Description: This variable is used in APD processes in
*
*
filters. It contains Delta date range
.
*
************************************************************************
*
PLEASE DO NOT USE THIS VARIBLE for any other Object
*
*
It should be used by APD - XXXXXXXX
*
************************************************************************
REPORT ZGET_DELTA_DATE.
DATA: ls_tvrv TYPE STANDARD TABLE OF tvarvc WITH HEADER LINE.
data: lv_date type Sy-datum,
lv_date2 TYPE sy-datum.
SELECT SINGLE * FROM tvarvc INTO CORRESPONDING FIELDS OF ls_tvrv
WHERE name = 'ZDELTA_DATE_APD'.
IF sy-subrc = 0.
lv_date = ls_tvrv-high. "Last run- High Value
lv_date2 = sy-datum - 1.
if lv_date lt lv_date2.
lv_date = lv_date + 1.
endif.
ls_tvrv-low = lv_date.
lv_date
= sy-datum - 1.
ls_tvrv-high = lv_date.
"Current Run
MODIFY tvarvc FROM ls_tvrv. "Update Variables
IF sy-subrc = 0.
COMMIT WORK.
ENDIF.
ENDIF.

(The logic works like setting Upper limit as 1 as safety interval.)

SAP COMMUNITY NETWORK


2010 SAP AG

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


6

APD: How to Get Delta if Created On/Changed On Date Field Available

6. Process Chain
The APD should run using Process chain to work delta
functionality and to set parameters correctly.
So create Process chain which will have two ABAP
program process types1. To run ZGET_DELTA_DATE program
2. To run APD using standard program
RSAN_PROCESS_EXECUTE
(Refer-How To Use Analysis Process in Process
Chains)

SAP COMMUNITY NETWORK


2010 SAP AG

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


7

APD: How to Get Delta if Created On/Changed On Date Field Available

Related Content
Analysis Process Designer (APD) Step by Step
How To Use Analysis Process in Process Chains
http://forums.sdn.sap.com/thread.jspa?threadID=1577721
For more information, visit the Business Intelligence homepage.

SAP COMMUNITY NETWORK


2010 SAP AG

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


8

APD: How to Get Delta if Created On/Changed On Date Field Available

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 do cument,
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.

SAP COMMUNITY NETWORK


2010 SAP AG

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


9

You might also like