OData List binding error “Failed to enhance query”

I am currently working with SAPUI5 and developing a extension for the Web Client using the OData Model V4 for data retrieval. However, I am having trouble concerning data binding of a child collection. The datastructure I want to access (which partially works, except for the collection) looks as follows:

{
    "Code": "5",
    "OBJ_CUST_ADDRCollection": [
        {
            "Code": "5",
            "U_Address": "Construction site",
            "U_Street": "Sample Street 20",
            "U_City": "New York",
            "U_ZipCode": "1234",
            "U_CntctName": "John Doe"
        }
        //This array usually contains multiple entries which have the same schema as the one above.
    ]
}

My model’s configuration looks as follows:

export const bpModel: ODataModel = new ODataModel({
        serviceUrl: `/b1s/v2/`,
        synchronizationMode: "None",
        operationMode: "Server",
        autoExpandSelect: true,
        earlyRequests: true,
        groupProperties : {
            UpdateGroup : {"submit" : "API"}
        },
        updateGroupId : updateGroupId
    });

To retrieve a specific entity, I have used an element binding to bind the bpModel to my view (the key is ‘5’ in this instance):

view.bindElement({
  path: `/OBJECT_CUSTOMER('${routingParams.customerObjCode}')`,
  model: bpModelName
});

I am using a fragment (for better readability) in my view, which contains the data binding to the collection “OBJ_CUST_ADDRCollection”:

<core:FragmentDefinition 
    xmlns="sap.m"
    xmlns:mvc="sap.ui.core.mvc"
    xmlns:core="sap.ui.core">

        <VBox width="100%">
            <Title text="{i18n>objectAddresses}" class="sapUiSmallMarginBottom"/>
            <Table id="objAddresses" 
                mode="MultiSelect" 
                class="sapUiSmallMarginBottom"
                items="{
                    path: 'OBJ_CUST_ADDRCollection',
                    model: 'BP'
                }"
                sticky="HeaderToolbar,InfoToolbar,ColumnHeaders">
                <headerToolbar>
                    <OverflowToolbar>
                        <ToolbarSpacer/>
                        <Button icon="sap-icon://add" press="addAddress"/>
                        <Button icon="sap-icon://delete" press="deleteAddresses"/>
                        <Button icon="sap-icon://action-settings" press="changeObjAddressSettings"/>
                    </OverflowToolbar>
                </headerToolbar>
                <columns>
                    <Column>
                        <Text text="{i18n>objectAddressesID}"/>
                    </Column>
                    <Column>
                        <Text text="{i18n>objectAddressesStreetPOBox}"/>
                    </Column>
                    <Column>
                        <Text text="{i18n>objectAddressesLocation}"/>
                    </Column>
                    <Column>
                        <Text text="{i18n>objectAddressesZipCode}"/>
                    </Column>
                    <Column>
                        <Text text="{i18n>objectAddressesCntctAtLoc}"/>
                    </Column>
                </columns>
                <items>
                    <ColumnListItem>
                        <cells>
                            <Text text="{BP>U_Address}" />
                            <Text text="{BP>U_Street}" />
                            <Text text="{BP>U_City}" />
                            <Text text="{BP>U_ZipCode}" />
                            <Text text="{BP>U_CntctName}" />
                        </cells>
                    </ColumnListItem>
                </items>
            </Table>
        </VBox>
</core:FragmentDefinition>

But whenever this fragment (and the corresponding view) is loaded, I encounter the error “Failed to enhance query options for auto-$expand/$select as the child binding has query options, but its path ‘OBJ_CUST_ADDRCollection’ points to a structural property – {“$select”:[“U_Address”,”U_Street”,”U_City”,”U_ZipCode”,”U_CntctName”]} sap.ui.model.odata.v4.lib._Helper”. When checking and manually testing the actual GET request sent by the OData model, I can see that the query parameter $select is used, which caused the request to fail. When I omitted this parameter (in my tests with Insomnia) the request worked.

How do I resolve this error?

At this point I have tried multiple things:

  • Setting “autoExpandSelect” to false. This caused the issue to disappear and the collection’s contents were displayed correctly. Yet, this isn’t a solution to me, as I intend to use a deep create later on and “autoExpandSelect: true” is required for this.
  • Changing the items aggregation slightly, by adding a “parameters” object containing $select: [ ] and $$ownRequest: true. The only thing this changed for me was, that my batch-request contained another request for the collection itself. The issue concerning $select still persists though.
  • Using a Service Layer Extension written in JavaScript. This option gave me a bit more freedom concerning the design of the endpoint, but I wasn’t able to access it with batch-requests. I had to set the groupId to $direct and autoExpandSelect to false for data to be displayed. This did work in the end, but also isn’t ideal. Firstly, the performance seems to be far worse when using a custom endpoint. Secondly, deep create still won’t work due to autoExpandSelect being set to false.

New contributor

angryBird is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật