SAP ABAP开发指南SAP ABAP

《SAP ABAP 开发指南》第四单元第四课时

2018-08-20  本文已影响5人  46b61a5f089d
翱翔云天的SAP 技术网校

程序源代码

Select

*选择数据
SELECT * FROM zaxyt_t_order INTO TABLE it_order.
LOOP AT it_order INTO wa_order.
  WRITE: /, wa_order-orderid,
            wa_order-customerid,
            wa_order-prodctid.
ENDLOOP.

SELECT SINGLE * FROM zaxyt_t_cust INTO wa_cust.
WRITE: /, wa_cust-mandt,wa_cust-custname.

SELECT * FROM zaxyt_t_product INTO wa_product.
  WRITE: /, wa_product-productid,wa_product-productname.
ENDSELECT.

Update

*修改数据
wa_cust-customerid = '3'.
wa_cust-custname = 'The first customer get update'.
UPDATE zaxyt_t_cust FROM wa_cust.
COMMIT WORK.

modify

*修改数据,modify
SELECT * FROM zaxyt_t_cust INTO TABLE it_cust.
LOOP AT it_cust INTO wa_cust WHERE customerid = '4'.
  wa_cust-custname = 'The second customer updated'.
ENDLOOP.
wa_cust-customerid = '5'.
wa_cust-custname = 'The third customer'.
append wa_cust to it_cust.
modify zaxyt_t_cust from TABLE it_cust.
commit work.

insert

*插入数据
wa_cust-customerid = '3'.
wa_cust-custname = 'The first customer'.
INSERT zaxyt_t_cust FROM wa_cust.
wa_cust-customerid = '4'.
wa_cust-custname = 'The second customer'.
INSERT zaxyt_t_cust FROM wa_cust.

wa_product-productid = '3'.
wa_product-productname = 'The first product'.
INSERT zaxyt_t_product FROM wa_product.
COMMIT WORK.

delete

*删除数据
delete from zaxyt_t_cust where customerid = '5'.
commit work.

运行结果展示

涉及到数据库操作,需要自己建立数据库表进行查看。

上一篇 下一篇

猜你喜欢

热点阅读