ABAP statements – an overview
In contrast with languages like C/C++ or Java, which define a limited set of language-specific statements and provide most functionality via libraries, ABAP contains an extensive body of built-in statements. These statements often support many options, which explains why ABAP programs look "verbose", especially when compared with programs written in C, C++ or Java.
This section lists some of the most important statements in the language, subdivided by function. Both the statements listed here and the subdivision used are fairly arbitrary and by no means exhaustive.
Declarative statements
These statements define data types or declare data objects which are used by the other statements in a program or routine. The collected declarative statements in a program or routine make up its declaration part.
Examples of declarative statements:
TYPES, DATA, CONSTANTS, PARAMETERS, SELECT-OPTIONS, TABLES
ABAP/4 – Advanced Business Application Programming Language.
4 – 4th Generation Language.
It is Not Case Sensitive.
Is Event Driven Programming Language.
This overview describing applications programming in the R/3 System. All applications programs, along with parts of the R/3 Basis system, are written in the ABAP Workbench using ABAP, SAP’s programming Language. The individual components of application programs are stored in a special section of the database called the R/3 Repository. The R/3 Repository serves as a central store for all of the development objects in the R/3 System. The following sections of this documentation cover the basics and characteristics of application programming.
A - Advanced
B - Business
A - Application(s)
P - Programming
Program :
A Program Is Group Of Meaningful Instructions.
An Instruction is Group of
Keywords + Variables + Operators + Data Types
Keywords :
Syntax : Each ABAP statement Should begin with a keyword and ends with a period.
Since Each Statement Should Start with a Keyword. It is Difficult to give the exact no. of Keywords So that Keywords are Divided into Different Types Depends On the Functionality Of the Keywords.
Types Of Keywords :
Declarative Key words : To Declare Variables.
TYPES, DATA, TABLES
Syntax for Variables : DATA < Var. Name> TYPE <Data Types>.
Database Keywords : To Work With Database Operations Such as
SELECT - To Select Data
INSERT - To Insert Data
UPDATE - To Change Data
DELETE - To Delete Data etc.
Control Keywords :
Statements are used to control the flow of an ABAP program within a processing block according to certain conditions.
Ex :
IF, ELSEIF, ENDIF.
DO-ENDDO, WHILE – ENDWHILE.
Definition Keywords are used to define Re-usable Modules (Blocks)
Ex :
FORM - ENDFORM
FUINCTION - ENDFUNCTION
MODULE - ENDMODULE
Calling Keywords :
Are used to call Re-usable Modules (Blocks) that are already defined.
PERFORM to Call FORM
CALL FUNCTION to Call FUNCTION
MODULE to Call MODULE
Operational Key Words :
To Process the data that you have defined using declarative statements.
Ex : WRITE, MOVE, ADD
Event Keywords :
Statements containing these keywords are used to define event blocks.
Ex : TOP-OF-PAGE To Print the Same Heading On the TOP Of Every Page.
END-OF-PAGE To Print the Same FOOTER for every Page on the Output List.
Date Types and Objects (Variables)
The physical units with which ABAP statements work at routine are called internal program data objects. The contents of a data occupy memory space in the program. ABAP statements access these contents by addressing the name of the data object. Each ABAP data objects has a set of technical attributes which are fully defined at all times when an ABAP program is running. The technical attributes of a data object are : Data Type, Field Length and Number of Decimal Places.
ABAP Contains the following Pre-defined Data Types :
Non-Numeric Data Types :
Character String (C)
Numeric Character String (N)
Date (D)
Time (T)
Numeric Types :
Integer (I)
Floating-point number (F)
Packed Number (P)
The Field Length for data types D, F, I and T is fixed. The field length determines the number of bytes that the data object occupies in memory. In types C, N, X and P, the length is not part of the type definition. Instead, you define it when you declare the data object in your program.
Data Type P is particularly useful for exact calculations in a business context. When you define an object with type P, you also specify a number of decimal places.
You can also define your own elementary data types in ABAP using the TYPES statements. You base these on the predefined data types. This determines all of the technical attributes of the new data type. For example, you could define a data type P_2 with two decimal places on the predefined data type P. You could then use the new type in your data declarations.
Predefine Elementary ABAP Types : All field lengths are specified in bytes.
Data Types
|
Initial Field Length
|
Valid Field Length
|
Initial Value
|
Meaning
|
Numerica Types | ||||
I
|
4
|
4
|
0
|
Integer (Whole Number)
|
F
|
8
|
8
|
0
|
Floating Point Number
|
P
|
8
|
1
16
|
0
|
Packed Number
|
Character (Non-Numeric) Types | ||||
C
|
1
|
1
6553
5
|
‘………..’
|
Text Field
(Alphanumeric Characters)
|
D
|
8
|
8
|
’00000000′
|
Date Field
(Format : YYYYMMDD)
|
N
|
1
|
1
6553
5
|
’0 … 0′
|
Numeric Text Fields
(Numeric Characters)
|
T
|
6
|
6
|
’000000′
|
Time Field
(Format : HHMMSS)
|
Note : Data Type N is not a numeric type. Type N objects can only contain number characters (0…….9) but are not represented internally as numbers. Typical type N fields are account numbers and zip codes.
Integers – Type 1
The value range of type 1 numbers is -2**31 to 2**31-1 and includes only whole numbers. Non-integer results of arithmetic operations (e.g. fractions) are rounded, not truncated.
You can use type 1 data for counters, number of items, indexes, time periods, and so on.
Packed Numbers – Type P
Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and number of digits after the decimal point. The valid size can by any value from 1 to 16 bytes. Two decimal digits arepacked into one byte, while the last byte contains one digit and the sign. When working with type P data, it is a good idea to set the program attributes Fixed point arithmetic. Otherwise, type P numbers are treated as integers.
Note : You can use type P data for such values as distances, weights, amounts of money, and so on.
Floating Point Numbers – Type F
The value ranges of type F numbers is 1×10**-307 to 1×10**308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the floating pointarithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.
You use type F fields when you need to cope with very large ranges and rounding errors are not critical.
Using I and F fields for Calculations is quicker than using P fields.
Operations using I and F fields are very similar to the actual machine code operations, while P fields requires more support from the software. Nevertheless, you have to use type P data to meet accuracy or value range requirements.
Character (Non-Numeric) Types :
Of the five non-numeric types, the four types C,D, N and T are characters types. Fields with these types are known as character field. Each position in one of these fields talks up enough space for the code of the character. Currently, ABAP only works with single-byte codes such as ASCII and EBCDI. However, an adaptation to UNICODE is in preparation. Under UNICODE, each character occupies two or four bytes.
Thanks for sharing this niche useful informative post to our knowledge, Actually SAP is ERP software that can be used in many companies for their day to day business activities it has great scope in future
ReplyDeleteSAP ABAP Training In Chennai
Quite Interesting post!!! Thanks for posting such a useful post. I wish to read your upcoming post to enhance my skill set, keep blogging.
ReplyDeleteRegards,
Python Training|Python Training Institutes in Chennai|FITA Chennai complaints|Fita Chennai reviews