Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
murthy_v
Employee
Employee
SAP Business ByDesign (ByD) provides you with REST/OData access to Customer Contract Price Components both header and item level components. This blog post provides you with an sample round trip examples of price components (create – read – update – delete) using ByD OData services for customer contract business object.

In the demo below you see how you can how to create custom OData service and use the service to perform CRUD operation on Customer Contract price components.


Example Scenario


In the example we are creating reading updating deleting (CRUD) price components of customer contract using SAP Business ByDesign Custom OData Services.

Sample customer contract header level price components include:

  • Overall Discount

  • Freight

  • Restocking Fee

  • Surcharge


Sample customer contract item level price components include:

  • Product Discount

  • Price

  • Surcharge (Fixed Value)

  • Surcharge (%)

  • Quality Loss Fee

  • Goodwill (%)

  • Warranty (%)

  • Working Condition (%)


Note: the customer contract document has pricing in set to Net or Gross pricing procedureboth options with samples are explained in detail.

User can create read update delete both header level and item level price components using the following Type Codes for both Net pricing and Gross pricing procedure, following are the list of type codes you can use to handle different price components.

List of Document / Header level price components in Net Pricing Procedure are listed below.







































 
          Price Component    Type Code
          Overall Discount       0007
          Freight       7PR8
         Restocking Fee       7PRB
         Surcharge       0001
         Surcharge 2       0002
         Surcharge 3       0003
         Surcharge 4       0004
         Surcharge 5       0005


List of Item level price components in Net Pricing Procedure are listed below.







































 
          Price Component    Type Code
          Product Discount       7PR6
          List Price       7PR1
         Surcharge       7PR3
         Surcharge (%)       7PR2
         Quality Loss Fee       7PRA
         Goodwill (%)       7PRC
         Warranty (%)       7PR9
         Working Condition (%)       7PR7

 

List of Document / Header level price components in Gross Pricing Procedure are listed below.



















 
          Price Component    Type Code
          Gross Overall Discount       1007
          Gross Freight       8PR8
          Gross Restocking Fee       8PRB


List of Item level price components in Net Pricing Procedure are listed below.































 
          Price Component    Type Code
          Gross Product Discount       8PR6
          Gross List Price       8PR1
          Gross Surcharge       8PR3
          Gross Surcharge (%)       8PR2
          Gross Quality Loss Fee       8PRA
          Gross Working Condition (%)       8PR7


Expose ByD Customer Contract Price Components as OData Service


Open work center view Application and User Management – OData Services and create a Custom OData Service for business object Customer Contract.

Make sure you expose header and item price component properties that enable you to create, filter, read, update and delete all relevant price components data incl. nodes Root,CustomerContractPriceAndTaxCalculationCustomerContractOperationalPriceComponent, CustomerContractItem, CustomerContractOperationalItemPriceComponent. In my example I included the following elements to my Custom OData Service “contractpricecomponents“:

  • ID

  • CustomerContractPriceAndTaxCalculation (header level price components)

  • CustomerContractOperationalPriceComponent

    • TypeCode

    • DecimalValue

    • CurrencyCode

    • BaseMeasureUnitCode

    • BaseDecimalValue

    • MeasureUnitCode

    • RateBaseQuantityTypeCode



  • CustomerContractItem (created from the Item association from CustomerContractPriceAndTaxCalculation )

  • CustomerContractOperationalItemPriceComponent (created from the OperationalItemPriceComponent association from CustomerContractItem )

    • TypeCode

    • DecimalValue

    • CurrencyCode

    • BaseMeasureUnitCode

    • BaseDecimalValue

    • MeasureUnitCode

    • RateBaseQuantityTypeCode






Activate your custom OData service and note down the Service URL from the OData Editor. In my example the service URL is

https://{{TenantHostname}}/sap/byd/odata/cust/v1/contractpricecomponents

If needed you can retrieve the metadata using the metadata URL

https://{{TenantHostname}}/sap/byd/odata/cust/v1/contractpricecomponents/$metadata

Note: replace the {{TenantHostname}} with ByD tenant host name, example: my123456.sapbydesign.com


Document Level Price Components


The customer contract document has pricing in set to Net or Gross pricing procedureboth options with samples are explained in detail.

User can create read update delete both header level price components using the following Type Codes for both Net pricing and Gross pricing procedure, following are the list of type codes you can use to handle different price components.

List of Document / Header level price components in Net Pricing Procedure are listed below.







































 
          Price Component    Type Code
          Overall Discount       0007
          Freight       7PR8
         Restocking Fee       7PRB
         Surcharge       0001
         Surcharge 2       0002
         Surcharge 3       0003
         Surcharge 4       0004
         Surcharge 5       0005

 

List of Document / Header level price components in Gross Pricing Procedure are listed below.



















 
          Price Component    Type Code
          Gross Overall Discount       1007
          Gross Freight       8PR8
          Gross Restocking Fee       8PRB


Create Update and Delete Overall Discount using the Custom OData Service


In the custom OData service select the header level price component relevant fields in co-relation with UI fields of Overall Discount in Total Pricing of Pricing and Invoicing tab of Customer Contract.





 

Step 1: Create Overall Discount

Using the http-method POST and entity set CustomerContractOperationalPriceComponent you can create Overall Discount, make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and MeasureUnitCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body ( the ParentObjectID is the Customer Contract Object ID)
{		
"ParentObjectID": "00163E7306A31ED9AE88CEDDADEFD798",
"TypeCode": "0007",
"DecimalValue": "10",
"MeasureUnitCode": "P1"
}

and the http-header parameter

  • x-csrf-token=fetch to get the CSRF-token to create the material via POST service call ( note: the x-csrf-token is fetched in the GET service call , for details refer to postman example collection ).

  • Note: Customer Contract ID should be the valid and existing id in system.



As result ByD returns the following OData response body:



 

As you can see the Overall Discount is created with relevant information.



      Note:  Details about x-csrf-token:

  • SAP Business ByDesign System generates a CSRF token and sends it back in the HTTP response header field X-CSRF-Token.
    This happens in a non-modifying request (such as GET) if the header field X-CSRF-Token with the value Fetch is sent along with the non-modifying request.

  • Note: CSRF (Cross Site Request Forgery) token is a random, hard-to-guess string. the server would generate a random string and is stored in the session or by setting a cookie containing the value

  • For example Steps to Follow:

  • Step 1: call the Get service by setting the Header key field “x-csrf-token”  with value “fetch”

  • Step 2: in the HTTP response header of above GET service call you read the field value “x-csrf-token”

  • Step 3: in the subsequent POST calls use the x-csrf-token .


 

Step 2: Update Overall Discount

Using the http-method PUT and entity set CustomerContractOperationalPriceComponentCollection you can update the Overall Discount, make sure you pass the values for following elements ObjectID, ParentObjectID, TypeCode, DecimalValue and MeasureUnitCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{
"ObjectID": "{{CustomerContractPriceComponentObjectID}}",
"ParentObjectID": "{{CustomerContractPriceComponentParentObjectID}}",
"TypeCode": "0007",
"DecimalValue": "30",
"MeasureUnitCode": "P1"
}



 

As result the customer contract overall discount gets updated:



 

Step 3: Delete Overall Discount

Using the http-method DELETE and entity set CustomerContractOperationalPriceComponentCollection you can delete the Overall Discount, make sure you pass the value of the specific instance id of overall discount which just got updated.

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

to delete an instance JSON body is required, you have to pass only the instance id as shown above.



Note: instance to be deleted can be fetched by performing the GET operation and getting the right instance of the overall all discount of customer contract.

GET before delete is required since after the UPDATE operation the instance id of the overall discount is changed.



 

Create Update and Delete Freight using the Custom OData Service


User can create document level Freinght in Total Pricing of Pricing and Invoicing tab of Customer Contract using the OData service by following the steps mentioned below.



 

Step 1: Create Freight 

Using the http-method POST and entity set CustomerContractOperationalPriceComponent you can create header level / document level Freight, and make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and CurrencyCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{		
"ParentObjectID": "00163E7306A31ED9AE88CEDDADEFD798",
"TypeCode": "7PR8",
"DecimalValue": "10",
"CurrencyCode": "USD"
}

 

As result ByD returns the following OData response body:



 

As you can see the document level Freight is created with relevant information.



 

Note: for Update and Delete of header level Freight please follow same steps as mentioned above in step 2 and step 3 of Overall Discount.

 

Create Update and Delete Restocking Fee using the Custom OData Service


User can create Restocking Fee in Total Pricing of Pricing and Invoicing tab of Customer Contract using the OData service by following the steps mentioned below.



 

Step 1: Create Restocking Fee

Using the http-method POST and entity set CustomerContractOperationalPriceComponent you can create Restocking Fee, and make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and CurrencyCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{		
"ParentObjectID": "00163E7306A31ED9AE88CEDDADEFD798",
"TypeCode": "7PRB",
"DecimalValue": "10",
"CurrencyCode": "USD"
}

 

As result ByD returns the following OData response body:



 

As you can see the Restocking Fee is created with relevant information.



 

Note: for Update and Delete of Restocking Fee please follow same steps as mentioned above in step 2 and step 3 of Overall Discount.


Create Update and Delete Surcharge using the Custom OData Service


User can create document level Surcharge in Total Pricing of Pricing and Invoicing tab of Customer contract using the OData service by following the steps mentioned below.



 

Step 1: Create Surcharge

Using the http-method POST and entity set CustomerContractOperationalPriceComponent you can create Surcharge, and make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and CurrencyCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{		
"ParentObjectID": "00163E7306A31EE9AE81BA7D941D2543",
"TypeCode": "0001",
"DecimalValue": "10",
"CurrencyCode": "USD"
}

 

As result ByD returns the following OData response body:



 

As you can see the Restocking Fee is created with relevant information.



 

Note: for Update and Delete of header level Surcharge please follow same steps as mentioned above in step 2 and step 3 of Overall Discount.

 

Note: you can create Five different Surcharge at customer contract header level (in case you have scoped “Additional Surcharge” in business configuration )

you can create additional surcharges by passing the following TypeCode 0002, 0003, 0004 and 0005 in the OData request.









 

Additional Surcharges in Customer Contract UI



 


Item Level Price Components


The customer contract document has pricing in set to Net or Gross pricing procedureboth options with samples are explained in detail.

User can create read update delete Item level price components using the following Type Codes for both Net pricing and Gross pricing procedure, following are the list of type codes you can use to handle different price components.

List of Item level price components in Net Pricing Procedure are listed below.







































 
          Price Component    Type Code
          Product Discount       7PR6
          List Price       7PR1
         Surcharge       7PR3
         Surcharge (%)       7PR2
         Quality Loss Fee       7PRA
         Goodwill (%)       7PRC
         Warranty (%)       7PR9
         Working Condition (%)       7PR7

List of Item level price components in Gross Pricing Procedure are listed below.































 
          Price Component    Type Code
          Gross Product Discount       8PR6
          Gross List Price       8PR1
          Gross Surcharge       8PR3
          Gross Surcharge (%)       8PR2
          Gross Quality Loss Fee       8PRA
          Gross Working Condition (%)       8PR7


Create Update and Delete Product Discount using the Custom OData Service


In the custom OData service select the item level price component relevant fields in co-relation with UI fields of Product Discount in Item Pricing of Pricing and Invoicing tab of Customer Contract.





 

 

Step 1: Create Product Discount

Using the http-method POST and entity set CustomerContractOperationalItemPriceComponentCollection you can create Product Discount, make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and MeasureUnitCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body ( ParentObjectID is the Item Object ID )
{		
"ParentObjectID": "00163E7306A31ED9AE88D048C127579C",
"TypeCode": "7PR6",
"DecimalValue": "10",
"MeasureUnitCode": "P1"
}

and the http-header parameter

  • x-csrf-token=fetch to get the CSRF-token to create the material via POST service call ( note: the x-csrf-token is fetched in the GET service call , for details refer to postman example collection ).

  • Note: Customer contract ID and Item ID (ObjectID) should be the valid and existing id in system.



As result ByD returns the following OData response body:



 

As you can see the Product Discount is created with relevant information.



     

Step 2: Update Product Discount

Using the http-method PUT and entity set CustomerContractOperationalItemPriceComponentCollection you can update the Product Discount, make sure you pass the values for following elements ObjectID, ParentObjectID, TypeCode, DecimalValue and MeasureUnitCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{
"ObjectID": "{{CustomerContractItemPriceComponentObjectID}}",
"ParentObjectID": "{{CustomerContractItemPriceComponentParentObjectID}}",
"TypeCode": "7PR6",
"DecimalValue": "30",
"MeasureUnitCode": "P1"
}



 

As result the Customer Contract  item product discount gets updated:



 

Step 3: Delete Product Discount

Using the http-method DELETE and entity set CustomerContractOperationalItemPriceComponentCollection you can delete the Product  Discount, make sure you pass the value of the specific instance id of product discount which just got updated.

https://{{TenantHostname}}/sap/byd/odata/cust/v1/contractpricecomponents/CustomerContractOperationalItemPriceComponentCollection('00163E7306A31ED9AE88D048C127579C00163E7306A31ED9AE9A4F4BD7DC5D7D')

to delete an instance JSON body is required, you have to pass only the instance id as shown above.



Note: instance to be deleted can be fetched by performing the GET operation and getting the right instance of the product discount of customer contract.

GET before delete is required since after the UPDATE operation the instance id of the product discount is changed.



 

Create Update and Delete Price using the Custom OData Service


User can create item Price in Item Pricing of Pricing and Invoicing tab of Customer Contract using the OData service by following the steps mentioned below.



 

Step 1: Create Price

Using the http-method POST and entity set CustomerContractperationalItemPriceComponentCollection you can create item Price, and make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and CurrencyCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{		
"ParentObjectID": "{{CustomerContractItemPriceComponentParentObjectID}}",
"TypeCode": "7PR1",
"DecimalValue": "100",
"CurrencyCode": "USD"
}

 

As result ByD returns the following OData response body:



 

As you can see the document level Freight is created with relevant information.



 

Note: for Update and Delete of Item Price please follow same steps as mentioned above in step 2 and step 3 of Product Discount.

Note: Price is determined from price master data by the system during creation of Item in Customer contract .

  • Use Case 1: Item Price is determined by system and price is overwritten by the OData service after the above price odata create call.

  • Use Case 2: Item Price is not determined by system and price is created by the OData service after the above price odata create call.



Create Update and Delete Item Surcharge using the Custom OData Service


User can create item level Surcharge in Item Pricing of Pricing and Invoicing tab of Customer Contract using the OData service by following the steps mentioned below.



 

Step 1: Create Item Surcharge (absolute value surcharge)

Using the http-method POST and entity set CustomerContractOperationalItemPriceComponentCollection you can create item Surcharge, and make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and CurrencyCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{		
"ParentObjectID": "{{CustomerContractItemPriceComponentParentObjectID}}",
"TypeCode": "7PR3",
"DecimalValue": "10",
"CurrencyCode": "USD"
}

 

As result ByD returns the following OData response body:



 

As you can see the document level Surcharge is created with relevant information.



 

Note: for Update and Delete of Item Surcharge please follow same steps as mentioned above in step 2 and step 3 of Product Discount.

 

Create Update and Delete Item Surcharge(%) using the Custom OData Service


User can create item level Surcharge (%) in Item Pricing of Pricing and Invoicing tab of Customer Contract using the OData service by following the steps mentioned below.



 

Step 1: Create Item Surcharge(%) percentage

Using the http-method POST and entity set CustomerContractOperationalItemPriceComponentCollection you can create item Surcharge(%), and make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and MeasureUnitCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{		
"ParentObjectID": "{{CustomerContractItemPriceComponentParentObjectID}}",
"TypeCode": "7PR2",
"DecimalValue": "10",
"MeasureUnitCode": "P1"
}

 

As result ByD returns the following OData response body:



 

As you can see the document level Surcharge(%) is created with relevant information.



 

Note: for Update and Delete of Item Surcharge(%) please follow same steps as mentioned above in step 2 and step 3 of Product Discount.

 

Create Update and Delete Item Quality Loss Fee using the Custom OData Service


User can create item level Quality Loss Fee in Item Pricing of Pricing and Invoicing tab of CustomerContract using the OData service by following the steps mentioned below.



 

Step 1: Create Item Quality Loss Fee

Using the http-method POST and entity set CustomerContractOperationalItemPriceComponentCollection you can create item Quality Loss Fee, and make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and CurrencyCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{		
"ParentObjectID": "{{CustomerContractItemPriceComponentParentObjectID}}",
"TypeCode": "7PRA",
"DecimalValue": "10",
"CurrencyCode": "USD"
}

 

As result ByD returns the following OData response body:



 

As you can see the document level Quality Loss Fee is created with relevant information.



 

Note: for Update and Delete of Item Quality Loss Fee please follow same steps as mentioned above in step 2 and step 3 of Product Discount.


Create Update and Delete Item Goodwill (%) using the Custom OData Service


User can create item level Goodwill (%) in Item Pricing of Pricing and Invoicing tab of Customer Contract using the OData service by following the steps mentioned below.



 

Step 1: Create Item Goodwill (%) percentage

Using the http-method POST and entity set CustomerContractOperationalItemPriceComponentCollection you can create item Goodwill (%), and make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and MeasureUnitCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{		
"ParentObjectID": "{{CustomerContractItemPriceComponentParentObjectID}}",
"TypeCode": "7PRC",
"DecimalValue": "10",
"MeasureUnitCode": "P1"
}

 

As result ByD returns the following OData response body:



 

As you can see the document level Goodwill(%) is created with relevant information.



 

Note: for Update and Delete of Item Goodwill(%) please follow same steps as mentioned above in step 2 and step 3 of Product Discount.

 

Create Update and Delete Item Warranty(%) using the Custom OData Service


User can create item level Warranty (%) in Item Pricing of Pricing and Invoicing tab of Customer Contract using the OData service by following the steps mentioned below.



 

Step 1: Create Item Warranty (%) percentage

Using the http-method POST and entity set CustomerContractOperationalItemPriceComponentCollection you can create item Warranyty(%), and make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and MeasureUnitCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{		
"ParentObjectID": "{{CustomerContractItemPriceComponentParentObjectID}}",
"TypeCode": "7PR9",
"DecimalValue": "10",
"MeasureUnitCode": "P1"
}

 

As result ByD returns the following OData response body:



 

As you can see the document level Warranty(%) is created with relevant information.



 

Note: for Update and Delete of Item Warranty(%) please follow same steps as mentioned above in step 2 and step 3 of Product Discount.

 

Create Update and Delete Item Working Condition(%) using the Custom OData Service


User can create item level Working Condition(%) in Item Pricing of Pricing and Invoicing tab of Customer Contract using the OData service by following the steps mentioned below.



 

Step 1: Create Item Working Condition (%) percentage

Using the http-method POST and entity set CustomerContractOperationalItemPriceComponentCollection you can create item Working Condition (%), and make sure you pass the values for following elements ParentObjectID, TypeCode, DecimalValue and MeasureUnitCode:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/customercontractpricecomponents/CustomerContractOpe...

In my example I’m using the JSON body
{		
"ParentObjectID": "{{CustomerContractItemPriceComponentParentObjectID}}",
"TypeCode": "7PR7",
"DecimalValue": "10",
"MeasureUnitCode": "P1"
}

 

As result ByD returns the following OData response body:



 

As you can see the document level Working Condition (%) is created with relevant information.



 

Note: for Update and Delete of Item Working Condition (%) please follow same steps as mentioned above in step 2 and step 3 of Product Discount.

Note: to Create Read Update and Delete price components in a customer contract with Gross Pricing Procedure please use the Type Codes mentioned in a table in the beginning of the blog and follow the similar steps mentioned above.