Sorting Internal Tables(内表排序)

原创 2011年01月19日 14:09:00

DATA: BEGIN OF LINE,
        LAND(3)  TYPE C,
        NAME(10) TYPE C,
        AGE      TYPE I,
        WEIGHT   TYPE P DECIMALS 2,
      END OF LINE.

DATA ITAB LIKE STANDARD TABLE OF LINE WITH NON-UNIQUE KEY LAND.

LINE-LAND = 'G'.   LINE-NAME   = 'Hans'.
LINE-AGE  = 20.    LINE-WEIGHT = '80.00'.
APPEND LINE TO ITAB.

LINE-LAND = 'USA'. LINE-NAME   = 'Nancy'.
LINE-AGE  = 35.    LINE-WEIGHT = '45.00'.
APPEND LINE TO ITAB.

LINE-LAND = 'USA'. LINE-NAME   = 'Howard'.
LINE-AGE  = 40.    LINE-WEIGHT = '95.00'.
APPEND LINE TO ITAB.

LINE-LAND = 'GB'.  LINE-NAME   = 'Jenny'.
LINE-AGE  = 18.    LINE-WEIGHT = '50.00'.
APPEND LINE TO ITAB.

LINE-LAND = 'F'.   LINE-NAME   = 'Michele'.
LINE-AGE  = 30.    LINE-WEIGHT = '60.00'.
APPEND LINE TO ITAB.

LINE-LAND = 'G'.   LINE-NAME   = 'Karl'.
LINE-AGE  = 60.    LINE-WEIGHT = '75.00'.
APPEND LINE TO ITAB.

PERFORM LOOP_AT_ITAB.

SORT ITAB.
PERFORM LOOP_AT_ITAB.

SORT ITAB.
PERFORM LOOP_AT_ITAB.

SORT ITAB STABLE.
PERFORM LOOP_AT_ITAB.

SORT ITAB DESCENDING BY LAND WEIGHT ASCENDING.
PERFORM LOOP_AT_ITAB.

FORM LOOP_AT_ITAB.
  LOOP AT ITAB INTO LINE.
    WRITE: / LINE-LAND, LINE-NAME, LINE-AGE, LINE-WEIGHT.
  ENDLOOP.
  SKIP.
ENDFORM.

 

 

 



 

 

 

 

DATA: BEGIN OF LINE,
        TEXT(6),
        XTEXT(160) TYPE X,
      END OF LINE.

DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY TEXT.

LINE-TEXT = 'Muller'.
CONVERT TEXT LINE-TEXT INTO SORTABLE CODE LINE-XTEXT.
INSERT LINE INTO TABLE ITAB.

LINE-TEXT = 'Möller'.
CONVERT TEXT LINE-TEXT INTO SORTABLE CODE LINE-XTEXT.
INSERT LINE INTO TABLE ITAB.

LINE-TEXT = 'Moller'.
CONVERT TEXT LINE-TEXT INTO SORTABLE CODE LINE-XTEXT.
INSERT LINE INTO TABLE ITAB.

LINE-TEXT = 'Miller'.
CONVERT TEXT LINE-TEXT INTO SORTABLE CODE LINE-XTEXT.
INSERT LINE INTO TABLE ITAB.

SORT ITAB.
PERFORM LOOP_AT_ITAB.

SORT ITAB BY XTEXT.
PERFORM LOOP_AT_ITAB.

SORT ITAB AS TEXT.
PERFORM LOOP_AT_ITAB.

FORM LOOP_AT_ITAB.
  LOOP AT ITAB INTO LINE.
    WRITE: / LINE-TEXT, line-.
  ENDLOOP.
  SKIP.
ENDFORM.

 

代码摘自:http://help.sap.com/saphelp_NW04/helpdata/en/fc/eb3800358411d1829f0000e829fbfe/content.htm

相关文章推荐

PAT 1041 Linked List Sorting (25)(链表排序)

题目1052. Linked List Sorting (25)时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

What Are Different Types Of Internal Tables and Their Usage

基础知识, 还要整清楚一点地,转贴地址: http://www.sap-img.com/abap/what-are-different-types-of-internal-tables-and-the...

Internal Sorting Algorithms Part 1/2: Elementary Sorts

Internal Sorting Algorithms Part 1/2: Elementary Sorts目录 Internal Sorting Algorithms Part 12 Element...

Internal Sorting Algorithms Part 2/2: Advanced Sorts

Internal Sorting Algorithms Part 2/2: Advanced Sorts目录 Internal Sorting Algorithms Part 22 Advanced ...

poj1094Sorting It All Out(拓扑排序)

这题挺奇怪的,我之前还真么做过这样的拓扑排序,之前卡了一阵子,这个题目是判断到第几个成环,到第几个正好能唯一排序,另一种就是怎么也排不了序,就是每个数据跑一遍拓扑排序就行了#include #inc...

POJ1094 Sorting It All Out(拓扑排序)每输入条关系判断一次

Sorting It All Out Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2918...

POJ-1094-Sorting It All Out(拓扑排序)

Language: Default Sorting It All Out Time Limit: 1000MS   Memory Limit: 10000K T...

排序算法(Shell Sorting希尔排序)

希尔(Shell)排序可以说是基于插入排序的一种更高级的排序算法。博文中给出了实现代码和10000个待排序序列排序运行时间。...

[ACM] POJ 1094 Sorting It All Out (拓扑排序)

解题思路: 拓扑排序的应用。参考http://www.cnblogs.com/pushing-my-way/archive/2012/08/23/2652033.html做的。 本题需要注意的问题很多...

poj1094——Sorting It All Out(拓扑排序)

DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Sorting Internal Tables(内表排序)
举报原因:
原因补充:

(最多只允许输入30个字)