0

I need to get navigation properties data. Does anybody know how to use navigation properties using SAP Cloud SDK?

I created a VDM by SAP Cloud SDK VDM Generator. The source OData is V2 and on S/4 HANA, which is generated by CDS View. What I want to execute is like following.

  • HTTP Method: GET
  • Path: <host, domain, port and path>/(parameter='test')/Set?&fileter=filed eq 'hoge'
fuku
  • 11
  • 2
  • Please remove your own answer and edit your initial questions instead. Also please avoid statements like "it throws an error". Instead, show the stack trace. – MatKuhr Aug 17 '20 at 15:26
  • I still don't quite understand your requirement. Please share a specific example of a query showcasing exactly what you want to execute. Also include the response you would expect. – MatKuhr Aug 17 '20 at 15:29

2 Answers2

0

You can either fetch the data directly by expanding the navigation properties in the OData call OR fetch them at a later point in time.

To follow the first approach leverage the select functionality of your service class. Pass in the navigation property that you want to retrieve e.g. MyEntityClass.TO_MY_NAVIGATION_PROPERTY. Check out the Cloud SDK documentation for the details and an example.

You then obtain the data by invoking its dedicated Getter on the result entity of your query e.g. myEntityObject.getMyNavigationPropertyIfPresent(). Or you omit expanding in your original request and use myEntityObject.getMyNavigationPropertyOrFetch(). This will again query the server specifically for the data of the navigation property.

MatKuhr
  • 505
  • 4
  • 13
  • I want to fetch the data without expansion, since I need to filter expanded data. I cannot fetch the later point in time, since OData with parameter on SAP Gateway cannot allow the way to fetch the data. I reluctantly use RFM via JCo. – fuku Aug 03 '20 at 00:32
  • I don't quite understand what your requirements are. Do you only want a filtered subset of navigation properties? Or only filter based on the properties but not get the data? What kind of error do you encounter when trying to fetch the data later? How is RFM related here? Please consider expanding your question with some details on this. – MatKuhr Aug 03 '20 at 06:52
0

Internal Incidents Stackoverflow

Thank you for replying. Let me explain in detail.

I created an OData from CDS View on S/4HANA 1709. The CDS View is with parameters. The OData should be called like this.

/(parameter='value')/Set?$filter=field eq 'value'

When I tried to call without navigation property, it occurs an error. /(parameter='value')

Besides, I need "filter" parameter for navigated entity, since it gets too many records without filtering. So I don't want to use the both expansion and 2-step fetch.

As workaround, I developed a function module which retrieves data from CDS view.

fuku
  • 11
  • 2