本篇內容介紹了“怎么在SAP ABAP編程環(huán)境里創(chuàng)建自己的Z表”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
創(chuàng)新互聯(lián)公司專注于故城企業(yè)網(wǎng)站建設,響應式網(wǎng)站設計,成都做商城網(wǎng)站。故城網(wǎng)站建設公司,為故城等地區(qū)提供建站服務。全流程按需網(wǎng)站建設,專業(yè)設計,全程項目跟蹤,創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務
選中ABAP包,右鍵創(chuàng)建一個新的Database Table:
維護表名為ZBOOKING:
表實現(xiàn)的源代碼:
@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; }
激活:
下一步,創(chuàng)建一個ABAP類,以代碼的方式往Z表里插入數(shù)據(jù)。
這個ABAP類要實現(xiàn)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.
執(zhí)行這個console應用:
成功插入兩條數(shù)據(jù):
選中Z表,選擇Open with Data Preview:
看到了成功插入的兩條數(shù)據(jù):
“怎么在SAP ABAP編程環(huán)境里創(chuàng)建自己的Z表”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質量的實用文章!