Skip to Content
Product Information

How to use Condition Record OData Service for Sales

Background

In S/4HANA, new synchronous inbound service (API_SLSPRICINGCONDITIONRECORD_SRV) provided to create, read, update, and delete condition records for pricing that are used in Sales.

The service contains entities for condition record, validity of condition record, pricing scale, and condition supplement.

Required Communication Scenario

To be able to use this service, you have to set up the communication scenario SAP_COM_0294.

Service Entity

Below is the service entity list for Sales part:

Entity Description
A_SlsPrcgConditionRecord Condition records
A_SlsPrcgCndnRecdValidity Validity of condition records
A_SlsPrcgCndnRecordScale Pricing scales defined for condition records and condition supplements
A_SlsPrcgCndnRecdSuplmnt Condition supplements

Service Operations

Create

You can use this operation to create condition records together with their validity, pricing scales, and condition supplements.

You can also create pricing scales and condition supplements for existing condition records.

Update

You can update condition records, validity periods, pricing scales, and condition supplements.

You can also use the update operation to setting the deletion flag for condition records and condition supplements.

For entity ‘A_SlsPrcgConditionRecord’, below fields support update action:

  • ConditionRateValue
  • ConditionExclusion
  • AdditionalValueDays
  • FixedValueDate
  • PaymentTerms
  • ConditionIsDeleted

For entity ‘A_SlsPrcgCndnRecdValidity’, below fields support update action:

  • ConditionValidityStartDate
  • ConditionValidityEndDate

For entity ‘A_SlsPrcgCndnRecdSuplmnt’, below fields support update action:

  • ConditionRateValue
  • ConditionIsDeleted

For entity ‘A_SlsPrcgCndnRecordScale’, below fields support update action:

  • ConditionScaleQuantity
  • ConditionScaleAmount
  • ConditionRateValue

Create and Update Example

The example already provided in help, you can directly copy it for using.

Link: https://help.sap.com/viewer/03c04db2a7434731b7fe21dca77440da/latest/en-US/61d84394b59c4b52b6bb71017c68ce26.html

Read

You can read condition records in the system. You can either retrieve all existing data at once or use any of the properties for each service entity as filters.

Most query options are supported, included: format, value, top, skip, count, inlinecount, orderby, select, filter, expand, links, not. For filter query option, supported below operations:

  • eq/ne
  • gt/lt
  • ge/le
  • and/or
  • not
  • ()
  • substringof(string po, string p1)
  • startswith(string p0, string p1)
  • endswith(string p0, string p1)

Read Example

Read Condition record validity with specific filter:
GET <host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity/?$filter=(ConditionType eq 'PPR0' and (Customer eq '10100001' or SalesOrganization gt '1010') and Material ge 'TG12' and Material le 'TG20')&$orderby=SalesOrganization asc,Material desc&$select=ConditionRecord,ConditionApplication,ConditionType,Material,SalesOrganization,Customer&$inlinecount=allpages
X-CSRF-Token: abc
Accept: application/json

Status: 200 OK
content-Type: application/json; charset=utf-8
dataserviceversion: 2.0

{
  "d" : {
    "__count" : "153",
    "results" : [
      {
        "__metadata" : {
          "id" : "<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity(ConditionRecord='0000031025',ConditionValidityEndDate=datetime'2019-08-31T00%3A00%3A00')",
          "uri" : "<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity(ConditionRecord='0000031025',ConditionValidityEndDate=datetime'2019-08-31T00%3A00%3A00')",
          "type" : "API_SLSPRICINGCONDITIONRECORD_SRV.A_SlsPrcgCndnRecdValidityType",
          "etag" : "W/\"'906E1481A5032A825AF1B960F8B3F308572B5E1D'\""
        },
         "ConditionRecord" : "0000032531",
        "ConditionApplication" : "V",
        "ConditionType" : "PPR0",
        "Customer" : "10100001",
        "Material" : "TG13",
        "SalesOrganization" : "1010"
      },
      {
        "__metadata" : {
          "id" : "<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity(ConditionRecord='0000014742',ConditionValidityEndDate=datetime'9999-12-31T00%3A00%3A00')",
          "uri" : "<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity(ConditionRecord='0000014742',ConditionValidityEndDate=datetime'9999-12-31T00%3A00%3A00')",
          "type" : "API_SLSPRICINGCONDITIONRECORD_SRV.A_SlsPrcgCndnRecdValidityType",
          "etag" : "W/\"'DB3099A5523928BEA2F3737F89AA52FDECC234B2'\""
        },
        "ConditionRecord" : "0000010476",
        "ConditionApplication" : "V",
        "ConditionType" : "PPR0",
        "Customer" : "",
        "Material" : "TG20",
        "SalesOrganization" : "1110"
      },
      {
        "__metadata" : {
          "id" : "<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity(ConditionRecord='0000014740',ConditionValidityEndDate=datetime'9999-12-31T00%3A00%3A00')",
          "uri" : "<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity(ConditionRecord='0000014740',ConditionValidityEndDate=datetime'9999-12-31T00%3A00%3A00')",
          "type" : "API_SLSPRICINGCONDITIONRECORD_SRV.A_SlsPrcgCndnRecdValidityType",
          "etag" : "W/\"'0225B5BA3E19B9D7010A8C7B0F30EF97340FFF32'\""
        },
        "ConditionRecord" : "0000017271",
        "ConditionApplication" : "V",
        "ConditionType" : "PPR0",
        "Customer" : "",
        "Material" : "TG20",
        "SalesOrganization" : "1310"
      },
      ......
    ]
  }
}
Read condition record and expand to validity:
GET <host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgConditionRecord('0000032848')?$expand=to_SlsPrcgCndnRecdValidity&$select=ConditionType,ConditionRecord,ConditionRateValue,ConditionRateValueUnit,to_SlsPrcgCndnRecdValidity/Customer,to_SlsPrcgCndnRecdValidity/Material,to_SlsPrcgCndnRecdValidity/ConditionValidityEndDate
X-CSRF-Token: abc
Accept: application/json
Status: 200 OK
content-Type: application/json; charset=utf-8
dataserviceversion: 2.0
{
  "d" : {
    "__metadata" : {
      "id" : "<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgConditionRecord('0000032848')",
      "uri" : "<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgConditionRecord('0000032848')",
      "type" : "API_SLSPRICINGCONDITIONRECORD_SRV.A_SlsPrcgConditionRecordType",
      "etag" : "W/\"'918FD4907CB16FAF18A51B57213939113E14A205'\""
    },
    "ConditionRecord" : "0000032848",
    "ConditionType" : "PPR0",
    "ConditionRateValue" : "150.00",
    "ConditionRateValueUnit" : "EUR",
    "to_SlsPrcgCndnRecdValidity" : {
      "results" : [
        {
          "__metadata" : {
            "id" : "<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity(ConditionRecord='0000032848',ConditionValidityEndDate=datetime'9999-12-31T00%3A00%3A00')",
            "uri" : "<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity(ConditionRecord='0000032848',ConditionValidityEndDate=datetime'9999-12-31T00%3A00%3A00')",
            "type" : "API_SLSPRICINGCONDITIONRECORD_SRV.A_SlsPrcgCndnRecdValidityType",
            "etag" : "W/\"'E24DA9AB38A9D16C66D99457E7EF7CB9E92A4AF2'\""
          },
          "ConditionValidityEndDate" : "\/Date(253402214400000)\/",
          "Customer" : "1001487",
          "Material" : "TG13"
        }
      ]
    }
  }
}

Delete

You can delete condition records, pricing scales, and condition supplements. When condition records are deleted, their validity, pricing scales, and condition supplements are no longer valid in pricing.

The delete action is decided by configuration for condition type, if set Delete from DB as ‘Do not delete (set the deletion flag only)’, see below delete action for detail:

Entity Delete Action
A_SlsPrcgConditionRecord Do not support and need use Update action to update deletion flag
A_SlsPrcgCndnRecdValidity Do not support on validity entity
A_SlsPrcgCndnRecordScale Delete from DB
A_SlsPrcgCndnRecdSuplmnt Update the deletion flag to ‘True’

If set Delete from DB as ‘with popup’ or ‘without popup’, see below delete action for detail:

Entity Delete Action
A_SlsPrcgConditionRecord

Delete condition validity from DB

Update deletion flag to ‘True’ for condition record

A_SlsPrcgCndnRecdValidity Do not support on validity entity
A_SlsPrcgCndnRecordScale Delete from DB
A_SlsPrcgCndnRecdSuplmnt Update the deletion flag to ‘True’

Delete Example

Delete Condition Record:
DELETE <host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgConditionRecord('0000068029')
X-CSRF-Token: abc
If-Match: W/"'1A0124695BDBD276B9CDAA653AB3A826A8F7CEBF'"

Status: 204 No Content 
dataserviceversion: 2.0

Delete Scale for Condition Record:
DELETE <host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecordScale(ConditionRecord='0000068029',ConditionSequentialNumber='1',ConditionScaleLine='1')
X-CSRF-Token: abc
If-Match: W/"'30E33BFCAE6AA0B84F31FE3C612D26A0FC1BCF6D'"

Status: 204 No Content 
dataserviceversion: 2.0

Batch

You can combine the create, read, update, and delete operations in a single batch request. The use of change sets is required for batching the create, update, and delete operations.

Batch requests are submitted as a single HTTP POST request to the $batch endpoint of the service.

Batch Example

Update condition validity and condition record together:
POST <host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/$batch
X-CSRF-Token: abc
Content-Type: multipart/mixed; boundary=batch


--batch
Content-Type: multipart/mixed; boundary=changeset

--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary

PATCH A_SlsPrcgCndnRecdValidity(ConditionRecord='0000068013',ConditionValidityEndDate=datetime'9999-12-31T00%3A00%3A00') HTTP/1.1
Content-Type: application/json
If-Match: W/"'3C7B20BD3183665B200940017C1E948205F04A09'"

{
  "ConditionValidityStartDate" : "2055-10-01T00:00:00",
  "ConditionValidityEndDate" : "2055-10-30T00:00:00"
}

--changeset--

--batch
Content-Type: multipart/mixed; boundary=changeset

--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary

PATCH A_SlsPrcgConditionRecord('0000068013') HTTP/1.1
Content-Type: application/json
If-Match: W/"'EFA2CB70489203861C00B818765BF8AD0FDD8F63'"

{
  "ConditionRateValue" : "99.99",
  "ConditionRateValueUnit" : "EUR",
  "AdditionalValueDays" : "15",
  "PaymentTerms" : "0001"
}

--changeset--


--batch--
Status: 202 Accepted 
dataserviceversion: 2.0 

--B9C9C566C935A32C487032E2B2DAECD50 
Content-Type: multipart/mixed; 
boundary=B9C9C566C935A32C487032E2B2DAECD51 
Content-Length: 238 

--B9C9C566C935A32C487032E2B2DAECD51 
Content-Type: application/http 
Content-Length: 71 
content-transfer-encoding: binary
 
HTTP/1.1 204 No Content 
Content-Length: 0 
dataserviceversion: 2.0 

--B9C9C566C935A32C487032E2B2DAECD51-- 

--B9C9C566C935A32C487032E2B2DAECD50 
Content-Type: multipart/mixed; 
boundary=B9C9C566C935A32C487032E2B2DAECD51 
Content-Length: 238 

--B9C9C566C935A32C487032E2B2DAECD51 
Content-Type: application/http 
Content-Length: 71 
content-transfer-encoding: binary 

HTTP/1.1 204 No Content 
Content-Length: 0 
dataserviceversion: 2.0 

--B9C9C566C935A32C487032E2B2DAECD51-- 

--B9C9C566C935A32C487032E2B2DAECD50--

Create condition record with Content ID:
POST <host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/$batch
X-CSRF-Token: abc
Content-Type: multipart/mixed; boundary=batch

--batch
Content-Type: multipart/mixed; boundary=changeset

--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary

POST A_SlsPrcgConditionRecord HTTP/1.1
Content-Type: application/json
Content-ID: 100

{
"ConditionTable" : "305",
"ConditionType" : "PPR0",
"ConditionRateValue" : "123.00",
"ConditionRateValueUnit" : "EUR"
}

--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary

POST $100/to_SlsPrcgCndnRecdValidity HTTP/1.1
Content-Type: application/json

{
"ConditionValidityStartDate" : "2020-12-13T00:00:00",
"ConditionValidityEndDate" : "2020-12-13T00:00:00",
"Customer" : "10100001",
"Material" : "TG11",
"SalesOrganization" : "1010",
"DistributionChannel" : "10"
}

--changeset--


--batch--
Status: 202 Accepted 
dataserviceversion: 2.0

--5F08CA948AF84FDE0846B858DA97A3C90
Content-Type: multipart/mixed; boundary=5F08CA948AF84FDE0846B858DA97A3C91
Content-Length:     10355

--5F08CA948AF84FDE0846B858DA97A3C91
Content-Type: application/http
Content-Length: 4671
content-transfer-encoding: binary

HTTP/1.1 201 Created
Content-Type: application/atom+xml;type=entry
Content-Length: 3391
location: <host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgConditionRecord('0000030257')
dataserviceversion: 2.0

content-id: 100

<?xml version="1.0" encoding="utf-8"?>
<entry m:etag="W/&quot;''&quot;" xml:base="<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<id><host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgConditionRecord('0000030257')</id>
<title type="text">A_SlsPrcgConditionRecord('0000030257')</title>
<updated>2020-01-17T09:16:53Z</updated>
<category term="API_SLSPRICINGCONDITIONRECORD_SRV.A_SlsPrcgConditionRecordType" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="A_SlsPrcgConditionRecord('0000030257')" rel="edit" title="A_SlsPrcgConditionRecordType"/>
<link href="A_SlsPrcgConditionRecord('0000030257')/to_SlsPrcgCndnRecdSuplmnt" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/to_SlsPrcgCndnRecdSuplmnt" type="application/atom+xml;type=feed" title="to_SlsPrcgCndnRecdSuplmnt"/>
<link href="A_SlsPrcgConditionRecord('0000030257')/to_SlsPrcgCndnRecdValidity" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/to_SlsPrcgCndnRecdValidity" type="application/atom+xml;type=feed" title="to_SlsPrcgCndnRecdValidity"/>
<link href="A_SlsPrcgConditionRecord('0000030257')/to_SlsPrcgCndnRecordScale" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/to_SlsPrcgCndnRecordScale" type="application/atom+xml;type=feed" title="to_SlsPrcgCndnRecordScale"/>
<content type="application/xml">
<m:properties>
<d:ConditionRecord>0000030257</d:ConditionRecord>
<d:ConditionSequentialNumber>1</d:ConditionSequentialNumber>
<d:ConditionTable>305</d:ConditionTable>
<d:ConditionApplication>V</d:ConditionApplication>
<d:ConditionType>PPR0</d:ConditionType>
<d:ConditionValidityEndDate>2020-12-13T00:00:00</d:ConditionValidityEndDate>
<d:ConditionValidityStartDate>2020-12-13T00:00:00</d:ConditionValidityStartDate>
<d:ConditionCalculationType>C</d:ConditionCalculationType>
<d:ConditionRateValue>123.00</d:ConditionRateValue>
<d:ConditionRateValueUnit>EUR</d:ConditionRateValueUnit>
......
<d:ETag/>
</m:properties>
</content>
</entry>
--5F08CA948AF84FDE0846B858DA97A3C91
Content-Type: application/http
Content-Length: 5385
content-transfer-encoding: binary

HTTP/1.1 201 Created
Content-Type: application/atom+xml;type=entry
Content-Length: 5039
location: <host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity(ConditionRecord='0000030257',ConditionValidityEndDate=datetime'2020-12-13T00%3A00%3A00')
dataserviceversion: 2.0
etag: W/"''"

<?xml version="1.0" encoding="utf-8"?>
<entry m:etag="W/&quot;''&quot;" xml:base="<host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<id><host>/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity(ConditionRecord='0000030257',ConditionValidityEndDate=datetime'2020-12-13T00%3A00%3A00')</id>
<title type="text">A_SlsPrcgCndnRecdValidity(ConditionRecord='0000030257',ConditionValidityEndDate=datetime'2020-12-13T00%3A00%3A00')</title>
<updated>2020-01-17T09:16:53Z</updated>
<category term="API_SLSPRICINGCONDITIONRECORD_SRV.A_SlsPrcgCndnRecdValidityType" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="A_SlsPrcgCndnRecdValidity(ConditionRecord='0000030257',ConditionValidityEndDate=datetime'2020-12-13T00%3A00%3A00')" rel="edit" title="A_SlsPrcgCndnRecdValidityType"/>
<link href="A_SlsPrcgCndnRecdValidity(ConditionRecord='0000030257',ConditionValidityEndDate=datetime'2020-12-13T00%3A00%3A00')/to_SlsPrcgCndnRecdSuplmnt" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/to_SlsPrcgCndnRecdSuplmnt" type="application/atom+xml;type=feed" title="to_SlsPrcgCndnRecdSuplmnt"/>
<link href="A_SlsPrcgCndnRecdValidity(ConditionRecord='0000030257',ConditionValidityEndDate=datetime'2020-12-13T00%3A00%3A00')/to_SlsPrcgConditionRecord" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/to_SlsPrcgConditionRecord" type="application/atom+xml;type=entry" title="to_SlsPrcgConditionRecord"/>
<content type="application/xml">
<m:properties>
<d:ConditionRecord>0000030257</d:ConditionRecord>
<d:ConditionValidityEndDate>2020-12-13T00:00:00</d:ConditionValidityEndDate>
<d:ConditionValidityStartDate>2020-12-13T00:00:00</d:ConditionValidityStartDate>
<d:ConditionApplication>V</d:ConditionApplication>
<d:ConditionType>PPR0</d:ConditionType>
<d:Customer>10100001</d:Customer>
<d:Material>TG11</d:Material>
<d:SalesOrganization>1010</d:SalesOrganization>
<d:DistributionChannel>10</d:DistributionChannel>
......
<d:ETag/>
</m:properties>
</content>
</entry>
--5F08CA948AF84FDE0846B858DA97A3C91--

--5F08CA948AF84FDE0846B858DA97A3C90--

Conclusion

In this blog, we introduced how to use condition record OData Service for sales part. User can direct copy the example in own system for create, read, update and delete action.

Source: https://help.sap.com/viewer/03c04db2a7434731b7fe21dca77440da/latest/en-US/7916962329ee49b293156fffddfb7dd8.html

Be the first to leave a comment
You must be Logged on to comment or reply to a post.