Local Declarations in Expressions

lightLET Expression- LET ……. IN

 


The LET expression allows to declare the so called local auxiliary fields may be variables or field symbols in an expression. The auxiliary fields can’t be accessed outside of the expression. 

In the below demo two auxiliary fields, variables LCL_LS_DATE & LCL_LV_SEP are declared and used in the IN section.

17


TYPES: BEGIN OF ty_date,
         dd(2), mm(2),yy(4),
       END OF ty_date,
       tt_date TYPE TABLE OF ty_date WITH EMPTY KEY.

DATA(lt_date) = VALUE tt_date(
  ( dd = ’05’ mm = ’10’ yy = ‘2016’ )
  ( dd = ’27’ mm = ’09’ yy = ‘2015’ )
  ( dd = ’19’ mm = ’06’ yy = ‘2014’ ) ).

DO lines( lt_date ) TIMES.
  DATA(date) = CONV string( LET lcl_ls_date = lt_date[ sy–index ]
                                                                 lcl_lv_sep = ‘:’
    IN |{ lcl_ls_date–dd }|
     & |{ lcl_lv_sep }|
     & |{ lcl_ls_date–mm }|
     & |{ lcl_lv_sep }|
     & |{ lcl_ls_date–yy }| ).
  WRITE:/ date.
ENDDO.


Output

18


Debugging 

19


20


A local field symbol can also be used instead of variable.

21.jpg


 

Leave a Reply