‎2011 Apr 04 5:00 PM
Hi,
Following is my select single query
SELECT SINGLE *
FROM z_table
WHERE mprn_from LE iv_pod_id
AND mprn_to GE iv_pod_id.
mprn_from and mprn_to is of type NUMC, length 10
iv_pod_id is of type CHAR, length 50
Value in iv_pod_id is '120000043221967'. This is not present in z_table. When we check using se16 and put the value in mprn_from and mprn_to, obviously it is truncated to 1200000432 becuase the field length is 10, and no records are selected when we press F8.
But when the above select single statement is executed, sy-subrc = 0 is returned. Some random value from Z-table is selected. I have no idea why this is happening.
Nik
‎2011 Apr 04 5:12 PM
Why you want to compare a field with length 50 to that of 10 ??
You have to find out if this is really necessary or not or may be the first 10 char are of relevance something like
l_var = iv_pod_id 0(10).
‎2011 Apr 05 6:41 AM
Hi,
1st it makes no sense searching with wrong field types.
2nd you would find results in SE16 if you are looking with ">=" or "<=" as in your query and not only with the exact value.
For that use the select options button just right of the execute button on se16 selection-screen.
Regards,
Klaus
‎2011 Apr 05 7:27 AM
In Utilities mprn is numc 10, and mpan is char 50.
iv_pod holds the value for both mpan and mprn. Before the select query there is no check as to which value iv_pod is holding, mpan or mprn. I am going to put the check now. But my question still remains unanswered. Why this erratic behaviour by simple select single statement.
‎2011 Apr 05 7:55 AM
Hi.. Nikhil Jadha.,
*check as below....
Tables : z_table.
Data : it like table of z_table,
wa like line of it.
SELECT SINGLE * FROM z_table into corresponding fields of WA WHERE mprn_from LE iv_pod_id AND mprn_to GE iv_pod_id.
With Regards,
Samba
Edited by: G.S.S.RAO on Apr 5, 2011 8:56 AM
‎2011 Apr 05 11:12 AM
Hi,
there is no erratic behaviour in SELECT SINGLE, it works fine as designed and look for 1st random table line that fulfills your query.
If there may be many hits, you will get several random answers in several queries.
Definitely the error is in your request! You should start your query with a field of same type as database field!
Move your field to compare ta a work field you define in program!
Regards,
Klaus
‎2011 Apr 05 8:10 AM
Hi Nikhil,
I dont understand for wat purpose you are trying to compare the values of length 10 and 50.
But i try to suggest a way. convert the iv_pod_id from char into numc value and save it in a variable.
perform comparison using that variable.
Hope it ll help you.
You have also mentioned even it is giving in that format it returns the value sy-subrc eq 0. It may be due to comparing the first 10 values and considering that it may be greater or lesser than it. It is a guess and i am sorry if it is wrong.
Edited by: Giriesh M on Apr 5, 2011 9:11 AM
‎2011 Apr 05 10:09 AM
hi ,
SELECT SINGLE *
FROM z_table
WHERE mprn_from LE iv_pod_id
AND mprn_to GE iv_pod_id.
mprn_from and mprn_to is of type NUMC, length 10
iv_pod_id is of type CHAR, length 50
Value in iv_pod_id is '120000043221967'. This is not present in z_table. When we check using se16 and put the value in mprn_from and mprn_to, obviously it is truncated to 1200000432 becuase the field length is 10, and no records are selected when we press F8.
But when the above select single statement is executed, sy-subrc = 0 is returned. Some random value from Z-table is selected. I have no idea why this is happening.
sy-subrc will return o only because
Value in iv_pod_id is '120000043221967'
and mprn_to is 10 character
i dont know what are values in mprn_from and mprn_to
Can you tell values
regards
Deepak.
‎2011 Apr 05 10:58 AM
Hi Nikhil,
Since everyone iterated the fact of diff. data types I wont touch that.
Reg SY-SUBRC = 0, you have used indefinitive comparators (i.e) GE and LE. There can be infinite possibilities of both.
>= 10 can be 10 or 100 or 1000 and similarly for <=10
Hence it is picking any such value and you get sy-subrc = 0. Also check SY-DBCNT for how many are possible
Check the internal table/ work area you are trying to select into and you'll understand your problem.
Regards
Naveen Vajja
Edited by: Ncvajja on Apr 5, 2011 12:04 PM