LT_* sorted before LS_*
Hey,
I've just discovered that in the DATA-declarations the table elements (LT_) are sorted before structures (LS_) by abap-cleaner.
Before:
After:
- Why?
- Is there a way to change this?
Thanks!
Regards, Vlad
I guess it could makes sense for LIKE LINE OF?
Hi Vlad,
this is because "Rearrange local declarations" (with the option "Rearrange DATA: … order by first usage") determines the first usage of each variable in the code and then rearranges the DATA declarations in that order. So, from your example I would expect that the variable lt_addrnr_objnr is used at an earlier point in the following code than the variable ls_addrnr_objnr.
This is indeed different with LIKE, because then, the first usage is already within the DATA section. For example, in this code,
DATA ls_any_struc TYPE ty_s_struc.
DATA lt_any_table LIKE STANDARD TABLE OF ls_any_struc.
lt_any_table = VALUE #( ).
ls_any_struc = VALUE #( ).
the order will (and must) be kept, because ls_any_struc is already used in the DATA section (and therefore it is used before lt_any_table).
Kind regards, Jörg-Michael
Hey @jmgrassau & @fabianlupa
you're both right, that makes sense now - my expectations had only personal preference.