Professional Documents
Culture Documents
Sap R/3 Abap/4 Training Manual: 5101 Camden Lane, Pearland, TX 77584
Sap R/3 Abap/4 Training Manual: 5101 Camden Lane, Pearland, TX 77584
com
www.LearnSAP.com
Course Outline
Section A
1. Introduction to ABAP
1.1. What is SAP R/3
1.2. SAP R/3 architecture and where ABAP fits in
2. ABAP Development Workbench Tools
2.1. Object Navigator
2.2. Workbench Organizer
2.3. Data Dictionary
2.4. Menu Painter
2.5. Screen Painter
Section B
3. Reports Statement
3.1. Line Size
3.2. Line-count
3.3. Message
3.4. Page Heading
3.5. Report Comment Section
4. Declarations
4.1. Tables
4.2. Includes
4.3. Variables (Data Types and Data Objects)
4.4. Structures
4.5. Internal Tables
4.6. Constants
5. Selection Screen / Input Fields
5.1. Parameters
5.2. Select Options
5.3. Section Screen Formatting
6. Program Events
6.1. Initialization
6.2. Start of Selection and End of Selection
6.3. At Selection Screen
6.4. At Line Selection
6.5. At User Command
7. Data Retrieval
7.1. Select Statement
7.2. Using the Select Statement for Single Line
7.3. Using the Select Statement for Several Lines
7.4. Using the Select Statement for Internal Table
7.5. Tables / Internal Table Operations
8. Processing Data
8.1. Assignment Statements
8.2. Arithmetic Expressions and Mathematical Functions
8.3. String Processing
8.4. Type Conversions
8.5. Logical Expressions
www.LearnSAP.com
8.6. Control Level Processing
8.7. Subroutines
8.8. Function Modules
8.9. Logical Database
8.10.
Variants
8.11.
Create Transactions for Reports
9. Formatting and Displaying Data
9.1. Event for Page Headers and Footers
9.2. Display Options
Section C
10.
Types of Program Analysis
10.1.
Static Checks
10.2.
Dynamic Checks and Short Dump Analysis
11.
Debugger
11.1.
Breakpoints in Programs
11.2.
Breakpoints in the Debugger
11.3.
Watchpoints
12.
Performance Tools
12.1.
Runtime Errors
12.2.
SQL Trace
Section D
13.
External Data Access
13.1.
Upload and download data from / to presentation server
13.2.
Upload and download data from / to application server
13.3.
Write a data extract program
14.
Section E
15.
Dialog Application
15.1.
Create a Module Pool
15.2.
Create a Transaction
16.
Screen Painter
16.1.
Use Screen painter to design a Screen
16.2.
Arrange Data Dictionary elements of the screen
16.3.
Set the OK-CODE
17.
Menu Painter
17.1.
Create GUI Status
17.2.
Create a Menu Bar for a Screen
www.LearnSAP.com
17.3.
17.4.
17.5.
18.
Section F
19.
ABAP Query
19.1.
Understand core functionality of SAP R/3 ABAP Query.
19.2.
Explain the relationship between a user group, info set and query report.
19.3.
Utilize the appropriate user groups and Info Sets to develop Queries.
19.4.
Create all three types of SAP query. Basic List, Statistic and ranked list.
www.LearnSAP.com
Section A
ABAP Workbench Overview
Objectives
Understand the use of ABAP/4 in developing SAP Application
Become familiar with the ABAP Workbench Tools
Become Familiar with the features of
Object Navigator
ABAP Editor
Change and Transport System
Data Dictionary
Menu Painter
Screen Painter
Table of Contents
Section A
1. Introduction to ABAP
1.1. What is SAP R/3?
1.2. SAP R/3 Architecture and where ABAP fits in
1.3. The Major Common Uses of ABAP/4
2. ABAP Development Workbench Tools
2.1. Object Navigator
Exercise A211 Create an ABAP Program using the Object Navigator
2.2. ABAP Editor
2.2.1. Editor Mode
2.2.2. Uploading and Downloading Source Code
2.2.3. ABAP/4 Attributes Screen
2.3. Change and Transport System
2.3.1. Development Class
Exercise A2311 Create a Development Class
2.3.2. Transport / Workbench Organizer
Exercise A2321 Assign Program to development class and display T.O.
www.LearnSAP.com
www.LearnSAP.com
1. Introduction to ABAP
1.1 What is SAP R/3?
SAP stands for Systems, Applications and Products in Data Processing. It is the name of the
company and also the name of the software. R/3 stands for Runtime System Three. It is one of
the ERP (Enterprise Resource Planning) systems around. Similar products are Oracle and
Peoplesoft. ERP is used by companies to plan, organize, integrate and manage their various
operations like accounting, finance, manufacturing and human resources. The main aim is to
improve efficiency and accuracy.
1.2 SAP R/3 Architecture and
Where ABAP fits in
R/3 is based on client/server
architecture and uses a
relational database to track all
information related to a
company. It is made up of small
programs called transactions. A
transaction is a program and set
of system; and change
functionality in the R/3 system.
R/3 gathers related transactions
together into groups and call
them modules. Thus a module
is a set of transactions that deal
with the same area of business
functionality. R/3 modeled in a
three-tier hierarchy is shown
below.
www.LearnSAP.com
does not have any input fields. In our example, it would contain a list of the sales that
occurred within the specified date range. The selection screen is optional. Not all reports
have one. However, all reports generate a list.
b. Interface a program that moves data into SAP BDC, Call Transaction or reads data
from SAP and writes it to a system file to be transferred to an external computer system
e.g. a legacy mainframe DATA EXTRACT
c. Custom Transaction a program similar to SAP transactions to fulfill some business
function not provided by SAP Dialog Programming.
2. ABAP Development Workbench Tools
The most important tools are:
a. ABAP Editor for writing and editing program code.
b. ABAP Dictionary for editing tables and other ABAP Dictionary Objects.
c. Menu Painter for designing the user interface (menu bar, standard toolbar, application
toolbar)
d. Screen Painter for designing screens for user dialogs
e. Function Builder for programming function modules (subroutines with a fixed interface
that are available system wide)
All development objects created with the development tools found in the ABAP Workbench are
classified as Repository Objects and are stored centrally in the R/3 Repository.
The R/3 Repository is a special part of the SAP systems central database. The Repository is
organized according to application. Each application is further divided into logical subdivisions
called development classes.
Repository objects are often made up of sub-objects that are themselves Repository objects.
Each Repository object must be assigned a development class when it is created.
ABAP Programming Syntax
Whichever type of program, ABAP syntax includes the following:
Naming Standards
The company you work for is a customer of SAP. Therefore, programs that you create at your
company are called customer programs. For programs, the customer name range is two to forty
characters long and the program name must start with the letter Y or Z. SAP reserves the letters
A through X for their own programs.
2.1 Object Navigator
The object navigator is also called in previous releases Object Browser (Rel 3x), Repository
Browser (Rel 4.x)
Object Navigator automatically calls other tools when actions require them. For example, creating
a new program from the Object Navigator screen. The Object Navigator calls the ABAP Editor
and, after creating the program, returns back to the Object Navigator screen.
An entire application can be created using the Object Navigator without directly calling any of the
other tools. In fact, the recommended method for creating an application is from the Object
www.LearnSAP.com
Navigator because you can see what you build. The Object navigator provides an overview of all
the elements in an application and access to all necessary administration tools from one single
interface.
www.LearnSAP.com
Object Navigator can be accessed in 2 ways.
Menu Path:
SAP Main Screen > Tools > ABAP Workbench > Overview > Object Navigator (Double Click)
Another way to reach the Object Navigator is to from the SAP Main Screen enter the transaction
SE80 into the transaction field and press Enter
Either way the Object Navigator is displayed. There are two input fields on this screen.
Object List Group This contains a list of the objects contained within this environment: Local
Objects, Application Hierarchy Program, Development Class, Function Group, Class/Interface,
Internet Service. Select Local Objects in this field.
www.LearnSAP.com
If you select the down-arrow key in the second input field, object group selected in the first field
the Display input field.
will be displayed. Click on
If the program already exists, it will be display under the object list. If it doesnt exist, a dialog box
pops open, click the YES pushbutton for SAP to create the program.
www.LearnSAP.com
As soon as you click on YES another dialog box pops open querying about the program structure
either as an individual file or a framework program for includes. Large programs can be split up
into several sub programs (includes).
Enter to continue
If this is the first time ever you are creating an ABAP program, another dialog window will pop
open requesting you to enter the Access Key so this user can be added as a Developer. Enter
your 20 Character access key here and click on continue. ( Note: this dialog only pops up once. )
www.LearnSAP.com
A new template pops up where you will define the important attributes of the new application.
There are three important fields that must be maintained. And these are;
Title: Short description of the program. The program name comes up as default in this field. You
can add more text to it. For example Khans First ABAP Program
Program Type: Chose Executable program. Reports are usually this type.
Application: Which the program will be assigned to. Select Cross-application.
Other fields are optional: status, authorization groups, logical database. After entering all the
values, click on
SAVE.
When you save a new object for the first time, the system displays a correction and transport
dialog box. Here the Development Class field needs to be maintained. See section 2.2.5 and
section 2.2.4 on Workbench. For now click the local object pushbutton.
www.LearnSAP.com
You will be returned to the opening screen of the object navigator. Go to the course code screen
by double clicking on the object name.
Source code appears in display mode with just one line of code report and report name. To
switch from display mode to change mode click on the pencil mark
Place cursor after the period at the end of first sentence and press enter to get you to the next
line. Type WRITE Hello World!.
www.LearnSAP.com
Activate the program by going to Programs > Activate
Press F8 or
www.LearnSAP.com
A list is produced. To go back to the editor from the report output window, click on the back arrow
or F3 function key.
www.LearnSAP.com
ABAP/4 programs consist of five components
1.
2.
3.
4.
5.
Source Code
Attributes
Text Elements
Documentation
Variants
Only the source code and program attributes components are required. The rest of the
components are optional, they will be looked at in another section.
All development objects and their components are stored in the R/3 Database. ABAP/4 programs
are interpreted; they are not compiled. The first time you execute a program, the system
automatically generates a runtime object. The runtime object is a pre-processed for of the source
code. However, it is not an executable that you can run at the operating system level. Instead, it
requires the R/3 system to interpret it. The runtime object is also known as the generated form of
the program. If you change the source code, the runtime object is automatically regenerated the
time you execute the program.
2.2.1 Editor Mode
The ABAP Editor has two different modes:
1. Front-end Editor
2. Back-end Editor
Front-end Editor
The front-end editor uses the SAP Textedit Control from the SAP Control Framework. It loads
your source code onto the front-end and allows you to perform many tasks without any
communication with the application server.
In the front-end editor, the ABAP source code is loaded onto the front-end and edited locally. The
advantage of this is that all editing functions that do not require communication with the backend
can be performed very quickly.
Back-end Editor
The back-end editor allows you to use the traditional back-end editor for editing your ABAP code.
The editor is line-based, and to use normal editor functions such as cut, copy and paste, you
must first select a block of lines. If is often useful to use the clipboards in this mode. If you have a
very long program (and specially if you are working in a WAN environment), the back-end editor
can produce better performance than the front-end editor. Furthermore, back-end editor allows
you to edit any development object that is based on the ABAP Editor.
You can change the mode from front-end to back-end by doing the following steps. To change
the editor mode from anywhere in the ABAP workbench: Chose utilities > settings.
www.LearnSAP.com
The User Specific Settings dialog box appears. Choose ABAP Editor. Set the editor mode to
back-end editor.
www.LearnSAP.com
5. Enter the path and filename of the file you want to read in the dialog box, then
choose copy.
www.LearnSAP.com
different, logically related parts. Each of these part is stored in different include program.
Include programs make your source code easier to read and maintain.
Status
This entry describes the status of the program development, for example, T for test program.
Application
This field contains the short form of your application, for example, F for Financial accounting. This
required entry enables the system to allocate the program to the correct business area.
Authorization Group
In this field, you can enter the name of a program group. This allows you to group different
programs together for authorization checks. The group name is a field of the two authorization
objects S_DEVELOP (program development and program execution) and S_PROGRAM
(program maintenance). Thus you can assign authorization to users according to program
groups. For more information about creating function modules, refer to the Users and
Authorization documentation.
Development Class
The development class is important for transports between systems. You combine all Workbench
objects assigned to one development class in one transportation request. If you are working in a
team you may have to assign your program to an existing development class, or you may be free
to create a new class section 2.3.1 on Workbench Organizer covers this. All programs assigned
to the development class $TMP are private objects and cannot be transported into other systems.
You can enter the development class directly into this field. Otherwise, the system prompts for it
when you save the attributes.
Choosing Local Objects is equivalent to entering $TMP in the field Development Class. You can
change the development class of a program later on by choosing Object Directory Entry from the
GOTO menu, click change, type in the desired development class.
Logical Database From Application
(Only for Executable Programs Reports)
These attributes determine the logical database used by the executable program (report) to read
data, and the application to which it belongs. Logical databases have unique names within their
application. However, system wide, you can have more than one logical database with the same
name. This is why you also need to specify the application. If you read data directly in your
program instead of using a logical database, you should enter an application, but leave the logical
database field empty.
Selection Screen Version
(Only for Executable Programs Reports)
If you do not specify a selection screen version, the system automatically creates a selection
screen based on the selection criteria of the logical database and the parameters and select
options statement in the program.
If you want to use a different selection screen, enter the number here (not 1000, since this is
reserved for the standard selection screen). The number must be smaller than 1000 and
correspond to an additional selection screen of the logical database. The possible values help
displays a list of available selection screens. You can also look in the selection include of the
logical database (Program DBxxxSEL, where xxx is the name of the logical database).