cancel
Showing results for 
Search instead for 
Did you mean: 

oData Filtering

Former Member
0 Kudos

Hi all,

I have created a oData service with an entityset which is giving desired result.

http://XXX:8000/sap/opu/odata/sap/zeban_final1_srv/EBANMAINMODSet

One record of the same is as follows -

<entry>

        <id>http://blr-mt-erpdq.mul.manipal.net:8000/sap/opu/odata/sap/zeban_final1_srv/EBANMAINMODSet('10004446')</id>

        <title type="text">EBANMAINMODSet('10004446')</title>

        <updated>2014-11-27T11:17:52Z</updated>

        <category term="zeban_final1_srv.EBANMAINMOD" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

        <link href="EBANMAINMODSet('10004446')" rel="self" title="EBANMAINMOD"/>

        <link href="EBANMAINMODSet('10004446')/PRTOSERVICELINEITEMS20" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PRTOSERVICELINEITEMS20" type="application/atom+xml;type=feed" title="PRTOSERVICELINEITEMS20"/>

        <link href="EBANMAINMODSet('10004446')/PRTOLINEITEMS20" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PRTOLINEITEMS20" type="application/atom+xml;type=feed" title="PRTOLINEITEMS20"/>

        <link href="EBANMAINMODSet('10004446')/PRTOCOMMENTMOD10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PRTOCOMMENTMOD10" type="application/atom+xml;type=feed" title="PRTOCOMMENTMOD10"/>

        <link href="EBANMAINMODSet('10004446')/PRTOSERVICELINEITEMS10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PRTOSERVICELINEITEMS10" type="application/atom+xml;type=feed" title="PRTOSERVICELINEITEMS10"/>

        <link href="EBANMAINMODSet('10004446')/PRTOCOMMENT10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PRTOCOMMENT10" type="application/atom+xml;type=feed" title="PRTOCOMMENT10"/>

        <link href="EBANMAINMODSet('10004446')/PRTOATTACHMENTLIST10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PRTOATTACHMENTLIST10" type="application/atom+xml;type=feed" title="PRTOATTACHMENTLIST10"/>

        <link href="EBANMAINMODSet('10004446')/PRTOAPPROVAL10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PRTOAPPROVAL10" type="application/atom+xml;type=feed" title="PRTOAPPROVAL10"/>

        <link href="EBANMAINMODSet('10004446')/PRTOLINEITEMS10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PRTOLINEITEMS10" type="application/atom+xml;type=feed" title="PRTOLINEITEMS10"/>

        <link href="EBANMAINMODSet('10004446')/$links/PRTOSERVICELINEITEMS20" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/PRTOSERVICELINEITEMS20" type="application/xml" title="PRTOSERVICELINEITEMS20"/>

        <link href="EBANMAINMODSet('10004446')/$links/PRTOLINEITEMS20" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/PRTOLINEITEMS20" type="application/xml" title="PRTOLINEITEMS20"/>

        <link href="EBANMAINMODSet('10004446')/$links/PRTOCOMMENTMOD10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/PRTOCOMMENTMOD10" type="application/xml" title="PRTOCOMMENTMOD10"/>

        <link href="EBANMAINMODSet('10004446')/$links/PRTOSERVICELINEITEMS10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/PRTOSERVICELINEITEMS10" type="application/xml" title="PRTOSERVICELINEITEMS10"/>

        <link href="EBANMAINMODSet('10004446')/$links/PRTOCOMMENT10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/PRTOCOMMENT10" type="application/xml" title="PRTOCOMMENT10"/>

        <link href="EBANMAINMODSet('10004446')/$links/PRTOATTACHMENTLIST10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/PRTOATTACHMENTLIST10" type="application/xml" title="PRTOATTACHMENTLIST10"/>

        <link href="EBANMAINMODSet('10004446')/$links/PRTOAPPROVAL10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/PRTOAPPROVAL10" type="application/xml" title="PRTOAPPROVAL10"/>

        <link href="EBANMAINMODSet('10004446')/$links/PRTOLINEITEMS10" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/relatedlinks/PRTOLINEITEMS10" type="application/xml" title="PRTOLINEITEMS10"/>

        <content type="application/xml">

            <m:properties

                xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"

                xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

                <d:Field5></d:Field5>

                <d:Field4></d:Field4>

                <d:Field3>10,000.00</d:Field3>

                <d:Field2>INR</d:Field2>

                <d:Field1>1G</d:Field1>

                <d:PrDate>PR Date - 14.11.2014</d:PrDate>

                <d:Wiid>000000609940</d:Wiid>

                <d:BsartTxt>Purchase Requisition Type - MGE NON-IT STNDRD PR</d:BsartTxt>

                <d:EkgrpTxt>Purchase Group - Facilities+Projcts</d:EkgrpTxt>

                <d:AfnamTxt>Requisitioned by - koti</d:AfnamTxt>

                <d:ErnamTxt>Created by - 11002013</d:ErnamTxt>

                <d:BanfnTxt>PR No. - 0010004446</d:BanfnTxt>

                <d:BstypTxt1>Purchase Document Category - B</d:BstypTxt1>

                <d:WerksTxt>Plant - MaGE</d:WerksTxt>

                <d:Banfn>10004446</d:Banfn>

                <d:Bsart>N-IT</d:Bsart>

                <d:Werks>1000</d:Werks>

                <d:Bstyp>B</d:Bstyp>

                <d:Ernam>11002013</d:Ernam>

                <d:Erdat>2014-11-14T00:00:00</d:Erdat>

                <d:Username>11000628</d:Username>

                <d:Afnam>koti</d:Afnam>

                <d:Menge>3.000</d:Menge>

                <d:Preis>10000.00</d:Preis>

                <d:BstypTxt>000000609940</d:BstypTxt>

                <d:Peinh>1</d:Peinh>

                <d:Ekgrp>160</d:Ekgrp>

            </m:properties>

        </content>

    </entry>

Now, I want to have a filter query like follows -

http://XXX:8000/sap/opu/odata/sap/zeban_final1_srv/EBANMAINMODSet?$filter=Banfn eq '10004446'.

It should give only the above record as output.

But instead it is giving all the records again.

Require your suggestion on how to solve this issue.

Regards,

Subhabaha Pal

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

If the odata is created using SEGW, please put external break point in DPC class (in case method is not redefined) or DPC_EXT class (in case method is re-defined). Its important to put break point with same ID from which service is being executed.

The break point needs to be in GET_ENTITY_SET method of entity set EBANMAINMODSet

On running the service, debugger will stop at the method. Probably the RFC which is used for mapping might not be filtering the data correctly.

Regards,

Aashika

aakash_neelaperumal2
Active Participant
0 Kudos

Please debug the entityset method *DPC_EXT. You will understand that the you are not restricting the output data based on the input you had given in the URl.

AshwinDutt
Active Contributor
0 Kudos

Hello Pal,


Do you have code in place to read the filter parameters inside your DPC or DPC_EXT class ?


If code is not in place please have a look here ->


Is your back-end logic is capable of taking those filter parameters as inputs and filter the data set and give back the result?

Please check the above.

Regards,

Ashwin

ChandraMahajan
Active Contributor
0 Kudos

Hi,

Have you implemented logic to handle $filter in get_entityset method of DPC_EXT class? you can check this blog for more details.

Regards,

Chandra