day1-abap bw handbook
DESCRIPTION
abap bw hand bookTRANSCRIPT
-
7/16/2019 Day1-ABAP BW Handbook
1/64
Copyright IBM Corporation 2007
IBM Global Business Services
April 08ABAP Handbook for BW Developer
ABAP In BW Enhancements [Day 1]
-
7/16/2019 Day1-ABAP BW Handbook
2/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 132
Overview
The first day will consist of the following broad level topics
Overview of ABAP language
Working with Function Modules ,Function Groups, FM and Executable
Programs.
ABAP Dictionary Objects
Use Of ABAP in R/3 Side (BW Specific Requirements).
-
7/16/2019 Day1-ABAP BW Handbook
3/64
Copyright IBM Corporation 2007
IBM Global Business Services
April 08ABAP Handbook for BW Developer
Overview of ABAP Language
-
7/16/2019 Day1-ABAP BW Handbook
4/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 134
The ABAP Editor(SE80) is used to create, maintain, and execute ABAPprograms.
Custom programs must start with a Y or a Z and can be up to 40 characters
in length.
In an ABAP program :
Each statement must end with a period. (full-stop)
Key words are always the first word in a statement
Words must be separated by at least one blank
ABAP statements can be indented and extend over several lines
ABAP programs must start with either the PROGRAM or REPORT statement.
Comments can be written by placing an asterisk (*) in column 1 or placing a
double quotation mark (") within a line.
Some basics about ABAP
-
7/16/2019 Day1-ABAP BW Handbook
5/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 135
Data Declaration
The data declaration is done mainlythrough LIKE and TYPE. The different data
types are as shown in the graphic.
Data: L_NAME(10) type C,
L_AGE(3) type I.
Constants and defaults values can also be
given.
Constants:
L_NAME(10) type C VALUE SAM,
L_AGE(3) type I VALUE 45.
-
7/16/2019 Day1-ABAP BW Handbook
6/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 136
Data Declaration (Contd.)
The normal method of declaring variables is
DATA:L_VARIABLE(length) TYPE .
We can declare types and reuse it internal table(s) many times .
Variables that you declare with the DATA statement live for as long as the context in which
they are defined. Therefore variables in an ABAP main program exist for the entire
runtime of the program, and local variables in procedures only exist for as long as the
procedure is running.
To retain the value of a local variable beyond the runtime of the procedure, you can
declare it using the STATICS statement. This declares a variable with the lifetime of the
context of the main program, but which is only visible within the procedure.
STATICS:L_VARIABLE(length) TYPE .
-
7/16/2019 Day1-ABAP BW Handbook
7/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 137
Data Declaration (Contd.)
When we want to deal with data within a specific interval , we use RANGE in ABAP.Todeclare a RANGE, we use the following command.
RANGES:R_PLANT for /BIC/AZCOPCO0800-PLANT.
Here we see /BIC/AZCOPCO0800 is the Active table of the DSOZCOPCO08.Whileusing range we have to see that after the FOR clause , we have to use a flat structure.
The structure of the Range table is .
-
7/16/2019 Day1-ABAP BW Handbook
8/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 138
Types of Database Tables
Transparent Table : Exists with the same structure both in dictionary as well asin database exactly with the same data and fields. E.g. CDHDR
Pooled Table : Pooled tables are logical tables that must be assigned to atable pool when they are defined. Pooled tables are used to store control
data. Several pooled tables can be combined in a table pool. The data ofthese pooled tables are then sorted in a common table in the database. E.g.Table DD02L Give TABCLASS as POOL you will get a list of tables
Cluster Table : Cluster tables are logical tables that must be assigned to atable cluster when they are defined. Cluster tables can be used to storecontrol data. They can also be used to store temporary data or texts, such asdocumentation. E.g. CDPOS
-
7/16/2019 Day1-ABAP BW Handbook
9/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 139
1. Select-Endselect. This is the Basic and the most rudimentary form of a selectstatement .
2. Select single . We can also select a single value from a databasetable.
3. Select from where. This is the select statement with a condition attached to it.We can refer to this condition as a filter.
4. Select into . We can store the results of a select statement inlocally declared variables.
5. Select into table . We can select data from a database
table into an internal table .
6. Select into Corresponding Fields of . If the data fields name ofan internal table are same we can use this statement .Then we do not have to
take into account the sequence of the internal table.
Types of SELECT Statement
-
7/16/2019 Day1-ABAP BW Handbook
10/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1310
System Variables
SY-SUBRC
0The execution of the select statement is success and output is not initial.
4The execution of the select statement is success and output is initial.
8The execution of the select statement is not successful. This is applicable fordynamic SQL calls.
It is based on the values returned for SY-SUBRC that the execution of the Select
statement should continue .
SY-TABIX
This is the system Index. This is predominantly used for Update or Insert
Statements .
This Practice is the start of Performance tuning concept. If our required
output is not achieved by the Select statement we will directly terminate
the program after showing an error message.
-
7/16/2019 Day1-ABAP BW Handbook
11/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1311
Joins between database tables
Consider the two database tables as shown below.
Bill No Item Sold Price
1 PAPER 2/-
1 PEN 1/-
1 PEN 1/-
2 PENCIL 1/-
2 ERASER 1/-SALESHDR
SALESDTL
We need to find
(1) Total Items bought by Company ABC .
(2) Is there any company which did not buy any Items.
Bill. No Co. Name Date
1 ABC 1-Jan-08
2 ABC 1-Feb-08
3 DEF 1-Mar-08
-
7/16/2019 Day1-ABAP BW Handbook
12/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1312
WRITE This statement shows the output on the Output screen of SE38.
/ This character denotes the new line . All portion after this is written into a new lineon the Output Screen
This Character denotes TAB. All portions after this is written after a TAB in the
Output Screen.
WRITE Statement
-
7/16/2019 Day1-ABAP BW Handbook
13/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1313
Decision Making 1 - IF Statement
IF-ENDIF. Basic Variant of a IF Statement .If . ENDIF.
IF-ELSE-ENDIF. If . . ELSE.. ENDIF.
IF-ELSEIF-ENDIF. If . . ELSEIF. .ENDIF.
With the Innovative combinations of this statement we can give shape to mostof the situations which we can predict to face.
-
7/16/2019 Day1-ABAP BW Handbook
14/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1314
Basic Exercise using the SELECT and SY-SUBRC
CHASSIS NO. MODEL DESCRIP
YEAR OF
MANUFAC COLOUR OWNER
MAR001 MAR MARUTI 800 2000 RED TOM
TATS002 TATS TATA SUMO 2002 WHITE JOHN
ZEN003 ZEN MARUTI ZEN 2004 BLACK SAM
SX4012 SX4 MARUTI SX4 2006 BLUE SAM
MAR002 OMNI MARUTI OMNI 2000 RED HARRY
-
7/16/2019 Day1-ABAP BW Handbook
15/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1315
Decision Making 2 - CASE Statement
CASE-WHEN-ENDCASE. CASE .WHEN Value 1. . WHEN Value 2. .
ELSE. < executable statement >. ENDCASE.
This is the basic form of the CASE statement . The CASE Statement in
Logic is very much similar to the IF-ELSE-ENDIF statement .However
when both these statements are compared , there are some vital
differences between there execution methods. The CASE statement is
used to distinguish between mutually exclusive options.
-
7/16/2019 Day1-ABAP BW Handbook
16/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1316
Decision Making 3 DO/WHILE Statement
A basic loop for repetitive jobs is LOOP-ENDLOOP. It is terminated by exit.
A DO loop is used to unconditionally execute a block of code multiple times.
DO 10 TIMES. WRITE Hello World. ENDDO.
WHILE loop conditionally executes a block of code, possibly multiple times.
WHILE . . ENDWHILE.
The CHECK statement is used to test a logical expression.
The EXIT statement unconditionally terminates a loop, subroutine, or
program.
The CONTINUE statement is used inside a loop. This ignores the present
iteration of the loop and goes to the next iteration.
-
7/16/2019 Day1-ABAP BW Handbook
17/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1317
Internal Tables
Declaration
(1) data: begin of it_first occurs 0,
name(20) type c,
age(2) type I,
data: end of it_first.
This is the example of a table with header line.
(2) types: begin of ty_first,
name(20) type c,
age(2) type I,
end of ty_first.
data: it_first type standard table of ty_first.
This is the example of a table without header line.
-
7/16/2019 Day1-ABAP BW Handbook
18/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1318
Types of Internal Tables
These are mainly of three types of Internal Tables .
Standard Table
data: it_first type standard table of ty_first.
Sorted Table
DATA: spfli_sort TYPE SORTED TABLE OF spfli WITH UNIQUE KEY carrid
connid.
Hashed TableDATA: spfli_tab TYPE HASHED TABLE OF spfli WITH UNIQUE KEY carrid
connid,
-
7/16/2019 Day1-ABAP BW Handbook
19/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1319
Header Line / Work Area/Initial Size
Header LineData: it_first type standard table of ty_first with header line.
Work Area
Data: wa_first type ty_first
Initial Size
Data: it_first type standard table of ty_first initial size 0.
-
7/16/2019 Day1-ABAP BW Handbook
20/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1320
Generic operations on Internal Tables
SORT : Sorting an internal table by some field values.
SORT IT_TABLE by COL1 COL2.
DELETE: Deletes an internal table based on a condition.
DELETE IT_TABLE where COL1 = VALUE1.
CLEAR: Frees the internal memory assigned to a variable/work area/internal table.
CLEAR IT_TABLE
REFRESH: Works same as CLEAR but applies to the body [] of an internal table.
REFRESH IT_TABLE[].
INSERT: Inserts lines in an internal table.
INSERT target FROM TABLE IT_TABLE ACCEPTING DUPLICATE KEYS.
-
7/16/2019 Day1-ABAP BW Handbook
21/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1321
Generic operations on Internal Tables
MOVE : This statement is not very much related to internal table . It can be used as
an assignment statement . E.g. MOVE WA_1 to WA_2.
CORRESPONDING : If the the internal table into which the selection fields are taken
are not in the same order as the selection fields , then the ABAP compiler
generates an error . To avoid this we use the statement
SELECT COL1 COL2 from DBTAB into corresponding fields of table IT_TABLE.
INTO : A better method is to declare the fields in the internal table in the same
sequence as the selection clause . Then we can use
SELECT COL1 COL2 from DBTAB into table IT_TABLE.
This scores over the COORESPONDING statement as it does not use the ABAP
Memory to sort the fields in the required order.
G S
-
7/16/2019 Day1-ABAP BW Handbook
22/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1322
Joins between database table and internal table
Consider the two tables we have seen earlier , SALESHDR is an internal tableand SALESDTL is a Database table
Bill No Item Sold Price
1 PAPER 2/-
1 PEN 1/-
1 PEN 1/-
2 PENCIL 1/-
2 ERASER 1/-SALESHDR
SALESDTL
Bill. No Co. Name Date
1 ABC 1-Jan-08
2 ABC 1-Feb-08
3 DEF 1-Mar-08
The difference between joining database tables and database table with an internal
table is
(1) You cannot put fields from the internal table in the SELECT cause of the Join.
(2) In a single query , we can join only one internal table.
(3) You cannot use the internal table in a WHERE clause after the join.
IBM Gl b l B i S i
-
7/16/2019 Day1-ABAP BW Handbook
23/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1323
Reading from Internal Tables
This statement reads a row from internal table itab. You have to specify the row by
either naming values table_key for the table key, a free condition free_key or an
index. The latter choice is possible only for index tables. The output result
determines when and where the row contents are read.
If the row to be read is not uniquely specified, the first suitable row is read. In the
case of index tables, this row has the lowest table index of all matching rows.
IBM Gl b l B i S i
-
7/16/2019 Day1-ABAP BW Handbook
24/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1324
Joining two Internal Tables
In most of the cases we shall encounter , we have to match two internal tables. The best method to do is looping through one and reading the other .The
main algorithm will be
Sort IT_TABLE2
Loop at IT_TABLE1 into WA_TABLE1.
read IT_TABLE2 into wa_table2 with key
COL1 = WA_TABLE1-COL1
COL2 = WA_TABLE1-COL2
binary search.
if sy-subrc = 0.
endif.
Endloop.
IBM Gl b l B i S i
-
7/16/2019 Day1-ABAP BW Handbook
25/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1325
Selecting unique values from Internal Tables
This is also a frequent requirement where we eliminate repeating values froman internal table . The main sequence of commands are
Sort IT_TABLE1 by COL1 COL2.
Delete adjacent duplicates from IT_TABLE1 comparing COL1 COL2.
IBM Global B siness Ser ices
-
7/16/2019 Day1-ABAP BW Handbook
26/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1326
Append
This statement is used to add rows to an internal table . The most common
format of this statement is .
append to .
However we can also use the variant
APPEND to SORTED BY < a field of itab>.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
27/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1327
Form/Perform
PERFORM command is used to call an ABAP subroutine (FORM) from any
program, subject to the normal ABAP runtime authorization checking. They canbe used to call subroutines for carrying out calculations, for obtaining data fromthe database that is needed at display or print time, for formatting data, and so on.
PERFORM commands are executed when a document is formatted for display orprinting.
The ABAP subroutine called via the command line stated above must be defined inthe ABAP report program as follows:
FORM TABLES IN_TAB STRUCTURE ITCSYOUT_TAB STRUCTURE ITCSY.
...
ENDFORM.The internal table OUT_TAB contains names and values of the CHANGING
parameters in the PERFORM statement. These parameters are local textsymbols, that is, character fields.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
28/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1328
AT Statement
The AT statement introduces a statement block that end with theENDAT statement. For Example, basic building block is
AT level.
ENDAT.
Probable control level changes are:
Level Meaning
FIRST First line of the internal table
LAST Last line of the internal table
NEW f Beginning of a group of lines with the same contents in the field f and in the fields left of f
END Of f End of a group of lines with the same contents in the field f and in the fields left of f
AT NEW f | AT END OF f.
...
ENDAT.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
29/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1329
COLLECT, CONCATENATE, CONDENSE NO-GAPS
Collect statement inserts the contents of a work area either as single row intoan internal table or adds the values of its numeric components to thecorresponding values of existing rows with the same key.
COLLECT INTO IT_TABLE [Result].
Concatenate: The contents of the data objects dobj1, dobj2, ... are
concatenated according to their sequence and assigned to the result fieldresult. If you use the SEPARATED BY addition, the content of the data objectsep is inserted between the contents of the consecutive data objects dobj1,dobj2 ....
CONCATENATE dobj1 dobj2 ... INTO result [SEPARATED BY sep].
Condense: In the variable text, leading and closing blanks are completelyremoved and any other directly consecutive blanks are all replaced by exactlyone space character or - if NO GAPS is specified - are also removedcompletely.
CONDENSE text [NO-GAPS].
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
30/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1330
Good Coding Practices/Simple performance parameters
1) After all select and read statements check the value of sy-subrc.2) Put the selection fields in the same order as that in the table.
3) Use comments whenever it can augment the code , do not use it too much as it
might hamper the readability of the code . Comments can be given by using the
symbol * at the beginning of a line or a half-line comment can be given using .
4) Use Types and data: .. type standard table of whenever applicable.5) Whenever business rules permit, try to use an internal table which has unique rows
for the FOR ALL ENTRIES criteria.
6) Avoid repetitive database hits/statements i.e. avoid SELECT statements in a loop,
SORT statements within a loop.
7) Avoid LOOP within a LOOP.
8) Try to use BINARY SEARCH whenever possible. Dont forget to sort before that.
9) Avoid repetitive sorting of an internal table in different parts of a single code.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
31/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1331
Self Help
For the topics not covered in this introduction, participant scan visit theTCODE ABAPDOCU. This is the ABAP document by SAP. It features
explanations on the different ABAP Keywords along with search option and
sample codes.
Another feature provided by SAP is that when the user browses throughsome previously written code he/she can press F1 on any particular keyword
and the SAP compiler shows the documentation on the keyword which is
maintained in the system.
Other self help options on the internet are
1) http://help.sap.com/
2) https://www.sdn.sap.com/irj/sdn
-
7/16/2019 Day1-ABAP BW Handbook
32/64
Copyright IBM Corporation 2007
IBM Global Business Services
April 08ABAP Handbook for BW Developer
Working with Function Modules, Function Groups andExecutable Programs
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
33/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1333
Function Group
Function groups are containers for function modules.
This contains three main programs TOP UXX FXX
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
34/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1334
Creating a FM
A Function module is an ABAP Program which takes some values as Input andgives some values as Output . The transaction where we create FMs is SM37.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
35/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1335
Example of a Function Module
Let us consider a function module Z_GET_POSITION_MGR_DETAILS / OrUse any Function Module . We will look at the various parameters for this
Module.
Input Parameters
Output Parameters
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
36/64
IBM Global Business Services
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1336
Example of a Function Module
Execution of a FM
The highlighted button is used for
execution.
Execution screen
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
37/64
G oba us ess Se ces
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1337
Executable Program Using SE38
After going to the TCode
Following settings are needed to
make an Executable Program.
After clicking on save , the nextscreen allows the user to input
the code.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
38/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1338
Program types SE38
Serial No. Types Discussions on Type
1 Executable Programs
An invisible system program takes care of all the executable programs. The system program calls
processing blocks in the program in a pre-defined order. It displays the selection screen at the
beginning of the program and outputs a list at the end. Executable programs allow you to work
with logical databases.
2
Module Pools for Screen Painter
Screens
Contain processing steps for screen modules from the transaction and can only be executed with a
transaction code or a menu function.
3 Includes
Contain program code that cannot be run of its own. You call them from another program using
INCLUDE statements.
4 Subroutines
Contain parts of programs (FORM routines) that can be called using external PERFORM
statements.
5 Function Groups
Contain function modules. Function groups and function modules are managed in the Function
Builder. Program type F is set by the Function Builder, and cannot be changed in the program
attributes.
6 Interface Pools
Contain interfaces. Classes and interfaces are managed (administered) in the Class Builder;
program type J cannot be changed in the attributes. Class Pools (K) Contain interfaces. Classes
and interfaces are managed (administered) in the Class Builder; program type K cannot be
changed in the attributes
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
39/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1339
Controls on SE38
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
40/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1340
SE80
SE80 is the object navigator for SAP. Through this we can actually build andcustomize different objects in SAP. Following are the features available in SE80.
MIME Repository Displays all directories with MIME objects that were imported into the current system. The
Public folder is always output. A selection of BSP applications is also given.
Repository Browser This browser is initially used when you start SE80.
It outputs Repository objects in the form of object lists. The objects are selected by
category (packages, programs, classes, local objects, etc.)
Repository Information System Displays all the objects of the information system without pre-selection.
Tag Library Displays tags for Web applications. You can limit the list to the relevant tag in ITS-basedapplications or in BSP applications by pre-selection.
Transport Organizer Outputs Transport Organizer requests in the current system.
-
7/16/2019 Day1-ABAP BW Handbook
41/64
Copyright IBM Corporation 2007
IBM Global Business Services
April 08ABAP Handbook for BW Developer
Working with ABAP Dictionary Objects
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
42/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1342
Database tables
Different Parts of a DB Table are
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
43/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1343
SE11
One can view and browse through all delivered and custom dictionary objects in SE11
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
44/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1344
View
There are mainly four types of view
1) Database View Maintained in SE11
2) Help View Maintained in SE54
3) Projection View
4) Maintenance view Maintained in SE54
The most commonly used view in BW is the Database View.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
45/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1345
Data Element
A data element describes either an elementary type or a reference type.
An elementary type is defined by the built-in data type, length and possibly the number of
decimal places. These type attributes can either be defined directly in the data element orcopied from a domain.
A reference type defines the types of reference variables in ABAP programs.
Domain
A domain describes the technical attributes of a field, such as the data type or the number ofpositions in a field. The domain defines primarily a value range describing the valid data
values for the fields referring to this domain.
Different technical fields of the same type can be combined in a domain. Fields referring to
the same domain are changed at the same time when a domain is changed. This ensures
the consistency of these fields.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
46/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1346
SE16
This is the data browser . It is very simple in operation . We just need to supply the tablename from where we need to examine the contents.
We can also select fields from the table and the selection parameters by our
convenience.
-
7/16/2019 Day1-ABAP BW Handbook
47/64
Copyright IBM Corporation 2007
IBM Global Business Services
April 08ABAP Handbook for BW Developer
ABAP on the R/3 Side
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
48/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 134848
Transaction Code CMOD
CMOD is used to write enhancement logic for business specific development purpose
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
49/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 134949
Developer has to create a project and assign RSAP0001 to this project to write
custom enhancement logic.
Projects in CMOD
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
50/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 135050
To enhance a data source, you have to code for populating the enhanced fields indifferent CMOD exits. Data source can be of four types, Transactional, Master Data
Attributes, Master Data Texts and Master Data Hierarchy.
Write your code at corresponding Exits.
Components of a Project in CMOD
Data Source CMOD Exit
Transactional data EXIT_SAPLRSAP_001
Master Data Attribute EXIT_SAPLRSAP_002
Master Data Text EXIT_SAPLRSAP_003
Master Data Hierarchy EXIT_SAPLRSAP_004
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
51/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1351
EXIT_SAPLRSAP_001:
Writing Enhancement Code in CMOD
This is a Function Module where you can write your code clicking on the INCLUDEZXRSAU01. The ABAP editor looks like
Syntax Check: Ctrl+F2
Activation: Ctrl+F3
OR
Use Buttons on the Editing Screen
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
52/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1352
Used to Install and Activate Delivered Data Sources
Transaction Code RSA5
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
53/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1353
Transaction Code RSA6
Transaction Code RSA6 is used to view, edit and enhance Data Sources in
R/3 side.
It contains the total tree structure of SAP delivered or Custom Data Sources
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
54/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1354
Why do we need Custom exits ?
As part of its business content, SAP delivers several standard extractors in SAP sourcesystems. These extractors, when implemented as part of the process of installing
DataSources from business content, enable you to extract data from your desired
application.
Often, users need to enhance these standard extractors to meet the specific needs of their
business or the application area. The process is well documented.
To quickly recap: In the source system, you activate your DataSource, analyze it, and find
that you need to enhance it. You edit the DataSource via transaction RSA6 where you
add (using an append structure) the fields you feel are missing from SAPs standard
extract structure. You populate these fields using SAP user exit RSAP0001.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
55/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1355
Enhancement of Data Sources in RSA6
Place cursor on the Data Source to enhance finding it in the Tree and click on
Enhance Extraction Structure button. Here we enhance 0CO_PC_01
It will automatically create a append structure
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
56/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1356
Give proper Field Name (ZZ_AUART, ZZ_VAPLZ) and Data Element (AUFART,
GEWRK) to create the new structure along with the Short Text (Order Type and WorkCenter Enhancement) for the append Structure
Developing the Append Structure
Check & Activate the Append Structure and go back to activate the total extract
structure for the data source.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
57/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1357
Selection, Hide, Inversion, Field Only
Selection: Set this indicator to use a field from the Data Source as the selection field in
the Scheduler for BW.Due to the properties of the Data Source, not every field can be used as a
selection field. In this case, this property is not changeable.
Hide: To exclude a field in the extraction structure from the data transfer, set this
flag. The field is then no longer available in BW for determining transfer rules
and therefore cannot be used for generating transfer structures.
Inversion: The field is inverted in the case of reverse posting i.e. it is multiplied by (- 1).
For this, the extractor has to support a delta record transfer process, in which
the reverse posting is identified.
Field Only:The indicator Field known only in Exit is set for the fields in an append
structure, then by default, these fields are not passed to the
extractor in the field list and the selection table.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
58/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1358
Coding in CMOD
Important Internal Tables/ Fields in EXIT_SAPLRSAP_001:
C_T_DATA
I_T_SELECT
I_DATASOURCE
Pseudo Code For Enhancement:
IF I_Datasource = .
Assign c_t_data [] to another internal table < internal table 1> for manipulation.
Pick relevant data with select statement from data base table into < internal table 2>.
Looping at
READ TABLE < internal table 2> WITH KEY < joining key fields>.
When match occurs.Assign field values in corresponding fields of
< Internal table 1 >
ENDLOOP.
Return < Internal table 1 > data to c_t_data [].
ENDIF.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
59/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1359
Overview of ABAP Keyword: Statics
When an info package runs in BW taking packet wise data from R/3 side. Situation can
occur that any variable should persist for the following packet when the previous one istransferred to BW.
Also to minimize database hit developer may have to cut short the selection condition
in Select statement. In such a scenario, static table or variable may help you to
increase the performance of extraction.
Declaration:
STATICS: BEGIN OF itab OCCURS 0,
Field1 LIKE -,
Field2 LIKE -,
END OF itab.
To declare a variable of static type:STATICS: l_var (4) type c.
You can also declare the same using TYPE instead of LIKE while declaring a static
table.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
60/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1360
Transaction Code RSA3 (Extractor Checker)
RSA3 can be used to check values for the Enhanced Extracted Fields.
Data Records/ Calls: It determines the packet size for extraction in checker.
Display Extr. Calls: It determines the packet size for displaying the result after extraction.
Debug Mode can be used to get into the backend coding.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
61/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1361
Debugging Using Break Point
Keyword: Break-point.
Hard Break Point: Permanent break point mentioned in code
Soft Break Point: In Debug mode, double click on a statement to put a temporary one.
Red button on the editor introduce a soft break point.
When you run the data source in the extractor checker, the program control stops at the
hard break point in the code.
You can have a look at different variables, table contents in the debugger screen and
check whether you are getting the expected result.
You can also give soft break point to the statement you feel erroneous, and go to itdirectly without stopping at previous steps.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
62/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1362
Use of Function Module in CMOD Exit
To use a function module in CMOD, click on Pattern at the top of the ABAP
editor. A pop up will come asking you the name of FM you want to use. Whenyou enter the name of FM, and click on OK a new pattern will be automatically
introduced at the cursor position in ABAP editor.
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
63/64
Copyright IBM Corporation 2007ABAP Handbook for BW Developer | May 1363
FM Pseudo Code in CMOD Exit
CALL FUNCTION < FM Name>
EXPORTING
=
=
=
IMPORTING =
=
=
CHANGING
=
=
= .
CMOD Editor Code For FM Looks Like
IBM Global Business Services
-
7/16/2019 Day1-ABAP BW Handbook
64/64
Summary
A quick recap of the topics covered so far
Overview of ABAP language
Working with Function Modules ,Function Groups, FM and Executable
Programs.
ABAP Dictionary Objects
Use Of ABAP in R/3 Side (BW Specific Requirements).