What is LET keyword in ABAP 7.4


Dear saplearners, in this blog post we will learn about LET keyword in ABAP 7.4

‘LET’ Keyword

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

  1. NEW
    • Single Values
    • Structures
    • Internal Tables
    • Classes
  2. VALUE
    • Structures
    • Internal Tables
  3. CONV
  4. CAST
  5. EXACT
  7. COND

Apart from the above constructor expressions the LET expressions can be used in all iteration expressions with FOR.

Example #1

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.

As the local variables declared using LET statement have short lifespan, after the statement is over those variables does not exists any longer.

Example #2

LET statement usage in constructor expression VALUE







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