1. 程式人生 > >修改內表數據並輸出結果

修改內表數據並輸出結果

odi loop google ogl 表數 插入數據 data into clas

*定義結構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.

修改內表數據並輸出結果