*----------------------------------------------------------------------*
* 作成者 : 張玉剛
* 作成日 : 2009/07/22
---------------------------------------------------------------------*
* 処理概要:
* 判断一个内表中的列是不是重复
*----------------------------------------------------------------------*
* 使用内表:
* IT_TABLE
* IT_TABLENEW
*----------------------------------------------------------------------*
REPORT Z_TEST5.
*----------------------------------------------------------------------*
* 类型定義
*----------------------------------------------------------------------*
"结构体定義
TYPES:
BEGIN OF T_STR_CLASS,
A(10) TYPE C,
B TYPE I,
END OF T_STR_CLASS,
"内表定義
T_IT_TABLE TYPE STANDARD TABLE OF T_STR_CLASS.
*----------------------------------------------------------------------*
* 变量定義
*----------------------------------------------------------------------*
DATA:
STR_CLASS TYPE T_STR_CLASS,
IT_TABLE TYPE T_IT_TABLE,
IT_TABLENEW TYPE T_IT_TABLE,
OLD TYPE I,
NEW TYPE I.
"向内表中倒入数据
STR_CLASS-A = 'A1'.
STR_CLASS-B = '1'.
APPEND STR_CLASS TO IT_TABLE.
CLEAR STR_CLASS.
STR_CLASS-A = 'A1'.
STR_CLASS-B = '1'.
APPEND STR_CLASS TO IT_TABLE.
CLEAR STR_CLASS.
"把内表中数据放到另一个内表中
IT_TABLENEW = IT_TABLE.
"按照要查找的是否重复的列排序
SORT IT_TABLENEW BY A B.
"按照a.b列删除内表中的数据
DELETE ADJACENT DUPLICATES FROM IT_TABLENEW COMPARING A B.
"取得表中数据的行数
DESCRIBE TABLE IT_TABLENEW LINES NEW.
DESCRIBE TABLE IT_TABLE LINES OLD.
IF OLD <> NEW.
MESSAGE '重複' TYPE 'E'.
ENDIF.