SAP ABAP 排序 SORT

排序 DESCENDING(降序) / ASCENDING(升序) 只对最近的字段有效 。
*&---------------------------------------------------------------------*
*& Report  ZWYB_004
*&
*&---------------------------------------------------------------------*
*&
*&排序
*&---------------------------------------------------------------------*

REPORT  ZWYB_004.

TYPES :BEGIN OF TYP_S,
         S1(10),
         S2(20),
       END OF TYP_S.
DATA LT_S TYPE TABLE OF TYP_S WITH HEADER LINE .
FIELD-SYMBOLS <FS_S> TYPE  TYP_S  .

CLEAR LT_S .
LT_S-S1 = 'A' .
LT_S-S2 = 'AAA'.
APPEND LT_S .


CLEAR LT_S .
LT_S-S1 = 'A' .
LT_S-S2 = 'DDD'.
APPEND LT_S .

CLEAR LT_S .
LT_S-S1 = 'B' .
LT_S-S2 = 'BBB'.
APPEND LT_S .

CLEAR LT_S .
LT_S-S1 = 'C' .
LT_S-S2 = 'CCC'.
APPEND LT_S  .

SORT LT_S BY  S1   S2 DESCENDING .

LOOP AT LT_S .
  WRITE : LT_S-S1 .
  WRITE :LT_S-S2 .
  WRITE : /.
ENDLOOP .
显示结果:排序 DESCENDING 只对最近的字段有效 。

 

 

posted @ 2022-04-03 20:22  冰里取火  阅读(2263)  评论(0编辑  收藏  举报