您好,登錄后才能下訂單哦!
本篇內容介紹了“怎么在SAP ABAP編程環境里創建自己的Z表”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
選中ABAP包,右鍵創建一個新的Database Table:
維護表名為ZBOOKING:
表實現的源代碼:
@EndUserText.label : 'Jerry''s booking' @AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE @AbapCatalog.tableCategory : #TRANSPARENT @AbapCatalog.deliveryClass : #A @AbapCatalog.dataMaintenance : #LIMITED define table zbooking { key client : abap.clnt not null; key booking : abap.int4 not null; customername : abap.char(50); numberofpassengers : abap.int2; emailaddress : abap.char(50); country : abap.char(50); dateofbooking : timestampl; dateoftravel : timestampl; @Semantics.amount.currencyCode : 'zbooking.currencycode' cost : abap.curr(15,2); currencycode : abap.cuky; lastchangedat : timestampl; }
激活:
下一步,創建一個ABAP類,以代碼的方式往Z表里插入數據。
這個ABAP類要實現if_oo_adt_classrun接口,類似Java里的console應用:
完整代碼:
CLASS zcl_data_generator DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES if_oo_adt_classrun. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. CLASS zcl_data_generator IMPLEMENTATION. METHOD if_oo_adt_classrun~main. DATA:it_bookings TYPE TABLE OF zbooking. * read current timestamp GET TIME STAMP FIELD DATA(zv_tsl). * fill internal table (itab) it_bookings = VALUE #( ( booking = '1' customername = 'Jerry' numberofpassengers = '3' emailaddress = 'jerry@sap.com' country = 'China' dateofbooking ='20190213125959' dateoftravel ='20190213125959' cost = '546' currencycode = 'EUR' ) ( booking = '2' customername = 'Tom' numberofpassengers = '1' emailaddress = 'tom@sap.com' country = 'USA' dateofbooking ='20190313125959' dateoftravel ='20190313125959' cost = '1373' currencycode = 'USD' lastchangedat = zv_tsl ) ). DELETE FROM zbooking. INSERT zbooking FROM TABLE @it_bookings. SELECT * FROM zbooking INTO TABLE @it_bookings. out->write( sy-dbcnt ). out->write( 'data inserted successfully!'). ENDMETHOD. ENDCLASS.
執行這個console應用:
成功插入兩條數據:
選中Z表,選擇Open with Data Preview:
看到了成功插入的兩條數據:
“怎么在SAP ABAP編程環境里創建自己的Z表”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。