Monday 22 July 2013

JULY 22



Introduction to various types of statement in ABAP/4 with example.

ABAP Statements



Statements and Keywords

Types of statements in ABAP/4:
  • Declarative Statements
  • Modularization Statements
  • Control Statements
  • Call Statements
  • Operational Statements
  • Database Statements

The source code of an ABAP program consists of comments and ABAP statements.

Comments are distinguished by the preceding signs * (at the beginning of a line) and “ (at any

position in a line).

ABAP statements always begin with an ABAP keyword and are always concluded with a period

(.) . Statements can be several lines long; conversely, a line may contain more than one

statement.

ABAP statements use ABAP data types and objects.


The first element of an ABAP statement is the ABAP keyword. This determines the category of

the statements. 

The different statement categories are as follows:
  • 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 keywords:   TYPES, DATA, TABLES

  • Modularization Statements
These statements define the processing blocks in an ABAP program.

The modularization keywords can be further divided into:

1.     Event Keywords

We use statements containing these keywords to define event blocks. There are no

special statements to conclude processing blocks - they end when the next processing

block is introduced.

Examples of event keywords are: AT SELECTION SCREEN, START-OF-SELECTION, AT USER-COMMAND
    
    2. Defining keywords

we use statements containing these keywords to define subroutines, function modules,

dialog modules and methods. We conclude these processing blocks using the ENDstatements.

Examples of definitive keywords: FORM ..... ENDFORM, FUNCTION ... ENDFUNCTION,
MODULE ... ENDMODULE.


  • Control Statements
we use these statements to control the flow of an ABAP program within a processing block

according to certain conditions.

Examples of control keywords: IF, WHILE, CASE

  • Call Statements
we use these statements to call processing blocks that we have already defined using

modularization statements. The blocks we call can either be in the same ABAP program or in a

different program.

Examples of call keywords: PERFORM, CALL, SET USER-COMMAND, SUBMIT, LEAVE TO

  • Operational Statements

These keywords process the data that we have defined using declarative statements.

Examples of operational keywords: WRITE, MOVE, ADD

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

1.     Open SQL

Open SQL is a subset of the standard SQL92 language. It contains only Data Manipulation

Language (DML) statements, such as SELECT, INSERT, and DELETE. It does not contain any

Data Definition Language (DDL) statements (such as CREATE TABLE or CREATE INDEX).

Open SQL contains all of the DML functions from SQL92 that are common to all of the database systems supported by SAP. It also contains a few SAP-specific functions. ABAP programs that use only Open SQL statements to access the database are fully portable. The database interface converts the OPEN SQL commands into commands of the relevant database.

       2.   Native SQL

Native SQL statements are passed directly from the database interface to the database without

first being converted. It allows us to take advantage of all of our database’s characteristics in

your programs. In particular, it allows us to use DDL operations. The ABAP Dictionary uses

Native SQL for tasks such as creating database tables. In ABAP programs that use Native SQL statements are database-specific, because there is no standardized programming interface for SQL92.