3

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.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
CuriousCase
  • 745
  • 2
  • 9
  • 22
  • 1
    Hi @CuriousCase, currently the SDK generates the URL without all the brackets that you expected, because logically they are the same. Unfortunately, it might be the case that some services don't support 2+ `and` operator and you need more brackets for splitting them into smaller pieces. I created a ticket to improve the SDK so that you can decide the structure of your filter. I'll let you know when it's released. – Junjie Tang Aug 28 '20 at 11:25

1 Answers1

2

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

Junjie Tang
  • 362
  • 1
  • 15