SORTED
NON-UNIQUE – не уникальный ключ, сортируются все без исключения
UNIQUE – уникальный ключ, выберется только первое из всех значение по ключу
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
REPORT zsort_hash_table. DATA: itab TYPE SORTED TABLE OF zavto WITH NON-UNIQUE KEY name, wtab TYPE zavto. wtab-name = 'lada'. wtab-car_mass = '10000'. wtab-total_mass = '0'. wtab-client = 'KurganStalMost'. INSERT wtab INTO TABLE itab. wtab-name = 'porshe'. wtab-car_mass = '13500'. wtab-total_mass = '10000'. wtab-client = 'KMZ'. INSERT wtab INTO TABLE itab. wtab-name = 'BMW'. wtab-car_mass = '11000'. wtab-total_mass = '9000'. wtab-client = 'KMZ'. INSERT wtab INTO TABLE itab. wtab-name = 'Ford'. wtab-car_mass = '19000'. wtab-total_mass = '11080'. wtab-client = 'KMZ'. INSERT wtab INTO TABLE itab. LOOP AT itab INTO wtab. WRITE: / wtab-name, wtab-car_mass, wtab-total_mass, wtab-client. ENDLOOP. |
COLLECT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
REPORT zcollect. DATA: itab TYPE TABLE OF zavto, wtab TYPE zavto. wtab-name = 'lada'. wtab-car_mass = '10000'. wtab-total_mass = '0'. wtab-client = 'KurganStalMost'. COLLECT wtab INTO itab. wtab-name = 'porshe'. wtab-car_mass = '13500'. wtab-total_mass = '10000'. wtab-client = 'KMZ'. COLLECT wtab INTO itab. wtab-name = 'Ford'. wtab-car_mass = '11000'. wtab-total_mass = '9000'. wtab-client = 'KMZ'. COLLECT wtab INTO itab. wtab-name = 'Ford'. wtab-car_mass = '19000'. wtab-total_mass = '11080'. wtab-client = 'KMZ'. COLLECT wtab INTO itab. LOOP AT itab INTO wtab. WRITE : / wtab-name, wtab-car_mass, wtab-total_mass, wtab-client. ENDLOOP. |
BINARY SEARCH
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
REPORT zcollect. DATA: itab TYPE TABLE OF zavto, wtab TYPE zavto. DO 100000 TIMES. wtab-name = 'car' && sy-index. wtab-car_mass = sy-index. INSERT wtab INTO TABLE itab. ENDDO. READ TABLE itab INTO wtab WITH KEY car_mass = '100' BINARY SEARCH. MESSAGE '' && wtab-name TYPE 'I'. |
SELECT FOR ALL SEARCH
1 2 3 4 5 6 7 8 9 10 11 12 |
REPORT zselect_for_all. DATA: imara TYPE TABLE OF mara, imakt TYPE TABLE OF makt, wmakt TYPE imakt. SELECT * FROM mara INTO TABLE imara. SELECT * FROM makt INTO TABLE imakt FOR ALL ENTRIES IN imara WHERE makt~matnr = imara-matnr. |