https://axforce.wordpress.com/2015/12/07/using-the-class-dimensionprovider-to-filter-a-query-with-multiple-financial-dimensions-criteria/
static void EDC_dimensionProvider(String10 _depvalue)
{
#define.dimAttr("Department")
#define.dimRangeValue("79")
Query query = new Query();
QueryRun queryRun;
QueryBuildDataSource queryCustTable;
QueryBuildRange queryDimRange;
string255 purchid;
PurchLine purchline;
DimensionProvider dimensionProvider;
DimensionAttributeValueSetStorage dimAttrValueSetStorage;
int countLine = 1;
int i;
container conpurchid;
queryCustTable = query.addDataSource(tableNum(PurchLine));
dimensionProvider = new DimensionProvider();
dimensionProvider.addAttributeRangeToQuery(
query,
queryCustTable.name(),
identifierStr(DefaultDimension),
DimensionComponent::DimensionAttribute,
#dimRangeValue,
#dimAttr,
true);
queryRun = new QueryRun(query);
while (queryRun.next()) {
purchline = queryRun.get(tableNum(PurchLine));
dimAttrValueSetStorage = DimensionAttributeValueSetStorage::find(purchline.DefaultDimension);
for (i = 1; i <= dimAttrValueSetStorage.elements(); i++) {
if(DimensionAttribute::find(dimAttrValueSetStorage.getAttributeByIndex(i)).Name == "Department")
{
if(confind(conpurchid, purchline.PurchId))
conpurchid = conIns(conpurchid,i,purchline.PurchId);
info(strFmt("PurchId %1:%2: %3",
purchline.PurchId,
DimensionAttribute::find(dimAttrValueSetStorage.getAttributeByIndex(i)).Name,
dimAttrValueSetStorage.getDisplayValueByIndex(i)));
}
}
}
}
No comments:
Post a Comment