User Exits in SAP BW

37
SAP AG, Dec. 1999 (Joachim Mette) Slide 1 Know How Network Call 16.12.1999 SAP AG BW Development User Exits in SAP BW

description

user exists

Transcript of User Exits in SAP BW

Page 1: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 1

Know How Network Call 16.12.1999

SAP AG BW Development

User Exits in SAP BW

Page 2: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 2

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.

Page 3: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 3

Meta Data ManagerMeta Data Manager

Business Explorer

BW Server

Meta DataRepositoryMeta DataRepository InfoCubesInfoCubes

SchedulingScheduling

MonitorMonitor

BrowserBrowser

Data ManagerData Manager

Non R/3 Production Data Extractor

Non R/3 Production Data Extractor

Non R/3 OLTP ApplicationsNon R/3 OLTP Applications

ODBO ODBO

3rd party OLAP client

3rd party OLAP client

OperationalData Store

OperationalData Store

R/3 OLTP ApplicationsR/3 OLTP Applications

OLTP Reporting

OLTP Reporting

Production DataExtractor

Production DataExtractor

Staging EngineStaging Engine

BAPIBAPI

Administrator Workbench

AdministrationAdministration

BAPIBAPI

Analyzer(hosted by MS Excel)

Analyzer(hosted by MS Excel)

OLAP ProcessorOLAP Processor

2.

1.

3. 4-

5.

User-Exits in BW

Page 4: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 4

1. Extending the Business Content

Page 5: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 5

Extending the Business Content

Page 6: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 6

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 medium-length 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.

Page 7: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 7

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.

Page 8: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 8

EXIT_SAPLRSAP_001: Interface Exporting/Tables

I_T_SELECT Table with the selection criteria stored in theScheduler of the BW

I_T_FIELDS List of the transfer structure fields. Only thesefields are actually filled in the data table and can be sensibly communicated with in theprogram.

C_T_DATA Table with data received from the API in theformat of the source system entered in table ROIS (field ROIS-STRUCTURE).

Page 9: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 9

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.

Page 10: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 10

EXIT_SAPLRSAP_002: Interface Exporting/Tables

I_T_SELECT Table with the selection criteria stored in theScheduler of the BW

I_T_FIELDS List of the transfer structure fields. Only thesefields are actually filled in the data table and can be sensibly communicated with in theprogram.

C_T_DATA Table with data received from the API in theformat of the source system entered in table RODCHABAS (field RODCHABAS-STRUCTURE).

Page 11: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 11

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.

Page 12: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 12

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.

Page 13: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 13

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 requestedhierarchy.

Page 14: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 14

EXIT_SAPLRSAP_004: Interface Exporting/Tables

I_T_LANGU Table with the language in which thedescriptions are requested.

C_T_HIETEXT Table with the description of the hierarchy inthe requested language.

C_T_HIENODE Table with all components of the hierarchy.

C_T_FOLDERT Table with the descriptions of all nodes thatcannot be posted to in the hierarchy in therequested language.

C_T_HIEINTV Table with those hierarchy sheets that represent value intervals.

Page 15: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 15

2. User Exit after Data loading

Page 16: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 16

OLTP System

Data Load : Procedure

InfoPackage

Extraction engineExtraction engineExtraction engineExtraction engine

SchedulerSchedulerSchedulerScheduler

PullPull

yellow green

red

MonitorMonitorMonitorMonitor

User Exit after Data LoadUser Exit after Data Load

callcall

BW

Page 17: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 17

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

Page 18: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 18

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 functionmodule is called at the end of an InfoPackageGroup)

Page 19: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 19

Interface - Importing

WRITE_TO_ODS = X if something is written to the ODS (not

filled if function module is called byInfoPackageGroup)

WRITE_TO_CUBE = X if something is written to an InfoCube(not filled if function module is called

byan Info PackageGroup)

GROUP_CALL = X if function module is called by anInfoPackageGroup, otherwise space

Page 20: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 20

Sourcesystem

Scenario 1: Delete old request

User Exit after Data Load

Delete last Request

Check

User Exit after Data Load

Delete last Request

Check

InfopackageInfoCube

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

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

Monitor

Page 21: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 21

Infopackage

Sourcesystem

InfoCube

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

Scenario 2: Send Mail after data load

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

User Exit after Data Load

Send Mail

Send Mail

User Exit after Data Load

Send Mail

Send Mail

Monitor

Page 22: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 22

3. User Exit for Variables

Page 23: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 23

User-Exit for Variables

Enhancement: RSR00001

The component for the enhancement is the function module EXIT_SAPLRRS0_001.

Page 24: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 24

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

Page 25: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 25

Interface - Importing

I_VNAM Name of the Variable; without &-signs

I_VARTYP 1: Characteristic Value2: Hierarchy node(s)3: Text4: Formula5: 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 up2: After Variable Pop up1.2B

1.2B

1.2B

Page 26: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 26

Interface Exporting

E_T_RANGE Table to return the valuesfields: 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

Page 27: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 27

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

Page 28: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 28

4. Virtual Characteristics andVirtual Key figures

Page 29: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 29

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.

Page 30: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 30

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 (Sold-quantity * 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.

Page 31: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 31

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

Page 32: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 32

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 virtualcharacteristics

E_T_KYFNM Table with the name of the virtual key figures

Page 33: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 33

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.

Page 34: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 34

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

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

Page 35: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 35

5. User Exit in BEx

Page 36: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 36

Microsoft ExcelMicrosoft Excel

Business Explorer Analyzer (Excel Add-in SAPBEX.XLA)

Business Explorer Analyzer (Excel Add-in SAPBEX.XLA)

Workbook

Worksheet 1 Worksheet 2

Query Directory(hidden)

State of Query 1

ResultsQuery 3

BW ServerBW Server

Remote Function Call

VBAModules

APICalls

State of Query 2

State of Query 3

ResultsQuery 2

ResultsQuery 1

VBAModules

Exits

Call “on refresh”

User Exit in BEx: Call "on refresh"

Page 37: User Exits in SAP BW

SAP AG, Dec. 1999 (Joachim Mette) Slide 37

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

SAPBEXonRefresh