You are on page 1of 64

IBM Global Business Services

ABAP In BW Enhancements [Day 1]

ABAP Handbook for BW Developer

April 08

Copyright IBM Corporation 2007

IBM Global Business Services

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

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Overview of ABAP Language

ABAP Handbook for BW Developer

April 08

Copyright IBM Corporation 2007

IBM Global Business Services

Some basics about ABAP


The ABAP Editor (SE80) is used to create, maintain, and execute ABAP programs.

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.

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Data Declaration
The data declaration is done mainly through 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.

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Data Declaration (Contd.)


The normal method of declaring variables is DATA:L_VARIABLE(length) TYPE <data 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 <data type>.

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Data Declaration (Contd.)


When we want to deal with data within a specific interval , we use RANGE in ABAP.To declare 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 DSO ZCOPCO08.While using range we have to see that after the FOR clause , we have to use a flat structure. The structure of the Range table is .

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Types of Database Tables


Transparent Table : Exists with the same structure both in dictionary as well as in database exactly with the same data and fields. E.g. CDHDR Pooled Table : Pooled tables are logical tables that must be assigned to a table 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 of these 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 a table cluster when they are defined. Cluster tables can be used to store control data. They can also be used to store temporary data or texts, such as documentation. E.g. CDPOS

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Types of SELECT Statement


1. Select-Endselect. This is the Basic and the most rudimentary form of a select
statement .

2. Select single <value>. We can also select a single value from a database
table.

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 <variable>. We can store the results of a select statement in


locally declared variables.

5. Select into table <internal table>. We can select data from a database
table into an internal table .

6. Select into Corresponding Fields of <table> . If the data fields name of


an internal table are same we can use this statement .Then we do not have to take into account the sequence of the internal table.

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

System Variables
SY-SUBRC

0 The execution of the select statement is success and output is not initial. 4 The execution of the select statement is success and output is initial. 8 The execution of the select statement is not successful. This is applicable for
dynamic 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.

10

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Joins between database tables


Consider the two database tables as shown below.
Bill. No 1 2 3 Co. Name ABC ABC DEF Date 1-Jan-08 1-Feb-08 1-Mar-08 Bill No 1 Item Sold PAPER Price 2/-

1
1 2

PEN
PEN PENCIL ERASER

1/1/1/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.

11

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

WRITE Statement
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 line
on the Output Screen

This Character denotes TAB. All portions after this is written after a TAB in the Output Screen.

12

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Decision Making 1 - IF Statement

IF-ENDIF. Basic Variant of a IF Statement . If <condition is true> <execute


statement 1,2,3> . ENDIF.

IF-ELSE-ENDIF. If <Condition1 is True>. <execute statements 1,2,3>. ELSE.


<execute statements 4,5>. ENDIF.

IF-ELSEIF-ENDIF. If <Condition1 is True>. <execute statements 1,2,3>. ELSEIF


<Condition2 is True>. <execute statements 4,5,6>.ENDIF.

With the Innovative combinations of this statement we can give shape to most of the situations which we can predict to face.

13

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Basic Exercise using the SELECT and SY-SUBRC

CHASSIS NO.
MAR001

MODEL
MAR

DESCRIP
MARUTI 800

YEAR OF MANUFAC
2000

COLOUR
RED

OWNER
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

14

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Decision Making 2 - CASE Statement


CASE-WHEN-ENDCASE. CASE <Variable>.WHEN Value 1. <executable
statement>. WHEN Value 2. <executable statement>. 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.

15

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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 <condition> . <executable statement>. 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.

16

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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.

17

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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 Table

DATA: spfli_tab TYPE HASHED TABLE OF spfli WITH UNIQUE KEY carrid connid,

18

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Header Line / Work Area/Initial Size


Header Line Data: 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.

19

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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.

20

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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.
21 ABAP Handbook for BW Developer | May 13
Copyright IBM Corporation 2007

IBM Global Business Services

Joins between database table and internal table


Consider the two tables we have seen earlier , SALESHDR is an internal table and SALESDTL is a Database table
Bill. No 1 2 3 Co. Name ABC ABC DEF Date 1-Jan-08 1-Feb-08 1-Mar-08 Bill No 1 1 1 2 Item Sold PAPER PEN PEN PENCIL ERASER Price 2/1/1/1/1/-

SALESHDR

SALESDTL

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.
22 ABAP Handbook for BW Developer | May 13
Copyright IBM Corporation 2007

IBM Global Business Services

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.

23

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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. <required logic> endif. Endloop.
24 ABAP Handbook for BW Developer | May 13
Copyright IBM Corporation 2007

IBM Global Business Services

Selecting unique values from Internal Tables


This is also a frequent requirement where we eliminate repeating values from an internal table . The main sequence of commands are Sort IT_TABLE1 by COL1 COL2. Delete adjacent duplicates from IT_TABLE1 comparing COL1 COL2.

25

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Append

This statement is used to add rows to an internal table . The most common format of this statement is . append <workarea> to <internal table itab>. However we can also use the variant APPEND <workarea> to <internal table itab> SORTED BY < a field of itab>.

26

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Form/Perform
PERFORM command is used to call an ABAP subroutine (FORM) from any program, subject to the normal ABAP runtime authorization checking. They can be used to call subroutines for carrying out calculations, for obtaining data from the 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 or printing. The ABAP subroutine called via the command line stated above must be defined in the ABAP report program as follows: FORM <form> TABLES IN_TAB STRUCTURE ITCSY OUT_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 text symbols, that is, character fields.

27

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

AT Statement
The AT statement introduces a statement block that end with the

ENDAT statement. For Example, basic building block is


AT level. <statement block> ENDAT.

Probable control level changes are:


Level Meaning

FIRST
LAST NEW f END Of f

First line of the internal table


Last line of the internal table Beginning of a group of lines with the same contents in the field f and in the fields left 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.

28

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

COLLECT, CONCATENATE, CONDENSE NO-GAPS


Collect statement inserts the contents of a work area either as single row into an internal table or adds the values of its numeric components to the corresponding values of existing rows with the same key. COLLECT <Work Area> INTO IT_TABLE [Result]. Concatenate: The contents of the data objects dobj1, dobj2, ... are concatenated according to their sequence and assigned to the result field result. If you use the SEPARATED BY addition, the content of the data object sep 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 completely removed and any other directly consecutive blanks are all replaced by exactly one space character or - if NO GAPS is specified - are also removed completely. CONDENSE text [NO-GAPS].
29 ABAP Handbook for BW Developer | May 13
Copyright IBM Corporation 2007

IBM Global Business Services

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.

30

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Self Help
For the topics not covered in this introduction, participant scan visit the TCODE 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 through some 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

31

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Working with Function Modules, Function Groups and Executable Programs

ABAP Handbook for BW Developer

April 08

Copyright IBM Corporation 2007

IBM Global Business Services

Function Group
Function groups are containers for function modules.

This contains three main programs TOP UXX FXX

33

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Creating a FM
A Function module is an ABAP Program which takes some values as Input and gives some values as Output . The transaction where we create FMs is SM37.

34

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Example of a Function Module


Let us consider a function module Z_GET_POSITION_MGR_DETAILS / Or Use any Function Module . We will look at the various parameters for this Module.

Input Parameters

Output Parameters

35

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Example of a Function Module


Execution of a FM

The highlighted button is used for execution.

Execution screen

36

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Executable Program Using SE38


After going to the TCode Following settings are needed to make an Executable Program.

After clicking on save , the next screen allows the user to input the code.

37

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Program types SE38


Serial No. Types Discussions on Type

Executable Programs Module Pools for Screen Painter Screens

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. Contain processing steps for screen modules from the transaction and can only be executed with a transaction code or a menu function. Contain program code that cannot be run of its own. You call them from another program using INCLUDE statements. Contain parts of programs (FORM routines) that can be called using external PERFORM statements. 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.

3 4

Includes Subroutines

Function Groups

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

38

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Controls on SE38

39

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

SE80
SE80 is the object navigator for SAP. Through this we can actually build and customize 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-based applications or in BSP applications by pre-selection.

Transport Organizer

Outputs Transport Organizer requests in the current system.

40

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Working with ABAP Dictionary Objects

ABAP Handbook for BW Developer

April 08

Copyright IBM Corporation 2007

IBM Global Business Services

Database tables
Different Parts of a DB Table are

42

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

SE11
One can view and browse through all delivered and custom dictionary objects in SE11

43

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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.

44

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Domain
A domain describes the technical attributes of a field, such as the data type or the number of positions 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.

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 or copied from a domain. A reference type defines the types of reference variables in ABAP programs.

45

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

SE16
This is the data browser . It is very simple in operation . We just need to supply the table name from where we need to examine the contents. We can also select fields from the table and the selection parameters by our convenience.

46

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

ABAP on the R/3 Side

ABAP Handbook for BW Developer

April 08

Copyright IBM Corporation 2007

IBM Global Business Services

Transaction Code CMOD


CMOD is used to write enhancement logic for business specific development purpose

48 48

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Projects in CMOD
Developer has to create a project and assign RSAP0001 to this project to write
custom enhancement logic.

49 49

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Components of a Project in CMOD

To enhance a data source, you have to code for populating the enhanced fields in different 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.
Data Source CMOD Exit

Transactional data Master Data Attribute

EXIT_SAPLRSAP_001 EXIT_SAPLRSAP_002

Master Data Text Master Data Hierarchy

EXIT_SAPLRSAP_003 EXIT_SAPLRSAP_004

50 50

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Writing Enhancement Code in CMOD


EXIT_SAPLRSAP_001:

This is a Function Module where you can write your code clicking on the INCLUDE ZXRSAU01. The ABAP editor looks like
Syntax Check: Ctrl+F2 Activation: Ctrl+F3 OR Use Buttons on the Editing Screen

51

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Transaction Code RSA5


Used to Install and Activate Delivered Data Sources

52

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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

53

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Why do we need Custom exits ?


As part of its business content, SAP delivers several standard extractors in SAP source systems. 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.

54

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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

55

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

Developing the Append Structure


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 Work Center Enhancement) for the append Structure

Check & Activate the Append Structure and go back to activate the total extract structure for the data source.

56

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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

Hide:

structure, then by default, these fields are not passed to the


extractor in the field list and the selection table.

57

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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 = <data source name>. 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 <internal table 1> READ TABLE < internal table 2> WITH KEY < joining key fields>. When match occurs. Assign <internal table 2 > field values in corresponding fields of < Internal table 1 > ENDLOOP. Return < Internal table 1 > data to c_t_data []. ENDIF.
58 ABAP Handbook for BW Developer | May 13
Copyright IBM Corporation 2007

IBM Global Business Services

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 is transferred 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 <DATABASE_TABLE_1>-<FIELD_NAME_1>, Field2 LIKE <DATABASE_TABLE_2>-<FIELD_NAME_2>, 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.

59

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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.

60

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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 it

directly without stopping at previous steps.

61

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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. When you enter the name of FM, and click on OK a new pattern will be automatically introduced at the cursor position in ABAP editor.

62

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

FM Pseudo Code in CMOD Exit


CALL FUNCTION < FM Name> EXPORTING <Field 1> = <Field 2> = <Field n> = IMPORTING <Field 1> = <Field 2> = <Field n> = CHANGING <Field 1> = <Field 2> = <Field n> =.

CMOD Editor Code For FM Looks Like

63

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

IBM Global Business Services

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

64

ABAP Handbook for BW Developer | May 13

Copyright IBM Corporation 2007

You might also like