Professional Documents
Culture Documents
April 08
Overview
The first day will consist of the following broad level topics
April 08
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.
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.
L_AGE(3)
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.
5. Select into table <internal table>. We can select data from a database
table into an internal table .
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
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
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
With the Innovative combinations of this statement we can give shape to most of the situations which we can predict to face.
13
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
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
16
Internal Tables
Declaration
end of ty_first.
data: it_first type standard table of ty_first. This is the example of a table without header line.
17
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
Initial Size
Data: it_first type standard table of ty_first initial size 0.
19
20
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
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
25
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
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
AT Statement
The AT statement introduces a statement block that end with the
FIRST
LAST NEW f END Of f
28
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.
30
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
April 08
Function Group
Function groups are containers for function modules.
33
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
Input Parameters
Output Parameters
35
Execution screen
36
After clicking on save , the next screen allows the user to input the code.
37
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
Controls on SE38
39
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.)
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
40
April 08
Database tables
Different Parts of a DB Table are
42
SE11
One can view and browse through all delivered and custom dictionary objects in SE11
43
View
There are mainly four types of view
44
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
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
April 08
48 48
Projects in CMOD
Developer has to create a project and assign RSAP0001 to this project to write
custom enhancement logic.
49 49
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
EXIT_SAPLRSAP_001 EXIT_SAPLRSAP_002
EXIT_SAPLRSAP_003 EXIT_SAPLRSAP_004
50 50
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
52
R/3 side.
It contains the total tree structure of SAP delivered or Custom Data Sources
53
54
55
Check & Activate the Append Structure and go back to activate the total extract structure for the data source.
56
Hide:
57
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
You can also declare the same using TYPE instead of LIKE while declaring a static table.
59
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
When you run the data source in the extractor checker, the program control stops at the
61
62
63
Summary
A quick recap of the topics covered so far
64