TODO Variable not used is not picking up dynamic code
When using variables in string templates for e.g. dynamic selects the system is not detecting the selection.
... DATA(test_variable) = 1 DATA(select_clause) = |cds_view( key = @test_variable )|. ... SELECT * FROM (select_clause) INTO @test. ...
Hi DoublG,
thanks for reporting this issue! You are right here – but I am afraid analyzing the content of literals, or strings that are built and then used dynamically would be more than ABAP cleaner can do.
ABAP cleaner does recognize embedded usage of variables in string templates – that's why in the following example, value3 gets a TODO, but value1 and value2 don't:
So, |... { embedded_variable } ...| works. In your example, however, the variable is not embedded in the template, but it is simply part of the string literal, which will then only be evaluated dynamically during SELECT. The same limitation is true for renaming in ADT: If you right-click "test_variable" in its declaration line and select context menu "Rename…", the literal cds_view( key = @test_variable ) will be unchanged.
I think the best that can be done here is to mark the variable as needed:
DATA(test_variable) = 1 ##NEEDED.
With that, ABAP cleaner will not add a TODO:
Kind regards, Jörg-Michael