2020 Apr 21 1:50 PM
When refactoring some legacy code, I came across this: I have a Select * Statement, and I copied it, so now I have to:
one is inside a LOOP AT t_ekkn INTO
the other inside LOOP AT t_ekkn ASSIGNING FIELD-SYMBOL
The Problem I face: The ATC-Check for 'unjustified' select * only identifies the first one as problematic. It seem to completely ignore the one with the field-symbol:
2020 Apr 27 12:06 PM
Hi Joachim Rees,
I agree that this is suprising at the first glance.
The reason is the following:
Both SELECT-statements fill the attribute gs_ekpo and then directly use one field of the result.
After the first SELECT-statement gs_ekpo is overwritten by the next SELECT-statement. Therefore it is clear that no more fields of this entry will be used.
This is the difference to the second SELECT-statement:
After ending the loop the end of the method is reached.
It is possible that gs_ekpo is read by some other method inside oder outside of the class. Therefore it is likely that the finding for this SELECT-statement would be a false-positive.
If you delete one of the selects you will not have any finding for the other one.
Best regards,
Friederike
2020 Apr 21 5:01 PM
And if you have only the one with the field symbols, you don't have the error?
2020 Apr 22 2:28 PM
Hi sandra.rossi , exactly this is the case, yes:
No finding on select *, although there should be one!
2020 Apr 27 12:06 PM
Hi Joachim Rees,
I agree that this is suprising at the first glance.
The reason is the following:
Both SELECT-statements fill the attribute gs_ekpo and then directly use one field of the result.
After the first SELECT-statement gs_ekpo is overwritten by the next SELECT-statement. Therefore it is clear that no more fields of this entry will be used.
This is the difference to the second SELECT-statement:
After ending the loop the end of the method is reached.
It is possible that gs_ekpo is read by some other method inside oder outside of the class. Therefore it is likely that the finding for this SELECT-statement would be a false-positive.
If you delete one of the selects you will not have any finding for the other one.
Best regards,
Friederike
2020 May 14 2:50 PM
Hey Friederike,
thanks for the detailed explanation! Makes sense!