‎2007 Sep 28 9:42 PM
Hi Experts,
I have an issue with 'READ TABLE' statement in a program. I am reading an internal table "i_output". The issue here is, it is working fine with some
customers(kunnr) but not for others.
The code:
do.
clear i_output.
read line sy-index.
if sy-subrc <> 0.
exit.
endif.
check not i_output is initial.
read table i_output with key kunnr = i_output-kunnr
vbeln = i_output-vbeln
posnr = i_output-posnr binary search.
check sy-subrc = 0.
Here in 'sy-subrc' it's returning '0' for some customers and sometimes '8'.
Can anybody please let me know what is wrong with this.
Thanks much.
‎2007 Sep 28 9:45 PM
SORT Table i_output first...since you are using binary search.
SORT i_output BY KUNNR VBELN POSNR.
read table i_output with key kunnr = i_output-kunnr
vbeln = i_output-vbeln
posnr = i_output-posnr binary search.
Sri
Message was edited by:
Sri Tayi
‎2007 Sep 28 9:45 PM
SORT Table i_output first...since you are using binary search.
SORT i_output BY KUNNR VBELN POSNR.
read table i_output with key kunnr = i_output-kunnr
vbeln = i_output-vbeln
posnr = i_output-posnr binary search.
Sri
Message was edited by:
Sri Tayi
‎2007 Sep 28 9:50 PM
Hi
SORTing of Internal is a must to use the BINARY search in read statement
So first SORT ITAB by KUNNR VBELN POSNR first
then use the READ statement as you wrote
then it will fetch the right records always
Regards
Anji
‎2007 Sep 28 9:57 PM
try this:
sort i_output by kunnr vbeln posnr.
read table i_output with key kunnr = i_output-kunnr
vbeln = i_output-vbeln
posnr = i_output-posnr .
check sy-subrc = 0.
This is something strange... how are you reading the same table with same conditions!!!!
Thanks,
SKJ
‎2007 Sep 28 10:02 PM
‎2007 Sep 28 10:03 PM
Hi
Paste your code completely then it is easy to solve
Regards
Anji
‎2007 Sep 28 10:20 PM
‎2007 Sep 28 10:25 PM
Other folks have coverd the need to sort.
Another issue can occur if the value you are using for kunnr is not properly formatted.
You may have to call
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = i_output-kunnr
IMPORTING
output = i_output-kunnr.to ensure kunnr is properly formatted before doing the read.
As noted above, I think you need to post more of your code to put things in context.
Good luck
Brian