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' . |
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 |
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. |
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' . |
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. |
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.Pesan | Type | Penjelasan |
---|---|---|
E | Error | Message 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. |
W | Warning | A message appears and the user must press Enter for the application to continue |
I | Information | A pop-up window opens with the message text and the user must press Enter to continue |
A | Abend | cancels the transaction that is being used by the user |
S | Success | provides an information message at the bottom of the screen. The information displayed is positive and is only intended for user feedback. |
X | Abort | This message cancels the program and generates an ABAP short dump. |
EAB011 This report does not support summarization of sub-numbers.There is an Error with the AB ID