Types of SAP ABAP Data Types Leeaning

Types of SAP ABAP Data Types Leeaning

In SAP ABAP programming, we need to use various variables to store various information. Variables are nothing but memory locations that are ordered to store values. This means that when you create a variable you reserve some space in memory. You might want to store information from various types of data such as characters, integers, floating points, etc. Based on the type of data from a variable, the operating system allocates memory and decides what can be stored in ordered memory.


Dasar Tipe Data


The following are the basic data types that are often used:
TypeKeyword
Byte fieldX
Text fieldC
IntegerI
Floating pointF
Packed numberP
Text stringSTRING

Baca Juga: Tutorial Lengkap SAP ABAP

The following table shows the data type, how much memory is needed to store the value in memory, and the minimum and maximum values ​​that can be stored in the variable types above
TypeTypical LengthTypical Range
X1 byteAny byte values (00 to FF)
C1 character1 to 65535
N (numeric text filed)1 character1 to 65535
D (character-like date)8 characters8 characters
T (character-like time)6 characters6 characters
I4 bytes-2147483648 to 2147483647
F8 bytes2.2250738585072014E-308 sd 1.7976931348623157E+308 positive atau negative
P8 bytes[-10^(2len -1) +1] to [+10^(2len -1) 1] (dimana len = fixed length)
STRINGVariableAny alphanumeric characters
XSTRING (byte string)VariableAny byte values (00 to FF)
Example:
?
1
2
3
4
5
6
7
8
9
10
11
12
REPORT YR_SEP_12.
DATA text_line TYPE C LENGTH 40.
text_line = 'A Chapter on Data Types'.
Write text_line.
DATA text_string TYPE STRING.
text_string = 'A Program in ABAP'.
Write / text_string.
DATA d_date TYPE D.
d_date = SY-DATUM.
Write / d_date.

In this example, we have a character string type C with a predetermined length of 40. STRING is a data type that can be used for character strings of variable length (text strings). The STRING data object type in general must be used for content such as characters whose length is still not important.
?
1
2
3
4
A Chapter on Data Types
A Program in ABAP
(tanggal pada saat kode dibuat ”DDMMYYYY”)<span style="font-family: "times new roman";"><span style="white-space: normal;">
</span></span>
Complex and Reference Types

complex types are classified into Structure types and Table types. In structure types, basic types and structures (ie structures embedded in structures) are grouped together.

  • Line or row type - Internal table rows can be basic, complex or reference types.
  • Key - Specifies a field or group of fields as internal table keys that identify table rows
  • Access method - Explains how the ABAP program accesses individual table entries.
SAP ABAP Syntax Basics Learning

SAP ABAP Syntax Basics Learning

The SAP ABAP program consists of comments and ABAP statements. Each statement in ABAP starts with a keyword and ends with a certain period of time, and ABAP is 'No' case sensitive. The first non-comment line in a program starts with the word REPORT. The report will always be the first line of every program that is made. The statement is followed by the name of the program that was made before. This line then ends with a stop. The syntax is as follows:

?
1
2
3
REPORT [Program_Name].
  
[Statements…].

Statements consist of a command and each variable and choice, ending with a period. During this period the statement appears at the end. This period marks where the statement is completed. Let's write the code
In the line below the REPORT statement, just type the statement:Write ‘ABAP Tutorial’.

?
1
2
3
REPORT Z_Test123_01.
 
Write 'This is ABAP Tutorial'.

Things to consider when writing statements:
  • Write statements can be written with anything as long as in quotation marks
  • Unlike some older programming languages, ABAP doesn't care where a statement starts on a line. You can use this program by using indents to show blocks of code
  • ABAP has no restrictions on the layout of statements. That is, several statements can be placed on one line, or one statement can span multiple lines.

Colon Notation


Sequential statements can be chained together if the beginning of each statement is identical. This is done with colons (:) operators and commas, which are used to end individual statements, like the end of a normal statement period
?
1
2
3
WRITE 'Hello'.
WRITE 'ABAP'.
WRITE 'World'.
By using it can be rewritten like this
?
1
2
3
4
5
6
7
WRITE: 'Hello',
       'ABAP',
       'World'.
 
Atau
 
WRITE: 'Hello', 'ABAP', 'World'.

Comment

Comments in SAP ABAP can be written by placing an asterisk (*) in the first position of the line, using can be rewritten like this
?
1
This is the comment line
Partial line comments can be indicated by entering double quotation marks (") after a statement
?
1
WRITE 'Hello'. "Here is the partial comment

Suppressing Blanks

NO-ZERO command follows the DATA statement. Press on all zeros of a number of fields that contain blanks. The output is usually easier for users to read.
?
1
2
3
4
5
REPORT Z_Test123_01.
 
DATA: W_NUR(10) TYPE N.
      MOVE 50 TO W_NUR.
      WRITE W_NUR NO-ZERO.
The output is:
?
1
 

If it does not use no zero then the output is 0000000050

Blank Lines

The SKIP command helps insert blank lines on the page
?
1
2
3
WRITE 'This is the 1st line'.
SKIP.
WRITE 'This is the 2nd line'.
The output is:
?
1
2
This is the 1st line
This is the 2nd line

Inserting Lines

the ULINE command automatically inserts a horizontal line into the output. It is also possible to control the position and length of the lines. The syntax is quite simple
?
1
2
WRITE 'This is Underlined'.
ULINE.
The output is:
?
1
This is Underlined (and a horizontal line below this).

Messages

The MESSAGE command displays the message specified by the message ID specified in the REPORT report at the start of the program. The message ID is a 2-character code that defines a collection of 1,000 messages that the program will access when the MESSAGE command is used.
PesanTypePenjelasan
EErrorMessage appears and the application stops at the current point. If the program runs, the job will be canceled and a message recorded in the job log.
WWarningA message appears and the user must press Enter for the application to continue
IInformationA pop-up window opens with the message text and the user must press Enter to continue
AAbendcancels the transaction that is being used by the user
SSuccessprovides an information message at the bottom of the screen. The information displayed is positive and is only intended for user feedback.
XAbortThis message cancels the program and generates an ABAP short dump.
Contoh:
EAB011 This report does not support summarization of sub-numbers.
There is an Error with the AB ID