CDS VIEW 一些注解

1:  @ObjectModel.readOnly , 该cds 只读

2: @AbapCatalog.sqlViewName: 'zsflightchild'   名字

3: @AccessControl.authorizationCheck: #CHECK   进行权限检查

4: @EndUserText.label: 'child_view'  用户看到的text

5:  @ObjectModel.association.type: [#TO_COMPOSITION_ROOT, #TO_COMPOSITION_PARENT]  能够从该view的页面跳转到 COMPOSITION_ROOT, COMPOSITION_PARENT 页面(浏览器页面)

6:  @ObjectModel.association.type: [#TO_COMPOSITION_CHILD]  能够跳转到 child页面

 7: @Metadata.allowExtensions: true  允许view进行extension,可以在extension view里面添加fiori element,fiorielement可以控制前端页面显示。

8: @Search.searchable: true    该view的字段可以用于搜索 

 9: 在cds view字段上面添加annotiation

 	@ObjectModel.readOnly: true
  	key SalesOrderItem.SalesOrderItemUUID,
  	
  	@ObjectModel.readOnly: true  //该字段只读
  	SalesOrderItem.SalesOrderUUID,
  	
  	@Search.defaultSearchElement: true  //该字段作为默认搜索字段
  	_SalesOrder.SalesOrder,
  	
  	
  	/* Exposed associations   */
  	@ObjectModel.association.type:  [ #TO_COMPOSITION_ROOT, #TO_COMPOSITION_PARENT ]   //用于view之间的跳转。
  	_SalesOrder,

 

 

 10: @OData.publish: true   该view 作为 odata服务发布。

 11:  RAP框架: view之间的重定向:

  11.1

@AbapCatalog.sqlViewName: 'ZA4HITRA284'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Travel'
@AbapCatalog.preserveKey: true

@ObjectModel.semanticKey: ['TravelID']
@ObjectModel.representativeKey: 'TravelID'

define root view ZA4H_I_Travel_284
  as select from /dmo/travel as Travel

  composition [0..*] of ZA4H_I_Booking_284 as _Booking  子view
  
  association [0..1] to /DMO/I_Agency      as _Agency   on $projection.AgencyID = _Agency.AgencyID
  association [0..1] to /DMO/I_Customer    as _Customer on $projection.CustomerID = _Customer.CustomerID
  association [0..1] to I_Currency         as _Currency on $projection.CurrencyCode = _Currency.Currency


{/* Associations */
      _Booking,
      _Agency,
      _Customer,
      _Currency
}

11.2 

@AbapCatalog.sqlViewName: 'ZA4HIBOOK284'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED

@Metadata.ignorePropagatedAnnotations:true

@EndUserText.label: 'Booking view'

define view ZA4H_I_Booking_284
  as select from /dmo/booking as Booking

  association        to parent ZA4H_I_Travel_284 as _Travel     on  $projection.TravelID     = _Travel.TravelID

  association [1..1] to /DMO/I_Customer          as _Customer   on  $projection.CustomerID   = _Customer.CustomerID
  association [1..1] to /DMO/I_Carrier           as _Carrier    on  $projection.CarrierID    = _Carrier.AirlineID
  association [1..1] to /DMO/I_Connection        as _Connection on  $projection.CarrierID    = _Connection.AirlineID
                                                                and $projection.ConnectionID = _Connection.ConnectionID

{
  key travel_id             as TravelID,
  key booking_id            as BookingID,
/* Associations */
      _Travel,
      _Customer,
      _Carrier,
      _Connection
}

11.3

@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Travel'

/* ===================
Layers of Comments:
1.) @Search       Chapter: E.3
2.) Text          Chapter: E.4
3.) @Consumption  Chapter: E.5
   ==================== */

@Metadata.allowExtensions: true

@Search.searchable: true

define root view entity ZA4H_C_Travel_284
  as projection on ZA4H_I_Travel_284 as Travel

{
      LastChangedAt,

      /* Associations */
//      @Search.defaultSearchElement: true
      _Booking : redirected to composition child ZA4H_C_Booking_284,  重定向
      _Agency,
      _Customer,
      _Currency
}

11.4: 

@EndUserText.label: 'Booking projection view'
@AccessControl.authorizationCheck: #NOT_REQUIRED

@Metadata.allowExtensions: true

/* ===================
Layers of Comments:
1.) @Search         Chapter: E.3
2.) Text            Chapter: E.4
3.) Consumption     Chapter: E.5
   ==================== */
//@Search.searchable: true

define view entity ZA4H_C_Booking_284
  as projection on ZA4H_I_Booking_284
{/* Associations */
      _Travel : redirected to parent ZA4H_C_Travel_284,  重定向
      _Customer,
      _Carrier
}

上面几个关系view,Booking和travel之间可以相互navigation

 12: 开启查询,分析功能

@Analytics.query: true

 

 

 

 reference:  https://blogs.sap.com/2016/04/23/my-cds-view-self-study-tutorial-part-8-my-summary-of-different-approaches-for-annotation-declaration-and-generation/

 

composition关键字代表两个view之间有relationship,例如父子关系等,使用association只说明两个view进行了组合。

你可能感兴趣的:(CDS VIEW 一些注解)