on 01-29-2023 2:52 PM
Hello there,
I am doing some work on the Open SAP RAP tutorial and I too had some problem with this. One of the very, very few things I like about SAP is that things are usually really well documented. Sadly, this was not one of such cases, as the only meaning full result for the "Transactional Projection View must be part of a business object." was this thread.
The problem is in defining the Data Definition View Entities, namely if one would simply generate Data Definitions by right clicking on the tables and then selecting the Define View Entity one would get something like this in the interfaces (analogously for the other table):
define root view entity ZNV_I_TRAVEL as select from znv_pmf_travel...
Now, this would work in terms of saving, activating and running normally, no problem here. Both tables would work actually... The problem manifests itself only once the projection views are created, and then only in the Travel table, i.e. the root one.
Here is the working code for both the interfaces and projection views for future reference:
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Travel Data Definition'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define root view entity ZNV_I_TRAVEL
as select from znv_pmf_travel as Travel
composition [0..*] of ZNV_I_BOOKING as _Booking
{
key travel_uuid as TravelUuid,
travel_id as TravelId,
agency_id as AgencyId,
customer_id as CustomerId,
begin_date as BeginDate,
end_date as EndDate,
@Semantics.amount.currencyCode: 'CurrencyCode'
booking_fee as BookingFee,
@Semantics.amount.currencyCode: 'CurrencyCode'
total_price as TotalPrice,
currency_code as CurrencyCode,
description as Description,
overall_status as OverallStatus,
created_by as CreatedBy,
created_at as CreatedAt,
last_changed_by as LastChangedBy,
last_changed_at as LastChangedAt,
local_last_changed_at as LocalLastChangedAt,
/* associations */
_Booking
}
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Booking Data Definition'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define view entity ZNV_I_BOOKING
as select from znv_pmf_booking as Booking
association to parent ZNV_I_TRAVEL as _Travel on $projection.TravelUuid = _Travel.TravelUuid
{
key booking_uuid as BookingUuid,
travel_uuid as TravelUuid,
booking_id as BookingId,
booking_date as BookingDate,
customer_id as CustomerId,
carrier_id as CarrierId,
connection_id as ConnectionId,
flight_date as FlightDate,
@Semantics.amount.currencyCode: 'CurrencyCode'
flight_price as FlightPrice,
currency_code as CurrencyCode,
@Semantics.user.createdBy: true
created_by as CreatedBy,
@Semantics.user.lastChangedBy: true
last_changed_by as LastChangedBy,
@Semantics.systemDateTime.localInstanceLastChangedAt: true
local_last_changed_at as LocalLastChangedAt,
/* associations */
_Travel
}
@EndUserText.label: 'Travel Projection View'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define root view entity ZNV_C_TRAVEL
as projection on ZNV_I_TRAVEL as Travel
{
key TravelUuid,
TravelId,
AgencyId,
CustomerId,
BeginDate,
EndDate,
@Semantics.amount.currencyCode: 'CurrencyCode'
BookingFee,
@Semantics.amount.currencyCode: 'CurrencyCode'
TotalPrice,
@Consumption.valueHelpDefinition: [{ entity : {name: 'I_Currency', element: 'Currency'} }]
CurrencyCode,
Description,
OverallStatus,
CreatedBy,
CreatedAt,
LastChangedBy,
LastChangedAt,
LocalLastChangedAt,
/* Associations */
_Booking : redirected to composition child ZNV_C_BOOKING
}@EndUserText.label: 'Booking Projection View'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view entity ZNV_C_BOOKING
as projection on ZNV_I_BOOKING as Booking
{
key BookingUuid,
TravelUuid,
BookingId,
BookingDate,
CustomerId,
CarrierId,
ConnectionId,
FlightDate,
@Semantics.amount.currencyCode: 'CurrencyCode'
FlightPrice,
@Consumption.valueHelpDefinition: [{ entity: {name: 'I_Currency', element: 'Currency'} }]
CurrencyCode,
CreatedBy,
LastChangedBy,
LocalLastChangedAt,
/* Associations */
_Travel : redirected to parent ZNV_C_TRAVEL
}
@EndUserText.label: 'Booking Projection View'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view entity ZNV_C_BOOKING
as projection on ZNV_I_BOOKING as Booking
{
key BookingUuid,
TravelUuid,
BookingId,
BookingDate,
CustomerId,
CarrierId,
ConnectionId,
FlightDate,
@Semantics.amount.currencyCode: 'CurrencyCode'
FlightPrice,
@Consumption.valueHelpDefinition: [{ entity: {name: 'I_Currency', element: 'Currency'} }]
CurrencyCode,
CreatedBy,
LastChangedBy,
LocalLastChangedAt,
/* Associations */
_Travel : redirected to parent ZNV_C_TRAVEL
}
In the end I would like to state that I am an absolute novice and that, even though it may be a silly problem to some, for a novice it is absolutely impossible with the atrociously low levels of documentation available at times. Again, I hope at least helps someone in the future and saves him/her the frustration I am sure many of us beginners went true.
Good day to you all!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.