ABAP programs are written with individual sentences (statements) and each sentence or line of code in the ABAP program is called as ABAP statement. In other words, statement is a combination of keywords, operands, operators, and expressions and so on.

Below are some characteristics about ABAP statements -

  • ABAP statements begins with an ABAP keyword and ends with a period(.).
    For example -
    Write 'Hello World, Welcome to TutorialsCampus'.
    
  • The words (keywords, variables, operators etc.) are always separated by at least one space. If words have more than one space in between, it will be considered as one.
    For example -
    Using blank in statements
  • ABAP statement can be more than one line long however it is not recommended. ABAP supports a single line contain more than one ABAP statement.
    For example -
    Write 
    'Hello World, Welcome to TutorialsCampus'.
    
  • There are no rules for ABAP statement starting position or indentation. ABAP statement can start in any column of the line.
    For example -
    	Write 
    		'Hello World, Welcome to TutorialsCampus'.
    
  • ABAP Statements are not case-sensitive. ABAP statement can be in any case (i.e. either lower case or upper case). Both are considered as same and no differentiation between upper and lower case for keywords, additions, and operands. ABAP considers all cases (upper, lower, and mixed cases) statements are valid and does not throws any error.
    For example, all the statements below are considered as valid even though they are in mixed case.
    Write 'This statement is valid'.
    wRItE 'This statement is valid'.
    WRITE 'This statement is valid'.
    write 'This statement is valid'.
    WritE 'This statement is valid'.
    
  • ABAP statements are formed with keywords, variables, data types and objects.
    For example, -
    DATA lv_number TYPE I VALUE 193.
    

Let us take an example of ABAP statement coded in the declaration part of program.

Statement Declaration Syntax

The above ABAP statement is used to declare variable lv-number of type integer(I) with a value 193(literal).

All elements (keywords, variables, data types and literals) are highlighted in the above diagram of the ABAP statement.

Let us take an example of ABAP statement coded in the processing block of program.

PROGRAM Z_FIRST_PROG.
WRITE 'Hello World, Welcome to TutorialsCampus'.

In the above example, PROGRAM and WRITE are the keywords. The program displays the list on the screen. In this case, the list consists of ‘Hello World, Welcome to TutorialsCampus’.

Statement Example Representation

The above diagram describes the structure of the program and all elements (keywords and literals) are highlighted.

What are the types of Statements?

The first element of an ABAP statement is the ABAP keyword. An ABAP keyword determines the category of the statements. The different statement categories are -

  • Declarative Statements
  • Modularization Statements
  • Control Statements
  • Call Statements
  • Operational Statements
  • Database Statements

Declarative Statements -

Declarative statements used to declare data objects that are used by other ABAP statements in the program or routine. Declarative keywords to form declarative statements.

Some of the declarative statements are –

TYPES: BEGIN OF lv_table,
	……
END OF lv_table.

DATA lv_variable TYPE lv_table.

TABLES table_wa.

Modularization Statements -

Modularization statements used to define the processing blocks in an ABAP program. There are two types of statements in modularization keywords and those are –

Event Statements –

Used to define event blocks. There are no special end statements for event statements and ends automatically when next processing block started.

Some of the Modularization statements are -

AT SELECTION-SCREEN ON <parameter_name>

START-OF-SELECTION. 
<statements-block>.

AT USER-COMMAND.
<statements-block>.

Defining statements –

Used to define subroutines, function modules, methods, and dialog modules. The END statements are the end statement for defining statements.

Some of the Defining statements are -

FORM <subroutine_name>. 
	<statements-block>
ENDFORM.

FUNCTION <function_name>. 
	<statements-block>
ENDFUNCTION.

MODULE <module_name> {OUTPUT|[INPUT]}.
  ...
ENDMODULE.

Control Statements -

Control statements used to control the flow of an ABAP program within a processing block based on the specified conditions.

Some of the Control statements are -

IF <condition>.  
   <statements-block>.    
ENDIF.

WHILE <logical-expression>  
	<statements-block>.  
ENDWHILE.

CASE <variable>. 
WHEN <value1>. 
   <statements-block>.
WHEN <value2>. 
   <statements-block>.
...... 
...... 
......  
WHEN <valuen>. 
   <statements-block>. 
WHEN OTHERS. 
   <statements-block>.  
ENDCASE.

Call Statements -

Call statements used to call processing blocks that are already defined using modularization statements. The calling blocks can either be in the same ABAP program or in a different program.

Some of the Call statements are -

PERFORM <subroutine-name> 
  USING <variables>.

CALL <function-name>/<method-name>.

SET USER-COMMAND <function-code>.

SUBMIT <report_name>

LEAVE PROGRAM.

Operational Statements -

Operational statements process(displays, moves etc,) the data.

Some of the Operational statements are -

WRITE <data-object>/<field-symbol>/<formal-parameter>/<text-symbol>

MOVE <field1> TO <field2>.

ADD <field1> TO <field2>.

Database Statements -

Database statements use the database interface to access the tables from the central database system. There are two kinds of database statement in ABAP - Open SQL and Native SQL.

Some of the Database statements are -

SELECT
INSERT
DELETE