Skip to Content
Jan 30, 2020 at 10:56 AM

Error in custom logic of CAP: " invalid column name: COUNT"

1135 Views Last edit Jan 30, 2020 at 11:10 AM 2 rev

I am creating an OData service using CAP.

Target is to get the below URL working.

<CF Trail>/analytics-output/ApplicationUsage?select=application,count&$orderby=count

Here is the service model.

    entity ApplicationUsage {
        key application : String(80);
            count       : Decimal;
            timestamp   : DateTime null;

Here is the implementation in custom logic (js file)

    srv.on('READ', 'ApplicationUsage', (req) => {
        selectQuery = 'select ' +
            'key app.application as application, ' +
            'COUNT(app.application) as count : Decimal ' +
            'from cis.fiorianalytics.Actions as action ' +
            'inner join cis.fiorianalytics.Apps as app on action.applicationID = '+
            'group by app.application';

        let query = cds.parse.cql(selectQuery);
        //Append the timestamp WHERE and ORDERBY condition
        query.SELECT.orderBy = req.query.SELECT.orderBy;
        query.SELECT.where = req.query.SELECT.where;

This works great in local deployment and I get the data. But it fails to work in HANA (after deployment to trial CF).

I end up getting not so useful error as below in the browser.

<error xmlns="">
<message>Internal Server Error</message>

When I look into the 'Log' on SCP, I see below line which seems to be related.

Any help is greatly appreciated.


cap-error.png (34.0 kB)