一个相反的默认排序

今天弄内表的时候发现向内表里填数据时用"APPEND...SORTED BY f"这条语句时,排序是按"f"关键字降序的,而且MS不能改.嗯,跟直接SORT的默认排序相反.

下面是程序和F1帮助.

*----------------------------------------------------

TYPES: BEGIN OF COMPANIES_TYPE,
        NAME(10), SALES TYPE I,
       END   OF COMPANIES_TYPE.

DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE
          INITIAL SIZE 3,
      WA_COMPANIES TYPE COMPANIES_TYPE.

WA_COMPANIES-NAME = 'big'.
WA_COMPANIES-SALES = 90.
APPEND WA_COMPANIES TO COMPANIES.

WA_COMPANIES-NAME = 'small'.
WA_COMPANIES-SALES = 10.
APPEND WA_COMPANIES TO COMPANIES.

WA_COMPANIES-NAME = 'too small'.
WA_COMPANIES-SALES =  5.
APPEND WA_COMPANIES TO COMPANIES.

WA_COMPANIES-NAME = 'middle'.
WA_COMPANIES-SALES = 50.
APPEND WA_COMPANIES TO COMPANIES SORTED BY SALES.

loop at companies into wa_companies.
  WRITE: / WA_COMPANIES-SALES.
endloop.

*------------------------------------------------------

APPEND [wa TO] itab SORTED BY f [ASSIGNING <fs>|REFERENCE INTO dref].

Effect

Inserts the new entry into table and re-sorts the table by the sub-field f in descending order. This only makes sense if the table was sorted beforehand. When the number of table entries reaches the INITIAL SIZE parameter value, the last entry is deleted if the value f of a new entry is greater (particularly suitable for ranked lists). You can only sort by one component, and may only use this variant with a STANDARD TABLE.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值