ABAP program is a combination of executable and non-executable statements. Every executable statement in ABAP starts with a keyword and ends with a period(.). First executable statement starts with REPORT keyword followed by the report-name (same as the program name) and ends with period. This first statement automatically written by the editor even though the program is creating for the first time.

Syntax -

*&---------------------------------------------------------------------*
*& Report  report_name
*&
*&---------------------------------------------------------------------*
*& 
*&
*&---------------------------------------------------------------------*

REPORT report_name.

[Statement1].
[Statement2].
.
.
[Statement-n].

In the above syntax, report_name is already filled by ABAP system while creating the program for the first time.


For example -

Assume ZNEWPROG99 is the new program. When creating ZNEWPROG99 program using the ABAP editor, below statement gets created automatically by the editor.


REPORT  ZNEWPROG99.

All executable statements can be coded after the REPORT statement. We will discuss below list of basic statements in this chapter one by one -

  • Blank Lines
  • Insert Lines
  • Suppressing Zeroes

Blank Lines -

ABAP had SKIP command to insert blank lines in between the output lines.

Syntax -

SKIP.
SKIP [no-of-lines].
SKIP [ TO LINE line-number].

  • SKIP - Skips the current line and the next output start displaying from next line.
  • SKIP no-of-lines - Skips specified no-of-lines from the current line and the output start displaying from next line after skip.
  • SKIP TO LINE line-number - Start the output from specified line-number.

Example -

Display the line numbers message for 3rd, 5th, 10th and 15th lines.


Code -

*&---------------------------------------------------------------------*
*& Report  ZSKIPLINE
*&---------------------------------------------------------------------*
*& Written by TutorialsCampus
*&---------------------------------------------------------------------*

REPORT  ZSKIPLINE.

* First row in output occupies with program name
* Second row in output occupies with line
* What ever writing in the output, starts displaying fro third line.
WRITE 'This is 3rd line'.

* Skip 4th line.
SKIP.

* Writing on the 5th row.
WRITE 'This is 5th line'.

* Skipping 4 lines.
SKIP 4.

* Wrting on the 10th row.
WRITE 'This is 10th line'.

* Moving the cursor to the 15th line.
SKIP TO LINE 15.

* Start writing on 15th row.
WRITE 'This is 15th line'.

Output -

Blank lines output

Explaining Example -

In the above example, each and every statement is preceeded with a comment to explain about the statement. Go through them to get clear understanding of example code.

First WRITE statement output displays at the line 3. SKIP statement skips the 4th line display. Second WRITE statement output displays at 5th line. So currently the cursor at the 5th line.

SKIP 4 – skips the 4 lines from 5th line and places the cursor at 10th line.Third WRITE statement output displays at 10th line.

SKIP TO LINE 15 – places the cursor at the 15th line. Fourth WRITE statement output displays at 15th line.


Note! As discussed in the previous chapter, any ABAP program output displays from 3rd line. The first line filled with program name and the 2nd line with the line.

Insert Lines -

Insert lines insert continuous line on the output. The ULINE used to insert a continuous line in the output. ABAP supports inserting full line and partial line. Inserting partial line requires more inputs from the user.

Syntax -

ULINE                        
ULINE AT starting_position(length) 
  • ULINE - Inserts a continuous underline in a new line.
  • ULINE AT starting_position(length) - Inserts an underline from the starting_position of the specified length.

Example -

Write a program to display full and partial underline.


Code -

*&---------------------------------------------------------------------*
*& Report  Z_ULINE
*&---------------------------------------------------------------------*
*& Written by TutorialsCampus
*&---------------------------------------------------------------------*

REPORT  Z_ULINE.

WRITE 'Underlined Text..!'.
ULINE.

ULINE AT 9(10).

Output -

insert lines example output

Explaining Example -

In the above example, each and every statement is preceeded with a comment to explain about the statement. Go through them to get clear understanding of example code.

ULINE - inserts full line after the WRITE statement line. ULINE AT 9(10) - inserts from 9th column of length 10 in the current line.


Supressing Zeroes -

ABAP supports supressing zeroes from the input data. It increases the readability and understandability. NO-ZERO statement used to supress the leading zeroes from the number field.

NO-ZERO only suppresses the zeroes while displaying. NO-ZERO not replaces the value in the actual numeric field. NO-ZERO applies on only numeric fields.

Syntax -

WRITE numeric-field NO-ZERO.

Example -

Write a program to display numeric value with and without NO-ZERO function.


Code -

*&---------------------------------------------------------------------*
*& Report  Z_NOZERO
*&---------------------------------------------------------------------*
*& Written by TutorialsCampus
*&---------------------------------------------------------------------*

REPORT  Z_NOZERO.

* Declaring W_N1 of type Numeric(N) with length 10 
* and initializing with 70.
DATA: W_N1(10) TYPE N VALUE 70.

* Displaying the value without specifying NO-ZERO
WRITE : 'Displaying numeric data without NO-ZERO:   ',W_N1.

* Skipping next two lines in the output.
SKIP 2.

* Displaying the value by specifying NO-ZERO
WRITE : 'Displaying numeric data with NO-ZERO:   ',W_N1 NO-ZERO.

Output -

Supresing zero example output

Explaining Example -

In the above example, each and every statement is preceeded with a comment to explain about the statement. Go through them to get clear understanding of example code.

W_N1(10) TYPE N VALUE 70 - initializes W_N1 with 70. WRITE : 'Displaying numeric data without NO-ZERO: ',W_N1. – displaying the entire value which includes leading zeroes. WRITE : 'Displaying numeric data with NO-ZERO: ',W_N1 NO-ZERO. - displaying the value without leading zeroes.


Supressing Blanks -

ABAP supports supressing blanks from the input data. It increases the readability and understandability. CONDENCE statement used to supress the spaces from the strings.

CONDENCE removes or supressing the spaces from the original data field. CONDENCE applies on only character fields.

Syntax -

CONDENCE character-field [NO-GAPS].

  • NO-GAPS - Removes entire blank spaces from the string. It is optional with CONDENCE.

Example -

Write a program to display string with and without CONDENCE function.


Code -

*&---------------------------------------------------------------------*
*& Report  Z_CONDENSE
*&---------------------------------------------------------------------*
*& Written by TutorialsCampus
*&
*&---------------------------------------------------------------------*

REPORT  Z_CONDENSE.

* Declaring variable of type character with length 50.
DATA: W_T1(50) TYPE C VALUE '     Tutorials Campus'.

* Displaying text before condense
WRITE : 'Text before condense - ',W_T1.

* Skipping next lines in the output
SKIP 2.

* Removing extra spaces from the string in w_t1.
CONDENSE W_T1.

* Display the extra spaces suppressed string.
WRITE : 'Text after condense - ',W_T1.

* Skipping next lines in the output
SKIP 2.

* Removing all spaces from the string in w_t1.
CONDENSE W_T1 NO-GAPS.

* Display all spaces removed string.
WRITE : 'Text after condense with NO_GAPS - ',W_T1.

Output -

Supressing blanks example output

Explaining Example -

In the above example, each and every statement is preceeded with a comment to explain about the statement. Go through them to get clear understanding of example code.

W_T1(50) TYPE C VALUE ' Leading spaces along with text' - initializes W_T1 with ' Leading spaces along with text'. WRITE : 'Text before condence:',W_T1 – displaying string before CONDENSE applied.

CONDENSE W_T1 - Supress leading spaces from the data field. WRITE : 'Text after condense:',W_T1 - displaying string after conversion.

CONDENSE W_T1 NO-GAPS - Supress all spaces from the data field. WRITE : 'Text after condense with NO-GAPS:',W_T1 - displaying string after conversion with NO-GAPS.