SAP BI Global Report Variable user exit modularization

Similar documents
Implementing Customer Exit Reporting Variables as Methods

BI Reporting user Exit Implementation Through Dynamic Class with Interface

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

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

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

Reporting Duplicate Entries

Role and Scope of ABAP in SAP BI

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

Triggering the Process Chains at Particular Date using Events

SAP BW Copy Existing DTP for Data Targets

Data Extraction & DS Enhancement in SAP BI Step by Step

SMT (Service Mapping Tool)

Standalone BW System Refresh

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

Procedure to Trigger Events in Remote System Using an ABAP Program

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

Easy Lookup in Process Integration 7.1

Table Row Popup in Web Dynpro Component

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

POWL: Infoset Generation with Web Dynpro ABAP

SAP BI Analysis Authorization (Customer Exit Variables)

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

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

Steps to Activate ALE Delta for Custom Master Datasource Created on ZTable

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

SDN Community Contribution

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

Custom BADI Using Function Module UJQ_RUN_AXIS_QUERY

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

Material Master Archiving in Simple Method

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

Linking Documents with Web Templates

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

Limitation in BAPI Scheduling Agreement (SA) Create or Change

Changing the Source System Assignments in SAP BW Objects without Affecting the Data Modeling

Custom Process types Remote Trigger and End Time

Process Chain Log Deletion

Step by Step Procedure for DSO Creation

Loading the Data for Time Dependent Hierarchy in SAP BI

Download SAP Query Output to Local/ Network Folders in Background

Reading Enhanced DataSource fields for the Remote Cube

MDM Syndicator: Custom Items Tab

Using Radio Buttons in Web Template

Recreating BIA Indexes to Address the Growth of Fact Index Table

DB Connect with Delta Mechanism

SDN Community Contribution

Data Source Replication and Activation of Transfer Structures

Dynamically Enable / Disable Fields in Table Maintenance Generator

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

Information Broadcasting Part 3 Scheduling the First Report

Material Listing and Exclusion

Financial Statement Version into PDF Reader

Creating Custom SU01 Transaction Code with Display and Password Reset Buttons

How to Write Inverse Routine with Expert Routine

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

Step by Step Guide to Enhance a Data Source

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

Maintaining Roles and Authorizations in BI7.0 - RSECADMIN

Developing Crystal Reports on SAP BW

Database Statistics During ODS Activation

Routines in SAP BI 7.0 Transformations

Using Rule Group in SAP-BI. Part - 1

Validity Table in SAP BW/BI

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

Working with Tabstrip in Webdynpro for ABAP

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

Exposing the XI monitoring functionality as a Web Service

Customized Transaction to Trigger Process Chain from Failed Step

About ITAB Duplicate_Key (SAP lrsaods) Runtime Error

Open Hub Destination - Make use of Navigational Attributes

Web Dynpro: Coloring Table Conditionally

SDN Community Contribution

Step by Step Guide to Creating a Process Type to Close an Open Request in a Cube in BI 7.0

Creating, Configuring and Testing a Web Service Based on a Function Module

How to Work with F4 Input Help Effectively in BEX

Planning Functions and Characteristic Relationship in Integrated Planning

How to Create and Schedule Publications from Crystal Reports

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

How to Integrate Web Dynpro ABAP in Portal and Capture Portal Logon User Name

How to Create and Execute Dynamic Operating System Scripts With XI

Exception Handling in Web Services exposed from an R/3 System

List of Values in BusinessObjects Web Intelligence Prompts

A Simple Web Dynpro Application to Locate Employee s Location into Google Map

Internationalization in WebDynpro ABAP Applications

Step by Step Method for File Archival in BW

Performance Tuning in SAP BI 7.0

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

Step-By-Step guide to Virtual InfoCube Implementation

Data Inconsistency in the Cube and Aggregate

Server Connectivity and Data Load from Non SAP System to BW

Material Master Extension for New Plant

Customizing Characteristic Relationships in BW-BPS with Function Modules

Creation of Key Figures with Higher Decimal Place Precision

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

Graphical Mapping Technique in SAP NetWeaver Process Integration

ABAP HR: Standard Info Type Enhancement

Displaying SAP Transaction as Internet Application in Portal

Generate Export Data Source

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

Web Dynpro ABAP: Dynamic Table

Transcription:

SAP BI Global Report Variable user exit modularization Applies to: SAP BI 7 Summary When designing a report, some requirements have certain complexity that lead to the creation of custom exit code global report variables. For example, a user enters a month and the report requires an interval created for the 'quarter to date' of the entered month: the user entered May 2008, the report requires a variable that reflects the interval Apr-May 2008 (Q2-2008). This type of variable requires a 'custom exit' code. SAP has traditionally provided for custom code enhancements in the form of user exits and recently in the form of BADI (Business Add-In). Basically a user exit is include in a function module that can be modified by the customer. The user exit FM for Global Report Variables EXIT_SAPLRRS0_001 tends to grow in a single piece of code and its maintenance become cumbersome. In an SAP BI Project, along with new reporting needs, new requirements for Global Report Variables of the type customer exit are generated. It is typical then for the respective user exit code to grow to a few thousand lines, resulting in code that is hard to manage, debug, and use in a multi-team environment. Code Modularization is a helpful tool for performance, documentation and multi-tasking Author: Alfonzo Vega Company: Vega Business Consulting Created on: 05 March 2009 Author Bio Alfonzo Vega is an independent Senior SAP BI Consultant. Alfonzo started working in the SAP technologies as a ECC MM Consultant in 1995, joined SAP Andina y del Caribe in Venezuela in 1996 and has worked on multiple SAP BI implementations since 1999. Alfonzo currently works in the US Midwest as an independent consultant 2009 SAP AG 1

Table of Contents Modularization...3 Dynamic Method Call...3 Useful Function Modules...7 Where used list...7 Variable test...7 Code for standard 'SAP' exit variables...7 Refresher on I_STEP...7 Related Content...9 Disclaimer and Liability Notice...10 2009 SAP AG 2

Modularization Modularization has advantages: The code is easier to read. Instead of scrolling through pages and pages of code, just go to a specific method in a class. If the code modules are independent, the local use of variables reduces the interference between developers. Also, developers can be working on a specific module without interfering with each other. The standard approach based on multiple case statements and if statements based on the variable name and the specific step makes it hard to know if you are inserting the code in the right place. The current approach goes through all the code to find the variable. A new approach could call the specific module directly. Figure 1 Code approach: go through IF..THEN..ELSEIF or CASE versus a dynamic method call Dynamic Method Call The basis for this modularization approach is a dynamic method call. Based on the variable, it calls a method with a name made of a standard prefix and the variable name, for example, ZBW_<vnam>. In a dynamic call, the ABAP/4 code will fail unless there is a 'catch' command. The idea is to 'migrate': start moving variables to the dynamic method call step by step. A variable E_VAR_PROCESSED is set in the method to 'tell' that the calculation was made and no need to continue through the 'old' code. In case there is no method for the specific variable, it will continue through the old code. Define a custom class in transaction SE24 and create one method per custom-exit global report variable. The methods will have exactly the same interface as the user exit function module plus a exporting parameter 'E_VAR_PROCESSED' as mentioned above. In this example, the class name is ZBW_XRSR. See images for the class definition and a sample method below. Bear in mind that in the step 3 no variable name gets passed to the user exit, so you need to write more code for this specific step, if needed. 2009 SAP AG 3

Figure 2 Class Definition - ZBW_XRSR Figure 3 Method example - interface In the sample method code below, based on a fiscal period entered by the user, the code selects the same period but on the prior year. Code for the dynamic method call is attached after the method code below. 2009 SAP AG 4

METHOD zbw_zp_currfp_prior_year. *---------------------------------------------------------------------* * 2008-08-25 D22K915560 Rel5 * * Based on fiscal period ZP_CURRFP derive the same fiscal * * period for the previous year * *---------------------------------------------------------------------* CONSTANTS: c_eq(2) TYPE c VALUE 'EQ', c_fp(9) TYPE c VALUE 'ZP_CURRFP', c_i(1) TYPE c VALUE 'I', c_x(1) TYPE c VALUE 'X', c_0 TYPE i VALUE 0, c_2 TYPE i VALUE 2. DATA: lv_fiscper TYPE poper, lv_fiscyr TYPE bdatj, s_var_range TYPE rrrangeexit, s_range TYPE rsr_s_rangesid. IF i_step = c_2. READ TABLE i_t_var_range INTO s_var_range WITH KEY vnam = c_fp. IF sy-subrc = c_0. CLEAR s_range. lv_fiscyr = s_var_range-low(4). lv_fiscyr = lv_fiscyr - 1. lv_fiscper = s_var_range-low+4(3). CONCATENATE lv_fiscyr lv_fiscper INTO s_range-low. s_range-sign = c_i. s_range-opt = c_eq. APPEND s_range TO e_t_range. ENDIF. ENDIF. e_var_processed = c_x. ENDMETHOD. Figure 4 Sample code for same period last year 2009 SAP AG 5

*A. Vega *Change to 'modularize the user exit' - Start DATA: lv_class TYPE string, lv_exc_ref TYPE REF TO cx_sy_dyn_call_error, lv_exc_text TYPE string, lv_meth TYPE string, lv_var_proc(1) TYPE c. CLEAR lv_var_proc. lv_class = 'ZBW_XRSR'. * Format called method name: prefix variable name with "ZBW_". CONCATENATE 'ZBW_' i_vnam INTO lv_meth. * Execute the assigned method for the DataSource. TRY. CALL METHOD (lv_class)=>(lv_meth) EXPORTING i_vnam = i_vnam i_vartyp = i_vartyp i_iobjnm = i_iobjnm i_s_cob_pro = i_s_cob_pro i_s_rkb1d = i_s_rkb1d i_periv = i_periv i_t_var_range = i_t_var_range i_step = i_step IMPORTING e_t_range = e_t_range e_meeht = e_meeht e_mefac = e_mefac e_waers = e_waers e_whfac = e_whfac e_var_processed = lv_var_proc changing c_s_customer = c_s_customer. *** Handle Exceptions. CATCH cx_sy_dyn_call_error INTO lv_exc_ref. lv_exc_text = lv_exc_ref->get_text( ). * message exc_text type 'I'. ENDTRY. IF NOT lv_var_proc IS INITIAL. EXIT. ENDIF. *Change to 'modularize the user exit' - End Figure 5 Dynamic method call code 2009 SAP AG 6

Useful Function Modules Where used list Function module RSZ_X_WHERE_USED_LIST_GET finds where a report element is used. To get where a global report variable is used, enter the value from table RSZGLOBV, field VARUNIID as the import parameter I_ELTUID in the function module. (field VNAM contains the 'readable' variable technical name). The table E_T_WHERE_USED_LIST will contain the list of queries that use the variable. Variable test Function Module RRS_VAR_VALUES_EXIT_FILL executes a global report variable user exit. As some of the variables execute in a specific step (I_STEP) it may need some break points and data manipulation to have the variable executed. Code for standard 'SAP' exit variables Function Module RREX_VARIABLE_EXIT has the code for SAP exit global report variables. If the variable is not 'solved' in this part of the code, it may execute at the end of this FM code as a RSVAREXIT_<varname>. For example RSVAREXIT_0I_CUFQU executes the code for variable 0I_CUFQU 'Current Quarter of Fiscal Year (SAP Exit)', resulting in a fiscal period interval for the current fiscal quarter. Refresher on I_STEP The global report variable user exit EXIT_SAPLRRS0_001 has I_STEP as an input parameter. You normally develop the custom code for a specific step, as explained below. It is useful to know the function modules involved when debugging, to set an appropriate breakpoint. I_STEP = 0. This step is not called during report execution but when a report variable is used in other instances such as InfoPackages and authorizations. I_STEP = 1 - Called prior to processing of variable pop-up and for each customer exit variables. Can be used to fill variable with default values. Function module EXIT_SAPLRRS0_001 is called with I_STEP = 1 in function module RRS_VAR_VALUES_EXIT_BEFORE Figure 6 Prior to User entry - I_STEP = 1 2009 SAP AG 7

I_STEP = 2 - Called after the processing of the variable pop-up. Only for those variables that are not marked as ready for input or are set to mandatory variable entry.. Function module EXIT_SAPLRRS0_001 is called with I_STEP = 2 in function module RRS_VAR_VALUES_EXIT_AFTER Figure 7 After User entry - I_STEP = 2 I_STEP = 3 - Called after all variable processing and gets called only once and not per variable. Here you can validate the user entries. Function module EXIT_SAPLRRS0_001 is called with I_STEP = 3 in function module RRS_VAR_VALUES_EXIT_CHECK Figure 8 After all variable processing - I_STEP = 3 2009 SAP AG 8

Related Content Customer Exits (SAP Library - BI Suite: Business Explorer) Dependencies for Variables of Type Customer Exit provides the explanation for the input variable I_STEP and a code sample SAP Note 792779 Report ANALYZE_RSZ_TABLES helps in fixing underlying table inconsistencies and it is a very good introduction to the main tables for reporting elements. 2009 SAP AG 9

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 10