S/4HANA系统中的价格管理模块,包括价格主数据管理和定价信息管理。S/4HANA系统作为定价管理系统,外围的采购系统可以从S/4HANA系统中读取定价信息,并且可以创建,修改和删除价格主数据。

S/4HANA系统提供价格主数据OData服务API_PURGPRICINGCONDITIONRECORD_SRV这个同步的主数据入站服务可以让用户获取,创建,更新和删除采购价格主数据。该OData服务包括采购中的定价记录,定价条件有效期,定价等级和定价补充。

定价数据集成场景配置

为了激活上述的OData服务,用户必须创建并激活通信场景SAP_COM_0294。

OData服务列表

1.png

OData服务操作

创建定价记录:创建定价记录针对非扁平数据结构,即纵深数据结构进行数据的创建。单独创建定价记录对扁平数据结构是不支持的,单独创建定价条件有效期也是不支持的,二者必须同时创建。但是针对已存在的定价记录,单独创建定价等级和定价补充支持扁平数据结构。

下面会针对不同的创建情况提供相对应的例子。

创建定价记录和定价条件有效期
请求正文 - 必须同时创建定价记录和定价条件有效期,无法单独创建定价记录或者定价条件有效期:
POST <host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord X-CSRF-Token: abc Content-Type: application/json Accept: application/json { "ConditionTable" : "017", "ConditionType" : "PPR0", "ConditionRateValue" : "200.00", "ConditionRateValueUnit" : "EUR", "to_PurgPrcgCndnRecdValidity" : [ { "ConditionValidityEndDate" : "2020-11-30T00:00:00", "ConditionValidityStartDate" : "2020-11-02T00:00:00", "ConditionType" : "PPR0", "Supplier" : "FIO-VEND01", "Material" : "TG11", "PurchasingOrganization" : "1010", "Plant" : "1010", "PurchasingInfoRecordCategory" : "3" } ]


返回结果:
Status: 201 Created
content-Type: application/json; charset=utf-8
location: <host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord('0000028014')
etag: W/"''"
dataserviceversion: 2.0

{
 "d" : {
    "__metadata" : {
      "id" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord('0000028014')",
      "uri" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord('0000028014')",
      "type" : "API_PURGPRCGCONDITIONRECORD_SRV.A_PurgPrcgConditionRecordType",
      "etag" : "W/\"''\""
    },
    "ConditionRecord" : "0000028015",
    "ConditionSequentialNumber" : "1",
    "ConditionTable" : "017",
    "ConditionApplication" : "M",
    "ConditionType" : "PPR0",
    "ConditionValidityEndDate" : "\/Date(1606694400000)\/",
    "ConditionValidityStartDate" : "\/Date(1604275200000)\/",
......
}


创建定价记录,定价条件有限期和定价等级
请求正文:
POST <host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord X-CSRF-Token: abc Content-Type: application/json Accept: application/json { "ConditionTable" : "017", "ConditionType" : "PPR0", "ConditionRateValue" : "200.00", "ConditionRateValueUnit" : "EUR", "to_PurgPrcgCndnRecdValidity" : [ { "ConditionValidityEndDate" : "2020-11-30T00:00:00", "ConditionValidityStartDate" : "2020-11-02T00:00:00", "ConditionType" : "PPR0", "Supplier" : "FIO-VEND01", "Material" : "TG11", "PurchasingOrganization" : "1010", "Plant" : "1010", "PurchasingInfoRecordCategory" : "3" } ], "to_PurgPricingCndnRecdScale" : [ { "ConditionSequentialNumber" : "1", "ConditionScaleLine" : "1", "ConditionScaleQuantity" : "10.000", "ConditionScaleQuantityUnit" : "PC", "ConditionRateValue" : "400.000", "ConditionRateValueUnit" : "EUR" }, { "ConditionSequentialNumber" : "1", "ConditionScaleLine" : "2", "ConditionScaleQuantity" : "20.000", "ConditionScaleQuantityUnit" : "PC", "ConditionRateValue" : "500.000", "ConditionRateValueUnit" : "EUR" }, { "ConditionSequentialNumber" : "1", "ConditionScaleLine" : "3", "ConditionScaleQuantity" : "30.000", "ConditionScaleQuantityUnit" : "PC", "ConditionRateValue" : "300.000", "ConditionRateValueUnit" : "EUR" } ] }

返回结果:
Status: 201 Created
content-Type: application/json; charset=utf-8
location: <host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord('0000028015')
etag: W/"''"
dataserviceversion: 2.0

{
  "d" : {
    "__metadata" : {
      "id" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord('0000028015')",
      "uri" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord('0000028015')",
      "type" : "API_PURGPRCGCONDITIONRECORD_SRV.A_PurgPrcgConditionRecordType",
      "etag" : "W/\"''\""
    },
    "ConditionRecord" : "0000028015",
    "ConditionSequentialNumber" : "1",
    "ConditionTable" : "017",
    "ConditionApplication" : "M",
    "ConditionType" : "PPR0",
......
}

创建定价记录,定价条件有效期和定价补充
请求正文:
POST <host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord X-CSRF-Token: abc Content-Type: application/json Accept: application/json { "ConditionTable" : "018", "ConditionType" : "PPR0", "ConditionRateValue" : "999.99", "ConditionRateValueUnit" : "EUR", "to_PurgPrcgCndnRecdValidity" : [ { "ConditionValidityEndDate" : "2021-11-30T00:00:00", "ConditionValidityStartDate" : "2021-11-05T00:00:00", "ConditionType" : "PPR0", "Supplier" : "FIO-VEND01", "Material" : "TG11", "PurchasingOrganization" : "1010", "PurchasingInfoRecordCategory" : "3" } ], "to_PurgPrcgCndnRecdSuplmnt" : [ { "ConditionSequentialNumber" : "2", "ConditionType" : "DRG1", "ConditionRateValue" : "10.0", "ConditionRateValueUnit" : "%" }, { "ConditionSequentialNumber" : "3", "ConditionType" : "PPR0", "ConditionRateValue" : "123.11", "ConditionRateValueUnit" : "EUR" } ] }

返回结果:
Status: 201 Created content-Type: application/json; charset=utf-8 location: <host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord('0000028020') etag: W/"''" dataserviceversion: 2.0 { "d" : { "__metadata" : { "id" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord('0000028020')", "uri" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgConditionRecord('0000028020')", "type" : "API_PURGPRCGCONDITIONRECORD_SRV.A_PurgPrcgConditionRecordType", "etag" : "W/\"''\"" }, "ConditionRecord" : "0000028020", "ConditionSequentialNumber" : "1", "ConditionTable" : "018", "ConditionApplication" : "M",
......
}

基于已存在的定价记录创建定价等级
请求正文 - 基于已存在的定价记录0000028022,创建定价等级:
POST <host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecordScale X-CSRF-Token: abc Content-Type: application/json Accept: application/json { "ConditionRecord" : "0000028022", "ConditionSequentialNumber" : "1", "ConditionScaleLine" : "1", "ConditionScaleAmount" : "1000", "ConditionScaleAmountCurrency" : "EUR", "ConditionRateValue" : "222.000", "ConditionRateValueUnit" : "EUR" }

返回结果:
Status: 201 Created
content-Type: application/json; charset=utf-8
location: <host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecordScale(ConditionRecord='0000028022',ConditionSequentialNumber='1',ConditionScaleLine='1')"
etag: W/"''"
dataserviceversion: 2.0

{
  "d" : {
    "__metadata" : {
      "id" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecordScale(ConditionRecord='0000028022',ConditionSequentialNumber='1',ConditionScaleLine='1')",
      "uri" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecordScale(ConditionRecord='0000028022',ConditionSequentialNumber='1',ConditionScaleLine='1')",
      "type" : "API_PURGPRCGCONDITIONRECORD_SRV.A_PurgPrcgCndnRecordScaleType",
      "etag" : "W/\"''\""
    },
    "ConditionRecord" : "0000028022",
    "ConditionSequentialNumber" : "1",
    "ConditionScaleLine" : "1",
    "ConditionScaleQuantity" : "0.000",
    "ConditionScaleQuantityUnit" : "",
    "ConditionScaleAmount" : "1000.00",
    "ConditionScaleAmountCurrency" : "EUR",
    "ConditionRateValue" : "222.00",
    "ConditionRateValueUnit" : "EUR",
    "ETag" : "",
    "to_PurgPrcgCndnRecdSuplmnt" : {
      "__deferred" : {
        "uri" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecordScale(ConditionRecord='0000028022',ConditionSequentialNumber='1',ConditionScaleLine='1')/to_PurgPrcgCndnRecdSuplmnt"
      }
    },
    "to_PurgPrcgConditionRecord" : {
      "__deferred" : {
        "uri" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecordScale(ConditionRecord='0000028022',ConditionSequentialNumber='1',ConditionScaleLine='1')/to_PurgPrcgConditionRecord"
      }
    }
  }
}

基于已存在的定价记录创建定价补充
请求正文 - 基于已存在的定价记录0000028020,创建定价补充:
POST <host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecdSuplmnt X-CSRF-Token: abc Content-Type: application/json Accept: application/json { "ConditionRecord" : "0000028020", "ConditionSequentialNumber" : "4", "ConditionType" : "PPR0", "ConditionRateValue" : "3000", "ConditionRateValueUnit" : "JPY" }

返回结果:
Status: 201 Created content-Type: application/json; charset=utf-8 location: <host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecdSuplmnt(ConditionRecord='0000028020',ConditionSequentialNumber='4')", etag: W/"''" dataserviceversion: 2.0 { "d" : { "__metadata" : { "id" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecdSuplmnt(ConditionRecord='0000028020',ConditionSequentialNumber='4')", "uri" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecdSuplmnt(ConditionRecord='0000028020',ConditionSequentialNumber='4')", "type" : "API_PURGPRCGCONDITIONRECORD_SRV.A_PurgPrcgCndnRecdSuplmntType", "etag" : "W/\"''\"" }, "ConditionRecord" : "0000028020", "ConditionSequentialNumber" : "4", "ConditionTable" : "018", "ConditionApplication" : "M", "ConditionType" : "PPR0", "ConditionValidityEndDate" : "\/Date(1638230400000)\/", "ConditionValidityStartDate" : "\/Date(1636070400000)\/", "CreatedByUser" : "", "CreationDate" : null, "ConditionTextID" : "", "PricingScaleType" : "", "PricingScaleBasis" : "C", "ConditionScaleQuantity" : "0.000", "ConditionScaleQuantityUnit" : "", "ConditionScaleAmount" : "0", "ConditionScaleAmountCurrency" : "", "ConditionCalculationType" : "C", "ConditionRateValue" : "3000", "ConditionRateValueUnit" : "JPY", "ConditionQuantity" : "1", "ConditionQuantityUnit" : "PC", "ConditionToBaseQtyNmrtr" : "0", "ConditionToBaseQtyDnmntr" : "0", "BaseUnit" : "", "ConditionLowerLimit" : "0", "ConditionUpperLimit" : "0", "ConditionAlternativeCurrency" : "", "ConditionExclusion" : "", "ConditionIsDeleted" : false, "AdditionalValueDays" : "0", "FixedValueDate" : null, "PaymentTerms" : "", "CndnMaxNumberOfSalesOrders" : "0", "MinimumConditionBasisValue" : "0.000", "MaximumConditionBasisValue" : "0.000", "MaximumConditionAmount" : "0.00", "IncrementalScale" : "0", "PricingScaleLine" : "0", "ConditionReleaseStatus" : "", "ETag" : "", "to_PurgPrcgCndnRecdValidity" : { "__deferred" : { "uri" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecdSuplmnt(ConditionRecord='0000028020',ConditionSequentialNumber='4')/to_PurgPrcgCndnRecdValidity" } }, "to_PurgPrcgConditionRecord" : { "__deferred" : { "uri" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecdSuplmnt(ConditionRecord='0000028020',ConditionSequentialNumber='4')/to_PurgPrcgConditionRecord" } }, "to_PurgPricingCndnRecdScale" : { "__deferred" : { "uri" : "<host>/sap/opu/odata/SAP/API_PURGPRCGCONDITIONRECORD_SRV/A_PurgPrcgCndnRecdSuplmnt(ConditionRecord='0000028020',ConditionSequentialNumber='4')/to_PurgPricingCndnRecdScale" } } } }


结语

上述文章中描述了定价记录,定价条件有限期,定价等级和定价补充的创建,用户可以直接拷贝上述提供的JSON请求正文来使用,同时用户也可以添加其他需要赋值的字段。由于篇幅有限,部分的返回结果无法完全提供,用户在使用时可以看到完整的返回结果。