Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CHECK not properly evaluating against a range table within a SELECT loop

Former Member
0 Likes
4,447

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

1 ACCEPTED SOLUTION
Read only

jrg_wulf
Active Contributor
0 Likes
2,912

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

2 REPLIES 2
Read only

jrg_wulf
Active Contributor
0 Likes
2,913

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

Read only

Former Member
0 Likes
2,912

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