Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@UI.presentationVariant.sortOrder is not working #38

Open
mainakaich opened this issue Jul 31, 2023 · 1 comment
Open

@UI.presentationVariant.sortOrder is not working #38

mainakaich opened this issue Jul 31, 2023 · 1 comment

Comments

@mainakaich
Copy link

In https://github.com/SAP-samples/abap-platform-rap-opensap/blob/main/week2/unit5.md, step 7, the following annotation is used

@ui: {
headerInfo: { typeName: 'Travel',
typeNamePlural: 'Travels',
title: { type: #STANDARD, label: 'Travel', value: 'TravelID' } } ,
presentationVariant: [{ sortOrder: [{ by: 'TravelID', direction: #DESC }] }] }

But this is giving following HTTP error when I am executing the fiori element preview from service binding.

{"error":{"code":"005056A509B11EE1B9A8FEA8DE87F78E","message":{"lang":"en","value":"Property desc not found in type TravelType"},"innererror":{"transactionid":"B59C0F42C9AF00D0E0064C6C73AFDC9D","timestamp":"20230731132547.3575230","Error_Resolution":{"SAP_Transaction":"For backend administrators: use ADT feed reader "SAP Gateway Error Log" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details","SAP_Note":"See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"}}}}
--440328ACE08C04162E2AD8A5960092FD0--

The reason for the error is, the URL which is generated is -
GET Travel?sap-client=100&$skip=0&$top=20&$orderby=%20desc&$select=TravelId%2cAgencyId%2cAgencyName%2cCustomerId%2cCustomerName%2cBeginDate%2cEndDate%2cBookingFee%2cCurrencyCode%2cTotalPrice%2cDescription%2cTravelStatus%2cTravelUuid&$inlinecount=allpages HTTP/1.1

Here in the orderby=%20desc& is not containing the TravelID as mentioned in the @ui annotation. Could you please check and help me.

@iboabap
Copy link

iboabap commented Dec 30, 2024

I encountered an issue where the field name in the annotation did not match the case of the actual field definition, which is case-sensitive.

Initially, I wrote the following annotation:

presentationVariant: [{ sortOrder: [{ by: 'TravelID', direction: #DESC }] }]

However, in my data model (ZI_TRAVEL), the field was defined as TravelId, not TravelID. Since the field names are case-sensitive, this mismatch caused the error.

The corrected annotation looks like this:

presentationVariant: [{ sortOrder: [{ by: 'TravelId', direction: #DESC }] }]

Here’s the complete and corrected metadata annotation:

@Metadata.layer: #CORE
@ui: {
  headerInfo: { 
    typeName: 'Travel',
    typeNamePlural: 'Travels',
    title: { type: #STANDARD, label: 'Travel', value: 'TravelId' } 
  },
  presentationVariant: [{ 
    sortOrder: [{ by: 'TravelId', direction: #DESC }] 
  }]
}
annotate view ZC_RAP_Travel_### with

This resolved the issue by aligning the field name in the annotation with its actual definition in the data model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants