05-01-2018 7:33 PM
I am in varsity currently working on a project, however l was thrown under the bus and l have to figure out how to use SAP tools for development. Now l've been relatively successful, however I'm struggling to display the data that contains foreign keys.
So far I've gotten to the stage where l can view my metadata and the relative addresses, but l do not know how to provide the address on initialization for it to populate my views.
So the context is: l have three tables, namely consultant, project and assignments. My assignments table is dependent on two foreign keys from project and consultant namely, consultantID and projectID.
So now my question is, how do l populate the view with the data from assignments, such that l can simply extract my consultant's information as well as my project information.
Any help would be greatly appreciated.
05-01-2018 9:32 PM
You can use $expand.
https://sapes5.sapdevcenter.com/sap/opu/odata/iwbep/GWSAMPLE_BASIC/SalesOrderLineItemSet(SalesOrderID='0500000000',ItemPosition='0000000010')?$expand=ToProduct,ToHeader
So navigating from the assignments to Consultant and Customer
Best regards
Andre
05-01-2018 10:25 PM
Hi Andre.
So l am unable to access that link (most likely due to my not being an actual client). I have however made a bit of progress and am currently stuck at one point. So the way I'm currently performing the read from my database is:
oModel.read("/Assignments?$expand=ConsultantDetails", { success: function(data) { console.log(data); which returns an array with 6 elements. My question is how do l now go about printing the data that's in those arrays, as l have tried using a $select statement which l think is incorrect to extract the data?
So in essence l am asking if l am correct in my syntax in doing this: oModel.read("/Assignments?$expand=ConsultantDetails($select=Consultant_Name, Consultant_Surname)", { success: function(data) { console.log(data); or am l wrong?
Sorry to bother you so much
Regards
Tatenda