2006 Nov 30 5:35 AM
Hello All,
I have a internal table with 3 fields in the following order:
VBELN (CHAR field), POSNR (NUMC field) and ETENR . I have sorted this table based on VBELN and POSNR; when I READ the TABLE with binary search WITH VBELN and POSNR as KEY fields, some times the read fails even if the entry is there.
If I READ TABLE without binary search it works good!
Anybody knows the reason and ideas to fix it.
Thanks
Kasee
2006 Nov 30 5:38 AM
I think your binary search works well only when you have one key. I am not sure though.
Regards,
Ravi
2006 Nov 30 5:43 AM
hi,
<i>when u read the table,
read it with key fields that are used for sorting.</i>
pls chk this link.
http://help.sap.com/saphelp_erp2005/helpdata/en/fc/eb373d358411d1829f0000e829fbfe/frameset.htm
rgds
anver
2006 Nov 30 5:46 AM
binary search works better for key fields....if vbeln and posnr are the key fields it will work fine...there might be a mistake in the definition..
2006 Nov 30 5:48 AM
Hi,
If you are reading the table using vbeln and posnr,sort the table by both.Otherwise,whatever things are used in reading,just sort with those fields.
2006 Nov 30 5:51 AM
Hello All,
I have sorted on both the key fields (VBELN and POSNR)!
Actually if both the fields are of same type (for example CHAR OR NUMC or just NUM) it works well for me.
Thanks
Kasee
2006 Nov 30 5:54 AM
2006 Nov 30 6:20 AM
hi,
check this..
vbeln posnr etenr
10 000001 12.13
10 000002 16.15
11 000001 112.13
11 000002 11.13
11 000003 18.30
index vbeln posnr etenr
0 10 000001 12.13
1 10 000002 16.15
2 11 000001 112.13 " index is set here
3 11 000002 11.13
4 11 000003 18.30
read table itab with key vbeln = 10
and posnr = 000002
binary search.
the index is set to 2 in here ..
now look for posnr here when im applying the binary search ..
there might be a possibility of posnr
10 < 11 (correct) and 000002 < 000001(false) so condition fails ..
this might be the case ..
i know that the binary search logic must read the index 0 and 1 that means the upper portion in the list leaving the index 3 and 4 ..
on the condition fail this is going down with sy-subrc <>0 as binary search is on
just check this ..
regards,
vijay.
2006 Nov 30 6:52 AM
Hello All,
I guess as Vinay says, this works for me. Can any body suggest ways to come over this problem?