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. This keyword is used for local declarations in constructor expressions.
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.
In the same way the LET keyword is also used to declare variables with short lifespans by getting us relieved from declaring helper variables.
Lets 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.
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.
As the local variables declared using LET statement have short lifespan, after the statement is over those variables does not exists any longer.
Also Read: Inline declarations in ABAP 7.4
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
SAPLearners.com is now on Telegram. Click here to join our channel and stay updated with the latest tutorials and updates.