SAP cloud sdk for javascript multiple and filters are directly appended: leads to "Expression can not converted into ABAP select options" on backend

Viewed 84

I have a read request to a ByDesign system and create in the following way:

const readRequest = QueryResults.requestBuilder()
            .getAll()
            .select(
                QueryResults.COFFMAT,
                QueryResults.CMATERIAL
            )
            .filter(
                and(and(
                    QueryResults.PARA_FISCYEARPER.greaterOrEqual(new BigNumber('0010000')),
                    QueryResults.PARA_FISCYEARPER.lessOrEqual(new BigNumber('0129999'))),
                    and(
                        QueryResults.CACCPSTDAT.greaterOrEqual(moment(validFrom)),
                        QueryResults.CACCPSTDAT.lessOrEqual(moment(validTo)),
                        QueryResults.CPERMEST.equals(PermanentEstablishmentID),
                     QueryResults.CACCBTT.equals(Constants.code.IssueForProduction)
                    ))

            );

And the request is generated in following URL encoding:

\QueryResults?$format=json&$select=COFFMAT,CMATERIAL&$filter=(PARA_FISCYEARPER%20ge%2010000L%20and%20PARA_FISCYEARPER%20le%20129999L%20and%20CACCPSTDAT%20ge%20datetime%272017-12-31T23:00:00.000%27%20and%20CACCPSTDAT%20le%20datetime%272020-12-31T23:00:00.000%27%20and%20CPERMEST%20eq%20%27P1100%27%20and%20CACCBTT%20eq%20%27344%27)

And here all the and filters are appended after each other which leads to an error thrown from the backend

Expression can not converted into ABAP select options

The working filter url and also what I would expect the generated URL encoding to be (notice the brackets)

\QueryResults?$format=json&$select=COFFMAT,CMATERIAL&$filter=((PARA_FISCYEARPER%20ge%2010000L%20and%20PARA_FISCYEARPER%20le%20129999L)%20and%20(CACCPSTDAT%20ge%20datetime%272017-12-31T23:00:00.000%27%20and%20CACCPSTDAT%20le%20datetime%272020-12-31T23:00:00.000%27%20and%20CPERMEST%20eq%20%27P1100%27%20and%20CACCBTT%20eq%20%27344%27))

Can the second case be achieved somehow because in case of or filters the brackets are being generated properly, only with and they don't work.

1 Answers

The version 1.28.1 has been released recently. It should generate the url with more brackets that you need. See release notes here.

Related