You are on page 1of 37

User Exits in SAP BW

Know How Network Call 16.12.1999

SAP AG BW Development
SAP AG, Dec. 1999 (Joachim Mette)

Slide 1

Definition User-Exit
For many SAP customers, the options available in customizing
are not sufficient, since they wish to change and adapt SAP
transactions to suit their own requirements. The problem here is
that, after every maintenance level or release upgrade, the
changes have to be adjusted to coincide with SAP corrections
and developments.
To reduce this effort in a SAP System (or to avoid it totally),
customers can make their own enhancements in a layer separate
from SAP.
Rather than make changes to the original code, they make them
in their own special area. This is created by SAP and delivered
empty or with standard values during system installation.
Customers can implement additional functionality in this area.

The applications programmer makes the necessary transaction


data explicitly available via an interface.
SAP AG, Dec. 1999 (Joachim Mette)

Slide 2

User-Exits in BW
Browser
Analyzer
(hosted by MS Excel)

3rd party OLAP


client

5.

Business Explorer
ODBO

Administrator
Workbench
Administration
Scheduling
Monitor

BW Server
Meta Data
Repository

3.

BAPI

OLAP Processor

Meta Data Manager

4-

Data Manager

Staging Engine
2.

InfoCubes
Operational
Data Store

BAPI

Non R/3 Production


Data Extractor

Non R/3 OLTP Applications

SAP AG, Dec. 1999 (Joachim Mette)

Slide 3

Production Data
Extractor
1.

OLTP
Reporting

R/3 OLTP Applications

1. Extending the Business Content

SAP AG, Dec. 1999 (Joachim Mette)

Slide 4

Extending the Business Content

SAP AG, Dec. 1999 (Joachim Mette)

Slide 5

User-Exit for Variables


Enhancement: RSAP0001
The components for the enhancement are the function modules:
EXIT_SAPLRSAP_001 (Transaction Data)
This function module allows you to fill user-defined fields that you have
attached to existing InfoSources as append structures.

EXIT_SAPLRSAP_002 (Master Data Attributes)


This function module allows you to fill user-defined fields that you have
attached to master data structures of the BW as append structures

EXIT_SAPLRSAP_003 (Texts)
This function module allows you to change the contents of a generated
text transfer table for a text request. This can be useful if only one short
text exists for an InfoObject but you would like to attach the mediumlength text from the user-defined table.

EXIT_SAPLRSAP_004 (Hierarchies)

This function module allows you to change the contents of a transfer table
created for a hierarchy request.
SAP AG, Dec. 1999 (Joachim Mette)

Slide 6

EXIT_SAPLRSAP_001: Interface - Importing


I_ISOURCE

Name of the InfoSource

I_UPDMODE

Transfer mode, as requested in the Scheduler


of the Business Information Warehouse.

SAP AG, Dec. 1999 (Joachim Mette)

Slide 7

EXIT_SAPLRSAP_001: Interface Exporting/Tables


I_T_SELECT

Table with the selection criteria stored in the


Scheduler of the BW

I_T_FIELDS

List of the transfer structure fields. Only these


fields are actually filled in the data table and
can be sensibly communicated with in the
program.

C_T_DATA

Table with data received from the API in the


format of the source system entered in table
ROIS (field ROIS-STRUCTURE).

SAP AG, Dec. 1999 (Joachim Mette)

Slide 8

EXIT_SAPLRSAP_002: Interface - Importing


I_CHABASNM

Name of the Characteristic

I_UPDMODE

Transfer mode, as requested in the Scheduler


of the Business Information Warehouse.

SAP AG, Dec. 1999 (Joachim Mette)

Slide 9

EXIT_SAPLRSAP_002: Interface Exporting/Tables


I_T_SELECT

Table with the selection criteria stored in the


Scheduler of the BW

I_T_FIELDS

List of the transfer structure fields. Only these


fields are actually filled in the data table and
can be sensibly communicated with in the
program.

C_T_DATA

Table with data received from the API in the


format of the source system entered in table
RODCHABAS (field
RODCHABAS-STRUCTURE).

SAP AG, Dec. 1999 (Joachim Mette)

Slide 10

EXIT_SAPLRSAP_003: Interface - Importing


I_CHABASNM

Name of the Characteristic

I_UPDMODE

Transfer mode, as requested in the Scheduler


of the Business Information Warehouse.

SAP AG, Dec. 1999 (Joachim Mette)

Slide 11

EXIT_SAPLRSAP_003: Interface Exporting/Tables


I_T_SELECT

Table with the selection criteria stored in the


Scheduler of the BW

I_T_LANGU

Table with the languages for which the texts


were requested.

C_T_TEXTS

Table with data received from the API in the


format of the structure RSTEXTTRSF.

SAP AG, Dec. 1999 (Joachim Mette)

Slide 12

EXIT_SAPLRSAP_004: Interface - Importing


I_S_REQUEST

Processing parameters for the data request

I_S_HIEBAS

Information about the Characteristic

I_S_HIEFLAG

Hierarchy control indicator

I_S_HIER_SEL

Structure that contains the requested


hierarchy.

SAP AG, Dec. 1999 (Joachim Mette)

Slide 13

EXIT_SAPLRSAP_004: Interface Exporting/Tables


I_T_LANGU

Table with the language in which the


descriptions are requested.

C_T_HIETEXT

Table with the description of the hierarchy in


the requested language.

C_T_HIENODE

Table with all components of the hierarchy.

C_T_FOLDERT

Table with the descriptions of all nodes that


cannot be posted to in the hierarchy in the
requested language.

C_T_HIEINTV

Table with those hierarchy sheets that


represent value intervals.

SAP AG, Dec. 1999 (Joachim Mette)

Slide 14

2. User Exit after Data loading

SAP AG, Dec. 1999 (Joachim Mette)

Slide 15

Data Load : Procedure


BW
User Exit after Data Load
call
red

InfoPackage
yellow

Scheduler
Scheduler

Monitor
Monitor

Pull

Extraction
Extraction engine
engine

OLTP System
SAP AG, Dec. 1999 (Joachim Mette)

Slide 16

green

User Exit after Data loading


Function module: rssm_start_second_process
Function module is called when exiting the request as well as
when exiting the InfoPackageGroup.

See also Note 137991

SAP AG, Dec. 1999 (Joachim Mette)

Slide 17

Interface - Importing
RNR

Request number of the load process

TSTATUS

Status (Icon_green_light for exited


successfully or Icon_red_light for exited
incorrectly or space for InfoPackgegroup
exited without check)

(@08@ = green, @09@ = yellow, @0A@ = red)

SOURCE

InfoSource for which data was loaded

LOGSYS

Source system for which data was loaded

TYP

Type of data (D=transaction data, M=master


data attributes, T=texts, H=hierarchies)

GNR

Group request number (only filled, if function


module is called at the end of an InfoPackage
Group)

SAP AG, Dec. 1999 (Joachim Mette)

Slide 18

Interface - Importing

WRITE_TO_ODS

= X if something is written to the ODS (not


filled if function module is called by
InfoPackageGroup)

WRITE_TO_CUBE = X if something is written to an InfoCube


(not filled if function module is called by
an Info PackageGroup)

GROUP_CALL

SAP AG, Dec. 1999 (Joachim Mette)

Slide 19

= X if function module is called by an


InfoPackageGroup, otherwise space

Scenario 1: Delete old request

InfoCube

Monitor

Infopackage

Request-No.1 (Full Load) (04.01.1999)


Request-No.1 (Full Load) (04.01.1999)

Request-No.2 (Full Load) (11.01.1999)


Request-No.2 (Full Load) (11.01.1999)

Sourcesystem

SAP AG, Dec. 1999 (Joachim Mette)

Slide 20

User Exit
after Data Load

Delete last Request

Check

Scenario 2: Send Mail after data load

InfoCube

Monitor

Infopackage

Request-No.1 (Initial Load) (04.01.1999)


Request-No.1 (Initial Load) (04.01.1999)

Request-No.2 (Delta Load) (11.01.1999)


Request-No.2 (Delta Load) (11.01.1999)

Sourcesystem

SAP AG, Dec. 1999 (Joachim Mette)

Slide 21

User Exit
after Data Load

Send Mail

Send Mail

3. User Exit for Variables

SAP AG, Dec. 1999 (Joachim Mette)

Slide 22

User-Exit for Variables


Enhancement: RSR00001

The component for the enhancement is the function module


EXIT_SAPLRRS0_001.

SAP AG, Dec. 1999 (Joachim Mette)

Slide 23

How to program a corresponding Include


Create variable with corresponding type for User Exit
Call up transaction CMOD in the Admin. Workbench
Create a Project
Select Enhancement Components
Select Enhancement RSR00001
Double-click on Exit EXIT_SAPLRRS0_001
Double-click on include ZXRSRU01 within the Exit
Add or change coding
Don't forget to activate the Project

Use the variable in a query

SAP AG, Dec. 1999 (Joachim Mette)

Slide 24

Interface - Importing
I_VNAM

Name of the Variable; without &-signs

I_VARTYP

1: Characteristic Value
2: Hierarchy node(s)
3: Text
4: Formula
5: Hierarchy

I_IOBJNM

Name of the InfoObject

I_S_COB_PRO

Information about InfoObject (Dataelement,


CheckTable, Length, Number of Decimals, ...)

I_S_RKB1D

Information about Reporting-Object;


here Query (Queryname, InfoCube, ...)

I_PERIV

Fiscal year variant

I_T_VAR_RANGE

Table with all Variables and their values

I_STEP

1: Before Variable Pop up


2: After Variable Pop up

1.2B

1.2B

1.2B

SAP AG, Dec. 1999 (Joachim Mette)

Slide 25

Interface Exporting
E_T_RANGE

Table to return the values


fields: low, high, sign, opt

E_MEEHT

Unit of measure

E_MEFAC

Number of Decimals for Unit

E_WAERS

Currency Code

E_WHFAC

Number of Decimals for Currency Value

SAP AG, Dec. 1999 (Joachim Mette)

Slide 26

Call-Sequence

First Call of the User-exit

Pop up to enter values for the variable


(if "Ready for Input" = 'X')

Second Call of the User-exit


if Variable of type "Mandatory variable entry" is not filled

if Text-variable is not filled

SAP AG, Dec. 1999 (Joachim Mette)

Slide 27

4. Virtual Characteristics and


Virtual Key figures

SAP AG, Dec. 1999 (Joachim Mette)

Slide 28

User-Exit for Virtual characteristics and key figures


Enhancement: RSR00002

The components for the enhancement are the function


modules EXIT_SAPMRSRU_001 and EXIT_SAPMRSRU_999.

SAP AG, Dec. 1999 (Joachim Mette)

Slide 29

What is a Virtual Characteristic / Key figure


A virtual characteristic / key figure is an object of the InfoCube.
The values are derived at query run time.
Examples:
The SalesRep is derived from Product and Customer. This
assignment changes frequently. Therefore the value for the
characteristic SalesRep can not be stored in the Cube.
You want to calculate with key figure-type attributes of an
InfoObject. E.g. Price is an attribute of Product. Sold-quantity is
an object of the InfoCube. You want to see the revenue (Soldquantity * Price) in your query.

You have an "Open-order-InfoCube". One InfoObject is the


Orderdate. You need a list with the number of days btw. the
orderdate and today.

SAP AG, Dec. 1999 (Joachim Mette)

Slide 30

How to program a corresonding Include


You must firstly define the characteristics, or key figures
within the InfoCube
Call up transaction CMOD in the Admin. Workbench
Create a Project
Select Enhancement Components
Select Enhancement RSR00002
Double-click on Exit EXIT_SAPMRSRU_001
Double-click on include ZXRSRU02 within the Exit
Display or change coding
Maintain include ZXRSRTOP
Maintain include ZXRSRZZZ

Don't forget to activate the Project


SAP AG, Dec. 1999 (Joachim Mette)

Slide 31

Interface Importing/Exporting
Importing:
I_S_RKB1D

Information about Reporting-Object;


here Query (Queryname, InfoCube, ...)

Exporting:
E_T_CHANM

Table with the name of the virtual


characteristics

E_T_KYFNM

Table with the name of the virtual key figures

SAP AG, Dec. 1999 (Joachim Mette)

Slide 32

Remarks
You should note that the data records transferred can be on a
different aggregation level depending on read procedure and
drilldown.
Moreover, compound information is not automatically changed with
compounded characteristics after changing a higher-level
characteristic. In addition, the compound characteristic must also be
defined in the mode RRKE_C_MODE-NO_SELECTION.
Furthermore, the fiscal year (0FISCYEAR), the fiscal year period
(0FISCPER) and the fiscal year variant (0FISCVARNT) cannot be read
or changed in the enhancement. (*)

Enhancement 999 may not be changed. Calling up serves to update


information via the structure C_S_DATA. This functionality is
completely taken over by form USER_INIT_GLOBALS.

SAP AG, Dec. 1999 (Joachim Mette)

Slide 33

Remarks
Can you use a Navigational Attribute on top of a Virtual characteristic?

Solution: Don't use a Navigational Attribute, use a virtual characteristic for the attribute value.

Select joins

with

The User-exit is called after the select

SAP AG, Dec. 1999 (Joachim Mette)

Slide 34

At this time the Virtual


characteristic is initial. The
attribute is the value of the
initial-entry from the
master-data table

Now, the Virtual


characteristic is filled

5. User Exit in BEx

SAP AG, Dec. 1999 (Joachim Mette)

Slide 35

User Exit in BEx: Call "on refresh"

BW Server
Remote Function Call
Microsoft Excel

Call
on
refresh

Query Directory
Exits
(hidden)

Business
BusinessExplorer
ExplorerAnalyzer
Analyzer
(Excel
Add-in
SAPBEX.XLA)
(Excel Add-in SAPBEX.XLA)

API
Calls

State of Query 1
State of Query 2

VBA
VBA
Modules Modules

State of Query 3

SAP AG, Dec. 1999 (Joachim Mette)

Results
Query 1
Results
Query 2
Worksheet 1

Slide 36

Results
Query 3

Worksheet 2
Workbook

SAPBEXonRefresh
When the first query is added to a workbook, the Analyzer
will also add a VBA subroutine to the workbook:
Sub SAPBEXonRefresh(queryID as String, resultArea as Range)
' your own code goes here ...
' example: MsgBox queryID
' example: MsgBox resultArea.rows.count
' example: resultArea.AutoFilter
End Sub

This subroutine will be called each time a query is


refreshed in the workbook
resultArea holds the result area after the refresh

queryID specifies which query has been refreshed

SAP AG, Dec. 1999 (Joachim Mette)

Slide 37