‎2006 Nov 07 3:05 PM
Hi all. I'm looping over itab_1 into wa_itab_1. I want to select a single row of data from itab_2 based on a value in wa_itab_1. I don't need to llop over both tables do I? Isn't there a more terse way of selecting the record from itab_2?
regards,
Mat
‎2006 Nov 07 3:07 PM
read table itab_2 with key field1 = wa_itab_1-field1
field2 = wa_itab_1-field2.
If your table is sorted by field1 and field2, you can add the BINARY SEARCH option to speed up the read.
read table itab_2 with key field1 = wa_itab_1-field1
field2 = wa_itab_1-field2
binary search.
Message was edited by: Michael Malvey
‎2006 Nov 07 3:08 PM
‎2006 Nov 07 3:08 PM
hi,
loop at tb1 into struct
read tab2 into struct2with key keyparam = struct-value.
if sy-subrc = 0.
row found
endif.
endloop.
grtz
Koen
‎2006 Nov 07 3:12 PM
Hi,
You can use the read statement to get the corresponding single record of the second table.
read table itab_2 into wa_itab_2 with key field1 = wa_itab_1-field1
...
binary search.
When you are using binary search make sure you are sorting the internal table by the order of the fields which are used in the read statement.
using binary search is the quicker than the nomal read statement.
Regards,
Satya,