ABAP Core Part 2: DATA, TYPES, CONSTANTS, Work Areas and Internal Tables
Preview · a free account unlocks the full lesson
Declare data the way real ECC/S/4 programs do: TYPES, DATA and CONSTANTS, dictionary types, structures (work areas) and internal tables, filling them with APPEND, CLEAR/REFRESH/FREE, and naming conventions — with the modern inline and VALUE syntax as a side note.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 1 of this series ran a first program; now it's time to learn how to declare the data a program actually works with, which is the foundation for everything else. TYPES defines a type, which allocates no memory on its own — it just describes a shape. DATA creates a real variable from a type. CONSTANTS creates a value that never changes afterward.
A type is declared like TYPES: BEGIN OF ty_flight, carrid TYPE s_carr_id, connid TYPE s_conn_id, fldate TYPE s_date, seatsmax TYPE s_seatsmax, seatsocc TYPE s_seatsocc, END OF ty_flight, followed by TYPES ty_flights TYPE STANDARD TABLE OF ty_flight to describe a table of that structure.
Variables, work areas, and tables are then created from those types with DATA: DATA lv_count TYPE i declares an elementary variable, DATA ls_flight TYPE ty_flight declares a structure, which acts as a work area holding one row, and DATA lt_flights TYPE ty_flights declares an internal table, which holds many rows of that structure.
Most projects follow a naming convention: lv_ for a local variable, ls_ or wa_ for a structure, lt_ or it_ for a table, gv_/gs_/gt_ for global versions of each, p_ for a parameter, and s_ for a select-option.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.