Business Object Generation (CDS – Object Model Annotations )
April 3, 2019

  1. Design / Prototype
  2. Create Dictionary Objects
  3. Create Interface View (CDS)
  4. Business Object Generation (CDS – Object Model Annotations )
  5. Generated Business Object
  6. BOPF – Development
  7. Test BOPF Object using BOBT
  8. Access Control (CDS)
  9. Consumption View (CDS)
  10. OData Service Generation and Registration
  11. Test OData Service using SAP Gateway Client
  12. UI development

First, Item Transactional View was created without any association to header view/node, then Header Transactional View was created with an association to the item view/node. Later, the Association to header was updated in the item view.

Item Transactional View

Draft table name is proposed and system will auto generate the table.

@AbapCatalog.sqlViewName: 'Z2812IPBITEMND'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK

-- Business Object Model - Item Data
@ObjectModel:{
  writeActivePersistence: 'Z2812_PB_D_ITEM',
  draftEnabled: true,
  writeDraftPersistence: 'Z2812_PB_D_ITM_D',
  
  createEnabled: true,
  updateEnabled: true,
  deleteEnabled: true,
  entityChangeStateId: 'PB_CHANGED_AT',
  
  lifecycle.enqueue.expiryBehavior    : #RELATIVE_TO_LAST_CHANGE,
  lifecycle.enqueue.expiryInterval    : 'PT60M',
  
  usageType: {
    serviceQuality: #D,
    sizeCategory: #L,
    dataClass: #TRANSACTIONAL
  }
}

@VDM.viewType: #TRANSACTIONAL
@EndUserText.label: 'Phone Book Item Transactional - Node View'
define view Z2812_I_PB_ITEM_ND 
   as select from Z2812_I_PB_ITEM as itemData
  -- Category Description
  left outer join Z2812_I_PB_CATG_TXT as _categoryText 
               on _categoryText.pb_category = itemData.pb_category 
  
  -- Association to Header 
  association [1..1] to Z2812_I_PB_HEAD_ND as _headData 
                  on $projection.pb_head_uuid = _headData.pb_head_uuid
{
  //itemData 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  key pb_item_uuid, 
  @ObjectModel.readOnly: true
  pb_head_uuid, 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  @ObjectModel.mandatory: true
  itemData.pb_category, 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  pb_category_desc, 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  @ObjectModel.mandatory: true
  pb_telephone, 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  pb_created_at, 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  pb_changed_at,
  
  @ObjectModel.association.type: [#TO_COMPOSITION_PARENT, 
                                  #TO_COMPOSITION_ROOT]
  _headData
}

Header Transactional View

Object Model Annotations used in View will auto generate Business Object and dependent node such as message, Lock and

@AbapCatalog.sqlViewName: 'Z2812IPBHEADND'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK

-- Business Object Model - Header Data
@ObjectModel:{
  modelCategory: #BUSINESS_OBJECT,
  transactionalProcessingEnabled: true,
  compositionRoot: true,
 
  semanticKey: ['PB_ID'],  
  alternativeKey: [{
    id: 'PB_ID',
    uniqueness: #UNIQUE_IF_NOT_INITIAL,
    element: ['PB_ID']
  }],
  
  writeActivePersistence: 'Z2812_PB_D_HEAD',
  draftEnabled: true,
  writeDraftPersistence: 'Z2812_PB_D_HDR_D',
  
  createEnabled: true,
  updateEnabled: true,
  deleteEnabled: true,
  entityChangeStateId: 'PB_CHANGED_AT',
  
  lifecycle.enqueue.expiryBehavior: #RELATIVE_TO_LAST_CHANGE,
  lifecycle.enqueue.expiryInterval: 'PT60M',
  
  usageType: {
    serviceQuality: #D,
    sizeCategory:   #L,
    dataClass:      #TRANSACTIONAL
  }
}

@VDM.viewType: #TRANSACTIONAL
@Metadata.ignorePropagatedAnnotations: true
@EndUserText.label: 'Phone Book Head Transactional - Node View - BO'
define view Z2812_I_PB_HEAD_ND 
  as select from Z2812_I_PB_HEAD as headData
  association [0..*] to Z2812_I_PB_ITEM_ND as _itemData 
                  on $projection.pb_head_uuid = _itemData.pb_head_uuid
{
  //headData 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  key pb_head_uuid,
  @ObjectModel.readOnly: true
  @ObjectModel.mandatory: true
  pb_id, 
  @ObjectModel.readOnly: true
  @ObjectModel.mandatory: true
  pb_owner, 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  pb_first_name, 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  pb_last_name, 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  pb_email_id, 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  pb_created_at, 
  @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
  pb_changed_at,
  
  @ObjectModel.association.type: [#TO_COMPOSITION_CHILD]
  _itemData
}

For more detail on Object Model Annotations, please refer to SAP Help.

<< Top