Internal Table name : itab_final.
work area name : wa_final
itab_final having 4 records as follows.
S.NO UID UNAME
1 A1 AUDI
2 B1 BMW
3 R1 RENAULT
4 H1 HONDA
I have one variable CID holding value R1.
In my program I have a READ statement like
READ TABLE itab_final INTO wa_final WITH KEY uid = cid BINARY SEARCH.
we have R1 in itab_final but still will get SY-SUBRC as 8 (READ statement failure) when we execute the above READ statement.
Solution 1 :
READ TABLE itab_final INTO wa_final WITH KEY uid = cid .
Solution 2:
SORT itab_final by uid.
READ TABLE itab_final INTO wa_final WITH KEY uid = cid BINARY SEARCH.
Sort the internal table based on the field which is used in READ statement as WITH KEY .
Conclusion : Both Solution 1 and Solution 2 will work fine. But when compare to Solution 1 , Solution 2 is better in performance wise.
work area name : wa_final
itab_final having 4 records as follows.
S.NO UID UNAME
1 A1 AUDI
2 B1 BMW
3 R1 RENAULT
4 H1 HONDA
I have one variable CID holding value R1.
In my program I have a READ statement like
READ TABLE itab_final INTO wa_final WITH KEY uid = cid BINARY SEARCH.
we have R1 in itab_final but still will get SY-SUBRC as 8 (READ statement failure) when we execute the above READ statement.
Solution 1 :
READ TABLE itab_final INTO wa_final WITH KEY uid = cid .
Solution 2:
SORT itab_final by uid.
READ TABLE itab_final INTO wa_final WITH KEY uid = cid BINARY SEARCH.
Sort the internal table based on the field which is used in READ statement as WITH KEY .
Conclusion : Both Solution 1 and Solution 2 will work fine. But when compare to Solution 1 , Solution 2 is better in performance wise.
No comments:
Post a Comment