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


TYPESBEGIN 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_dateVALUE tt_date(
  dd ’05’ mm ’10’ yy ‘2016’ )
  dd ’27’ mm ’09’ yy ‘2015’ )
  dd ’19’ mm ’06’ yy ‘2014’ ).

DO lineslt_date TIMES.
  DATA(dateCONV stringLET lcl_ls_date lt_date[ syindex ]
                                                                 lcl_lv_sep ‘:’
    IN |{ lcl_ls_datedd }|
     & |{ lcl_lv_sep }|
     & |{ lcl_ls_datemm }|
     & |{ lcl_lv_sep }|
     & |{ lcl_ls_dateyy }| ).
  WRITE:date.
ENDDO.


Output

18


Debugging 

19


20


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

21.jpg


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s