Article directory
OverView
- Create ABAP Package
- Customized base table
- Write test data to bottom table
- View test data
[0] Provision
If you have not created a BTP Trail User Account, you need to apply for an account first and connect to BTP through Eclipse. For details, see " 00 - RAP Development Environment Configuration "
Booster - Abap Environment - Start
- If it prompts Error that Entitlement is missing, click to enter Subaccount and click Entitlements on the left
- Click the Configure Entitlements button and click Add Service Plans
- Add ABAP environment
- Then go back to the main console and try
Download Service Key for Eclipse to connect to BTP
[1] New Package
Project - New - ABAP Package
ZTRAVEL_APP_10001
Create a Package named here
PS Package can be added to Favorite Packages for easy retrieval
[2] Create Table
Package - New - Other ABAP Repository Object
ZTRAVEL_10001
Create a Table named here
The following is the definition of Table:
@EndUserText.label : 'Database table for travel data 10001'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table ztravel_10001 {
key client : abap.clnt not null;
key mykey : sysuuid_x16 not null;
travel_id : /dmo/travel_id;
agency_id : /dmo/agency_id;
customer_id : /dmo/customer_id;
begin_date : /dmo/begin_date;
end_date : /dmo/end_date;
@Semantics.amount.currencyCode : 'ztravel_10001.currency_code'
booking_fee : /dmo/booking_fee;
@Semantics.amount.currencyCode : 'ztravel_10001.currency_code'
total_price : /dmo/total_price;
currency_code : /dmo/currency_code;
description : /dmo/description;
overall_status : /dmo/overall_status;
created_by : syuname;
created_at : timestampl;
last_changed_by : syuname;
last_changed_at : timestampl;
}
Save and activate (the shortcut keys are the same as the GUI side "Ctrl + S, Ctrl + F3")
[3] Insert MockData
After creating the Table, the next step is to write several pieces of test data. Here, we write them by constructing a class.
Package - New - ABAP Class
Create zcl_generate_travel_data_10001
a class named here with the following code:
CLASS zcl_generate_travel_data_10001 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_generate_travel_data_10001 IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA itab TYPE TABLE OF ztravel_10001.
* fill internal travel table (itab)
itab = VALUE #(
( mykey = '02D5290E594C1EDA93815057FD946624' travel_id = '00000022' agency_id = '070001' customer_id = '000077' begin_date = '20190624' end_date = '20190628' booking_fee = '60.00' total_price = '750.00' currency_code = 'USD'
description = 'mv' overall_status = 'A' created_by = 'MUSTERMANN' created_at = '20190612133945.5960060' last_changed_by = 'MUSTERFRAU' last_changed_at = '20190702105400.3647680' )
( mykey = '02D5290E594C1EDA93815C50CD7AE62A' travel_id = '00000106' agency_id = '070005' customer_id = '000005' begin_date = '20190613' end_date = '20190716' booking_fee = '17.00' total_price = '650.00' currency_code = 'AFN'
description = 'Enter your comments here' overall_status = 'A' created_by = 'MUSTERMANN' created_at = '20190613111129.2391370' last_changed_by = 'MUSTERMANN' last_changed_at = '20190711140753.1472620' )
( mykey = '02D5290E594C1EDA93858EED2DA2EB0B' travel_id = '00000103' agency_id = '070010' customer_id = '000011' begin_date = '20190610' end_date = '20190714' booking_fee = '17.00' total_price = '800.00' currency_code = 'AFN'
description = 'Enter your comments here' overall_status = 'X' created_by = 'MUSTERFRAU' created_at = '20190613105654.4296640' last_changed_by = 'MUSTERFRAU' last_changed_at = '20190613111041.2251330' )
).
* delete existing entries in the database table
DELETE FROM ztravel_10001.
* insert the new table entries
INSERT ztravel_10001 FROM TABLE @itab.
* output the result as a console message
out->write( |{ sy-dbcnt } travel entries inserted successfully!| ).
ENDMETHOD.
ENDCLASS.
Ctrl + F3 activates, F9 executes writing data
[4] Check Data
Switch to the Table tab and execute F8 to view the bottom table data.
At this point, the customized base table has been completed.