关闭

ABAP SORT

标签: abapsort顺序多字段sap
3874人阅读 评论(1) 收藏 举报
分类:

SORT MAN1 BY HIGH WEIGHT DESCENDING.

SORT MAN1 DESCENDING BY HIGH WEIGHT.

的效果是不一样的。

REPORT  YTEST20160527.
DATA:BEGIN OF MAN,
  NAME(20) TYPE C,
  HIGH TYPE P DECIMALS 2,
  WEIGHT TYPE P DECIMALS 2,
END OF MAN.

DATA: MAN1 LIKE HASHED TABLE OF MAN WITH UNIQUE KEY NAME.

MAN-NAME = 'JAY'.
MAN-HIGH = '1.68'.
MAN-WEIGHT = 120.
INSERT MAN INTO TABLE MAN1.


MAN-NAME = 'ADOLF'.
MAN-HIGH = '1.69'.
MAN-WEIGHT = 100.
INSERT MAN INTO TABLE MAN1.

MAN-NAME = 'BABO'.
MAN-HIGH = '1.70'.
MAN-WEIGHT = 130.
INSERT MAN INTO TABLE MAN1.

LOOP AT MAN1 INTO MAN.
  WRITE:/ MAN-NAME,MAN-HIGH,MAN-WEIGHT.
ENDLOOP.

SORT MAN1 BY HIGH WEIGHT DESCENDING.
SKIP.
ULINE.
LOOP AT MAN1 INTO MAN.
  WRITE:/ MAN-NAME,MAN-HIGH,MAN-WEIGHT.
ENDLOOP.

SORT MAN1 DESCENDING BY HIGH WEIGHT.
SKIP.
ULINE.
LOOP AT MAN1 INTO MAN.
  WRITE:/ MAN-NAME,MAN-HIGH,MAN-WEIGHT.
ENDLOOP.


结果如图:

结论:

SORT MAN1 BY HIGH WEIGHT DESCENDING.--------------------只有WEIGHT 字段是降序,其他字段还是默认的升序

SORT MAN1 DESCENDING BY HIGH WEIGHT.--------------------BY后面所有的字段都是降序

多个字段排序,字段在前面的优先排序


1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:272250次
    • 积分:3842
    • 等级:
    • 排名:第8744名
    • 原创:121篇
    • 转载:17篇
    • 译文:0篇
    • 评论:15条
    文章分类
    最新评论