Perform filter on expanded entity with SAP Cloud SDK

floste :

So this might be an easy one, but I somehow can't wrap my head around it. I am trying to find a business partner by its e-mail address using the SAP Cloud SDK.

This is what I have so far:

final List<BusinessPartner> businessPartners = new DefaultBusinessPartnerService()
                        .getAllBusinessPartner()
                        .select(BusinessPartner.BUSINESS_PARTNER,
                                BusinessPartner.TO_BUSINESS_PARTNER_ADDRESS
                                        .select(BusinessPartnerAddress.TO_EMAIL_ADDRESS
                                                .select(AddressEmailAddress.SEARCH_EMAIL_ADDRESS)))
                        .filter(AddressEmailAddress.SEARCH_EMAIL_ADDRESS.eq(email)) //something like this?
                        .top(10)
                        .execute();

Now, how can I perform a filter operation on the expanded entity AddressEmailAddress? The one I came up with obviously doesn't. I have troubles navigating to the expanded entity using the fluent API.

Any ideas?

Alexander Dümont :

Since my proposal worked for you. Let me rephrase the comment as answer.

Unfortunately it's not possible to filter on expanded entities for SAP OData V2 service endpoints. A fallback strategy would be to directly query for the "filtered" item in the entity collection (leaf) and run additional OData requests to traverse to your original entity (root).

In your case, I would recommend querying directly for the AddressEmailAddress, to resolve BusinessPartnerAddress by the AddressId. Next step is to resolve BusinessPartner by the businessPartner field, e.g.

public List<BusinessPartner> getBusinessPartnersByEmail(
    @Nonnull BusinessPartnerService service,
    @Nonnull String email
)
    throws ODataException
{
    List<AddressEmailAddress> emailAddresses = service
        .getAllAddressEmailAddress()
        .filter(AddressEmailAddress.SEARCH_EMAIL_ADDRESS.eq(email))
        .execute();

    List<BusinessPartnerAddress> addresses = new LinkedList<>();
    for( AddressEmailAddress emailAddress : emailAddresses ) {
        addresses.addAll(
            service
                .getAllBusinessPartnerAddress()
                .filter(BusinessPartnerAddress.ADDRESS_ID.eq(emailAddress.getAddressID()))
                .execute());
    }

    List<BusinessPartner> businessPartners = new LinkedList<>();
    for( BusinessPartnerAddress address : addresses ) {
        businessPartners.add(service.getBusinessPartnerByKey(address.getBusinessPartner()).execute());
    }

    return businessPartners;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Generate VDM for SFSF using Java in SAP Cloud SDK: "Failed to convert response into ODataFeed""

From Java

Generate VDM for SFSF using Java in SAP Cloud SDK: Generated URI is wrong

From Java

How to fix a DestinationAccessException thrown by the SAP Cloud SDK during application startup

From Java

Unable to load servlet filter class: com.sap.cloud.sdk.cloudplatform.security.servlet.HttpSecurityHeadersFilter (SCP Neo)

From Java

SAP Cloud SDK method for output service in OData form

From Dev

S/4HANA Cloud SDK :com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces does not exist

From Dev

How do I access OData service using the SAP S/4HANA Cloud SDK in existing application?

From Dev

Cloud-SDK Filter by subfields

From Dev

Cannot access S/4HANA on Premise system via Cloud Connector using SAP Cloud SDK for JavaScript

From Dev

How to execute integrationtests for own OData service in SAP Cloud SDK

From Dev

SAP Cloud SDK JavaScript: No CSRF Token for onPremise destination with Location ID

From Dev

SAP Cloud SDK Spring Security JARS

From Dev

Is the SAP Cloud SDK VDM Generator handling EDMX annotations correctly?

From Dev

Calling BAPI from Java using SAP Cloud SDK version 3.0

From Dev

Principal Propagation is not working in the latest version of SAP Cloud SDK

From Dev

SAP Cloud SDK for javascript using the destination

From Dev

Found class com.sap.cloud.sdk.cloudplatform.naming.JndiLookupFacade, but interface was expected

From Dev

Check if filter element is expanded or collapsed

From Dev

Securing a JS application built with SAP Cloud SDK

From Dev

Root cause & Propagation of Exception in SAP Cloud SDK

From Dev

SAP Cloud SDK JavaScript URL encoding ODATA filter (API_PRODUCT_SRV)

From Dev

Dependency conflicts between SAP-Cloud-SDK and SAP cloud-security-xsuaa-integration

From Dev

Office 365 - Filter on expanded messages

From Dev

Filter expanded OData request

From Dev

Getting JSON parser error when using sap-cloud-sdk

From Dev

How to get user info and authorities in SAP Cloud SDK 3.0 and above

From Dev

ZSH expanded variables in [[ ... ]] do not perform globbing

From Dev

com.sap.cloud.sdk.datamodel.odata render empty fields

From Dev

SAP Cloud SDK on premise connection is aborted because SYTEM_USER not found?

Related Related

  1. 1

    Generate VDM for SFSF using Java in SAP Cloud SDK: "Failed to convert response into ODataFeed""

  2. 2

    Generate VDM for SFSF using Java in SAP Cloud SDK: Generated URI is wrong

  3. 3

    How to fix a DestinationAccessException thrown by the SAP Cloud SDK during application startup

  4. 4

    Unable to load servlet filter class: com.sap.cloud.sdk.cloudplatform.security.servlet.HttpSecurityHeadersFilter (SCP Neo)

  5. 5

    SAP Cloud SDK method for output service in OData form

  6. 6

    S/4HANA Cloud SDK :com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces does not exist

  7. 7

    How do I access OData service using the SAP S/4HANA Cloud SDK in existing application?

  8. 8

    Cloud-SDK Filter by subfields

  9. 9

    Cannot access S/4HANA on Premise system via Cloud Connector using SAP Cloud SDK for JavaScript

  10. 10

    How to execute integrationtests for own OData service in SAP Cloud SDK

  11. 11

    SAP Cloud SDK JavaScript: No CSRF Token for onPremise destination with Location ID

  12. 12

    SAP Cloud SDK Spring Security JARS

  13. 13

    Is the SAP Cloud SDK VDM Generator handling EDMX annotations correctly?

  14. 14

    Calling BAPI from Java using SAP Cloud SDK version 3.0

  15. 15

    Principal Propagation is not working in the latest version of SAP Cloud SDK

  16. 16

    SAP Cloud SDK for javascript using the destination

  17. 17

    Found class com.sap.cloud.sdk.cloudplatform.naming.JndiLookupFacade, but interface was expected

  18. 18

    Check if filter element is expanded or collapsed

  19. 19

    Securing a JS application built with SAP Cloud SDK

  20. 20

    Root cause & Propagation of Exception in SAP Cloud SDK

  21. 21

    SAP Cloud SDK JavaScript URL encoding ODATA filter (API_PRODUCT_SRV)

  22. 22

    Dependency conflicts between SAP-Cloud-SDK and SAP cloud-security-xsuaa-integration

  23. 23

    Office 365 - Filter on expanded messages

  24. 24

    Filter expanded OData request

  25. 25

    Getting JSON parser error when using sap-cloud-sdk

  26. 26

    How to get user info and authorities in SAP Cloud SDK 3.0 and above

  27. 27

    ZSH expanded variables in [[ ... ]] do not perform globbing

  28. 28

    com.sap.cloud.sdk.datamodel.odata render empty fields

  29. 29

    SAP Cloud SDK on premise connection is aborted because SYTEM_USER not found?

HotTag

Archive