cancel
Showing results for 
Search instead for 
Did you mean: 

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

geltinger
Explorer

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

Accepted Solutions (0)

Answers (2)

Answers (2)

emre_bal
Participant
0 Kudos

Hello Georg,

I am stucked at the same point, when i add product id as query parameter, i found the price list that i want to get. But, could not get the price because of the association PriceSpecification is empty(returns 0 records in the collection).

If you achieved to overcome of this issue, can you please share some advice for me?

horst.schaude I've checked similar topics on community and could not figure out how to overcome this issue. Any ideas will be helpful for me. Thanks in advance.

Regards,

Emre

geltinger
Explorer
0 Kudos

Nobody an answer on that question?