Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to create your own Z table in SAP ABAP programming environment

Shulou Source: shulou.com Published: 2022-05-31 16:04:38 10月16日 Update

This article introduces the knowledge of "how to create your own Z table in the SAP ABAP programming environment". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Select the ABAP package and right-click to create a new Database Table:

The maintenance table is named ZBOOKING:

Source code for the table implementation:

EndUserText.label: 'Jerry''s booking'@AbapCatalog.enhancementCategory: # NOT_EXTENSIBLE@AbapCatalog.tableCategory: # TRANSPARENT@AbapCatalog.deliveryClass: # A@AbapCatalog.dataMaintenance: # LIMITEDdefine 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 (1510); currencycode: abap.cuky; lastchangedat: timestampl;}

Activate:

Next, create an ABAP class to insert data into the Z table in code.

This ABAP class implements the if_oo_adt_classrun interface, similar to the console application in Java:

Complete code:

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 abundant'). ENDMETHOD.ENDCLASS.

Execute the console application:

Two pieces of data were successfully inserted:

Select the Z table and select Open with Data Preview:

You see two pieces of data that were successfully inserted:

This is the end of "how to create your own Z table in SAP ABAP programming environment". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Data environment programming success code content more knowledge application practicality learning and then dilemma reality situation interface article way case source code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux Microsoft Apple Xiaomi