select
When reading entities, the API offers select( ... ) on the builders.
Through it, the query parameters $select and $expand are set.
It restricts the response to the given selection of properties in the request.
The properties that can be selected or expanded are represented via static fields on the entity class.
So there will be a field for each property.
E.g. the business partner entity has BusinessPartner.FIRST_NAME as a representation of a property and BusinessPartner.TO_BUSINESS_PARTNER_ADDRESS as a representation of a navigation property.
A navigation property means that there is a relation between a business partner and their addresses.
In this case, one business partner can have multiple addresses.
In SAP S/4HANA, navigation properties typically start with TO_.
BusinessPartner.requestBuilder()
.getAll()
.select(
BusinessPartner.FIRST_NAME,
BusinessPartner.LAST_NAME,
BusinessPartner.TO_BUSINESS_PARTNER_ADDRESS
)
.execute(destination);
The above translates to the following query parameters:
$select=FirstName,LastName,to_BusinessPartnerAddress/*&$expand=to_BusinessPartnerAddress
One can also select properties of the expanded navigation property:
BusinessPartner.requestBuilder()
.getAll()
.select(
BusinessPartner.FIRST_NAME,
BusinessPartner.TO_BUSINESS_PARTNER_ADDRESS.select(
BusinessPartnerAddress.ADDRESS_ID,
BusinessPartnerAddress.CITY_CODE
)
)
.execute(destination);
The above translates to the following query parameters:
$select=FirstName,to_BusinessPartnerAddress/AddressID,to_BusinessPartnerAddress/CityCode&$expand=to_BusinessPartnerAddress