Skip to Content
0
Former Member
May 12, 2010 at 03:30 AM

Could not use binary search for matnr field

49 Views

The bellow code doesn't work, please help:

data: begin of gs_mara,
       matnr type matnr,
       meins type meins,
      end of gs_mara.
data: gt_mara like table of gs_mara with key matnr,
      gs_temp like gs_mara.

select matnr meins up to 1000 rows
from mara
into table gt_mara.

if sy-subrc = 0.
  sort gt_mara by matnr descending.

  loop at gt_mara into gs_mara.
     read table gt_mara into gs_temp
     with key matnr = gs_mara-matnr binary search.
     if sy-subrc = 0.
       write: gs_temp-matnr, gs_temp-meins.
     endif.
  endloop.
endif.