按 table 的特定字段对动态 table 进行排序

Sorting dynamic table by certain field of that table

我在动态 table 排序时遇到问题。我正在通过动态字段符号读取 table。如何按 table 的某个字段(在 select 之后)对 table 进行排序。我知道这个字段在 table 中,但由于它是动态的,我不能简单地使用 "sort table by field".'

有哪些替代方案?

你可以排序

FIELD-SYMBOL <product_list> TYPE STANDARD TABLE.

单列

CONSTANTS category TYPE char30 VALUE 'CATEGORY'.
SORT <product_list> BY (category).

并通过多列

DATA(category_and_price) = VALUE abap_sortorder_tab( ( name = 'CATEGORY' ) 
                                                     ( name = 'PRICE'
                                                       descending = abap_true ) ).

SORT <product_list> BY (category_and_price).

ABAP Keyword Documentation article SORT itab 中所述。