Quantcast
Channel: SCN : Blog List - All Communities
Viewing all articles
Browse latest Browse all 2548

XSOdata with Navigation Property

$
0
0

A sample example for XSOdata  with Navigation Property


Scenario of Purchase Order(PO) Header andItem: In a single service we can navigate to Item level from Header to Item with Association .

Lets start with very basic example of VBAK (PO Header), VBAP(PO Item).


Example Code in a .XSOdata file

 

service namespace "workshop.aisurya.XSOdata" {
"<YourSchema>"."VBAK" as "POHeader" with ("MANDT","VBELN","ERDAT") navigates ("ToPoItemAssctn" as "ItemRef");
"<YourSchema>"."VBAP" as "POItems" with ("MANDT","VBELN","POSNR","MATNR","ARKTX"); 
association "ToPoItemAssctn" principal "POHeader"("VBELN") 
multiplicity "1" dependent "POItems"("VBELN") multiplicity "*";
}

Below Image for reference

1.png

 

 

Activate the changes and Run As XS Service.

 

Lets check the Metadata of service.

 

https://<Host:Port>/workshop/aisurya/XSOdata/po.xsodata/$metadata

 

2.png

 

As highlighted in the image(ItemRef) is a navigation property from Header to Item level.

 

Lets test the service only for 2 records by providing query option as (top=2).

 

https://<Host:Port>/workshop/aisurya/XSOdata/po.xsodata/POHeader?$top=2&$format=json



3.png

 

Here ItemRef is the navigation property of corresponding PO Items with URI. We can explicitly open in new tab and get the result also .

 

Now lets check Expand option for Showing Header and Corresponding Items.

 

$Expand Feature to fetch Corresponding Item along with Header.

 

https://<Host:Port>/workshop/aisurya/XSOdata/po.xsodata/POHeader?$top=2&$format=json&$expand=ItemRef

 

POHeader (MANDT='800', VBELN='0000004970')


4.png



Now this service can be consumed in different UI ‘s  depending upon the requirement.



Viewing all articles
Browse latest Browse all 2548

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>