Routines in SAP BI 7.0 Transformations

Similar documents
Role and Scope of ABAP in SAP BI

Integration of Web Dynpro for ABAP Application in Microsoft Share Point Portal

Extracting Missing Fields of Data Source Which Are Present In Their Extract Structure

Easy Lookup in Process Integration 7.1

How to use Boolean Operations in the Formula as Subsidiary for IF Condition

Reporting Duplicate Entries

Recreating BIA Indexes to Address the Growth of Fact Index Table

Triggering the Process Chains at Particular Date using Events

Step by Step Procedure for DSO Creation

Data Extraction & DS Enhancement in SAP BI Step by Step

Maintaining Roles and Authorizations in BI7.0 - RSECADMIN

Using Radio Buttons in Web Template

Graphical Mapping Technique in SAP NetWeaver Process Integration

Creation of Sets in SAP-ABAP, How to Read them INI SAP-ABAP Reports

POWL: Infoset Generation with Web Dynpro ABAP

Implementing Customer Exit Reporting Variables as Methods

DB Connect with Delta Mechanism

SAP BI BO Unit/Currency Logic for Unknown Units Case Study

Step By Step: the Process of Selective Deletion from a DSO

This article explains the steps to create a Move-in letter using Print Workbench and SAPScripts.

Reading Enhanced DataSource fields for the Remote Cube

How to Write Inverse Routine with Expert Routine

Open Text DocuLink Configuration - To Access Documents which are Archived using SAP

Displaying SAP Transaction as Internet Application in Portal

Material Listing and Exclusion

Step by Step Guide on How to Use Cell Definition in BEx Query

Dynamically Enable / Disable Fields in Table Maintenance Generator

SDN Community Contribution

How to Create Top of List and End of List of the ALV Output in Web Dynpro for ABAP

Step by Step Guide to Enhance a Data Source

MDM Syndicator: Custom Items Tab

Applies To:...1. Summary...1. Table of Contents...1. Procedure..2. Code... Error! Bookmark not defined.0

Custom Process types Remote Trigger and End Time

Replacement Path: Explained with an Illustrated Example

Using Query Extract to Export Data from Business warehouse, With Pros and Cons Analyzed

ABAP Code - Recipients (Specific Format) SAP BW Process Chain

SAP BW Copy Existing DTP for Data Targets

About ITAB Duplicate_Key (SAP lrsaods) Runtime Error

Step by Step Approach for End Routine with Look Up

Customized Transaction to Trigger Process Chain from Failed Step

Linking Documents with Web Templates

SMT (Service Mapping Tool)

Material Master Extension for New Plant

Database Statistics During ODS Activation

Implementation and Usage of Transformation End Routine in SAP BI 7.0

Standalone BW System Refresh

Hierarchy in Business Objects with Expanded Hierarchy Logic

Step by Step Guide How to Use BI Queries in Visual Composer

How to Display Result Row in One Line While Reporting On Multiproviderer

Process Chain Log Deletion

Using Rule Group in SAP-BI. Part - 1

How to Configure User Status in mysap SRM

ABAP HR: Standard Info Type Enhancement

Using Nested Exception Aggregation in BEx Reports- Scenario

Xcelsius Tricks Part 5 Create a Loading Bar in SAP Crystal Dashboard and Presentation Design (Xcelsius 2008)

SDN Community Contribution

Procedure to Trigger Events in Remote System Using an ABAP Program

Setting up Connection between BW and R/3 for Data Load

Validity Table in SAP BW/BI

How to Default Variant Created for Report Developed In Report Painter/Writer

Step by Step Guide for PI Server Start and Stop Procedure

Customizing Characteristic Relationships in BW-BPS with Function Modules

Freely Programmed Help- Web Dynpro

Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

Transfer Material Attributes (Material Type) from R/3 to SAP GRC Global Trade Services (GTS)

How to Create and Schedule Publications from Crystal Reports

Custom BADI Using Function Module UJQ_RUN_AXIS_QUERY

Table Row Popup in Web Dynpro Component

Solution to the Challenges in Pivoting

Creating Custom SU01 Transaction Code with Display and Password Reset Buttons

Web Dynpro: Coloring Table Conditionally

Performance Optimization of Long Running Queries Using OLAP Cache

Download SAP Query Output to Local/ Network Folders in Background

Web Dynpro ABAP: Dynamic Table

Material Master Archiving in Simple Method

How to Create View on Different Tables and Load Data through Generic Datasource based on that View

Add /Remove Links on ESS Home Page in Business Package 1.5

Step by Step Method for File Archival in BW

Adding Custom Fields to Contract Account Screen

MDM Import Manager - Taxonomy Data (Attribute Text Values) Part 3

Internationalization in WebDynpro ABAP Applications

List of Values in BusinessObjects Web Intelligence Prompts

Using ABAP-OO in BI- Transformations through Custom Class

Using Customer Exit Variables in BW/BI Reports Part - 1

Easy Application Integration: How to use the Records Management Call Handler Framework

Open Hub Destination - Make use of Navigational Attributes

Cut Over Activities Specific for LIS* Data Sources

Purpose of Goods Receipt Message indicator in Purchase Orders

Data Flow During Different Update Mode in LO Cockpit

Data Mining: Scoring (Linear Regression)

Restricting F4 (Input Help) Values While Running a SAP BW Query

ecatt Part 6 System Data Container

Limitation in BAPI Scheduling Agreement (SA) Create or Change

How to Reference External JAR Files in Web Dynpro DC in SAP NW Portal 7.3

Totals in Adobe forms

Using Customer Exit Variables in BW/BI Reports: Part - 4

Using Customer Exit Variables in BW/BI Reports: Part - 14

Information Broadcasting Part 3 Scheduling the First Report

Comparison Terms and SPL Check Logic

Common Queries/Errors while working with Adobe Print PDF Forms

Transcription:

Routines in SAP BI 7.0 Transformations Applies to: SAP BI 7.0. For more information, visit the Business Intelligence homepage. Summary This paper gives an overview about the different routines available in SAP BI 7.0 Transformation. In particular the paper highlights when and where an appropriate routine has to be used and shows how to implement.the paper explains the concepts based on a simple scenario for all the routines. The paper also gives the sample code and results at the end of each routine. Author: Vamsi Kiran Talluri Company: Tata Consultancy Services Ltd. Created on: 22 July 2009 Author Bio The author works for Tata Consultancy Services Ltd. His expertise includes SAP BI and ABAP. 2009 SAP AG 1

Table of Contents Introduction... 3 Scenario... 3 Characteristic or Field Routine... 4 Definition... 4 Approach to Scenario... 4 How to Implement... 4 Sample Code... 7 Output... 7 Start Routine... 8 Definition... 8 Approach to Scenario... 8 How to Implement... 8 Sample Code... 10 Output... 11 End Routine... 12 Definition... 12 Approach to Scenario... 12 How to Implement... 12 Sample Code... 13 Output... 14 Expert Routine... 15 Definition... 15 Approach to Scenario... 15 How to Implement... 15 Sample Code... 18 Output... 18 Related Content... 19 Disclaimer and Liability Notice... 20 2009 SAP AG 2

Introduction Routines are used to define complex transformation rules. In most of the cases data won t be coming directly in desired form before sending to the target. In some cases output needs to be derived on some incoming data. In such cases we need to go for writing of routines at the transformation level. There are four types of Routines available Characteristic or Field Routine Start Routine End Routine Expert Routine The routine which we need to go for depends on when it needs to be executed. Suppose if some logic needs to be implemented before transformation then the start routine needs to be implemented. This Paper presents in detail about each of the above Routine. Scenario The Scenario is for each incoming record comes up with unique key job number with its Start and End Date. At the output there is one key figure Total no of days which is the difference of End and Start Dates and based on the key figure value Total no of days. This same scenario is taken to explain each routine. 2009 SAP AG 3

Characteristic or Field Routine Definition It operates on a single record for a single characteristic or key figure. The value gets modified in the routine based on one or more source fields before it is transferred to the target Approach to Scenario The Key figure total no of days needs to be populated using start and end dates. So to calculate total no of days we are going to write a field routine. But for that start and end date values need to be mapped to the key figure. How to Implement In the above screen shot all the source fields are mapped one to one to the target. 2009 SAP AG 4

We have mapped start and end date to the key figure and now double click on the equal to symbol Once clicked u can see the source fields start and end dates because we have mapped them. Now choose Rule Type as Routine. Once clicked routine it will take to the editor 2009 SAP AG 5

We need to write the logic there. Once written it will take to the result which is nothing but total no of days. 2009 SAP AG 6

The logic is written it is end date minus start date. Syntax is checked it showed no errors. Save the Routine and activate the transformation. Sample Code Output RESULT = SOURCE_FIELDS-/BIC/RT_ENDT - SOURCE_FIELDS-/BIC/RT_SRTDT. 2009 SAP AG 7

Start Routine Definition The start routine is run at the start of the transformation. The start routine has a table in the format of the source structure as input and output parameters. It is used to perform preliminary calculations and store these in a global data structure or in a table. This structure or table can be accessed from other routines. You can modify or delete data in the source_package. Approach to Scenario For field routine it will act on each record but in start routine it will have all the data in source_package. In Start routine we will have the structure of the source fields. So in this scenario the key figure is not available in source. So in Start routine we calculate the total no of days for each record with its unique key job number and store them in an internal table. The internal table is global and it can be accessed every where. So we have to write a field routine for key figure total no of days mapped with job number. Using this job number we will read the value of key figure total no of days from internal table and update the result i.e. total no of days key figure. How to Implement Click on start routine and it will take to the editor. In the start routine there will be table source_package which contains all the data and has the structure of source. Here we will read the job number from source_package and update it into internal table and total no of days key figure value into internal table using start and end dates. 2009 SAP AG 8

Once this is done the value of key figure is in internal table and from there we need to get into target. So for that a field routine needs to be written to read from value from internal table. The key to internal table to get unique value is job number so job number is mapped to key figure. Here Job number is mapped to the key figure. And a field routine is written to read the total no of days using this job number. 2009 SAP AG 9

Sample Code Types: begin of itabtype, job_numb type /bic/oirt_jobno, stg_numb type /bic/oirt_stgno, profile type /bic/oirt_prfl, tot_days type /bic/oirt_wkydy1, end of itabtype. data : itab type standard table of itabtype with key job_numb, wa_itab like line of itab. Keep this part in global section because we have to read the internal table once it is populated and hence it should be visible every where. data : wa_source_package type _ty_s_sc_1. loop at source_package into wa_ source_package. move wa_ source_package -/BIC/RT_JOBNO to wa_itab-job_numb. move wa_ source_package -/BIC/RT_stgNO to wa_itab-stg_numb. wa_itab-tot_days = wa_ source_package -/BIC/RT_ENDT - wa_ source_package - /BIC/RT_SRTDT. if wa_itab-tot_days le 10. wa_itab-profile = '(0-10)'. elseif wa_itab-tot_days gt 10 and wa_itab-tot_days le 20. wa_itab-profile = '(10-20)'. else. wa_itab-profile = '(20-NN)'. endif. append wa_itab to itab. endloop. By this code we has populated the internal table and we has to get the values for the age profile and total no of days for this by using the key for the table ie job number 2009 SAP AG 10

This is the code in the field routine which gets the value from the internal table and populates when the job number in the internal table is same as the coming job number read table itab into wa_itab with key job_numb = SOURCE_FIELDS-/BIC/RT_JOBNO. if sy-subrc = 0. Result = wa_itab-profile. endif. Output 2009 SAP AG 11

End Routine Definition An end routine is a routine with a table in the target structure format as input and output parameters. You can use an end routine to postprocess data after transformation on a package-by-package basis. Data is stored in result_package. Approach to Scenario End Routine is processed after start routine, mappings, field routines and finally before the values is transferred to the output. End routine has the structure of the target and result_package contains the entire data which finally is the output. For our scenario we have one to one mapping for all the fields except total no of days so in result_package it will not have the value for each record. So in End Routine we will calculate the key figure value for each record and modify the result_package and there by the output will also contain the key figure. How to Implement In transformation all are mapped one to one. Click End Routine at the top it will take to the editor. There we have to modify the result_package with the key figure value updated. 2009 SAP AG 12

In the end routine we will loop over the result_package and using the start and end dates of each record the key figure value is calculated and updated again into the result_package. Check the routine and save the routine and activate the transformation. Sample Code Data: wa_result_package type _ty_s_tg_1. Loop at RESULT_PACKAGE into wa_result_package. wa_result_package-/bic/rt_wkydy1 = wa_result_package-/bic/rt_endt - wa_result_package-/bic/rt_srtdt. if wa_result_package-/bic/rt_wkydy1 le 10. wa_result_package-/bic/rt_prfl = '(0-10)'. Else if wa_result_package-/bic/rt_wkydy1 gt 10 and wa_result_package-/bic/rt_wkydy1 le 20. wa_result_package-/bic/rt_prfl = '(10-20)'. else. wa_result_package-/bic/rt_prfl = '(20-NN)'. endif. modify RESULT_PACKAGE from wa_result_package. End loop. 2009 SAP AG 13

Output 2009 SAP AG 14

Expert Routine Definition An Expert routine is a routine with contains both the source and target structure. we can use Expert routine if there are not sufficient functions to perform transformation. Approach to Scenario For Expert Routine every things needs to be written using coding. In simple an expert routine performs all the actions of Start Routine, Mappings, Field and End Routines. In Expert Routine we will read from source_package which contains all the data and update into result_package which should be the output and when doing we will calculate the key figure total no of days. How to Implement Click Transformation and go to edit and click the expert routine. If clicked it asks to confirm the transformation mappings will be deleted and will be taken to coding part editor. 2009 SAP AG 15

Click yes to continue Here we can see that both the source fields and result fields are available because the expert routine has to take care of every thing. It should cover the transformation mappings, start and end routine codes. The code given below is implemented in the editor of expert routine and shown in below screenshot. 2009 SAP AG 16

After check the consistency and save and activate as we do for start and end routine. Then the transformation will have only one mapping from source to target saying expert routine.see that start and end routine are also disabled. And activate the transformation. 2009 SAP AG 17

Sample Code Data : wa_source_package type _ty_s_sc_1. * creating work areas* data : wa_result_package type _ty_s_tg_1. loop at SOURCE_PACKAGE into wa_source_package. *transformation mappings mappings in code * move wa_source_package -/BIC/RT_JOBNO to wa_result_package-/bic/rt_jobno. move wa_source_package -/BIC/RT_STGNO to wa_result_package-/bic/rt_stgno. move wa_source_package -/BIC/RT_SRTDT to wa_result_package-c/rt_srtdt. move wa_source_package -/BIC/RT_ENDT to wa_result_package-/bic/rt_endt. wa_result_package-/bic/rt_wkydy1 = wa_source_package -/BIC/RT_ENDT - wa_source_package -/BIC/RT_SRTDT. if wa_result_package-/bic/rt_wkydy1 le 10. wa_result_package-/bic/rt_prfl = '(0-10)'. elseif wa_result_package-/bic/rt_wkydy1 gt 10 and wa_result_package-/bic/rt_wkydy1 le 20. wa_result_package-/bic/rt_prfl = '(10-20)'. else. wa_result_package-/bic/rt_prfl = '(20-NN)'. endif. append wa_result_package to RESULT_PACKAGE. endloop. 1) In Expert Routine we will fetch the values from source_package into work area of source_package. 2) Move this work area to the output work area i.e. to result_package (This step is nothing but transformation mapping in code) 3) Append the work area to the result_package (which actually is the output). 4) Continue Steps 1-3 until all the records are transferred from source to target. ( taken care by loop statement) Output 2009 SAP AG 18

Related Content For more information, visit the Business Intelligence homepage. 2009 SAP AG 19

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. 2009 SAP AG 20