SAP ABAP Statement syntax including basic implementation code

See below for details and syntax for specific SAP ABAP statements but also note there are a few basic syntax rules which are valid for writing all ABAP code including:

•  All statements must end with period/full stop (Example: SELECT * from EKKO into it_ekko.)

•  ABAP statements and keywords are not case sensitive (Example: SELECT, Select, select).

•  String values are enclosed within single quotes (Example: ld_string = 'Hello World'.)

•  You can use * or " for commenting purposes. * must be placed at the start of the line and " can be placed any where.

Example using all of the above syntax rules

* The select statement retrieves data from the ekko table
* into an internal table called it_ekko
	Select *
	  FROM ekko              "get data for ekko table
	  into TABLE it_ekko
	 WhERe ebeln = '12345'.  "only retrieves values that match this where clause
"Note: You can use the pretty printer functionality to auto format your code

[+] Variable manipulation(TRANSLATE, CONDENSE, TAB, ROUND, MOD..)
Commands to change the contents of ABAP data fields

RANGE Statement/Command
Create a range table which is used to store a range of values, same structure as a select option

ABAP WRITE command
Display basic report output to user using WRITE

IF, CHECK and WHEN condition statements
Using the IF,CHECK and WHEN statements to add conditions to your ABAP program

ABAP MODIFY command
Modifying data within an ABAP internal table or database table

UPDATE statement syntax
Updating data within an SAP database table

ABAP CONCATENATE statement
Display basic report output to user using WRITE


AUTHORITY-CHECK SAP Statement/Command
Used to check if a user has authroity to view/change sap data

EJECT Statement/Command to force a new page when printing
Forces new page when printing ABAP code listing

DESCRIBE SAP Statement/Command
The describe command is used to describe certain properties of and internal table

STRLEN command
Get value length of a SAP field using STRLEN command

MEMORY ID - Export and Import
Pass data between sap programs using MEMORY ID (Export/Import)

SELECT Statement/Command
Selecting data from SAP databases

SELECT SAP data from any table
Example ABAP code to select, convert and display data from any SAP TABLE

SUBMIT report (Excecute rep from within a rep)
Executing a report from within another report using the SUBMIT statement

VARYING Statement/Command
Function of the DO loop which allows you to move horizontaly along a table row without actually having to specify each individual field name

STARTING NEW TASK
Execute function module using STARTING NEW TASK statement

IN UPDATE TASK
Execute function module using IN UPDATE TASK statement

IN BACKGROUND TASK
Execute function module using IN BACKGROUND TASK statement

DELETE Statement/Command
Delete entries of an SAP internal table using the DELETE command

READ Statement/command
Get entries of an SAP internal table using the READ command

COLLECT Statement/Command
Insert entries into an SAP internal table and sum up interger values using the COLLECT command

PERFORM Statement/Command - passing internal table
Using the perform command to pass internal table

More ABAP Statements/Commands
See more SAP ABAP statements and their syntax



Related Articles

ABAP COLLECT statement syntax to add up all numeric internal table values within SAP
ABAP DELETE statement keyword to delete data from SAP internal and database tables
ABAP DESCRIBE statement keyword to get information about tables and fields
PERFORM TABLES command passing internal table as parameter
ABAP read command to read line of internal table in SAP
ABAP UPDATE command to modify database field values
AUTHORITY-CHECK abap Statement / command
ABAP delete command in SAP
ABAP MODIFY statement to update SAP data within database and internal tables
ABAP WRITE statement command with in SAP to display data report to users
Concatenate ABAP statement syntax for concatenating data objects, sting values or rows of an SAP internal table
ABAP EXPORT data TO MEMORY ID and import it back again
IF, CHECK & WHEN ABAP commends example source code and information
Call Function module IN BACKGROUND TASK - Execute abap code in seperate background process
Function module IN UPDATE TASK statement - Execute abap code in seperate unit of work
ABAP STRLEN command to get the value length of a SAP field
SAP ABAP SELECT command and its different uses
SELECT..ENDSELECT command
ABAP FOR ALL ENTRIES SELECT statement addition in SAP data retrieval
ABAP SELECT inner join statement to select from two tables at the same time
SELECT directly into an internal table
SELECT directly into an internal table when field order is different
Function module STARTING NEW TASK statement - Execute abap code in seperate work process