Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // AbapCatalog controls ABAP runtime env and dictionary
- //sqlViewName defines name of generated by dictionary SQL view
- @AbapCatalog.sqlViewName: 'zkhrccipark'
- //
- @AbapCatalog.compiler.compareFilter: true
- // defines behavior of the auth check.
- // runtime engines uses status of this annotation for auth check
- // NOT_REQUIRED means that auth check is execunted only if a DCL role exists for this CDS
- @AccessControl.authorizationCheck: #NOT_REQUIRED
- // just describtion for the vies, could be represented on UI
- @EndUserText.label: 'Park composite view'
- // ObjectModel annotations provide definition of structural and transactional aspects of business data model
- @ObjectModel: {
- // annotation defines performance parameters for CDS consuming
- usageType:{
- // dataClass annotation has indicator role, so that consumers of this CDS can define suitable caching stratagies for the selected data
- dataClass: #TRANSACTIONAL,
- // describes which performance characteristics a CDS model has
- serviceQuality: #A,
- // every view assigned to a size category, which defines result set or the set of data to be calculated or searched while consuming
- sizeCategory: #S
- },
- // enables transactional runtime support
- transactionalProcessingEnabled: true,
- // defines the toot of the compositional hierarchy for the darft business object
- // to be crated (root of the BO tree I guess)
- compositionRoot: true,
- // specifies the database table for stroing active data entries
- writeActivePersistence: 'zkhr_cc_park',
- // alowing creation of new instances. EXTERNAL_CALCULATION making create property be calculated in a BOPF property determination
- // it's like we making BOPF responsible for create activity
- createEnabled: 'EXTERNAL_CALCULATION',
- // alowing deletion. managing same as create
- deleteEnabled: 'EXTERNAL_CALCULATION',
- // alowing updating. managing same as updating
- updateEnabled: 'EXTERNAL_CALCULATION',
- // with this annotation we can define semantic key for the hole view.
- // semantic key uses field value as human-readable key for more comfertable consuming
- semanticKey: ['ParkID'],
- // allows you to make objects drafts in the app
- // and(!) enables draft mechanizm in all child nodes
- draftEnabled: true,
- // specifies the name of the datatable for storing draft data
- // generates automatically after activation of the CDS BO view
- // like shadow table for intemediate storage
- writeDraftPersistence: 'zkhr_cc_park_d'
- }
- define view zkhr_cc_i_park
- as select from zkhr_cc_p_park
- // accociation to the child node of car
- association [1..*] to zkhr_cc_i_car as _Car on $projection.ParkUUID = _Car.ParkUUID
- // accociation to the child node of dates
- association [0..*] to zkhr_cc_i_dates as _Dates on $projection.ParkUUID = _Dates.ParkUUID
- // accociation to the child node of carscount, which provides about amount of cars in the park
- association to zkhr_cc_i_carscount as _CarsCount on $projection.ParkUUID = _CarsCount.ParkUUID
- {
- key ParkUUID,
- // makes this element mandatory, if it's true, the field must be filled by the consumer while executing
- // with EXTERNAL_CALCULATION we can define how the element is defined as mandatory
- @ObjectModel.mandatory: true
- ParkID,
- ParkName,
- Capacity,
- // if readonly is true, then consumer not able to update the field
- @ObjectModel.readOnly: true
- _CarsCount.CarsCount as CarsCount,
- // if readonly is true, then consumer not able to update the field
- @ObjectModel.readOnly: true
- case
- when _CarsCount.CarsCount < Capacity then 'O'
- else 'C'
- end as ParkStatus,
- // if readonly is true, then consumer not able to update the field
- @ObjectModel.readOnly: true
- case
- when _CarsCount.CarsCount > 0 and _CarsCount.CarsCount <= div(Capacity, 2) then 3
- when _CarsCount.CarsCount > div(Capacity, 2) and _CarsCount.CarsCount < Capacity then 2
- when _CarsCount.CarsCount >= Capacity and _CarsCount.CarsCount <= Capacity then 1
- else 0
- end as CapacityCriticality,
- // if readonly is true, then consumer not able to update the field
- @ObjectModel.readOnly: true
- 'https://leverx.com/images/header/ic_logo.svg' as imageUrl,
- // bounding system field value with this element throught Semantics
- @Semantics.systemDateTime.createdAt: true
- crea_date_time,
- // bounding system field user value with this element throught Semantics
- @Semantics.user.createdBy: true
- crea_uname,
- // bounding system field last changed value with this element throught Semantics
- @Semantics.systemDateTime.lastChangedAt: true
- lchg_date_time,
- // bounding system field last changed by with this element throught Semantics
- @Semantics.user.lastChangedBy: true
- lchg_uname,
- // with association annotation we defining association type in a compositional hierarchy
- // in our case runtime engine for object processing is BOPF, and with enabled transationalprocessing it connects all linked objects with this annotation
- // when we defining compositional hierarchy and want to connect sub views we must use TO_COMPOSITIONAL_CHILD
- @ObjectModel.association.type: [#TO_COMPOSITION_CHILD]
- _Car,
- _Dates
- }
Add Comment
Please, Sign In to add comment