In many places in ABAP code, we need a variable with an exact data type.
In the past, this variable had to be declared beforehand.
This had several disadvantages:
- The declaration takes time, especially when the exact data type first had to be determined.
- The declaration takes up space in the source code without adding logic. For scalar types, it’s one line; for structures, it can quickly become many lines.
- There is a strong coupling between different code sections, sometimes even across classes.
TYPES: BEGIN OF linetype,
task_id TYPE zbc_tasks-task_id,
status TYPE zbc_tasks-status,
solution TYPE zbc_tasks-solution,
END OF linetype.
DATA tasks TYPE STANDARD TABLE OF linetype
WITH DEFAULT KEY.
SELECT task_id,
status,
solution
FROM zbc_tasks
INTO TABLE @tasks.
out->write( tasks ).
ENDMETHOD.