This cheatsheet provides a brief overview of ABAP’s unique features and syntax, including code blocks for variables, functions, loops, conditionals, file manipulation, and more.
ABAP (Advanced Business Application Programming) is a high-level programming language used to develop enterprise applications in the SAP environment. It is known for its strong integration with SAP systems and its ability to handle large amounts of data.
This cheatsheet is designed to serve as a quick reference guide for ABAP developers of all levels. It includes examples of common syntax and programming constructs, as well as a list of resources for further learning.
* declaring a variable
DATA variable_name TYPE data_type.
* dynamic typing
DATA variable_name TYPE any.
variable_name = 'string'.
variable_name = 123.
* defining a function
FUNCTION function_name.
* function body
ENDFUNCTION.
* calling a function
CALL FUNCTION function_name.
* do loop
DO.
* loop body
ENDDO.
* while loop
WHILE condition.
* loop body
ENDWHILE.
* for loop
DO num_times TIMES.
* loop body
ENDDO.
* if statement
IF condition.
* if body
ELSEIF condition.
* else if body
ELSE.
* else body
ENDIF.
* ternary operator
result = condition1 AND condition2.
* reading from a file
OPEN DATASET filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
WHILE sy-subrc = 0.
READ DATASET filename INTO line.
* process line
ENDWHILE.
CLOSE DATASET filename.
* writing to a file
OPEN DATASET filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
TRANSFER 'content' TO filename.
CLOSE DATASET filename.