Sei sulla pagina 1di 20

How to use Return Table in Update

Rules

Applies to:
SAP NetWeaver BW 3.x. For more information, visit the Business Intelligence homepage.

Summary
The objective of this paper is to explain the use of Return Table concept in Update Rules which allows
distributing aggregated value and also helps to attain the structured data according to user requirement.
Author: Rudra Pradeep Reddy Neelapu
Company: Satyam Computer Services Ltd.
Created on: 26 May 2009

Author Bio

Working as a SAP Technical consultant with Satyam Computer Services Ltd.Skill set includes
SAP Business Intelligence, ABAP and Business Objects.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 1
How to use Return Table in Update Rules

Table of Contents
Introduction .........................................................................................................................................................3
Business Scenario #1 .........................................................................................................................................3
Background Information ..................................................................................................................................4
Step-by-Step Procedure..................................................................................................................................5
Prerequisite..................................................................................................................................................................5
Code for Scenario # 1 .....................................................................................................................................8
Start Routine: ...............................................................................................................................................................8
Update Routine: ...........................................................................................................................................................9
Business Scenario #2 .......................................................................................................................................12
Background Information ................................................................................................................................12
Step-by-Step Procedure................................................................................................................................13
Prerequisite................................................................................................................................................................13
Code for Scenario #2 ....................................................................................................................................16
Related Content................................................................................................................................................19
Disclaimer and Liability Notice..........................................................................................................................20

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 2
How to use Return Table in Update Rules

Introduction
Return table in Update rules is used to generate additional records based on one data record. It returns
multiple records by splitting the single record based on the specified conditions.
Update routines generally only have one return value. However, in the Data Field Calculation tab strip, you
can create a routine by choosing the Return table option. The corresponding key figure or characteristic field
for which routine now has a return table instead of a return value. Using this we can generate multiple records
from one data record. In Routines with Return Table the RESULT parameter is replaced with the
RESULT_TABLE. The return table has the same structure as the data target. We can fill the key figure or data
field, for which the routine was created, plus its characteristics or key fields. The calculated characteristic
values are stored in the ICUBE_VALUES structure. We can fill the RESULT_TABLE return table by copying
the ICUBE_VALUES structure and only fill the corresponding key figure and adjust the characteristic values.
Using this Return Table allows you to distribute aggregated values and also helps in attaining the structured
data as required.

Business Scenario #1
To distribute aggregated value using Return Table Concept.
Our source delivers revenue generated by an Organization which needs to be distributed across its Services
based on %Revenue Share of each service.
Source data record structure is as follows:
Organization Revenue
10009 1000
Revenue generated by the Organization need to be distributed across its services, based on its contribution in
Revenue using %Revenue Share.
Organization Service %Revenue Share
10009 A 0.50
10009 B 0.25
10009 C 0.10
We can attain the Revenue value generated by each service using the Return Table in Update Rules by
splitting the single data record of Organization revenue across its Services.
Organization Service Revenue by Service
10009 A ??
10009 B ??
10009 C ??

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 3
How to use Return Table in Update Rules

Note: If you use a key figure routine with return table and additional currency translation, the currencies are NOT stored in
ICUBE_VALUES structure, because they are only calculated once the routine has been executed.

In this scenario fixed currency is used; the currency is fixed for the amount. The key figure refers specifically to
the currency (here USD), so the currency does not have to be entered again in the data record.

Background Information
The Data Source delivers the Organization Revenue. The following processing steps are required in the
Update Rules:
Read the master data table with the Services in the Organization and its % revenue Share in the Start
Routine.
Create a Routine with Return table selected, to divide the key figure (Revenue of Organization) by its
Services that have been read from the master data table.
Create an entry in the return table for each Service.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 4
How to use Return Table in Update Rules

Step-by-Step Procedure

Prerequisite
Create Master Data ODS: ZSER

To maintain the organization Services and %Revenue share.

In this scenerio I am maintaing the same with a flat file.


Data in ODS ZSER is maintained as below.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 5
How to use Return Table in Update Rules

Create an ODS: Z_RTRN


Create an Info Provider with the final structure which in turn is the RETURN TABLE Structure.

Create Data Source: ZIS_RTRN


It has the structure of Source Data Record.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 6
How to use Return Table in Update Rules

Create Update Rules between the Data Source ZIS_RTRN and ODS Z_RTRN.
Create a Start Routine to fetch the Master Data of Services of an Organization and its contribution Share into
an internal table.
Now create a Routine by selecting the Return table option for filed ZREV which gives us the Revenue
generated by each Share in the total Organization Revenue.

Now the code is written for the Field ZREV and its corresponding Characteristics and key fields can be filled
simultaneously using the Return Table.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 7
How to use Return Table in Update Rules

Code for Scenario # 1

Start Routine:

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 8
How to use Return Table in Update Rules

Update Routine:

Here we are filling the RESULT_TABLE, which contains the structure of our data target Z_RTRN with
ICUBE_VALUES; hence all the Characteristic values are copied to it.
We are appending each of the field to the RESULT_TABLE by looping across internal table itab, which
contains the master data of Services across the Organization and its contribution Share.
We are calculating the Revenue generated by each service by its share contribution.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 9
How to use Return Table in Update Rules

For the above scenario we have to create a Flat File (.csv) corresponding to the Data Source structure. Create
an Info Pack for the data source.
Flat File Structure:
Organization Revenue
10009 1000

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 10
How to use Return Table in Update Rules

Preview of the data record

And schedule the load

We can observe that the single data record has been split to 3 records in the Update Rules based on the
Services offered by Organization.
Below is the required result of service wise revenue generated across an Organization.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 11
How to use Return Table in Update Rules

Business Scenario #2
We can attain the required structure for the data by formatting the input source data using Return Table
Concept.
The data records form R/3 had Issue descriptions corresponding to a key filed Item Code in more than one
column in a single row. In BW end we require to display the issues encountered by an item in a single column
one below the other.
Source data record structure is as follows:
Item Code Issue 1 Issue 2
10008 Lack of durability Unavailability of Spare parts
10009 Frequent issues High cost

Need to display all the issues against a product in a Single Column. This can be attained using the Return
Table in Update Rules.
Item Code Issue
10008 Lack of durability
10008 Unavailability of Spare parts
10009 Frequent issues
10009 High cost

Background Information
The Data Source delivers the Item Code with descriptions of Issue1 and Issue2.
The following processing steps are required in the Update Rules:
Create a Routine with Return table selected, to append the Issue2 description record to item with
Issue1.For attaining this we maintain a temporary key filed ZON_ASID along with item code as we
are loading into an ODS in this scenario, to avoid the possibility of records getting overwritten.
Create an entry in the return table for each Issue Description.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 12
How to use Return Table in Update Rules

Step-by-Step Procedure

Prerequisite
Create a ODS: ZRETURN
Create an Info Provider with the final structure which in turn is the RETURN TABLE Structure.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 13
How to use Return Table in Update Rules

Create Data Source: ZRETURN


It has the structure of Source Data Record.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 14
How to use Return Table in Update Rules

Create Update Rules between the Data Source ZRETURN and ODS ZRETURN.
Now Create a Routine for field ZPRI_SO1 (Issue) with Return table Option Selected.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 15
How to use Return Table in Update Rules

Code for Scenario #2


Now the code is written for the Field ZPRI_SO1 and its corresponding Characteristics and key fields can be
filled simultaneously using the Return Table.

We are appending each of the field to the RESULT_TABLE based on the issue description. As we are loading
the data into ODS we are appending the description of Issue2 of first item code to Issue 1 description by using
a temporary field ZON_ASID.
For the above Scenario Create a Flat File (.csv) corresponding to the Data Source structure.
Create an Info Pack for the data Source.
Flat File Structure:
Item Code Issue 1 Issue 2
10008 Lack of durability Unavailability of Spare parts
10009 Frequent issues High cost

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 16
How to use Return Table in Update Rules

Preview of the data record

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 17
How to use Return Table in Update Rules

Schedule the Load.

We can observe that the 2 data record has been split to 4 records in the Update Rules i.e. one record got
appended below the other.
Below is the required result of Issue Description for an Item Code.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 18
How to use Return Table in Update Rules

Related Content
Taken most of the inputs from sap help in preparing this Article.
http://help.sap.com/saphelp_nw04/helpdata/en/7f/61fc37f456491ee10000009b38f8cf/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/21/894eeee0b911d4b2d90050da4c74dc/frameset.htm
https://www.sdn.sap.com/irj/scn/thread?messageID=6293014#6293014
https://www.sdn.sap.com/irj/scn/thread?messageID=515459
For more information, visit the Business Intelligence homepage.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 19
How to use Return Table in Update Rules

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 SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 20

Potrebbero piacerti anche