//Method
public void filterQueryByDimension(Query _query,DataSourceName _dataSourceName,FieldName _fieldName)
{
DimensionProvider dimensionProvider = new DimensionProvider();
void addDimFilter(Notes _rangeValue,Name _dimensionName)
{
if (_rangeValue)
{
dimensionProvider.addAttributeRangeToQuery( _query,
_dataSourceName,
_fieldName,
DimensionComponent::DimensionAttribute,
_rangeValue,
_dimensionName);
}
}
dimensionProvider.clearDimensionRangesFromQuery(_query);
addDimFilter("<Dimension values from Contract Paramter>", "BusinessUnit");
addDimFilter("<Dimension values from Contract Paramter>", "CostCenter");
addDimFilter("<Dimension values from Contract Paramter>", "Department");
}
//Job (tested)
static void SAN_FilterDimensionTestJob(Args _args)
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryRun qr;
SalesTable salesTable;
//Functions
void addDimFilter(
DimensionProvider _dimensionProvider,
Notes _rangeValue,
Name _dimensionName,
Query _query,
DataSourceName _dataSourceName,
FieldName _fieldName)
{
if (_rangeValue)
{
_dimensionProvider.addAttributeRangeToQuery( _query,
_dataSourceName,
_fieldName,
DimensionComponent::DimensionAttribute,
_rangeValue,
_dimensionName);
}
}
void filterQueryByDimension(
Query _query,
DataSourceName _dataSourceName,
FieldName _fieldName)
{
DimensionProvider dimensionProvider = new DimensionProvider();
;
dimensionProvider.clearDimensionRangesFromQuery(_query);
//addDimFilter(dimensionProvider,"<Dimension values from Contract Paramter>", "BusinessUnit",_query,_dataSourceName,_fieldName);
//addDimFilter(dimensionProvider,"<Dimension values from Contract Paramter>", "CostCenter",_query,_dataSourceName,_fieldName);
//addDimFilter(dimensionProvider,"<Dimension values from Contract Paramter>", "Department",_query,_dataSourceName,_fieldName);
}
;
qbds = query.addDataSource(tableNum(SalesTable));
filterQueryByDimension(query,qbds.name(),fieldStr(SalesTable, DefaultDimension));
qr = new QueryRun(query);
while (qr.next())
{
salesTable = qr.get(tableNum(SalesTable));
info(salesTable.SalesId);
}
}
public void filterQueryByDimension(Query _query,DataSourceName _dataSourceName,FieldName _fieldName)
{
DimensionProvider dimensionProvider = new DimensionProvider();
void addDimFilter(Notes _rangeValue,Name _dimensionName)
{
if (_rangeValue)
{
dimensionProvider.addAttributeRangeToQuery( _query,
_dataSourceName,
_fieldName,
DimensionComponent::DimensionAttribute,
_rangeValue,
_dimensionName);
}
}
dimensionProvider.clearDimensionRangesFromQuery(_query);
addDimFilter("<Dimension values from Contract Paramter>", "BusinessUnit");
addDimFilter("<Dimension values from Contract Paramter>", "CostCenter");
addDimFilter("<Dimension values from Contract Paramter>", "Department");
}
//Job (tested)
static void SAN_FilterDimensionTestJob(Args _args)
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryRun qr;
SalesTable salesTable;
//Functions
void addDimFilter(
DimensionProvider _dimensionProvider,
Notes _rangeValue,
Name _dimensionName,
Query _query,
DataSourceName _dataSourceName,
FieldName _fieldName)
{
if (_rangeValue)
{
_dimensionProvider.addAttributeRangeToQuery( _query,
_dataSourceName,
_fieldName,
DimensionComponent::DimensionAttribute,
_rangeValue,
_dimensionName);
}
}
void filterQueryByDimension(
Query _query,
DataSourceName _dataSourceName,
FieldName _fieldName)
{
DimensionProvider dimensionProvider = new DimensionProvider();
;
dimensionProvider.clearDimensionRangesFromQuery(_query);
//addDimFilter(dimensionProvider,"<Dimension values from Contract Paramter>", "BusinessUnit",_query,_dataSourceName,_fieldName);
//addDimFilter(dimensionProvider,"<Dimension values from Contract Paramter>", "CostCenter",_query,_dataSourceName,_fieldName);
//addDimFilter(dimensionProvider,"<Dimension values from Contract Paramter>", "Department",_query,_dataSourceName,_fieldName);
}
;
qbds = query.addDataSource(tableNum(SalesTable));
filterQueryByDimension(query,qbds.name(),fieldStr(SalesTable, DefaultDimension));
qr = new QueryRun(query);
while (qr.next())
{
salesTable = qr.get(tableNum(SalesTable));
info(salesTable.SalesId);
}
}
No comments:
Post a Comment