API business hub is the perfect starting point for your API journey , you can use it to see the response as well as to work with different options delivered with the API.
For this particular blog we will take an example of Purchase contract API and will create a purchase contract , add a new item and update header as well as item data.
API Hub - https://api.sap.com/
Search for the Purchase contract, and select the Purchase Contract ODATA API.
Prerequisite - Your system is connected and configured to API Hub.
Now to test it out with your connected system , Log In with your credentials and click on Configure Environment to connect to your S4 system.
In the snapshot posted above , on the left hand side we have different nodes which are supported by this API namely-
1. A_PurchaseContarct (Header Node) - Purchase Contract Header Data
2. A_PurchaseContractItem (Item Node) - Purchase Contract Item Data
3. A_PurCtrPartners (Partner Node ) - Purchase Contract Partner Data
4. A_PurContrItemCondition (Condition Node) - Purchase Contract Item Price Conditions
5. A_PurCtrAccount (Account Assignments Node) - Purchase Contract Item Account Assignments
6. A_PurCtrAddress (Address Node) - Purchase Contract Address
And the Last
7. Batch Requests - This option can be used for any node to perform operations in a BATCH request . Since this API ONLY supports BATCH requests for Update of existing contract, we will do all our UPDATE and INSERT (Addition of new item etc.) here.
As part of this blog series we will explore the GET operation of this API in this blog.
Various ODATA parameters are supported by this API for example-
1. $top - Can be used to fetch first n number of records.
2.$skip - Can be used to skip first n records and fetch the rest.
3. $filter - Can be used to filter the result set.
For example - PurchaseContract eq '4600000075' can be used to filter the result set for Purchase Contract - 4600000075 .
4. $Inlinecount - Returns count of number of entities.
5. $orderby - Option to sort the result set , we have two options here either to sort by a field in ascending or descending order. The fields are listed by which sorting can be done.
6. $select - We can select the fields which needs to be part of result set.
7. $expand - Can be used to fetch the expanded entity result set. Here for purchase contract header (parent) we have Items and Partners as child entity sets.
Click on Execute and if the GET call is successful we will get HTTP code as 200 and Contract details in the response.
This covers the GET operations.
Insert (POST) and Update (PATCH) options will be covered in the next blogs.
Insert (POST) Operation - https://s4hanacloud.community.sap/blogs/show/KV7jpvmPuqCDC5aLlpMNTl
Update (PATCH & POST) Operation - https://s4hanacloud.community.sap/blogs/show/xIVNB17IbLjm13Xuq9UxvW