How to Write a Routine in DTP Selection Applies to:

How to Write a Routine in DTP
Selection
Applies to:
SAP NetWeaver Business Warehouse (Formerly BI), Will also work on SAP BI 3.5. For more information,
visit the EDW homepage
Summary
This article gives clear picture about how to use a Routine for 0FISCPER in DTP Selection based on System
Date.
Author:
Surendra Kumar Reddy Koduru
Company: Accenture. (Bangalore/INDIA)
Created on: 13 July 2011
Author Bio
Surendra Kumar Reddy Koduru is a SAP BI Lead Consultant currently working with Accenture. He
has got rich experience and worked on various BW/BI Implementation/Support Projects and he is the
author for various Articles and Blogs (SAP-BW/BI) in SAP Community Network.
SAP COMMUNITY NETWOR
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
1
How to Write a Routine in DTP Selection
Table of Contents
Introduction: ........................................................................................................................................................ 3
Live Scenario: ..................................................................................................................................................... 3
InfoCube 0PC_C01 Data Flow: .......................................................................................................................... 3
DTP: .................................................................................................................................................................... 4
Code Window: .................................................................................................................................................... 8
Code before Change: ......................................................................................................................................... 9
Code after Change: .......................................................................................................................................... 10
Activate DTP: .................................................................................................................................................... 13
All Tabs of DTP: ................................................................................................................................................ 14
Data loading using above DTP: ........................................................................................................................ 15
Monitor Screen: ................................................................................................................................................ 16
PSA Data: ......................................................................................................................................................... 18
InfoCube Data: .................................................................................................................................................. 19
Related Content ................................................................................................................................................ 20
Disclaimer and Liability Notice .......................................................................................................................... 21
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2
How to Write a Routine in DTP Selection
Introduction:
This article addresses the requirement of a Routine in DTP selection on 0FISCPER. Using this routine, I
need to load only that particular Fiscal Year Period into InfoCube and other data just ignore in PSA it self.
Live Scenario:
Some times when we are loading data from PSA into InfoCubes/DSO’s, we need some selections in DTP;
this is useful especially when you want to load using some selections from PSA. Here we need only Current
Fiscal Year Period i.e. 006.2011 (this is based on 06.2011 because I written this article on 27-06-2011 so as
per this date the Fiscal Year period is 006.2011, I used Fiscal Year Variant as K4)
We are loading data to 0PC_C01 InfoCube and using DataSource 0CO_PC_01, this DataSource supports
Full Load only so we need to restrict the data loads for Current Year using DTP from PSA. To load Current
Fiscal Year Period based on System Date we need to write the ABAP Routine in DTP selection.
InfoCube 0PC_C01 Data Flow:
See the below Screen.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
3
How to Write a Routine in DTP Selection
The above flow is in BI 7.X, and till PSA, we need to use InfoPackage and from PSA to InfoCube we need to
use DTP, in DTP we are going to write Routine.
DTP:
Create the DTP and then click on Filter button and see the see the Selection fields, if you won’t find your
selection field, then you need to click on Change Selection and then select you filed after that you see it in
selection screen.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
4
How to Write a Routine in DTP Selection
To see all fields then click on Change Selection Button.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
5
How to Write a Routine in DTP Selection
If you need any other fields, you just select it from list and then move to left side. After that you see you
selection fields in the actual selection screen like below…
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
6
How to Write a Routine in DTP Selection
In this scenario we want to write routine in Fiscal Year/Period i.e. to load data from PSA to InfoCube for
current Fiscal Year/Period based on System Date. Click on Routine button and then it will ask Name give
some name and continue, it will go to window code.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
7
How to Write a Routine in DTP Selection
Code Window:
Once you click on Editor Button, it will go to Code window like below.
In above screen you can see ABAP Code Editor; here we are going to write the ABAP code to load only
Current Fiscal Year Period Data based on SY-DATUM (System Date).
Eg: Today Date is 27-06-2011, as per this date the Fiscal Year Period is 006.2011. (I used Fiscal Year
Variant as K4).
So the data is loaded only for 006.2011 period using DTP from PSA.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
8
How to Write a Routine in DTP Selection
Code before Change:
*&---------------------------------------------------------------------*
*& Include
RSBC_SEL_ROUTINE_TPL
*&---------------------------------------------------------------------*
program conversion_routine.
* Type pools used by conversion program
type-pools: rsarc, rsarr, rssm.
tables: rssdlrange.
* Global code used by conversion rules
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
* DATA:
...
*$*$ end of global - insert your declaration only before this line
*-*
* ------------------------------------------------------------------*
Fieldname
=
*
data type
=
*
length
= 000000
* ------------------------------------------------------------------form compute_
tables l_t_range structure rssdlrange
using i_r_request type ref to IF_RSBK_REQUEST_ADMINTAB_VIEW
i_fieldnm type RSFIELDNM
changing p_subrc like sy-subrc.
*
Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line
*-*
data: l_idx like sy-tabix.
read table l_t_range with key
fieldname = ' '.
l_idx = sy-tabix.
*....
if l_idx <> 0.
modify l_t_range index l_idx.
else.
append l_t_range.
endif.
p_subrc = 0.
*$*$ end of routine - insert your code only before this line
endform.
SAP COMMUNITY NETWORK
© 2011 SAP AG
*-*
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
9
How to Write a Routine in DTP Selection
Code after Change:
Now we will write few lines of ABAP code to fulfill our requirement. See the below code. Once you write the
code, check the syntax error, if it is Ok then Save the routine.
The code which is written in above window is given in below page, so you can compare the code before and
after.
*&---------------------------------------------------------------------*
*& Include
RSBC_SEL_ROUTINE_TPL
*&---------------------------------------------------------------------*
program conversion_routine.
* Type pools used by conversion program
type-pools: rsarc, rsarr, rssm.
tables: rssdlrange.
* Global code used by conversion rules
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
10
How to Write a Routine in DTP Selection
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
* DATA:
...
*$*$ end of global - insert your declaration only before this line
*-*
* ------------------------------------------------------------------*
Fieldname
=
*
data type
=
*
length
= 000000
* ------------------------------------------------------------------form compute_
tables l_t_range structure rssdlrange
using i_r_request type ref to IF_RSBK_REQUEST_ADMINTAB_VIEW
i_fieldnm type RSFIELDNM
changing p_subrc like sy-subrc.
*
Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line
*-*
data: l_idx like sy-tabix.
read table l_t_range with key
fieldname = ' '.
l_idx = sy-tabix.
*....
*******Surendra Kumar Reddy Koduru******Begin******
data:
zdate LIKE sy-datum, " Data Declaration.
zbuper LIKE t009b-poper,
zbdatj LIKE t009b-bdatj,
zperiod(7) TYPE c.
zdate = sy-datum - 1.
*
*
*
*
*
*
*
*
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date
= zdate
I_MONMIT
= 00
i_periv
= 'K4'
IMPORTING
e_buper
= zbuper
e_gjahr
= zbdatj.
EXCEPTIONS
INPUT_FALSE
= 1
T009_NOTFOUND
= 2
T009B_NOTFOUND
= 3
OTHERS
= 4
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CONCATENATE zbdatj zbuper INTO zperiod.
l_t_range-fieldname = 'FISCPER'.
l_t_range-option = 'EQ'.
l_t_range-sign = 'I'.
l_t_range-low = zperiod.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
11
How to Write a Routine in DTP Selection
*******Surendra Kumar Reddy Koduru******End******
append l_t_range.
****You just comment the below IF condition.
* if l_idx <> 0.
*
modify l_t_range index l_idx.
* else.
*
append l_t_range.
* endif.
p_subrc = 0.
*$*$ end of routine - insert your code only before this line
endform.
"compute_
*-*
Once you write code and check it and save and come back then activate DTP
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
12
How to Write a Routine in DTP Selection
Activate DTP:
Once you close the above screen then you need to activate the DTP and then Version Icon shows in Green.
See the below screen after activation of DTP.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
13
How to Write a Routine in DTP Selection
All Tabs of DTP:
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
14
How to Write a Routine in DTP Selection
Data loading using above DTP:
Once you click on Execute Button, you can see the below dialog box, just click on Yes and see details in
Monitor.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
15
How to Write a Routine in DTP Selection
Monitor Screen:
See the below Monitor screen, you can find our selection also under Selection in right side and number of
records transferred.
See above screen, you can find only 6 records which are fulfilling our condition in DTP routine. Actuall in
PSA you can find more number of records.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
16
How to Write a Routine in DTP Selection
Click on Header Tab and see the details.
In above screen you can see the selection also i.e. FISCPER = 2011006, because this is calculated in DTP
routine based on System date (i.e. 27-06-2011).
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
17
How to Write a Routine in DTP Selection
PSA Data:
Right click on DataSource and then Manage and open PSA and select the request and click on Icon like
below to see the data in PSA.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
18
How to Write a Routine in DTP Selection
See in above screen, you can find 23986 records are loaded into PSA, and out of these we got only 6
records into our InfoCube for 006.2011 Period.
InfoCube Data:
In below screen you can see the Data in InfoCube, there are only 6 records.
So in this way we can use the DTP routines to restrict the unwanted data.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
19
How to Write a Routine in DTP Selection
Related Content
For all Articles and Blogs by Surendra Kumar Reddy, Please visit this URL
Using Customer Exit Variables in BW Reports Part - 1
Using Customer Exit Variables in BW Reports Part - 2
Using Customer Exit Variables in BW Reports Part - 3
Using Customer Exit Variables in BW Reports Part - 4
Using Customer Exit Variables in BW Reports Part - 5
Using Customer Exit Variables in BW Reports Part - 6
Using Customer Exit Variables in BW Reports: Part - 8
Using Customer Exit Variables in BW Reports: Part - 9
Using Customer Exit Variables in BW Reports: Part - 10
Using Customer Exit Variables in BW Reports: Part - 11
Using Customer Exit Variables in BW Reports: Part - 12
Using Customer Exit Variables in BW Reports: Part - 13
Using Customer Exit Variables in BW Reports: Part - 14
Using Customer Exit Variables in BW Reports: Part - 15
Using Customer Exit Variables in BW Reports: Part - 16
Using Customer Exit Variables in BW Reports: Part - 17
Using Customer Exit Variables in BW Reports: Part - 18
Inventory Management (0IC_C03) Part - 1
Inventory Management (0IC_C03) Part - 2
Inventory Management (0IC_C03) Part - 3
To Check the Files/Reports in Application Server and trigger mail alerts
Calculating the Ageing of the Materials
Using Selective Deletion in Process Chains
Triggering the Process Chains at Particular Date using Events
Analysis Process Designer (APD) Part - 1
Analysis Process Designer (APD) Part - 2
Analysis Process Designer (APD): Part - 3
Open Hub Destination: Part 1
Open Hub Destination: Part 2
InfoSpoke Part 1
InfoSpoke Part 2
Using Rule Group in SAP-BI Part - 1
For more information, visit the EDW homepage
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
20
How to Write a Routine in DTP Selection
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.
SAP COMMUNITY NETWORK
© 2011 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
21