ABAP Basics: Syntax, Data Types, Keyword Index
A practical walkthrough of ABAP syntax, data types and where to find the keyword index, written for photographers who also write code between shoots.

How do you write basic ABAP syntax and statements?
ABAP is a typed, statement-based language: every line ends with a period, every declaration names a type, and the compiler reads your source from top to bottom inside a program or a class. If you can read an exposure table, you can read ABAP: the structure is rigid, the vocabulary is finite, and the order of operations matters more than cleverness. The three things you need first are the shape of a statement, the type system, and a keyword reference you can search. A statement is a keyword, some operands, and a period. That period is not decoration; it terminates the statement the way a shutter release terminates an exposure. Whitespace and line breaks are free, so you can wrap a long statement across several lines without changing its meaning. DATA: lv_count TYPE i, lv_name TYPE string. lv_count = 10. lv_name = 'Frame 01'. WRITE: / lv_name, lv_count. ``` The chained `DATA:` form declares several variables under one keyword, separated by commas. The colon is a shorthand that expands into separate statements at compile time. You will see it constantly in older code, and it is still legal in new code. Assignment uses a single `=`. Comparison uses `=`, `<>`, `<`, `>`, `<=`, `>=`. String literals sit in single quotes; text symbols and comments use other markers. A comment line starts with an asterisk in column one, and an inline comment starts with a double quote. Control flow is readable at a glance: IF lv_count > 5. WRITE / 'Above threshold'. ELSE. WRITE / 'Below threshold'. ENDIF. DO 3 TIMES. WRITE / sy-index. ENDDO. CASE lv_name. WHEN 'Frame 01'. WRITE / 'First'. WHEN OTHERS. WRITE / 'Other'. ENDCASE. ```
What data types do you use in ABAP?
ABAP splits types into two families: elementary types that hold a single value, and complex types built from them. The elementary set you will use most is small. | Type | Meaning | Typical use | | --- | --- | --- | | `I` | Integer | Counters, indexes, quantities | | `P` | Packed decimal | Amounts, measurements with decimals | | `F` | Floating point | Scientific values, rarely for money | | `C` | Character | Fixed-length text | | `N` | Numeric text | Zero-padded numbers, document IDs | | `D` | Date | `YYYYMMDD` | | `T` | Time | `HHMMSS` | | `STRING` | Variable-length text | Free text, no trailing blanks | | `XSTRING` | Byte sequence | Binary payloads | The distinction between `C` and `STRING` matters more than beginners expect. A `C` field has a fixed length and pads with blanks; a `STRING` grows and shrinks. Comparing the two without care gives you results that look wrong until you remember the padding. Complex types cover structures, which group fields under one name, and internal tables, which hold many rows of the same shape. A structure is your record layout; an internal table is your working set in memory. You declare them with `TYPES` or `DATA`, and you can base a table on a structure or on an elementary type. TYPES: BEGIN OF ty_frame, name TYPE string, count TYPE i, END OF ty_frame. DATA: lt_frames TYPE STANDARD TABLE OF ty_frame, ls_frame TYPE ty_frame. ls_frame-name = 'Frame 01'. ls_frame-count = 12. APPEND ls_frame TO lt_frames. ``` That pattern, structure plus table plus `APPEND`, is the backbone of report programming. Once you can declare it, fill it, loop over it and sort it, you can read most ABAP you will meet in maintenance work.
Where do I find the ABAP keyword index?
The keyword index is not a single page you memorize; it is a lookup habit. In the SAP environment, the ABAP keyword documentation is the authoritative reference, and it is searchable by statement name. You open it from the editor or from the help portal, type the keyword, and read the syntax diagram plus the notes on return codes and restrictions. Outside the official documentation, community references organize the same keywords by theme. A keyword index is useful precisely because ABAP has a finite vocabulary: once you know that `READ TABLE`, `LOOP AT`, `SORT` and `APPEND` exist, you stop guessing and start looking them up. Keep the index open in a second window while you write. The habit costs nothing and saves the kind of debugging session where the bug is a missing period three lines up.
How do you move from syntax to a working report?
Syntax gets you a program that compiles. A report needs a selection screen, a data retrieval step, and an output step. The shortest path is: declare your types, declare a selection screen with `PARAMETERS` or `SELECT-OPTIONS`, read data into an internal table, process the table in a `LOOP`, and write the result. PARAMETERS: p_count TYPE i DEFAULT 10. START-OF-SELECTION. DO p_count TIMES. WRITE: / 'Line', sy-index. ENDDO. ``` That is a complete, runnable program. Everything else in report programming is elaboration: better selection criteria, better table access, better output. The `START-OF-SELECTION` event is where the main work belongs, and it runs after the selection screen has been processed.
What trips people up first?
Three things, in order of frequency. Missing periods, which turn two statements into one and produce a syntax error that points at the wrong line. Type mismatches, where a character field meets a numeric field and the conversion is not what you assumed. And unchecked `SY-SUBRC`, where a read fails silently and the program continues with stale data in the work area. None of these are exotic. They are the same class of mistake as forgetting to reset a camera setting between shoots: the tool did what you told it, and you told it the wrong thing. Read the syntax diagram, check the type, check the return code. That sequence resolves most of what you will hit in the first months.
A note on where to practice
You do not need a production system to learn the language. A trial or sandbox system with the editor and the debugger is enough to write declarations, build an internal table, loop over it and inspect variables at a breakpoint. The debugger is where ABAP stops being abstract: you watch a value change, you see which statement set it, and the syntax you read on the page becomes a sequence of events you can predict. Practice there, keep the keyword index open, and the language stops looking like a wall of uppercase words.
Two system fields do a lot of quiet work. SY-SUBRC holds the return code of the last operation, and SY-INDEX counts loop passes. Checking SY-SUBRC after a read or a call is the difference between code that works on your data and code that works on everyone's data. If you want a structured reference for the statement forms and the internal table operations that follow, the Italian-language guide at ABAP syntax and statements walks through the language from declarations to APPEND, LOOP, READ TABLE and SORT.


