Skip to content

Commit 14037fd

Browse files
authored
Add files via upload
Week 2 upload
1 parent cb7ea21 commit 14037fd

14 files changed

+480
-0
lines changed

week2/sources/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# CODE SNIPPETS
2+
3+
The final source codes of all objects created in week 2 (at the end of each unit) is stored in this folder.
4+
5+
**Naming Convention:** **W**<_week_number_>**U**<_unit_number_>**\_**<_tadir_type_>**\_**<_object_name_>
6+
7+
8+
**Note:**
9+
Please note that all occurrences of the placeholder **`####`** used in object names and code snippets shall be replaced with the suffix of your choice during the exercises. The suffix shall contain a maximum of 4 characters. Numbers and letters are allowed.
10+
Examples: `496`, `1234`, `AB12`, `YZ89`, etc...
11+
12+
13+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
CLASS zcl_generate_demo_data_#### DEFINITION
2+
PUBLIC
3+
FINAL
4+
CREATE PUBLIC .
5+
6+
PUBLIC SECTION.
7+
INTERFACES if_oo_adt_classrun.
8+
PROTECTED SECTION.
9+
PRIVATE SECTION.
10+
ENDCLASS.
11+
12+
CLASS zcl_generate_demo_data_#### IMPLEMENTATION.
13+
METHOD if_oo_adt_classrun~main.
14+
15+
" delete existing entries in the database table
16+
DELETE FROM zrap_atrav_####.
17+
DELETE FROM zrap_abook_####.
18+
19+
" insert travel demo data
20+
INSERT zrap_atrav_#### FROM (
21+
SELECT
22+
FROM /dmo/travel
23+
FIELDS
24+
uuid( ) AS travel_uuid ,
25+
travel_id AS travel_id ,
26+
agency_id AS agency_id ,
27+
customer_id AS customer_id ,
28+
begin_date AS begin_date ,
29+
end_date AS end_date ,
30+
booking_fee AS booking_fee ,
31+
total_price AS total_price ,
32+
currency_code AS currency_code ,
33+
description AS description ,
34+
CASE status
35+
WHEN 'B' THEN 'A' " accepted
36+
WHEN 'X' THEN 'X' " cancelled
37+
ELSE 'O' " open
38+
END AS overall_status ,
39+
createdby AS created_by ,
40+
createdat AS created_at ,
41+
lastchangedby AS last_changed_by ,
42+
lastchangedat AS last_changed_at ,
43+
lastchangedat AS local_last_changed_at
44+
ORDER BY travel_id UP TO 200 ROWS
45+
).
46+
COMMIT WORK.
47+
48+
" insert booking demo data
49+
INSERT zrap_abook_#### FROM (
50+
SELECT
51+
FROM /dmo/booking AS booking
52+
JOIN zrap_atrav_#### AS z
53+
ON booking~travel_id = z~travel_id
54+
FIELDS
55+
uuid( ) AS booking_uuid ,
56+
z~travel_uuid AS travel_uuid ,
57+
booking~booking_id AS booking_id ,
58+
booking~booking_date AS booking_date ,
59+
booking~customer_id AS customer_id ,
60+
booking~carrier_id AS carrier_id ,
61+
booking~connection_id AS connection_id ,
62+
booking~flight_date AS flight_date ,
63+
booking~flight_price AS flight_price ,
64+
booking~currency_code AS currency_code ,
65+
z~created_by AS created_by ,
66+
z~last_changed_by AS last_changed_by ,
67+
z~last_changed_at AS local_last_changed_by
68+
).
69+
COMMIT WORK.
70+
71+
out->write( 'Travel and booking demo data inserted.').
72+
ENDMETHOD.
73+
74+
ENDCLASS.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@EndUserText.label : 'Booking data'
2+
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
3+
@AbapCatalog.tableCategory : #TRANSPARENT
4+
@AbapCatalog.deliveryClass : #C
5+
@AbapCatalog.dataMaintenance : #RESTRICTED
6+
define table zrap_abook_#### {
7+
key client : mandt not null;
8+
key booking_uuid : sysuuid_x16 not null;
9+
travel_uuid : sysuuid_x16 not null;
10+
booking_id : /dmo/booking_id;
11+
booking_date : /dmo/booking_date;
12+
customer_id : /dmo/customer_id;
13+
carrier_id : /dmo/carrier_id;
14+
connection_id : /dmo/connection_id;
15+
flight_date : /dmo/flight_date;
16+
@Semantics.amount.currencyCode : 'zrap_abook_####.currency_code'
17+
flight_price : /dmo/flight_price;
18+
currency_code : /dmo/currency_code;
19+
created_by : syuname;
20+
last_changed_by : syuname;
21+
local_last_changed_at : timestampl;
22+
23+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@EndUserText.label : 'Travel data'
2+
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
3+
@AbapCatalog.tableCategory : #TRANSPARENT
4+
@AbapCatalog.deliveryClass : #C
5+
@AbapCatalog.dataMaintenance : #RESTRICTED
6+
define table zrap_atrav_#### {
7+
key client : mandt not null;
8+
key travel_uuid : sysuuid_x16 not null;
9+
travel_id : /dmo/travel_id;
10+
agency_id : /dmo/agency_id;
11+
customer_id : /dmo/customer_id;
12+
begin_date : /dmo/begin_date;
13+
end_date : /dmo/end_date;
14+
@Semantics.amount.currencyCode : 'zrap_atrav_####.currency_code'
15+
booking_fee : /dmo/booking_fee;
16+
@Semantics.amount.currencyCode : 'zrap_atrav_####.currency_code'
17+
total_price : /dmo/total_price;
18+
currency_code : /dmo/currency_code;
19+
description : /dmo/description;
20+
overall_status : /dmo/overall_status;
21+
created_by : syuname;
22+
created_at : timestampl;
23+
last_changed_by : syuname;
24+
last_changed_at : timestampl;
25+
local_last_changed_at : timestampl;
26+
27+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@AccessControl.authorizationCheck: #CHECK
2+
@EndUserText.label: 'Booking BO view'
3+
define view entity ZI_RAP_Booking_####
4+
as select from zrap_abook_#### as Booking
5+
6+
association to parent ZI_RAP_Travel_#### as _Travel on $projection.TravelUUID = _Travel.TravelUUID
7+
8+
association [1..1] to /DMO/I_Customer as _Customer on $projection.CustomerID = _Customer.CustomerID
9+
association [1..1] to /DMO/I_Carrier as _Carrier on $projection.CarrierID = _Carrier.AirlineID
10+
association [1..1] to /DMO/I_Connection as _Connection on $projection.CarrierID = _Connection.AirlineID
11+
and $projection.ConnectionID = _Connection.ConnectionID
12+
association [1..1] to /DMO/I_Flight as _Flight on $projection.CarrierID = _Flight.AirlineID
13+
and $projection.ConnectionID = _Flight.ConnectionID
14+
and $projection.FlightDate = _Flight.FlightDate
15+
association [0..1] to I_Currency as _Currency on $projection.CurrencyCode = _Currency.Currency
16+
{
17+
key booking_uuid as BookingUUID,
18+
travel_uuid as TravelUUID,
19+
booking_id as BookingID,
20+
booking_date as BookingDate,
21+
customer_id as CustomerID,
22+
carrier_id as CarrierID,
23+
connection_id as ConnectionID,
24+
flight_date as FlightDate,
25+
@Semantics.amount.currencyCode: 'CurrencyCode'
26+
flight_price as FlightPrice,
27+
currency_code as CurrencyCode,
28+
@Semantics.user.createdBy: true
29+
created_by as CreatedBy,
30+
@Semantics.user.lastChangedBy: true
31+
last_changed_by as LastChangedBy,
32+
@Semantics.systemDateTime.localInstanceLastChangedAt: true
33+
local_last_changed_at as LocalLastChangedAt,
34+
35+
/* associations */
36+
_Travel,
37+
_Customer,
38+
_Carrier,
39+
_Connection,
40+
_Flight,
41+
_Currency
42+
43+
}
44+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@AccessControl.authorizationCheck: #CHECK
2+
@EndUserText.label: 'Travel BO view'
3+
define root view entity ZI_RAP_Travel_####
4+
as select from zrap_atrav_#### as Travel
5+
6+
composition [0..*] of ZI_RAP_Booking_#### as _Booking
7+
8+
association [0..1] to /DMO/I_Agency as _Agency on $projection.AgencyID = _Agency.AgencyID
9+
association [0..1] to /DMO/I_Customer as _Customer on $projection.CustomerID = _Customer.CustomerID
10+
association [0..1] to I_Currency as _Currency on $projection.CurrencyCode = _Currency.Currency
11+
{
12+
key travel_uuid as TravelUUID,
13+
travel_id as TravelID,
14+
agency_id as AgencyID,
15+
customer_id as CustomerID,
16+
begin_date as BeginDate,
17+
end_date as EndDate,
18+
@Semantics.amount.currencyCode: 'CurrencyCode'
19+
booking_fee as BookingFee,
20+
@Semantics.amount.currencyCode: 'CurrencyCode'
21+
total_price as TotalPrice,
22+
currency_code as CurrencyCode,
23+
description as Description,
24+
overall_status as TravelStatus,
25+
@Semantics.user.createdBy: true
26+
created_by as CreatedBy,
27+
@Semantics.systemDateTime.createdAt: true
28+
created_at as CreatedAt,
29+
@Semantics.user.lastChangedBy: true
30+
last_changed_by as LastChangedBy,
31+
@Semantics.systemDateTime.lastChangedAt: true
32+
last_changed_at as LastChangedAt,
33+
@Semantics.systemDateTime.localInstanceLastChangedAt: true
34+
local_last_changed_at as LocalLastChangedAt,
35+
36+
/* associations */
37+
_Booking,
38+
_Agency,
39+
_Customer,
40+
_Currency
41+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@EndUserText.label: 'Booking BO projection view'
2+
@AccessControl.authorizationCheck: #CHECK
3+
@Search.searchable: true
4+
@Metadata.allowExtensions: true
5+
6+
define view entity ZC_RAP_Booking_####
7+
as projection on ZI_RAP_Booking_#### as Booking
8+
{
9+
key BookingUUID,
10+
TravelUUID,
11+
@Search.defaultSearchElement: true
12+
BookingID,
13+
BookingDate,
14+
@Consumption.valueHelpDefinition: [{ entity : {name: '/DMO/I_Customer', element: 'CustomerID' } }]
15+
@ObjectModel.text.element: ['CustomerName']
16+
@Search.defaultSearchElement: true
17+
CustomerID,
18+
_Customer.LastName as CustomerName,
19+
@Consumption.valueHelpDefinition: [{entity: {name: '/DMO/I_Carrier', element: 'AirlineID' }}]
20+
@ObjectModel.text.element: ['CarrierName']
21+
CarrierID,
22+
_Carrier.Name as CarrierName,
23+
@Consumption.valueHelpDefinition: [ {entity: {name: '/DMO/I_Flight', element: 'ConnectionID'},
24+
additionalBinding: [ { localElement: 'CarrierID', element: 'AirlineID' },
25+
{ localElement: 'FlightDate', element: 'FlightDate', usage: #RESULT},
26+
{ localElement: 'FlightPrice', element: 'Price', usage: #RESULT },
27+
{ localElement: 'CurrencyCode', element: 'CurrencyCode', usage: #RESULT } ] } ]
28+
ConnectionID,
29+
FlightDate,
30+
@Semantics.amount.currencyCode: 'CurrencyCode'
31+
FlightPrice,
32+
@Consumption.valueHelpDefinition: [{entity: {name: 'I_Currency', element: 'Currency' }}]
33+
CurrencyCode,
34+
LocalLastChangedAt,
35+
36+
/* associations */
37+
_Travel : redirected to parent ZC_RAP_Travel_####,
38+
_Customer,
39+
_Carrier,
40+
_Connection,
41+
_Flight
42+
43+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@EndUserText.label: 'Travel BO projection view'
2+
@AccessControl.authorizationCheck: #CHECK
3+
@Search.searchable: true
4+
@Metadata.allowExtensions: true
5+
6+
define root view entity ZC_RAP_Travel_####
7+
as projection on ZI_RAP_Travel_#### as Travel
8+
{
9+
key TravelUUID,
10+
@Search.defaultSearchElement: true
11+
TravelID,
12+
@Consumption.valueHelpDefinition: [{ entity: { name: '/DMO/I_Agency', element: 'AgencyID'} }]
13+
@ObjectModel.text.element: ['AgencyName']
14+
@Search.defaultSearchElement: true
15+
AgencyID,
16+
_Agency.Name as AgencyName,
17+
@Consumption.valueHelpDefinition: [{ entity: { name: '/DMO/I_Customer', element: 'CustomerID'} }]
18+
@ObjectModel.text.element: ['CustomerName']
19+
@Search.defaultSearchElement: true
20+
CustomerID,
21+
_Customer.LastName as CustomerName,
22+
BeginDate,
23+
EndDate,
24+
@Semantics.amount.currencyCode: 'CurrencyCode'
25+
BookingFee,
26+
@Semantics.amount.currencyCode: 'CurrencyCode'
27+
TotalPrice,
28+
@Consumption.valueHelpDefinition: [{ entity: { name: 'I_Currency', element: 'Currency'} }]
29+
CurrencyCode,
30+
Description,
31+
TravelStatus,
32+
LastChangedAt,
33+
LocalLastChangedAt,
34+
35+
/* Associations */
36+
_Agency,
37+
_Booking : redirected to composition child ZC_RAP_Booking_####,
38+
_Currency,
39+
_Customer
40+
}
41+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
@Metadata.layer: #CORE
2+
@UI: {
3+
headerInfo: { typeName: 'Booking',
4+
typeNamePlural: 'Bookings',
5+
title: { type: #STANDARD, value: 'BookingID' } } }
6+
7+
annotate view ZC_RAP_Booking_####
8+
with
9+
{
10+
@UI.facet: [ { id: 'Booking',
11+
purpose: #STANDARD,
12+
type: #IDENTIFICATION_REFERENCE,
13+
label: 'Booking',
14+
position: 10 } ]
15+
16+
@UI: { identification: [ { position: 10, label: 'Booking UUID' } ] }
17+
BookingUUID;
18+
19+
@UI.hidden: true
20+
TravelUUID;
21+
22+
@UI: { lineItem: [ { position: 20 } ],
23+
identification: [ { position: 20 } ] }
24+
BookingID;
25+
26+
@UI: { lineItem: [ { position: 30 } ],
27+
identification: [ { position: 30 } ] }
28+
BookingDate;
29+
30+
@UI: { lineItem: [ { position: 40 } ],
31+
identification: [ { position: 40 } ] }
32+
CustomerID;
33+
34+
@UI: { lineItem: [ { position: 50 } ],
35+
identification: [ { position: 50 } ] }
36+
CarrierID;
37+
38+
@UI: { lineItem: [ { position: 60 } ],
39+
identification: [ { position: 60 } ] }
40+
ConnectionID;
41+
42+
@UI: { lineItem: [ { position: 70 } ],
43+
identification: [ { position: 70 } ] }
44+
FlightDate;
45+
46+
@UI: { lineItem: [ { position: 80 } ],
47+
identification: [ { position: 80 } ] }
48+
FlightPrice;
49+
50+
@UI.hidden: true
51+
LocalLastChangedAt;
52+
}

0 commit comments

Comments
 (0)