Hi All;
i have created this query with select statements before and now i want to use an AOT query and modify it in rdp class for an ssrs report
The Issue : in query rdp functions after i create a range for dates i want to select first only row for each "ADVCheckID" with the max "ADVCHKStepSequence"
---------------------------------------------------------------------------------------------------------
Business Logic :
while Select AdvChk
{
while select firstOnly AdvChekStpActul
order by AdvChekStpActul.ADVCHKStepSequence desc
where AdvChekStpActul.ADVCheckID == AdvChk.ADVCheckID
&& AdvChekStpActul.TransDate <= NotesDate
&& AdvChekStpActul.TransDate
&& AdvChekStpActul.Applied == 1
{
if ( (AdvChekStpActul.ADVCHKStepType == Steptype || !Steptype) && (AdvChekStpActul.ADVCHKStepGroupID == StepGroup) && (AdvChk.ADVCheckGroupID == CheckGroup || !CheckGroup) && (AdvChekStpActul.ADVCHKStepID == StepId || !StepId) )
{
TmpDB.CustAccount = AdvChk.CustAccount ;
TmpDB.CustName = AdvChk.CustName ;
TmpDB.AmountCur = AdvChk.AmountCur ;
TmpDB.ADVNetAmount = AdvChk.ADVNetAmount ;
TmpDB.ADVCheckSource = AdvChk.ADVCheckSource ;
TmpDB.ADVCheckGroupID = AdvChk.ADVCheckGroupID ;
TmpDB.ADVCHKStepType = AdvChekStpActul.ADVCHKStepType ;
TmpDB.ADVCheckID = AdvChekStpActul.ADVCheckID ;
TmpDB.Voucher = AdvChekStpActul.Voucher ;
TmpDB.ADVCHKStepID = AdvChekStpActul.ADVCHKStepID ;
TmpDB.TransDate = AdvChekStpActul.TransDate ;
TmpDB.ADVCHKStepGroupID = AdvChekStpActul.ADVCHKStepGroupID ;
TmpDB.ADVCHKStepSequence = AdvChekStpActul.ADVCHKStepSequence ;
TmpDB.LedgerName = DimensionAttributeValueCombination::getDisplayValue(AdvChekStpActul.LedgerDimension);
TmpDB.LedgerDimension = AdvChekStpActul.LedgerDimension ;
}
-----------------------------------------------------------------------------------------------------
QUERY RDP:
qbds = query.dataSourceTable(tablenum(ADVChecks));
queryBuildDataSource = query.dataSourceTable(tablenum(ADVCHKCheckStepsActual));
qbd = query.dataSourceTable(tablenum(ADVCHKCheckStepsActual));
qr = new QueryRun(query);
if(NotesDate)
{
queryBuildRange = queryBuildDataSource.findRange(fieldnum(ADVCHKCheckStepsActual, TransDate));
if (!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(ADVCHKCheckStepsActual, TransDate));
}
// If an Notes Date has not been set, then use the parameter value to set it.
if(!queryBuildRange.value())
{
queryBuildRange.value(queryRange(DateTimeUtil::minValue() , NotesDate ));
}
}
queryBuildDataSource.relations(true) ;
qbds.addOrderByField(fieldNum(ADVChecks,ADVCheckID), SortOrder::Descending) ;
queryBuildDataSource.addOrderByField(fieldNum(ADVCHKCheckStepsActual,ADVCHKStepSequence), SortOrder::Descending) ;
// qr = new QueryRun(query);
while (qr.next())
{
TmpDB.clear();
AdvChk = qr.get(tablenum(ADVChecks));
AdvChekStpActul = qr.get(tablenum(ADVCHKCheckStepsActual));
if ( (AdvChekStpActul.ADVCHKStepType == Steptype || !Steptype) && (AdvChekStpActul.ADVCHKStepGroupID == StepGroup) && (AdvChk.ADVCheckGroupID == CheckGroup || !CheckGroup) && (AdvChekStpActul.ADVCHKStepID == StepId || !StepId) )
{
TmpDB.CustAccount = AdvChk.CustAccount ;
TmpDB.CustName = AdvChk.CustName ;
TmpDB.AmountCur = AdvChk.AmountCur ;
TmpDB.ADVNetAmount = AdvChk.ADVNetAmount ;
TmpDB.ADVCheckSource = AdvChk.ADVCheckSource ;
TmpDB.ADVCheckGroupID = AdvChk.ADVCheckGroupID ;
TmpDB.ADVCHKStepType = AdvChekStpActul.ADVCHKStepType ;
TmpDB.ADVCheckID = AdvChekStpActul.ADVCheckID ;
TmpDB.Voucher = AdvChekStpActul.Voucher ;
TmpDB.ADVCHKStepID = AdvChekStpActul.ADVCHKStepID ;
TmpDB.TransDate = AdvChekStpActul.TransDate ;
TmpDB.ADVCHKStepGroupID = AdvChekStpActul.ADVCHKStepGroupID ;
TmpDB.ADVCHKStepSequence = AdvChekStpActul.ADVCHKStepSequence ;
TmpDB.LedgerName = DimensionAttributeValueCombination::getDisplayValue(AdvChekStpActul.LedgerDimension);
TmpDB.LedgerDimension = AdvChekStpActul.LedgerDimension ;
TmpDB.insert() ;
}