SAP/abap-cleaner

Error when constant is used to specify variable size

MDagni opened this issue · 5 comments

Did you know that you can use constants to specify the size of a char typed variable? The following code generates an error in Abap Cleaner:

report ztest.

constants c_size type i value 10.

data lv_text(c_size) type c.

lv_text = '1234567890'.

This is the error:

image

Hi Mehmet,

thanks for reporting this bug – this case is indeed not yet considered by the cleanup rule "Make implicit type explicit"!

Kind regards,
Jörg-Michael

Hi Mehmet,

thanks again – I thought I solved this, but I just realized there are more issues connected to this, therefore keeping it open for now!

Kind regards,
Jörg-Michael

Hi Mehmet,

okay, with the next release, these issues should now be resolved:

  • "Make implicit type explicit" correctly resolves the implicit types,
  • "Rearrange local declarations" now keeps the CONSTANTS before the TYPES (because they are used there),
  • "Delete unused variables" recognizes that the constants are used and therefore cannot be commented out:

image

Thanks again for reporting this!

Kind regards,
Jörg-Michael

Thank you for solving it quickly 🙂

Hi Mehmet,

thanks a lot – this should now be fixed in version 1.19.3, which was just released!

Kind regards,
Jörg-Michael