2014 Nov 03 9:14 PM
Hello again everyone!
Seems I've found yet another syntactical peculiarity while trying to reuse standard code, so let's just dive right in...
Here's the block of code I'm struggling with:
Now, in debugger, I can see that bwkey contains 1510 and the range table is empty:
This being the case, I would expect that the check should evaluate to false (and set sy-subrc NE 0), and skip the remainder of this selection loop iteration, continuing with the next iteration. However:
...it seems to have evaluated it as being true!!!
How could this be the case, as (with the range table empty at this point) 1510 is NOT "in" an empty table?
Thanks in advance, and <removed by moderator> for helpful answers!
Richard
Message was edited by: Manish Kumar
2014 Nov 03 10:15 PM
Hi Richard,
as a matter of fact, this is the correct behaviour. An empty range will always return true on check.
This is not at all peculiar when you think of it as a non-existent condition.
Mind you, the result would turn out as false, if you had only an empty row in the ranges table. Since this would be an existent condition, it would be evaluated according to the rules and most certainly be treated as false.
What i do find peculiar, is the way you check the range WHITHIN the select-loop instead of a select condition.
And while giving advice on improvement, you could still enhance your coding by gathering only those values, that are needed and by combining both selects by join.
Best regards - Jörg
Hello again everyone!
Seems I've found yet another syntactical peculiarity while trying to reuse standard code, so let's just dive right in...
Here's the block of code I'm struggling with:
Now, in debugger, I can see that bwkey contains 1510 and the range table is empty:
This being the case, I would expect that the check should evaluate to false (and set sy-subrc NE 0), and skip the remainder of this selection loop iteration, continuing with the next iteration. However:
...it seems to have evaluated it as being true!!!
How could this be the case, as (with the range table empty at this point) 1510 is NOT "in" an empty table?
Thanks in advance, and <removed by moderator> for helpful answers!
Richard
Message was edited by: Manish Kumar
2014 Nov 03 10:15 PM
Hi Richard,
as a matter of fact, this is the correct behaviour. An empty range will always return true on check.
This is not at all peculiar when you think of it as a non-existent condition.
Mind you, the result would turn out as false, if you had only an empty row in the ranges table. Since this would be an existent condition, it would be evaluated according to the rules and most certainly be treated as false.
What i do find peculiar, is the way you check the range WHITHIN the select-loop instead of a select condition.
And while giving advice on improvement, you could still enhance your coding by gathering only those values, that are needed and by combining both selects by join.
Best regards - Jörg
2014 Nov 04 3:04 PM
Thanks Jörg!
Now that it's been explained as such, that actually makes perfect sense!
Regarding the improvements you've suggested, as I previously stated, this comes directly from SAP standard code. I completely agree, and they may do well to heed your suggestions...
Thanks again!
Richard
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |