Skip to Content
0

Building BOPF business object from CDS view

Dec 20, 2017 at 12:39 PM

177

avatar image
Former Member

Hi,

I am trying to build a BOPF Business Object representing tables KNA1, KNVK and ADR2 in sweet harmony. The aim is to be able to hopefully change names, addresses and contact info for the customer contact persons in a Fiori Elements App.

My CDS's are as below

@AbapCatalog.sqlViewName: 'ZV_I_CUST'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Basic view for cust search for Sales contact app 1'

@ObjectModel.semanticKey: 'kunnr' 
@ObjectModel.modelCategory: #BUSINESS_OBJECT
@ObjectModel.compositionRoot: true
@ObjectModel.transactionalProcessingEnabled: true
@ObjectModel.writeActivePersistence: 'kna1'
@ObjectModel.representativeKey: 'kunnr'   
@ObjectModel.updateEnabled: true

define view ZCDS_CAPP1_I_CUST as select from kna1 as _customers
  association[1..*] to ZCDS_CAPP1_I_CONTPERS 
     as _contpers on $projection.kunnr = _contpers.kunnr
{
    key kunnr,
    name1,
    ort01,    
    
    -- exposing the association to contacts
    @ObjectModel.association.type:  [#TO_COMPOSITION_CHILD  ] 
   _contpers
 }
@AbapCatalog.sqlViewName: 'ZV_I_CONTPERS'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Basic view for contact persons for Sales contact app 1'


@ObjectModel.semanticKey:  [ 'kunnr', 'parnr' ] 
@ObjectModel.writeActivePersistence: 'knvk'
@ObjectModel.representativeKey: [ 'parnr', 'kunnr'] 
@ObjectModel.updateEnabled: true


define view ZCDS_CAPP1_I_CONTPERS as select from knvk as _contpers 
  association [1..1] to ZCDS_CAPP1_I_PHONE 
       as _phone on $projection.prsnr = _phone.persnumber
  association [1..1] to ZCDS_CAPP1_I_CUST 
       as _customers on $projection.kunnr = _customers.kunnr

  {
    key parnr,
    key kunnr,
    namev,
    name1,
    abtnr,
    _contpers.prsnr,
         
//  exposing the association to contacts
    @ObjectModel.association.type:  
        [#TO_COMPOSITION_PARENT, #TO_COMPOSITION_ROOT ] 
    _customers,
    @ObjectModel.association.type:  [#TO_COMPOSITION_CHILD]
    _phone
}
@AbapCatalog.sqlViewName: 'ZV_I_CONTPERS_P'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Basic view for contact person phone'

@ObjectModel.semanticKey: 'PERSNUMBER'
@ObjectModel.writeActivePersistence: 'adr2'
@ObjectModel.representativeKey: 'persnumber'   
@ObjectModel.updateEnabled: true

define view ZCDS_CAPP1_I_PHONE as select from adr2 as _phone 
  association [1..1] to ZCDS_CAPP1_I_CONTPERS 
     as _contpers on $projection.persnumber = _contpers.prsnr
  {
    key persnumber,
    telnr_long,
    
//  exposing the association to contacts
    @ObjectModel.association.type:  [#TO_COMPOSITION_PARENT ] 
    _contpers
    
//    @ObjectModel.association.type: [#TO_COMPOSITION_ROOT]
//    _contpers._customers
}

As far as I understand I must declare a navigation back to the root element even for my last CDS. I have tried a couple of different options, but none seems to work. Any advice?

Also, I get a error message in Eclipse when activating saying

[BO Sync] Cannot find source attribute PARNR in association _PHONE (view ZCDS_CAPP1_I_CONTPERS)

What does that mean, and more importantly, how to I resolve it?

kind regards,

Glenn

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Jan 16 at 07:30 PM
0

Bumping this one. No one have any clue?

Share
10 |10000 characters needed characters left characters exceeded