0% found this document useful (0 votes)
13 views12 pages

ABAP Programming Basics 1725044345

Uploaded by

ybreghtan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views12 pages

ABAP Programming Basics 1725044345

Uploaded by

ybreghtan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

1️⃣

Introduction to ABAP Programming


Introduction to ABAP Editor:-
ABAP editor is a tool for ABAP coding.

It is one of the main tool of the ABAP workbench.

The transaction code for ABAP editor is SE38.

Any customized program must start with Z or Y as first alphabet.

A statement is a sequence of words that ends with a period.

In the ABAP editor, the keywords appear in the blue color.

First Program in ABAP editor :-


Step 1:- Go to TCODE SE38.

Step 2 :- give a name starting with Z or Y and click on create button.

Introduction to ABAP Programming 1


Step 3 :- Provide a meaningful title to our program and in type select the program as
executable type → click on save.
Note:- We select a type as executable whenever, we want to execute or run a program.

Assign the package and press enter, a screen will appear.

Introduction to ABAP Programming 2


For executable program, first word will always be REPORT ( in blue color ) and the name in
the black color.

In the above image we can see a statement.

Note :- A statement is sequence of words and every statement ends with dot(.) sign in ABAP.

Ctrl + S is the shortcut to save our program.

After saving the program we must use Ctrl + F2 for syntax check and Ctrl + F3 to execute
the program.

We use F8 to execute our program.

To change the program in read/write mode, we use the below button.

Display object list :- We can navigate to SE80 transaction code from our program after click
on display object list.

Introduction to ABAP Programming 3


Functionalities of ABAP Editor :-
Save :- Ctrl + S

Syntax Check - Ctrl + F2

Activation :- Ctrl + F3

Execute :- F8

Display/Change :- Ctrl + F1

Display Object List :- Ctrl + Shift + F5

Some more Functionalities of ABAP Editor :-


The use of pretty printer is used to format the ABAP code. It makes the code more readable.

The shortcut key for pretty printer is Shift + F1.

The various functionalities of pretty printer are as follows :-

Indentation

Introduction to ABAP Programming 4


Convert uppercase/lowercase

Note :- To check the various functionalities of the pretty printer.


Click on utilities → settings → pretty printer

Introduction to ABAP Programming 5


So, you can use the pretty printer in any way as you prefer.

Comments in ABAP Programming :-


A comment is an explanation that is added to the source code of a program to help the
person reading the program to understand it.

Comments are ignored when the program is generated by the ABAP compiler.

The * character at the start of a program line indicates that the entire line is comment.

The “character, which can be entered at any position in the line, indicates that the remaining
content in the line is a comment.

Comment our lines - Ctrl + ,

Uncomment lines - Ctrl +.

*******************
*Examples of if statement
if sy-subrc eq 0.

Introduction to ABAP Programming 6


write : 1, 2.
endif. "End of if statement

************

Note :- Don’t worry, much about the code at this moment, just try to understand how things are
going, it will get easier to understand with time.

As you can see, in the above code, how we have used * and “ to use single line comments.

For commenting and uncommenting multiple lines at the same, select all the lines and press
Ctrl + , to comment and Ctrl + . to uncomment.

Concepts Of Data Types :-


Data types are templates for creating data objects.

A data types defines the technical attributes ( types and length ) of data objects.

Data types do not use any memory space.

Data types can be defined independently in the ABAP program or in ABAP Dictionary.

Data Objects :-
A data object is an instance of a data type.

A data objects holds the content or data.

It occupies the memory space based upon the data type specified.

*******************************
*Example:-
DATA lv_empid(20) type n,
lv_empid = 10.
*******************************

Introduction to ABAP Programming 7


In the above example, DATA = keyword, lv_empid is the name of the data object, TYPE =
keyword, n(numeric) = is a data type of that data object.

Categories of data types :-


There are three categories of data types :-

Elementary types

Complex types

Reference types

1. Elementary Types :-
They are predefined data types

They are not composed of other data types.

Elementary Datatypes are of 2 types :-


1. Fixed Length data types - C(character), N(numeric), I(Integer), P(packed number),
F(floating point), D(date), T(time), X(hexadecimal)

2. Variable length data types - String, Xstring

2. Complex Data Types :-


There is no pre-defined complex data type in ABAP.

Introduction to ABAP Programming 8


They are the combination of elementary data types.

There are 2 types of complex data types :-


1. Structure Type

2. Table Type

3. Reference Data Types :-


There is no-predefined reference data type.

It describes data objects that contain references to other objects.

There are two types of reference data types :-


1. Data reference

2. Object reference

*********************************
*Example:-
lo_object type ref to ZCLASS.
**********************************

In the above syntax - lo_object = Name of the data object, TYPE REF TO = keyword,
ZCLASS = name of already existing class.

Types of Data Objects :-


The Data objects are of 2 types

1. Literals(unnamed data objects )

2. Named data objects

1. Literals(Unnamed Data Objects )

Introduction to ABAP Programming 9


Literals don’t have any name that’s why they are called as unnamed data object.

They are fully defined by their value.

There are 2 types of literals :-

Numeric Literals :- Numeric Literals have sequence of numbers. Examples - 123, -4567
etc.

Character Literals :- Character Literals are sequences of alphanumeric characters in


single quotation marks. Examples :- ‘Test 123’, ‘SAP ABAP’ etc.

2. Named Data Objects :-


Data objects that have a name are called as named data objects.

The various types of named data objects are as follows :-

1. Variable

2. Constants

3. Text Symbols.

Variables :-
Variables are data objects whose contents can be changed.

Variables are declared using the DATA, CLASS-DATA, STATICS, PARAMETERS,


SELECT-OPTIONS, and RANGES statements.

***************************
*Example :-
DATA lv_empid(20) type n.
lv_empid = 10.
lv_empid = 20.
****************************

Introduction to ABAP Programming 10


Constants :-
Constants are data objects whose contents can not be changed.

Constants are declared using the CONSTANTS keyword.

********************************
*Example
CONSTANTS lc_pi type p decimals 3 value '3.141'.
*********************************

Text Symbols :-
A text symbol is data object that is not declared in the program itself.

It is defined as a part of the text elements of the program.

Note :- Text symbols are not written inside the code.

Introduction to ABAP Programming 11


Introduction to ABAP Programming 12

You might also like