3.4. Manipulation - LET

 LET : Used to create variable and assign            values locally

Before continuing further , let see some important points that needs to be taken care before using LET operator.

1.A LET expression defines variables or field symbol as local fields to assigns values .
 
2.These variable can be used as an operand for an expression. 
 
3.Though it is created implicitly while defining but these variables can't be used outside its expression                   and is only valid in the expression.
 

* Simple example : Here we will see a very simple example to use LET , later in further blogs we will see how we can make use of LET with other operators.

 
  TYPES : BEGIN OF ty_int1,
          value TYPE i,
          value1 TYPE i,
          END OF ty_int1.
  DATA  lt_int1 TYPE TABLE OF ty_int1.

* Lets use LET to change values of lt_int1

 DO 5 TIMES.
    DATA(ls_int1) = VALUE ty_int1( LET lv1 = sy-index + 10
                                    lv2 = lv1 + 20
                                    IN value = lv1
                                     value1 = lv2
                                  ).
    APPEND ls_int1 TO lt_int1.
    CLEAR ls_int1.
ENDDO.


 

Next - Loop with GROUP BY

 

No comments:

Post a Comment