cancel
Showing results for 
Search instead for 
Did you mean: 

CAP Expand query does not function

cbsmerveguel
Explorer
0 Kudos
332

Hi all,

We have 2 entitysets from onpremise backend that we want to do an expand to. Basically entityset1 ("InspectionLotChars") should be expanded to its navigation association ("CharacteristicCatalogSet"). I have used below syntax to do it.

 But it does return an empty array although CharacteristicCatalogSet has data in it for that specific entityset InpectionLotChars. 

 

 

    const characteristicCatalogQuery = SELECT.from('InspectionLotChars', a => {
      a.CharacteristicCatalogSet(`*`)
        (b => {
          b`.*`
        })
    }).where({
      INSPLOT: '123456789',
      INSPOPER: '0010',
      INSPCHAR: '0020'
    });

 

 

 During debug from JS (since same statement also called from UI5 for another app):

this.getView().getModel().read("/InspectionLotChars(INSPLOT='" + found.INSPLOT + "',INSPOPER='" + found.INSPOPER + "',INSPCHAR='" + found.INSPCHAR + "')/CharacteristicCatalogSet"); 

We realized the call from JS is interpreted into CQN as below:

 

let characteristicCatalogQuery2 = SELECT.from({
      ref: [
        {
          id: 'CustomerReportService.InspectionLotChars',
          where: [
            { ref: ['INSPLOT'] }, '=', { val: '123456789' },
            'and',
            { ref: ['INSPOPER'] }, '=', { val: '0010' },
            'and',
            { ref: ['INSPCHAR'] }, '=', { val: '0020' }
          ]
        },
        'CharacteristicCatalogSet'
      ]
    });

 

And interestingly if we use this CQN directly in the CAP service, we can get the result set as well. 


Would anyone have a comment why the first Select statement does not work and secondly how to convert the second one into a CQL style SELECT statement. 


Appreciate for any helpful comment.

Best,

Merve

gregorw
Active Contributor
0 Kudos
Have you tried to add an await?
cbsmerveguel
Explorer
0 Kudos
@gregorw I double checked the await command after your reply. I already use await during the request handling, but it ends with an empty array nevertheless. const characteristicCatalogSetResult = await this.tx(request).run(characteristicCatalogQuery); I tried to add the await on the query preparation (Select statement), but in that case ended with an error.

Accepted Solutions (0)

Answers (1)

Answers (1)

cbsmerveguel
Explorer
0 Kudos

entered this message by mistake, cant delete it. please ignore.