ABAP - New escape characters
If you should have the new symbols @ and # somewhere in the code, you do not have to despair immediately, we will help you understand the new logic.
With the extension of the SELECT statement and the inclusion of new language elements, some new symbols have also been adopted in the modern ABAP. These are also very often used depending on the use of the new commands and constructs.
So that you can easily learn them, here just two examples where we want to explain the effects.
" Select statement
SELECT * FROM adrc INTO TABLE @DATA(lt_adrc).
" Create a structure
DATA ls_t001 TYPE t001.
ls_t001 = VALUE #( bukrs = '1234' butxt = 'Test input' ).
The @ within the SELECT
The @ symbol not only stands for the delimiter in an e-mail address, but is used in the Select to say where a statement or variable belongs. Everything marked with @ in Select belongs to the program and is not part of the database statement.
This can be used to perform various actions in selects:
- Definition of a table for the result (example above)
- Transfer of parameters and select options
- Usage of inline functions within a select
Hint: Once you use the new logic, it must be applied in the full select statement. The fields are then separated by a comma. More in a separate article how it works.
The # in a function
Whether hash tag, rhombus or picket fence, the # is also used as a new symbol in ABAP and describes the context-dependent data types, especially in the inline functions.
In the example above, it refers to a data type of the variable to which the structure is assigned via VALUE. The value statement knows that it should refer to the data type of the variable ls_t001 when generating the data type.
Often you will find this:
- Handover to methods
- New inline functions
The new escape symbols are relatively easy to understand, given what they are meant for. The usage is mandatory for all new commands, so there is no way around it.