SAP Knowledge Base Article - Public

3521811 - How to get the condition data from the OData API API_SLSPRICINGCONDITIONRECORD_SRV?

Symptom

This KBA describes how to get the condition data from the OData API API_SLSPRICINGCONDITIONRECORD_SRV from the following perspectives:

  1. General example, not specify the fields of the condition table.
  2. Get fields of condition table from CDS A_SlsPrcgConditionTableField or API API_SLSPRCGCONDITIONTABLE.
  3. Get the access sequence of the condition type from CDS A_SlsPricingConditionType or API API_SLSPRICINGCONDITIONTYPE_SRV.  
  4. Get the condition table, fields of the access sequence from CDS A_SalesPricingAccessField or API API_SLSPRCGACCESSSEQUENCE.   
  5. General way to get GFN of condition type.
  6. Example with exact GFNs.

"Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental."

Environment

SAP S/4HANA Cloud Public Edition

Resolution

  1. General example, not specify the fields of the condition table:
    /sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity?$filter=ConditionType eq 'ZTFC' and Material eq 'TG11' and to_SlsPrcgConditionRecord/ConditionTable eq '999'&$expand=to_SlsPrcgConditionRecord

    Example with exact GFNs:
    After getting the GFNs of the condition table, then change URI as below to get all fields of condition table and the record
    /sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity?$select=ConditionType,ConditionRecord,Material,YY1_TestFieldControl_PCI,ConditionValidityEndDate,ConditionValidityStartDate,to_SlsPrcgConditionRecord&$filter=ConditionType eq 'ZTFC' and Material eq 'TG11' and to_SlsPrcgConditionRecord/ConditionTable eq '999'&$expand=to_SlsPrcgConditionRecord&$format=json

    General example, not specify the fields of the condition table.
    UI app:
    "Manage Prices – Sales" app can operate on record, record text, validity, and record scale; cannot support supplement, supplement text, supplement scale.
    Supplement can be maintained by VK12, "Set Material Prices – Sales" app.

     
    OData API:
    /sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity?$filter=ConditionType eq 'ZTFC' and Material eq 'TG11' and to_SlsPrcgConditionRecord/ConditionTable eq '999'&$expand=to_SlsPrcgConditionRecord

    A_SlsPrcgConditionRecord
     
    A_SlsPrcgCndnRecdValidity
     

    Here the fields Material, YY1_TestFieldControl_PCI are for condition table number 999 (database table A999).
    The entity A_SlsPrcgConditionRecord stores the amount, currency. But do not use the start date (ConditionValidityStartDate and end date (ConditionValidityEndDate), use them in the entity A_SlsPrcgCndnRecdValidity. 
    A_SlsPrcgCndnRecdValidity is a fake CDS , contains no data in database, its data should be fetched from runtime, and it is a combination of all the condition tables, like A304, A305, A4AK, and custom condition tables. So need to run the OData API to get it. 
    From a real case, it should get the data from A_SlsPrcgCndnRecdValidity and A_SlsPrcgConditionRecord at the same time; in some special case, like a record in A_SlsPrcgConditionRecord with deletion flag as true, it may not exist in the condition table (physically deleted), then also not exist in the A_SlsPrcgCndnRecdValidity.

  2. Get fields of condition table from CDS A_SlsPrcgConditionTableField or API API_SLSPRCGCONDITIONTABLE:

    The field PricingConditionField is for the VK12, as internal filed, PrcgConditionGlobalFieldName is GFN for CDS and API used. The GFN of custom fields is the same as PricingConditionField by the system runtime.
     

    /sap/opu/odata4/sap/api_slsprcgconditiontable/srvd_a2x/sap/slsprcgconditiontable/0001/SlsPrcgConditionTableField?$filter=ConditionTable eq '999'
     

  3. Get the access sequence of the condition type from CDS A_SlsPricingConditionType or API API_SLSPRICINGCONDITIONTYPE_SRV:
     

    /sap/opu/odata/SAP/API_SLSPRICINGCONDITIONTYPE_SRV/A_SlsPricingConditionType?$filter=ConditionType eq 'ZTFC'

     

  4. Get the condition table, fields of the access sequence from CDS A_SalesPricingAccessField or API API_SLSPRCGACCESSSEQUENCE:
    Query all fields of the condition table of access sequence or all fields of the access sequence.
     
    /sap/opu/odata4/sap/api_slsprcgaccesssequence/srvd_a2x/sap/slsprcgaccesssequence/0001/SalesPricingAccess?$filter=AccessSequence eq 'ZTFC'

     

  5. General way to get GFN of condition type:
    Get access sequence of condition type, then get condition table of access sequence, then get GFN of condition table.

  6. Example with exact GFNs:
    After getting the GFNs of the condition table, then change URI as below to get all fields of condition table and the record.

    /sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity$select=ConditionType,ConditionRecord,Material,YY1_TestFieldControl_PCI,ConditionValidityEndDate,ConditionValidityStartDate,to_SlsPrcgConditionRecord&$filter=ConditionType eq 'ZTFC' and Material eq 'TG11' and to_SlsPrcgConditionRecord/ConditionTable eq '999'&$expand=to_SlsPrcgConditionRecord&$format=json
     
     

See Also

Keywords

condition data, OData API, API_SLSPRICINGCONDITIONRECORD_SRV, condition table, A_SlsPrcgConditionTableField, API_SLSPRCGCONDITIONTABLE, access sequence, condition type, A_SlsPricingConditionType, API_SLSPRICINGCONDITIONTYPE_SRV, A_SalesPricingAccessField, API_SLSPRCGACCESSSEQUENCE, GFN , KBA , SD-MD-CM-2CL , Conditions and Condition Maintainance (Public Cloud) , Problem

Product

SAP S/4HANA Cloud Public Edition all versions ; SAP S/4HANA Cloud all versions

Attachments

Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png
Pasted image.png