Professional Documents
Culture Documents
ABAP For BI 7.0
ABAP For BI 7.0
ABAP Programming in BW
Table of Contents
Purpose..........................................................................................................3
Objective........................................................................................................3
Scope............................................................................................................3
Common Implementation scenarios of ABAP Programming in BW..........................4
Using Field Symbols in Routines......................................................................10
Differences between Transfer/Update Rules and Transformations .......................10
List of useful SAP Standard Programs/Function Modules/Classes..........................11
Optimization considerations............................................................................14
Tips for code changes.....................................................................................14
Variants........................................................................................................14
• Purpose
• The purpose of this document is to outline and define concepts and strategies that
constitute best practices regarding the use of ABAP programming in BW.
• It is strongly suggested that all staff (both senior and new hires) follow this
document closely.
• Objective
• Objective of this document is to develop programming process guidelines and
development standards considering the possibilities exist for using ABAP to
customize the BW environment to transform the data as requirements dictate, as
well as provide additional processing during extraction and updates.
• Scope
ABAP Programming Scope in BW and R/3 extractors
For BI 7.0, in data staging, there are many aspects that we can write abap
code to deal with data.
1. InfoPackage Routine
The infopackage routine given below is an example to create dynamic file name.
2. Start Routines
Actually, we write ABAP code here is for data cleansing or data consolidation.
3. Transformation Rules
It is processed in the transformation and actually this routine is written for some
particular fields.
In the transformation, select the particular field and right click the rule detail, in the
rule type, choose 'Routine'.
4. End Routine
End Routine is processed after transformation, actually for data cleansing.
5. Expert Routine
This type of routine is only intended for use in special cases. You can use the expert routine
if there are not sufficient functions to perform a transformation. The expert routine
should be used as an interim solution until the necessary functions are available in the
standard routine.
While writing routines, in order to dramatically improve performance, the following steps
should be taken:
Use Internal Tables of Master Data (instead of direct read of physical P-Tables)
*Global Section
TYPES:
BEGIN OF CUSTOMER_DATA,
END OF CUSTOMER_DATA.TYPES:
BEGIN OF ZCUSTSALES_DATA,
END OF CUSTOMER_DATA.
DATA:
FROM /BI0/PCUSTOMER
FROM /BI0/PZCUSTSALE
DATA:
RESULT_FIELDS-MATERIAL = LINE_DATA_PACKAGE-MATERIAL.
RESULT_FIELDS-CUSTOMER = LINE_DATA_PACKAGE-CUSTOMER.
RESULT_FIELDS-ZCUSTSALE = LINE_DATA_PACKAGE-ZCUSTSALE.
RESULT_FIELDS-CALMONTH = LINE_DATA_PACKAGE-CALMONTH.
*Read the proper CUSTOMER data from Internal Table using Binary Search.
CLEAR LINE_CUSTOMER_DATA.
CUSTOMER = LINE_DATA_PACKAGE-CUSTOMER
RESULT_FIELDS-CUST_CLAS = LINE_DATA_PACKAGE-CUST_CLAS.
RESULT_FIELDS-SALES_OFF = LINE_DATA_PACKAGE-SALES_OFF.
*Read the proper ZCUSTSALE data from Internal Table using Binary Search.
CLEAR LINE_ZCUSTSALE_DATA.
ZCUSTSALE = LINE_DATA_PACKAGE-ZCUSTSALE
RESULT_FIELDS-DISTR_CHAN = LINE_DATA_PACKAGE-DISTR_CHAN.
RESULT_FIELDS-SALES_GRP = LINE_DATA_PACKAGE-SALES_GRP.
ENDLOOP.
Whenever you address a field symbol in a program, you are addressing the field that
is assigned to the field symbol. After successful assignment, there is no difference
in ABAP whether you reference the field symbol or the field itself. You must assign
a field to a field symbol before you can address it in a program.
BW 3.5 BI 7.0
Internal Table DATA: BEGIN OF INT_EBELN It's 2 step process in BI 7.0. 1st step
OCCURS 0, declare the structure and in 2nd step
OI_EBELN LIKE declare Internal table referring to the
/BI0/POI_EBELN-OI_EBELN, above structure
/BIC/ZMEXPDGRP LIKE TYPES: BEGIN OF INT_EBELN_STRU,
/BI0/POI_EBELN-/BIC/ZMEX OI_EBELN TYPE
PDGRP, /BI0/POI_EBELN-OI_EBELN,
/BIC/ZMPOVERNO LIKE /BIC/ZMEXPDGRP TYPE
/BI0/POI_EBELN-/BIC/ZMPO /BI0/POI_EBELN-/BIC/ZMEXPDGRP,
VERNO, /BIC/ZMPOVERNO TYPE
/BIC/ZMPURSTAT LIKE /BI0/POI_EBELN-/BIC/ZMPOVERNO,
/BI0/POI_EBELN-/BIC/ZMPU /BIC/ZMPURSTAT TYPE
RSTAT, /BI0/POI_EBELN-/BIC/ZMPURSTAT,
/BIC/ZMPORLSON LIKE /BIC/ZMPORLSON TYPE
/BI0/POI_EBELN-/BIC/ZMPO /BI0/POI_EBELN-/BIC/ZMPORLSON,
RLSON, /BIC/ZMVALD_PO TYPE
/BIC/ZMVALD_PO LIKE /BI0/POI_EBELN-/BIC/ZMVALD_PO,
/BI0/POI_EBELN-/BIC/ZMVA END OF INT_EBELN_STRU.
Reading data from READ TABLE INT_EBELN 1st define a Work area and read from
Internal Table INTO WA_PO WITH KEY there.
OI_EBELN = WA_PO LIKE LINE OF INT_EBELN à
DATA_PACKAGE-OI_EBELN Work Area
BINARY SEARCH. READ TABLE INT_EBELN INTO WA_PO
IF SY-SUBRC = 0. WITH KEY
DATA_PACKAGE-/BIC/ZMVAL OI_EBELN = WA_DATA_PACKAGE-
D_PO = OI_EBELN BINARY SEARCH.
WA_PO-/BIC/ZMVALD_PO. IF SY-SUBRC = 0.
DATA_PACKAGE-/BIC/ZMEXP WA_DATA_PACKAGE-/BIC/ZMVALD_PO
DGRP = = WA_PO-/BIC/ZMVALD_PO.
WA_PO-/BIC/ZMEXPDGRP. WA_DATA_PACKAGE-/BIC/ZMEXPDGRP
DATA_PACKAGE-/BIC/ZMPOR = WA_PO-/BIC/ZMEXPDGRP.
LSON = WA_DATA_PACKAGE-/BIC/ZMPORLSO
WA_PO-/BIC/ZMPORLSON. N = WA_PO-/BIC/ZMPORLSON.
DATA_PACKAGE-/BIC/ZMPUR WA_DATA_PACKAGE-/BIC/ZMPURSTA
STAT = T = WA_PO-/BIC/ZMPURSTAT.
WA_PO-/BIC/ZMPURSTAT.
RSCDS_NULLELIM Delete fact table rows where all Key Figure values are zero. See
Note 619826.
SAP_CONVERT_NORMAL_TRANS Convert Basic Cube to Transactional Cube and the opposite way
around.
UNIT_CONVERSION_SIMPLE Used to convert any unit to another unit. (Ref. table : T006)
DATE_COMPUTE_DAY Returns a number what day of the week the date falls on.
DATE_TO_DAY
• Optimization considerations
• Use SELECT * with care. Do not use SELECT * when populating internal tables if
NOT all columns are required; only select the necessary columns.
• To reduce database access by repeated selections, it’s better to scan a table once
into the internal table and then read the internal table using statement
• READ TABLE … BINARY SEARCH. But be careful and consider resource issues when
selecting into an internal table – balance between optimization and memory
resources
• Avoid MOVE-CORRESPONDING statements. Instead use MOVE statement and
move fields individually.
• Structure of internal table should match the order the fields are returned from the
select statement when selecting into an internal table thereby avoiding usage of the
statement ‘into corresponding fields’.
• Avoid nested selects if possible.
• Be careful using ‘CHECK’ statements, consider to incorporate the selection criteria
into the select statement.
• Variants
• The Developer is responsible for ensuring test variants are not transported to the
production instance.