内表的一些操作例子(工作区赋值使用了新语法)
- 构造一个内表BOOK,字段有BOOKNO,BOOKNAME,ZUOYE,PRICE.
- 输入几组数据:
BOOKNO |
BOOKNAME |
ZUOYE |
PRICE |
1 |
TEST |
MARK |
55 |
2 |
ERRO |
WRITE |
43 |
3 |
PRO |
BACKER |
67 |
4 |
中国历史 |
QINCHAO |
88 |
3、插入一个新的数据在第三行,每一列数据分别是‘5’,’insert’,’insert’,’36’
4、删除第4行数据
5、把数据复制给一个新的内表BOOK1
6、按照价格排序BOOK
7、修改第2条数据,把PRICE改为55.
TYPES:BEGIN OF TY_DATA, BOOKNO(20) TYPE C, BOOKNAME(20) TYPE C, ZUOYE(20) TYPE C, PRICE TYPE I, END OF TY_DATA. DATA:BOOK TYPE STANDARD TABLE OF TY_DATA WITH HEADER LINE. book = VALUE #( BOOKNO = '1' BOOKNAME = 'test' ZUOYE = 'mark' PRICE = 55 )."新语法 APPEND BOOK. book = VALUE #( BOOKNO = '2' BOOKNAME = 'ERRO' ZUOYE = 'WRITE' PRICE = 43 ). APPEND BOOK. book = VALUE #( BOOKNO = '3' BOOKNAME = 'PRO' ZUOYE = 'BAKER' PRICE = 67 ). APPEND BOOK. BOOK-BOOKNO = '4'. BOOK-BOOKNAME = '中国历史'. BOOK-ZUOYE = 'QINCHAO'. BOOK-PRICE = 88. APPEND BOOK. LOOP AT BOOK. WRITE:/ BOOK-BOOKNO,/ BOOK-BOOKNAME,/ BOOK-ZUOYE,/ BOOK-PRICE. ENDLOOP. WRITE:/ SY-ULINE. BOOK-BOOKNO = '5'. BOOK-BOOKNAME = 'INSERT'. BOOK-ZUOYE = 'INSERT'. BOOK-PRICE = 36. INSERT BOOK INDEX 3. LOOP AT BOOK. WRITE:/ BOOK-BOOKNO,/ BOOK-BOOKNAME,/ BOOK-ZUOYE,/ BOOK-PRICE. ENDLOOP. WRITE:/ SY-ULINE. DELETE BOOK INDEX 4. LOOP AT BOOK. WRITE:/ BOOK-BOOKNO,/ BOOK-BOOKNAME,/ BOOK-ZUOYE,/ BOOK-PRICE. ENDLOOP. WRITE:/ SY-ULINE. DATA:BOOK1 TYPE STANDARD TABLE OF TY_DATA WITH HEADER LINE. BOOK1[] = BOOK[]. LOOP AT BOOK1. WRITE:/ BOOK1-BOOKNO,/ BOOK1-BOOKNAME,/ BOOK1-ZUOYE,/ BOOK1-PRICE. ENDLOOP. WRITE:/ SY-ULINE. SORT BOOK BY PRICE. LOOP AT BOOK. WRITE:/ BOOK-BOOKNO,/ BOOK-BOOKNAME,/ BOOK-ZUOYE,/ BOOK-PRICE. ENDLOOP. WRITE:/ SY-ULINE. BOOK-PRICE = 55. MODIFY BOOK INDEX 2. LOOP AT BOOK. WRITE:/ BOOK-BOOKNO,/ BOOK-BOOKNAME,/ BOOK-ZUOYE,/ BOOK-PRICE. ENDLOOP.