Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report