Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
solene_roques
Participant
Dear all,

I wil explain in this blog post how to create a Sales Order based on a Sales Quote via Odata.

Business context : a quote has been created in SAP ByDesign (status Open) and your requirment is to trigger the sales order creation based on this quote.

Overview : it is a two phases process : first, you need to create a sales order has an empty shell. Then, by adding a reference to a sales quote, all the information (headers, items, prices...) will be automatically fulfilled.

 

Step 1 : configure the Odata service

- You can use the standard service khsalesorder or create your own OData service based on the business object SalesOrder node Root

- If you created your own webservice, select at least one field (ID for example)

- In the Function import tab, create the action AddReferenceWithDataProvision as follows:


- If you created your own webservice, assign the OData service to the workcenter CRM_SALESORDERS.

-Save and activate the OData service

 

Step 2:  do a GET call to obtain the xcsrf-token

As you know, to be able to post data through OData, you need a x-csrf token. You can call any Odata service, here you called the service khsalesorder filtered on one Sales Order ID to reduce the execution time.

Note: all REST calls are made from PostMan in this blog post.


 

Step 3 : Create an « empty » sales order

The only information needed is a customer.

{
"BuyerParty": {
"PartyID": "TW_003"
}
}


  • Header to add:  Key = x-csrf-token ; Value = xxxxxxxxxxxxxxxxxxxxxxx



 

For the next action, we need the ObjectID of the newly created Sales Order:
<ObjectID>00163E71D2F31EDBA7D260A1F20E3EAF</ObjectID>

The Sales Order created is empty for the moment (only the customer is entered) :


Step 4 : add reference to sales quote

The action ‘AddReferenceWithDataProvision’ will fulfill the new Sales Order with the quote data.

Key: ObjectID, Value = ‘00163E71D2F31EDBA7D260A1F20E3EAF‘



    • The second parameter is the Customer Quote ID




Key: BusinessTransactionDocumentKey_BusinessTransactionDocumentID, Value = '107'



    • The third parameter is the business type code corresponding to a Customer Quote e.g. 30




Key: BusinessTransactionDocumentKey_BusinessTransactionDocumentTypeCode, Value = '30'

  • Header to add:  Key = x-csrf-token ; Value = xxxxxxxxxxxxxxxxxxxxxxx



The Sales Order is now fulfilled with the quote data:


After this action, the quote status is set as completed (same as a manual Sales Order creation):


 

 

Conclusion:

The calls have been done from PostMan for this post. However, you can launch from any third party system : SCPi or any middleware.

It is also possible to realize the same process through a PDI absl script: the functions available in OData are also available in absl.

 

Hope it would help someone

Best regards

 
Labels in this area