cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in Association using CDS

12-02-2019 11:41 AM
sas3 Explorer
8050 views 7 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hi Experts,

I found an interesting read on my recent visit to SAPTechEd which explains creating a transactional FIORI application and using CDS as the data provider. The CDS view created was used as a Data Source and transaction behavior were managed through Gateway methods overriding the MPC_EXT and making specific entity as sap:creatable.
I have tried to replicate a similar operation through Flight Tables. I'm on 7.50, SP- 0011.

My CDS views are shown below at the code section.

Note - The CDS views are providing correct records when I'm following the association path through ADT.
I created the gateway service by mapping the CDS as reference data source.

Now I created a FIORI element application of type ListReport using the Gateway service built.

The application descriptor file considered the dependent entity - zcds_booking_details and navigation has been identified correctly.

The application is up and running when the basic consumption view i.e. ZCDS_FLIGHT_DETAILS is executed. Association of that view, the ZCDS_BOOKING_DETAILS is not being triggered and not fetching results.



The error in Gateway was - Unknown entity 'ZSRV_FLIGHT_BOOKING~zcds_booking_details' type 'SADL'



The application Log shows 3 consecutive messages. Out of that 2 are interesting

Upon Debugging the framework I got a point where a method init_transaction() is failing and CX_SADL_CONTRACT_VIOLATION is being raised.

I still don't know why the Entity not found error is appearing. Additionally I wonder if there is any transaction processing annotation like @ObjectModel is required. The document I was referring(provided in TechEd hands-on session) didn't have anything like that. What is that I'm missing here?

1. ZCDS_FLIGHT_DETAILS is the consumption view for application


@AbapCatalog.sqlViewName: 'zv_flight_info'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS view for Flight Information Display'
@Search.searchable: true
@UI.headerInfo.typeName: 'Flight'
@UI.headerInfo.typeNamePlural: 'Flights'
define view zcds_flight_details
                    
as select from zv_flight_basic as basic
    
association [0..*] to zcds_booking_details as _sbook on $projection.carrid = _sbook.carrid and 
                                                        $projection.connid = _sbook.connid and 
                                                        $projection.fldate = _sbook.fldate
    
{
       //basic 
//       key mandt, 
       @UI.lineItem: [{position: 10 }]
       @UI.identification: [{position: 10 }]
       @Search.defaultSearchElement: true
       @Search.fuzzinessThreshold: 0.7
       @Search.ranking: #HIGH
       @UI.selectionField: [{ position: 10 }]
       key carrid, 
       @UI.lineItem: [{position: 20 }]
       @UI.identification: [{position: 20 }]
       @Search.defaultSearchElement: true
       @Search.fuzzinessThreshold: 0.7
       @Search.ranking: #MEDIUM
       @UI.selectionField: [{ position: 20 }]
       key connid, 
       @UI.lineItem: [{position: 30 }]
       @UI.identification: [{position: 30 }]
       @UI.selectionField: [{ position: 30 }]
       key fldate, 
       
       @UI.lineItem: [{position: 40 }]
       @UI.identification: [{position: 40 }]
         price, 
       @UI.lineItem: [{position: 50 }]
       @UI.identification: [{position: 50 }]  
         currency, 
         planetype, 
       @UI.lineItem: [{position: 60, 
                      label: 'Economy Seats Available' }]
       @UI.identification: [{position: 60 }]
         economy_sa,
         
       @UI.lineItem: [{position: 70, 
                      label: 'Business Seats Available' }]
       @UI.identification: [{position: 70 }]
         business_sa,
         
       @UI.lineItem: [{position: 80, 
                      label: 'FirstClass Seats Available' }]
       @UI.identification: [{position: 80 }]
         firstclass_sa,      
         countryfr, 
         cityfrom, 
         airpfrom, 
         countryto, 
         cityto, 
         airpto, 
         duration, 
         deptime, 
         arrtime, 
         distance, 
         distid, 
         fltype, 
         period,
        
        /* Associations */
//        _sflight[inner],
        _sbook[inner]
        
}




2. My Association View - ZCDS_BOOKING_DETAILS


@AbapCatalog.sqlViewName: 'zv_booking_det'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Booking Details CDS'
define view zcds_booking_details 
   
as select from sbook {
    
    //sbook 
//    key mandt, 
    @UI.hidden: true
    key carrid, 
    @UI.hidden: true
    key connid, 
    @UI.hidden: true
    key fldate, 
    
    @UI.lineItem.position: 10
      bookid, 
    
    @UI.lineItem.position: 20
      customid, 
    
    @UI.lineItem.position: 30
      custtype, 
    
    @UI.lineItem.position: 40
      smoker, 
      luggweight, 
      wunit, 
      invoice, 
      class, 
      forcuram, 
      forcurkey, 
      loccuram, 
      loccurkey, 
      order_date, 
      counter, 
      agencynum, 
      cancelled, 
      reserved, 
    @UI.lineItem.position: 50
      passname, 
      passform, 
      passbirth
}
0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

I tried to reproduce your issue, but for me it worked, but I selected data from SFLLIGHT since I did not know the definition of zv_flight_basic.

Can you share the definition of zv_flight_basic ?

I tried the following URL in my SEGW project

/sap/opu/odata/SAP/ZTESTRDS_INNER_SRV/zcds_flight_details(carrid='AA',connid='0017',fldate=datetime'2019-06-20T00%3A00%3A00')/to_sbook

And it delivers the following

I used the following DDL source code for zcds_flight_details that in my case reads directly from table SFLIGHT.

@AbapCatalog.sqlViewName: 'zv_flight_info'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS view for Flight Information Display'
@Search.searchable: true
@UI.headerInfo.typeName: 'Flight'
@UI.headerInfo.typeNamePlural: 'Flights'
define view zcds_flight_details
                    
as select from sflight as basic
    
association [0..*] to zcds_booking_details as _sbook on $projection.carrid = _sbook.carrid and 
                                                        $projection.connid = _sbook.connid and 
                                                        $projection.fldate = _sbook.fldate
    
{
       //basic 
//       key mandt, 
       @UI.lineItem: [{position: 10 }]
       @UI.identification: [{position: 10 }]
       @Search.defaultSearchElement: true
       @Search.fuzzinessThreshold: 0.7
       @Search.ranking: #HIGH
       @UI.selectionField: [{ position: 10 }]
       key carrid, 
       @UI.lineItem: [{position: 20 }]
       @UI.identification: [{position: 20 }]
       @Search.defaultSearchElement: true
       @Search.fuzzinessThreshold: 0.7
       @Search.ranking: #MEDIUM
       @UI.selectionField: [{ position: 20 }]
       key connid, 
       @UI.lineItem: [{position: 30 }]
       @UI.identification: [{position: 30 }]
       @UI.selectionField: [{ position: 30 }]
       key fldate, 
       
       @UI.lineItem: [{position: 40 }]
       @UI.identification: [{position: 40 }]
         price, 
       @UI.lineItem: [{position: 50 }]
       @UI.identification: [{position: 50 }]  
         currency, 
         planetype, 
//       @UI.lineItem: [{position: 60, 
//                      label: 'Economy Seats Available' }]
//       @UI.identification: [{position: 60 }]
//         economy_sa,
//         
//       @UI.lineItem: [{position: 70, 
//                      label: 'Business Seats Available' }]
//       @UI.identification: [{position: 70 }]
//         business_sa,
//         
//       @UI.lineItem: [{position: 80, 
//                      label: 'FirstClass Seats Available' }]
//       @UI.identification: [{position: 80 }]
//         firstclass_sa,      
//         countryfr, 
//         cityfrom, 
//         airpfrom, 
//         countryto, 
//         cityto, 
//         airpto, 
//         duration, 
//         deptime, 
//         arrtime, 
//         distance, 
//         distid, 
//         fltype, 
//         period,
        
        /* Associations */
//        _sflight[inner],
        _sbook[inner]
        
}
sas3
Explorer
0 Likes

Hi Andre,

For some reason my gateway construct was not working properly. I created a new GW project and that worked perfectly.

Thanks a ton for all the support!
P.S - What is the minimum version requirement to execute this feature?

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Reference Data Source projects are supported as of SAP NW 7.50.

In SAP NW 7.40 you can use the so called mapped data source approach. Here you would have to map the entity sets and the associations to CDS views and their associations.

https://help.sap.com/doc/saphelp_nw751abap/7.51.0/de-DE/82/0b24ce35c745bb9e0fb3a6e8d6dbd4/frameset.h...

But CDS views require at least NW 740 SP05

Answers (2)

Answers (2)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Likes

Have you tried whether the navigation works in the data preview in ADT?

sas3
Explorer
0 Likes

Yes. Association works perfectly in ADT.
ZCDS_FLIGHT_DETAILS view



Association result when clicked on the last entry with flight date 2018-06-0

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Likes

I would try to make the field bookid a key field in your CDS view ZCDS_BOOKING_DETAILS as well.

Because otherwise the association _sbook isn't a 1 to many but a 1 to 1 association.

association [0..*] to zcds_booking_details as _sbook on $projection.carrid = _sbook.carrid and 
                                                        $projection.connid = _sbook.connid and 
                                                        $projection.fldate = _sbook.fldate
sas3
Explorer
0 Likes

Hi Andre,

Changed the ZCDS_BOOKING_DETAILS and made bookid as key field but no luck!