Dear saplearners, in this blog post we will learn about LET keyword in ABAP 7.4
LET is a new syntax keyword introduced in ABAP 7.4 which is ABAP Platform version for SAP S/4HANA 1909 release. This keyword is used for local declarations in constructor expressions. It is used to define variables and field-symbols and assign values to them.
In our previous blog posts we learned about inline declarations to declare the variables with out explicit data type declaration in a program, start of sub-routine, method etc. Inline declarations will reduce the number of lines in programs.
Also Read: Inline declarations in ABAP 7.4
In the same way the LET also used to declare variables with short lifespans by getting us relieved from declaring helper variables.
Let’s see how this can make an ABAPer happier.
Where can I use LET?
LET expressions can be used in the following constructor expressions
- Single Values
- Internal Tables
- Internal Tables
Apart from the above constructor expressions the LET expressions can be used in all iteration expressions with FOR.
Example#1 – LET Usage in CONV Expression
In the below ABAP code snippet demonstrates the LET statement usage in constructor expression CONV.
In the above example line-29, we have used LET statement to declare local variables airline_name, airline_from, airline_to and used them to built the final output string.
With out LET statement, we would have declared the helper variables before the LOOP statement and use them. Thanks to LET statement in avoiding those unwanted declaration of helper variables.
Example#2 – LET Usage in VALUE Expression
In the below ABAP code snipper demonstrates, LET statement usage in constructor expression VALUE.
Congrats..! You have successfully learned about LET keyword in ABAP 7.4. So start using the new syntax and write some good code.
Please feel free to comment and let us know your feedback. Subscribe for updates