alex_khryst

CDS consumption view example

Aug 31st, 2021 (edited)
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
DCL 6.44 KB | None | 0 0
  1. // AbapCatalog controls ABAP runtime env and dictionary
  2. //sqlViewName defines name of generated by dictionary SQL view
  3. @AbapCatalog.sqlViewName: 'zkhrcccpark'
  4. @AbapCatalog.compiler.compareFilter: true
  5. // defines behavior of the auth check.
  6. // runtime engines uses status of this annotation for auth check
  7. // NOT_REQUIRED means that auth check is execunted only if a DCL role exists for this CDS
  8. @AccessControl.authorizationCheck: #NOT_REQUIRED
  9. // just describtion for the vies, could be represented on UI
  10. @EndUserText.label: 'Park consumption view'
  11.  
  12. // defines if CDS view or entity is relevant for search scenarios
  13. @Search.searchable: true
  14.  
  15. // enabling metadata extansions in additional dict object
  16. @Metadata.allowExtensions: true
  17.  
  18. // ObjectModel annotations provide definition of structural and transactional aspects of business data model
  19. @ObjectModel: {
  20. // annotation defines performance parameters for CDS consuming
  21. usageType:{
  22. // dataClass annotation has indicator role, so that consumers of this CDS can define suitable caching stratagies for the selected data
  23.   dataClass: #TRANSACTIONAL,
  24.   // describes which performance characteristics a CDS model has
  25.   serviceQuality: #A,
  26.   // every view assigned to a size category, which defines result set or the set of data to be calculated or searched while consuming
  27.   sizeCategory: #S
  28. },
  29. //   defines the toot of the compositional hierarchy for the darft business object
  30. // to be crated (root of the BO tree I guess)
  31.     semanticKey: 'ParkID',
  32.  
  33.     // defines the root of compositional hierarchy
  34.     compositionRoot: true,
  35.  
  36.     // I guess this annotation describes the main column of a view
  37.     representativeKey: 'ParkUUID',
  38.     // makes thansactional requests to a consumption view be deligated to the
  39.     // transactional runtime of the underlying BO view
  40.     // (which is annotated with @ObjectModel.transactionalProcessingEnabled: true
  41.     // in composite view, i guess)
  42.     transactionalProcessingDelegated: true,
  43.     // alowing creation of new instances. EXTERNAL_CALCULATION making create property be calculated in a BOPF property determination
  44.     // it's like we making BOPF responsible for create activity
  45.     createEnabled: 'EXTERNAL_CALCULATION',
  46.     // alowing deletion. managing same as create
  47.   deleteEnabled: 'EXTERNAL_CALCULATION',
  48.   // alowing updating. managing same as updating
  49.   updateEnabled: 'EXTERNAL_CALCULATION',
  50.  
  51.     draftEnabled: true
  52. }
  53. define view zkhr_cc_c_park
  54.   as select from zkhr_cc_i_park
  55.   // association to child consumption view car
  56.   association [1..*] to zkhr_cc_c_car        as _Car        on  $projection.ParkUUID = _Car.ParkUUID
  57.   // association to child consumption view dates
  58.   association [0..*] to zkhr_cc_c_dates      as _Dates      on  $projection.ParkUUID = _Dates.ParkUUID
  59.   // association to value help view
  60.   association [1..1] to Zkhr_cc_i_parkvh     as _ParkVH     on  $projection.ParkID = _ParkVH.ParkID
  61.   // association to park status view (provides park status field value)
  62.   association [1..1] to zkhr_cc_c_parkstatus as _ParkStatus on  $projection.ParkStatus = _ParkStatus.StatusCode
  63.                                                             and _ParkStatus.Language   = $session.system_language
  64. {
  65.       // allows to show or hide data fields on the object page
  66.       @UI.hidden: true
  67.   key ParkUUID,
  68.  
  69.       // allowing making search with this field
  70.       @Search: {
  71.       // enabling freestyle search for the element, but not for all 'cause of performance
  72.             defaultSearchElement: true,
  73.             // describes the percent of match for search result
  74.             fuzzinessThreshold: 0.9,
  75.             // specifies how relevant the values of an element are for ranking
  76.             // HIGH means that element has high importance
  77.             ranking: #HIGH
  78.           }
  79.  
  80.       // defines text from a specific element to discribe value on UI
  81.       @ObjectModel: {
  82.         text: {
  83.           element: [ 'ParkName' ]
  84.         }
  85.       }
  86.       // enables referencing to a CDS view or entity which provides help view for this field
  87.       @Consumption: {
  88.         valueHelp: '_ParkVH'
  89.       }
  90.       ParkID,
  91.  
  92.       // just provides human readable text which is not (opionally) language-dependent
  93.       @Semantics.text: true
  94.       // allowing making search with this field
  95.       @Search: {
  96.       // enabling freestyle search for the element, but not for all 'cause of performance
  97.         defaultSearchElement: true,
  98.         // describes the percent of match for search result
  99.         fuzzinessThreshold: 0.7,
  100.         // specifies how relevant the values of an element are for ranking
  101.             // HIGH means that element has high importance
  102.         ranking: #HIGH
  103.       }
  104.  
  105.       @EndUserText.quickInfo: 'Park Name'
  106.       ParkName,
  107.       Capacity,
  108.  
  109.       // if readonly is true, then consumer not able to update the field
  110.       @ObjectModel.readOnly: true
  111.       CarsCount,
  112.  
  113.       // allows to show or hide data fields on the object page
  114.       @UI.hidden: true
  115.       // if readonly is true, then consumer not able to update the field
  116.       @ObjectModel.readOnly: true
  117.       @EndUserText.label: 'Capacity Criticality'
  118.       CapacityCriticality,
  119.  
  120.  
  121.       @ObjectModel: {
  122.       // if readonly is true, then consumer not able to update the field
  123.         readOnly: true,
  124.         //defines associated CDS view which provides text description for the annotated field
  125.         text: {
  126.          association: '_ParkStatus'
  127.        }
  128.       }
  129.       // enables referencing to a CDS view or entity which provides help view for this field
  130.       @Consumption.valueHelp: '_ParkStatus'
  131.       // allowing making search with this field
  132.       @Search: {
  133.       // enabling freestyle search for the element, but not for all 'cause of performance
  134.       defaultSearchElement: true,
  135.       // describes the percent of match for search result
  136.       fuzzinessThreshold: 0.7,
  137.       // specifies how relevant the values of an element are for ranking
  138.           // HIGH means that element has high importance
  139.       ranking: #HIGH
  140.       }
  141.       ParkStatus,
  142.  
  143.  
  144.       @ObjectModel.readOnly: true
  145.       crea_date_time,
  146.  
  147.  
  148.       @ObjectModel.readOnly: true
  149.       crea_uname,
  150.  
  151.  
  152.       @ObjectModel.readOnly: true
  153.       lchg_date_time,
  154.  
  155.  
  156.       @ObjectModel.readOnly: true
  157.       lchg_uname,
  158.  
  159.       @ObjectModel.readOnly: true
  160.       imageUrl,
  161.  
  162.       @ObjectModel.association.type: [#TO_COMPOSITION_CHILD]
  163.       _Car,
  164.       _Dates,
  165.       _ParkVH,
  166.       _ParkStatus
  167. }
  168.  
Add Comment
Please, Sign In to add comment