Search code examples
s4sdk

Cloud-SDK Filter by subfields


I'm using S4 Cloud-SDK to make queries on SAP S/4 Hana and I trying to get information about Business Partners filtering with company code. The fields that I'm looking for are:

  • Supplier FullName
  • Supplier Email
  • Tax1 Number
  • Representative Name
  • Supplier Code

For that I'm using BusinessPartnerService to get these fields. The problem is, I'm doing lots of queries to get this information and I would like to reduce the number of queries to the database. One of the queries is listed below.

List<BusinessPartner> businessPartners = businessPartnerService.getAllBusinessPartner().select(
    BusinessPartner.TO_SUPPLIER.select(Supplier.TO_SUPPLIER_COMPANY),
    BusinessPartner.TO_BUSINESS_PARTNER_CONTACT, BusinessPartner.TO_BU_PA_IDENTIFICATION, 
    BusinessPartner.TO_BUSINESS_PARTNER_ADDRESS, BusinessPartner.TO_BUSINESS_PARTNER_TAX, BusinessPartner.ALL_FIELDS)
    .execute();

Is it possible to filter the query above using an EntityLink? For example, something similar to the following:

.filter(BusinessPartner.TO_SUPPLIER.select(
        Supplier.TO_SUPPLIER_COMPANY.COMPANY_CODE.eq("ABCD")))

Solution

  • Update: Version 2.8.0 and above support 1:1 navigation properties.