Info

You are currently browsing the 2&5… & Coo4U… weblog archives for the day March 9, 2008.

March 2008
M T W T F S S
« Feb   Apr »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Archive for March 9, 2008

ABAP tips: binary search

在read table的时候,为了提高查找内表的效率,通常使用二分法查找,即binary search。但是使用这个关键字有一个小tip:
查找对象和被查找对象的关键字或关键字组合必须是相同的,且排列顺序也要相同。
Eg:
loop it_A.
  read table it_B with key date = lt_A-date2
                                            matnr = lt_A-matnr2
                                            BINARY SEARCH.
endloop.

在此之前,必须 sort it_A by date matnr. 和Sort it_B by date2 matnr2. 两个关键字都要sort,且不能一个升序,一个降序。

|