SAP ABAP
(Basics to Advanced)
Basics of ABAP Programming
www.zarantech.com
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Disclaimer
• This presentation, including examples, images, and references are provided for
informational purposes only.
• Complying with all applicable copyrights laws is the responsibility of the user.
• Without limiting the rights under copyright, no part of this document may be
reproduced, stored or introduced into a retrieval system, or transmitted in any
form or by any means.
• Credits shall be given to the images taken from the open-source and cannot be
used for promotional activities.
© Copyright 2021, ZaranTech LLC. All rights reserved.
3 Agenda
• Lesson 1 - Developing a Simple ABAP Program
• Lesson 2 - Introducing ABAP Syntax
• Lesson 3 - Implementing a Simple Dialog
• Lesson 4 - Customizing the ABAP Editor
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Basics of ABAP Programming
Lesson 1 – Developing a Simple ABAP Program
• What is ABAP?
• Develop a simple ABAP program
4
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 What is ABAP?
5
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 SAP ABAP Programming
What is ABAP?
A dvanced
B usiness
A pplication
P rogramming
6
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 SAP ABAP Programming
What is ABAP?
• ABAP is a programming language created by SAP for
the development of application programs.
• SAP developers use ABAP to build the transactions
that comprise SAP R/3 applications.
• SAP customers use ABAP to add additional business
functionality (i.e., customize) the SAP R/3
applications.
7
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Developing a Simple ABAP Program
Basics of ABAP Programs and the ABAP Editor
• The best way to learn how to program in ABAP (or any
programming language) is to start writing code.
• The tool that ABAP developers work with most is called the
ABAP Editor.
• You can access the ABAP Editor by using transaction code
SE38.
8
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Developing a Simple ABAP Program
Basics of ABAP Programs and the ABAP Editor
To create and run your first ABAP program, you need to
understand the following:
• How to create a new program
• How to work with the Editor
• The most important Editor functions
• How to formulate a correct ABAP statement
9
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Developing a Simple ABAP Program
Creating Programs in the ABAP Editor
10
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Developing a Simple ABAP Program
Program Attributes
11
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Developing a Simple ABAP Program
The ABAP Editor
12
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Developing a Simple ABAP Program
Basic ABAP Syntax Rules
13
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Developing a Simple ABAP Program
Characteristics of ABAP Syntax
• ABAP programs consist of individual statements.
• The first word in a statement is called an ABAP keyword.
• Each statement ends with a period.
• Two words must be separated by a space.
• Statements can be indented.
• The ABAP runtime system does not differentiate between
upper and lowercase in keywords, additions, and operands.
14
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Developing a Simple ABAP Program
Key Functions in the ABAP Editor
15
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Developing a Simple ABAP Program
Key Functions in the ABAP Editor
• Save - Saves your code, but does not check the syntax for correctness or activate the
program. It is good practice to save your work regularly.
• Check Syntax - Checks that all syntax in your program is correct
• Activate - Activates the program. When you save a program, the system stores an inactive
version of the program in the Repository. Activating a program generates the runtime
object that is used when the program is executed.
• Direct Processing- Executes the program. As a developer, you need to know whether your
code behaves as expected. Use this function to test your program regularly.
16
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Basics of ABAP Programming
Lesson 2 – Introducing ABAP Syntax
• Describe ABAP syntax
• Add comments to code
• Consult keyword documentation
17
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Key Characteristics of ABAP Language
• Is typed
• Enables multi-lingual applications
• Enables SQL access
• Has been enhanced as an object-oriented language
• Is platform-independent
• Is upward-compatible
18
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Key Characteristics of ABAP Language
• ABAP is especially designed for dialog-based business applications.
• To support the type specific processing of data, different numeric and character-like
types are available.
• Using translatable text elements, you can develop multi-lingual applications.
• The Open SQL standard embedded in ABAP allows direct database access.
• ABAP Objects is the object-oriented enhancement of the ABAP language.
• ABAP syntax has the same meaning or function, regardless of the relational database
system and operating system for the application and presentation server.
• Applications implemented in ABAP will run in future releases. 19
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
ABAP Statements
• Start with a keyword
• End with a period (without exception)
• May contain additions and operands (depending
on the keyword used)
• Can span multiple lines
• Words must be separated by at least one space
20
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
What Goes Between the Keyword and the Period?
21
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Steps for Creating a Chained Statement
• Write the identical beginning part of the
statements (the keyword), followed by a colon.
• After the colon, list the end parts of the
statements (separated by commas).
• Blank spaces and line breaks are allowed before
and after the separators (colons, commas,
periods).
22
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Comments
• A comment is an explanation that is added to a program to help others understand the code.
• Comments are ignored when the program is generated. They are not executable statements.
23
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
There are two different types of comments in ABAP
• The * character at the start of a program line indicates that the entire line is a comment.
Therefore, the ABAP runtime system ignores the whole line.
• The " character, which can be entered at any position in the line, indicates that the remaining
content in the line is a comment.
• It is good practice to place whole line comments on the line above the statements that they
describe.
• End of line comments are most suitable for declarations, rather than executable statements.
24
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Learning More About ABAP Keywords
25
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
ABAP Keyword Documentation
There are two ways to open this documentation
• Place your cursor on the keyword that you want to learn about, then press F1. This opens the
documentation for that specific statement.
• Choose the (Help On) button.
The ABAP Keyword Documentation is an important tool for all ABAP developers.
Explore the documentation to familiarize yourself with the contents and learn how to quickly
research unfamiliar topics.
26
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Basics of ABAP Programming
Lesson 3 – Implementing a Simple Dialog
• Implement a simple dialog using the PARAMETERS
statement
27
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Simple Dialog with the PARAMETERS Statement
28
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Simple Dialog with the PARAMETERS Statement
• The PARAMETERS keyword defines an input field on
what is known as a Selection Screen.
• Every parameter you define in your ABAP program has
a single corresponding input field on the selection
screen.
• The selection screen also includes an Execute button
that the user chooses once he or she fills the supplied
input field (or fields).
29
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
The Parameter Keyword
30
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Selection Screen Works
• When the user enters a value and chooses Execute, the input value is transferred to this internal
variable.
• It can then can be used in further calculations or operations.
31
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Multiple Input Fields on a Selection Screen
• selection screens display the technical
names of input fields as their labels (for
example, pa_name and pa_age )
• You can replace these technical names
with more meaningful selection texts,
which can also be translated into other
languages
32
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Selection Screen Text
• To maintain selection texts from the
ABAP Editor, choose Goto→ Text
Elements → Selection Texts .
• To maintain translations for selection
texts, choose Goto→ Translation .
33
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Basics of ABAP Programming
Lesson 4 – Customizing the ABAP Editor
• Customize the ABAP Editor
34
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
ABAP Editor
35
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Choosing the ABAP Editor You Wish to Use
36
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
The New ABAP Editor
• The new ABAP Editor was
developed for SAP NetWeaver 7.0.
• It can be imported by a support
package for SAP NetWeaver
Application Server (AS) 6.40 and
SAP NetWeaver AS 6.20 (SP 18 or
SP 59)
37
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Selection Screen Text
• You can specify the display colors for different objects in the source code (such as
keywords, comments, and literals).
• You can choose the font and font size to be used for the source code.
• You can use code hints to increase the speed at which you write.
• The Editor provides code hints for ABAP keywords, and you can also choose to enable code
hints for variables.
38
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Pretty Printer
• Programs that are visually well presented are
faster and easier to read, understand, and
maintain.
• All versions of the ABAP Editor include a tool
called the Pretty Printer.
• This can be used (to a limited extent) to
format source code and make it easier to
comprehend.
39
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
The Pretty Printer are following Possibilities
• Keyword capitalization
• Indentation of logically-related blocks
• You can change the Pretty Printer settings by choosing Utilities→ Settings, then choosing
the ABAP Editor→ Pretty Printer tab page
• The Pretty Printer settings are not applied immediately.
• You must trigger the process by choosing the Pretty Printer button.
• We recommend that you trigger the Pretty Printer frequently while developing a program.
40
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Code Hints
• Code hints are one of the main strengths of
the new ABAP Editor, because they reduce the
amount of typing you need to do.
• While you type your code, the hints suggest
common keywords and recently used
identifiers
• If one suggestion is available, the code hint
displays in black letters on a white
background. 41
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Code Templates
• Some code hints contain the symbol § (as shown in the figure Code Templates). These
hints denote special Code Templates.
• The Editor contains a number of predefined code templates that are suggested by code
hints.
• If you see the § symbol in a code hint, you can insert that predefined template by
pressing TAB.
• The difference between a code hint and a code template is that code hints typically
appear for a single keyword, while a code template appears for a block of routine code
42
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Code Templates
43
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Editor Settings
• The Pretty Printer allows you to format your code to a limited extent.
• The new ABAP Editor also provides more extensive formatting options. You can access these
options by choosing the button in the bottom-right corner of the Editor.
• The coloring of different code elements
• The font and font size
• The duration for which code hints display on screen
• The Editor delivers initial values for all settings, and the settings are user-specific, not
systemwide.
44
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Editor Settings
45
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Program Generation and Activation
46
© Copyright 2021, ZaranTech LLC. All rights reserved.
2 Introducing ABAP Syntax
Program Generation and Activation
• When you have checked the syntax and corrected any errors, activate the program by choosing
(Activate) or pressing CTRL + F3.
• Every new program starts as inactive. To make it possible for the current version of the program
to be accessed by all users, you must activate it.
47
© Copyright 2021, ZaranTech LLC. All rights reserved.
2
Q&A Session
48
© Copyright 2021, ZaranTech LLC. All rights reserved.
© Copyright 2021, ZaranTech LLC. All rights reserved.
Thank you
Subscribe to our Channel for more Informative Videos.
https://www.youtube.com/user/ZaranTech