Vous êtes sur la page 1sur 11

SAP How-to Guide

Business Analytics

How to SELECT in SAP BW transformations

Applicable Releases:
SAP BW 7.0* and later releases

Version 1.0
April 2012

Copyright 2013 SAP AG. All rights reserved.


No par t of this p ubli cati on may be r epr o du ced or tr ansmi tte d in a ny f or m or for any pur p ose wi th out th e expr es s per missio n of S AP AG. Th e inf or matio n co nt aine d her ei n may b e ch ang ed wi th out pr ior no tice.
S ome sof twar e pr o duc ts mar ke ted by S AP AG and i ts dis tr ibu tor s co nt ain pr opr iet ar y sof twar e c ompo ne nts of o th er soft war e ve ndor s.
Micr oso ft, Wi nd ows, Ex cel, Ou tlo ok, a nd P ow er P oint ar e r egist er ed tr a demar ks of Mi cr oso ft Cor p or ati on.
IBM, DB2, DB2 U niver sal Da tab ase, S ys tem i, S yst em i5, S yst em p, S yst em p5, S ys tem x, S ys tem z, S yst em z10, S ystem z9, z10, z 9, iS er ies, pS er ies, xS er ies , zS er ies, eS er ver , z/VM , z/OS , i5 /OS , S /390, OS / 390, OS / 400, AS /400, S /390 P ar allel E nter pr ise S er ver , P ower VM, P ower Ar chit ect ur e, P OWER6+ , P OWER6 , P OWER5+ , P OWER5, P OWER, O penP ow er , P ower P C, Batc hP ipes, Bla deCe nter , S ys tem S tor a ge, GP FS , HACMP , RE TAIN, DB2 Co nne ct, RACF, Re db ooks, OS / 2, P ar allel S ys plex, MVS /ES A, AIX,
Intelli gen t Miner , We bS pher e, N et fini ty, Ti voli a nd I nfor mix ar e tr ademar ks or r egister e d tr a demar ks o f IBM Cor por ati on.
Linux is th e r egist er ed tr ademar k o f Li nus Tor val ds in t he U.S . a nd o th er cou ntr ies.
Adobe , th e Ado be lo go, Acr o ba t, P ostS cr ip t, a nd Rea der ar e ei ther tr a demar ks or r egister e d tr a demar ks o f Ado be S yst ems Inc or por a ted i n t he Uni te d S ta tes a nd/ or ot her co untr ie s.
Or acle is a r egis ter ed tr ademar k of Or acl e Cor por a tio n.
UNIX, X/Open, OS F/1, an d M oti f ar e r egis ter ed tr adem ar ks of the O pe n Gr ou p.
Citr ix, ICA, P r ogr am Neigh bor ho od, Me taFr ame , WinFr ame, Vid eoFr ame , an d M ultiWin ar e tr ad emar ks or r egis ter ed tr ademar ks of Ci tr ix S ystems, I nc.
HTM L, XML, XH TM L an d W3C ar e tr ademar ks or r egister e d tr a demar ks o f W3C, Wor ld Wi de Web C ons or tium, Massa chu set ts In sti tu te o f Te chn olo gy.
Java is a r egis ter e d tr ad emar k of S u n Mi cr osys tems, In c.
JavaS cr ipt is a r egist er ed tr ademar k o f S un Micr osy stems, Inc., use d un der lice nse f or tec hn olog y inve nte d a nd impl emen ted by Ne tsca pe.
S AP , R/3, S AP NetWeaver , Due t, P ar tner Edg e, ByDesig n, S AP BusinessO bjec ts E xpl or er , S tr eamWor k, an d o ther S AP pr odu cts a nd s er vices men tio ne d her ei n as well a s th eir r espec tive lo gos ar e tr ad emar ks or r egis ter ed tr ademar ks of S AP AG in Ger many a nd o th er cou ntr ies.

All other pr o du ct a nd s er vice nam es men tion ed ar e the tr ad emar ks of their r es pec tive c ompa nies. Da ta c ont aine d in this doc umen t ser ves i nfor ma tion al p ur pose s onl y. Nati on al pr o duc t spe cific atio ns may v ar y.
The i nfor ma tion i n t his d ocume nt is pr opr ie tar y t o S AP . No par t of t his d ocum ent ma y be r e pr od uce d, co pied , or tr ansmi tt ed in any for m or for an y pur pose wi th ou t t he ex pr ess pr ior wr it ten per missio n of S AP AG.
This doc umen t is a pr elimin ar y ver sion an d no t su bjec t t o yo ur license agr eeme nt or any o th er agr eeme nt wi th S AP . This doc umen t co nt ains o nly in te nde d str a te gies, d evel opmen ts, a nd fu ncti onali ties of t he S AP pr odu ct a nd is no t in ten ded to be bi ndi ng u po n S AP to an y par ti cular c our se o f b usines s, pr o duc t str a teg y, an d/ or devel opme nt. P lea se n ote th at this d ocum en t is su bjec t to cha nge a nd ma y be c ha nge d by S AP at a ny tim e wit hou t n otic e.
S AP assumes no r esp onsi bilit y for er r or s or omissio ns in this doc umen t. S AP does not w ar r ant the accur a cy or com plet ene ss of th e inf or matio n, t ext, gr aphi cs, link s, or o ther it ems co ntai ned withi n t his mat er ial. T his d ocume nt is pr ovid ed wi th out a war r an ty of any ki nd, eit her expr ess or implied , incl udin g b ut n ot limi ted to the im plied w ar r anti es of mer c han ta bility, fit ness for a par ticul ar pur p ose, or n on -in fr ingeme nt.
S AP shall have n o liabili ty f or dama ges o f an y kin d incl udi ng wit ho ut limit ati on dir ect, s peci al, in dir ect, or cons eq uen tial d amage s th at may r es ult fr om th e use of thes e mater ial s. T his limita tio n shall no t ap ply in c ases of in te nt or gr o ss ne glige nce.
The s ta tu tor y lia bility for per so nal i njur y an d d efec tive pr od uct s is no t af fec te d. S AP has no con tr ol ov er the i nf or matio n t hat y ou ma y acce ss t hr oug h t he us e of ho t links con tai ned i n t hese ma ter ials a nd does no t en dor se y our us e of thir d -p ar ty Web pag es n or pr ovid e any w ar r anty wha tso ever r elati ng t o t hir d- par ty W eb p ages .

SAP How-to Guides are intended to simplify the product implementtation. While specific product features and procedures typically are

Business Objects and the Business Objects logo, BusinessObjects,

explained in a practical business context, it is not implied that those

Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other

features and procedures are the only approach in solving a specific

Business Objects products and services mentioned herein as well as their

business problem using SAP NetWeaver. Should you wish to receive

respective logos are trademarks or registered trademarks of Business

additional information, clarification or support, please refer to SAP

Objects Software Ltd. Business Objects is an SAP company.

Consulting.

S ybase a nd Ad ap tive S er ver , iAnyw her e, S yb ase 3 65, S QL A nywh er e, an d o ther S yb ase pr o du cts a nd s er vices men tio ne d her ein as well as th eir r espec tive lo gos ar e tr ad emar ks or r egist er ed tr ademar ks of S yb ase, I nc. S yb ase is a n S AP company .

Any software coding and/or code lines / strings (Code) included in this
documentation are only examples and are not intended to be used in a
productive system environment. The Code is only intended better explain
and visualize the syntax and phrasing rules of certain coding. SAP does
not warrant the correctness and completeness of the Code given herein,
and SAP shall not be liable for errors or damages caused by the usage of
the Code, except if such damages were caused by SAP intentionally or
grossly negligent.
Disclaimer
Some components of this product are based on Java. Any code change
in these components may cause unpredictable and severe malfunctions
and is therefore expressively prohibited, as is any decompilation of these
components.
Any Java Source Code delivered with this product is only to be used by
SAPs Support Services and may not be modified or altered in any way.

Document History
Document Version

Description

1.10

Second Review

1.00

First draft of this guide

2.00

Official Release

Typographic Conventions

Icons

Type Style

Description

Icon

Example Text

Words or characters quoted


from the screen. These
include field names, screen
titles, pushbuttons labels,
menu names, menu paths,
and menu options.
Cross-references to other
documentation

Example text

Emphasized words or
phrases in body text, graphic
titles, and table titles

Example text

File and directory names and


their paths, messages,
names of variables and
parameters, source text, and
names of installation,
upgrade and database tools.

Example text

User entry texts. These are


words or characters that you
enter in the system exactly
as they appear in the
documentation.

<Example
text>

Variable user entry. Angle


brackets indicate that you
replace these words and
characters with appropriate
entries to make entries in the
system.

EXAMPLE TEXT

Keys on the keyboard, for


example, F2 or ENTER.

Description
Caution
Note or Important
Example
Recommendation or Tip

How to SELECT in SAP BW transformations

Table of Contents
1.

Business Scenario ........................................................................................................... 2

2.

Step by Step Solution ...................................................................................................... 3

3.

Conclusions / Recommendations ................................................................................... 5

4.

Appendix ......................................................................................................................... 6

March 2013

How to SELECT in SAP BW transformations

1.

Business Scenario

For complex data staging scenarios within SAP BW it is usually necessary to manipulate data, this
can be done at several points during loading:

Start routine
Expert routine
End routine

The following scenario is about manipulation and transformation of data during staging through the
data warehouse. Scenario:
(1) You need to do a lookup on custom Z-table and populate a field in this case ZCOUNTRY in
the data target (InfoCube) within transformation from DataStore Object to InfoCube.
In order to accomplish the above task it has been determined to use End Routine for the
Enhancement. As best practice it is well known and recommendable to use internal tables rather
than SELECT SINGLE statement in performance point of view. As mentioned on SAP NetWeaver
BW powered by SAP HANA this best practices remains valid, therefore the data selection via the
internal table will be showed.
For demonstration purposes data will be loaded from a DataStore Object to an InfoCube. In the
transformation for field 0SOLD_TO a lookup for country in the customer Z-Table will be done.

This transformation will be enhanced via end routines by performing the following actions:
(1) Get the country from Z-Table for each 0SOLD_TO and populate field ZCOUNTRY in the
Data Target (InfoCube)
A SAP BW system powered by HANA at current state doesnt change much on the ABAP
Application Layer, a lot of well-known performance optimizations in this area are remaining valid.
Therefore the present How to guide shows an efficient way to use SELECT statements in
transformation in SAP NetWeaver BW powered by SAP HANA as well as with SAP BW on other
databases.

March 2013

How to SELECT in SAP BW transformations

2.

Step by Step Solution


(1) Create Transformation from DataStore Object to InfoCube.
(2) Create End Routine as follows.

Add Global Declaration. Refer to appendix for the ABAP Code.

March 2013

How to SELECT in SAP BW transformations


Remarks on the shown example:
-

If it is useful to read a table according to our example ZCUSTLOC in the end routine is
depending on the amount of records. Considering tables, in our example ZCUSTLOC, with a
lot of entries it is recommendable to read only the relevant Data Packages and to buffer this
table (usage of FOR ALL ENTRIES IN <result_package>). See also Note 1662726 Optimizing select with FOR ALL ENTRIES in SAP HANA database
In scenarios where a lookup of data of BW InfoObjects is executed it is recommendable to
use the standard rule type reading master data because this is already optimized for data
selects without the need to use ABAP coding. This is also possible for Navigation Attributes
and DataStore objects since BW 7.30 (see below).
The mentioned best practices are also valid for scenarios where 3.x data flow logic is used
as well as for new HANA optimized objects like shown.
New standard look-up features with SAP BW 7.30:
Beside the possibility to the do master data look up via a routine or rule (reading master
data) it is also possible switch on the navigation attribute in the source object to make this
attribute visible as a source field in the transformation. Hence it is available as field for
staging, which makes it not necessary to read to master data separately:

Afterwards the navigation attribute become available in the transformation and can be
used:

There is also a new look-up feature available for lock ups in DataStore Object.
These standard functionalities are fully optimized, easy to use and therefore highly
recommended to use.

March 2013

How to SELECT in SAP BW transformations

3.

Conclusions / Recommendations

There is significant improvement in End Routine Processing times when using Read Table rather
than Select Single with-in Loop Statement. Select Single should be avoided with in a loop whereever possible.
Valid for SAP NetWeaver BW powered by SAP HANA:
(1) Due to the architecture of SAP HANA database recommendation and best practices of
good ABAP coding are valid and still important.
(2) During different loading cycles it has been observed that larger DTP - Data Package size of
100,000 - 150,000 records showed a significant performance gain than smaller
DataPackages.
(3) Secondary indexes on customer Z-Tables might not be required, as data is already stored
in column store with in HANA. DataStore Object Secondary indexes arent required on SAP
HANA anymore. However for some use cases secondary indexes can still be beneficial. This
is especially true for highly selective queries on non-primary key fields. These queries can
be significantly improved by indexes on single fields which are most selective. (Note
1740373 - DSO: Maintenance of database indexes in SAP HANA.)
All best practices of the following SAP Notes should be considered for SAP HANA as well:
- Note 1227667 - Guidelines for expert routine: Design rules
- Note 1258089 - Design rule: Adding records to the start routine
- Note 1223532 - Design rules: Adding records to end routine

March 2013

How to SELECT in SAP BW transformations

4.

Appendix

DATA: BEGIN OF I_S_CUSTOMER,


/BIC/S_CUSTOMER TYPE ZCUSTLOC-/BIC/S_CUSTOMER,
/BIC/S_COUNTRY TYPE ZCUSTLOC-/BIC/S_COUNTRY,
END OF I_S_CUSTOMER.
DATA: i_t_customer like HASHED table of I_S_CUSTOMER with uniq
ue key
/BIC/S_CUSTOMER.
select /BIC/S_CUSTOMER /BIC/S_COUNTRY from zcustloc
into corresponding fields of table i_t_customer.
if sy-subrc = 4.
RAISE EXCEPTION TYPE CX_RSROUT_ABORT.
endif.
sort i_t_customer by /BIC/S_CUSTOMER.
loop at RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
read table i_t_customer into I_S_CUSTOMER with key
/BIC/S_CUSTOMER = <RESULT_FIELDS>-/BIC/S_SOLD_TO.
if sy-subrc eq 0.
<RESULT_FIELDS>-/BIC/S_COUNTRY = I_S_CUSTOMER/BIC/S_COUNTRY.
endif.
endloop.

March 2013

www.sap.com/contactsap
www.sdn.sap.com/irj/sdn/howtoguides

Vous aimerez peut-être aussi