Skip to Content
1
Nov 08, 2019 at 02:25 PM

Determine price of one Product from Base Price List C4C over BO SalesPriceList

437 Views Last edit Nov 12, 2019 at 01:08 PM 2 rev

Hello together,

my requirement is to get base prices of a product in C4C over ABSL coding. The prices are maintained in the base price list. I found this thread here

How to query DiscountList on overall customer discounts in SAP C4C?

that gives me a good entry. With the coding listed there I get all prices of the base price list. But then I need to loop over the whole price collection which is time and memory consuming. Is there a way to restrict the resultset so that only the price for one product is given back over the API:

My code:

import ABSL;
import AP.FO.PriceAndTax.Global;


// Init Query
var priceList : BusinessObject::SalesPriceList;
var price : BusinessObject::SalesPriceList.PriceSpecification;
var propertyValuation : BusinessObject::SalesPriceList.PriceSpecification.PropertyValuation;


var initQuery = SalesPriceList.QueryByGroupCode;
var initSelParams = initQuery.CreateSelectionParams();
initSelParams.Add(initQuery.GroupCode.content, "I", "EQ", "PLALL1");
var initQueryResult = initQuery.Execute(initSelParams);

var query  = SalesPriceList.QueryByTypeCodeAndPropertyIDAndPropertyValue;
var parms = query.CreateSelectionParams();

parms.Add(query.TypeCode.content, "I", "EQ", "7PL0");
parms.Add(query.ReleaseStatusCode, "I", "EQ", "3");
parms.Add(query.ValidityPeriod.EndTimePoint.Date, "I", "GE", Date.ParseFromString("20191108"));
parms.Add(query.ValidityPeriod.StartTimePoint.Date, "I", "LE", Date.ParseFromString("20191108"));


/*
//FURTHER RESTRICTIONS
parms.Add(query.PropertyValuationPriceSpecificationElementPropertyValuation1.PriceSpecificationElementPropertyReference.PriceSpecificationElementPropertyID.content, "I", "EQ", "CND_PRODUCT_ID");
parms.Add(query.PropertyValuationPriceSpecificationElementPropertyValuation1.PriceSpecificationElementPropertyValue.ID.content, "I", "EQ", "10000141");
parms.Add(query.PropertyValuationPriceSpecificationElementPropertyValuation2.PriceSpecificationElementPropertyReference.PriceSpecificationElementPropertyID.content, "I", "EQ", "CND_PRODUCT_ID_TYPE_CODE");
parms.Add(query.PropertyValuationPriceSpecificationElementPropertyValuation2.PriceSpecificationElementPropertyValue.Code.content, "I", "EQ", "1");
parms.Add(query.PropertyValuationPriceSpecificationElementPropertyValuation3.PriceSpecificationElementPropertyReference.PriceSpecificationElementPropertyID.content, "I", "EQ", "CND_PRODUCT_TYPE_CODE");
parms.Add(query.PropertyValuationPriceSpecificationElementPropertyValuation3.PriceSpecificationElementPropertyValue.Code.content, "I", "EQ", "1");
parms.Add(query.PropertyValuationPriceSpecificationElementPropertyValuation4.PriceSpecificationElementPropertyReference.PriceSpecificationElementPropertyID.content, "I", "EQ", "PRC_PRICE_LIST");
parms.Add(query.PropertyValuationPriceSpecificationElementPropertyValuation4.PriceSpecificationElementPropertyValue.ID.content, "I", "EQ", "00163E7663E81ED9BEFCA847B4043938");
*/


var queryResult = query.Execute(parms);

foreach (priceList in queryResult) {
foreach (price in priceList.PriceSpecification) {
foreach (propertyValuation in price.PropertyValuation) {

Trace.Info( propertyValuation.PriceSpecificationElementPropertyValuation.PriceSpecificationElementPropertyReference.PriceSpecificationElementPropertyID.content );
Trace.Info( propertyValuation.PriceSpecificationElementPropertyValuation.PriceSpecificationElementPropertyValue.Code.content );
Trace.Info( propertyValuation.PriceSpecificationElementPropertyValuation.PriceSpecificationElementPropertyValue.ID.content );
}
}
}

With this I get all my prices from the base price list. If I uncomment the block //FURTHER RESTRICTIONS I would expect that only the price of a single product is given back, but instead the resultset is empty.

Does anybody know how to fill the API for my requirement?

Best regards ,
Georg