修改内表数据并输出结果
Posted 独吊东南枝
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了修改内表数据并输出结果相关的知识,希望对你有一定的参考价值。
*定义结构ty_sales
TYPES:BEGIN OF ty_sales,
customerid(3) TYPE n,
productid(3) TYPE n,
orderid(3) TYPE n,
customername(10) TYPE c,
amount TYPE i,
END OF ty_sales.
*定义内表和工作区
DATA: it_sales TYPE STANDARD TABLE OF ty_sales WITH KEY customerid productid orderid.
DATA wa_sales TYPE ty_sales.
*添加数据
*插入数据
wa_sales-customerid = ‘001‘.
wa_sales-productid = ‘001‘.
wa_sales-orderid = ‘001‘.
wa_sales-customername = ‘Apple‘.
wa_sales-amount = 10.
APPEND wa_sales TO it_sales.
wa_sales-customerid = ‘003‘.
wa_sales-productid = ‘002‘.
wa_sales-orderid = ‘001‘.
wa_sales-customername = ‘Microsoft‘.
wa_sales-amount = 10.
APPEND wa_sales TO it_sales.
wa_sales-customerid = ‘002‘.
wa_sales-productid = ‘002‘.
wa_sales-orderid = ‘001‘.
wa_sales-customername = ‘Google‘.
wa_sales-amount = 10.
APPEND wa_sales TO it_sales.
wa_sales-customerid = ‘003‘.
wa_sales-productid = ‘001‘.
wa_sales-orderid = ‘001‘.
wa_sales-customername = ‘Google‘.
wa_sales-amount = 10.
APPEND wa_sales TO it_sales.
*将公司代码为001的订单 公司名称改为Apple2
LOOP AT it_sales INTO wa_sales WHERE customerid = ‘001‘.
wa_sales-customername = ‘Apple2‘.
MODIFY it_sales FROM wa_sales.
ENDLOOP.
*将数据输出屏幕
LOOP AT it_sales INTO wa_sales.
WRITE: / wa_sales-customerid,wa_sales-productid,wa_sales-orderid,wa_sales-customername,wa_sales-amount.
ENDLOOP.
以上是关于修改内表数据并输出结果的主要内容,如果未能解决你的问题,请参考以下文章