As this requirement has come up several times in the past, but to my knowledge has only been made possible recently after opening a request with SAP support, i feel it’s appropriate to share it with the development community (also because SAP provided most of the code).

The code below can be used to query all the Sales Price Specifications for a particular Product. It’s up to you to differentiate between the other parameters like customer group, sales organization, etc.

import AP.Common.GDT;
import AP.Common.Global;
import AP.FO.PriceAndTax.Global;

//-----Required - Initialization Query-----
var
QrySalesPriceListByGroupCode = BusinessObject::SalesPriceList.QueryByGroupCode;
var
QrySalesPriceListByGroupCodeParameters = QrySalesPriceListByGroupCode.CreateSelectionParams();
QrySalesPriceListByGroupCodeParameters.Add(QrySalesPriceListByGroupCode.GroupCode.content, "I", "EQ",PLPRICE1");
var QrySalesPriceListByGroupCodeResults = QrySalesPriceListByGroupCode.Execute(QrySalesPriceListByGroupCodeParameters);

//-----Query The Price Specification
var QryPriceSpecificationOverview =
BusinessObject::SalesPriceList.PriceSpecificationOverview.QueryByPrSpecTypeCodeAndPrSpecPropertyIDAndPrSpecPropertyValue;
var QryPriceSpecificationOverviewParameters = QryPriceSpecificationOverview.CreateSelectionParams();
//Consistent
QryPriceSpecificationOverviewParameters.Add(QryPriceSpecificationOverview.PriceSpecificationConsistencyStatusCode,"I","EQ","3");
//Released
QryPriceSpecificationOverviewParameters.Add(QryPriceSpecificationOverview.PriceSpecificationListReleaseStatusCode,"I","EQ","3");

var RelevantProductID : ProductInternalID;
//Determine RelevantProductID per customer-specific requirement

// 7PR1 means get price of value
QryPriceSpecificationOverviewParameters.Add(QryPriceSpecificationOverview.PriceSpecificationPriceSpecificationElementTypeCode.content,"I","EQ","7PR1");
// Product ID for which price has to be found
QryPriceSpecificationOverviewParameters.Add(QryPriceSpecificationOverview.PriceSpecificationPropertyValuationPriceSpecificationElementPropertyValuation1.PriceSpecificationElementPropertyReference.PriceSpecificationElementPropertyID.content,"I","EQ","CND_PRODUCT_ID");
QryPriceSpecificationOverviewParameters.Add(QryPriceSpecificationOvervie
w.PriceSpecificationPropertyValuationPriceSpecificationElementPropertyValuation1.PriceSpecificationElementPropertyValue.ID.content,"I","EQ",RelevantProductID);

// Product is a composite Key ( CND_PRODUCT_ID  + CND_PRODUCT_ID_TYPE_CODE + CND_PRODUCT_TYPE_CODE  )
QryPriceSpecificationOverviewParameters.Add(QryPriceSpecificationOverview.PriceSpecificationPropertyValuationPriceSpecificationElementPropertyValuation2.PriceSpecificationElementPropertyReference.PriceSpecificationElementPropertyID.content,"I","EQ","CND_PRODUCT_ID_TYPE_CODE");
// 1 Means ID ( technical purpose )
QryPriceSpecificationOverviewParameters.Add(QryPriceSpecificationOverview.PriceSpecificationPropertyValuationPriceSpecificationElementPropertyValuation2.PriceSpecificationElementPropertyValue.Code.content,"I","EQ","1");
QryPriceSpecificationOverviewParameters.Add(QryPriceSpecificationOverview.PriceSpecificationPropertyValuationPriceSpecificationElementPropertyValuation3.PriceSpecificationElementPropertyReference.PriceSpecificationElementPropertyID.content,"I","EQ","CND_PRODUCT_TYPE_CODE");
// 1 Means Material ( technical Purpose ) , 2 means service product
QryPriceSpecificationOverviewParameters.Add(QryPriceSpecificationOverview.PriceSpecificationPropertyValuationPriceSpecificationElementPropertyValuation3.PriceSpecificationElementPropertyValue.Code.content,"I","EQ","1");

var QryPriceSpecificationOverviewResults = QryPriceSpecificationOverview.Execute(QryPriceSpecificationOverviewParameters);

//Parse The Result Data
To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply