Hi,
I am using below query to combine - vendor aging query Across companies but not a success yet.
public void ProcessReport()
{
VendTrans vendtrans, vendTransTmp, vendTransBalance;
VendSettlement vendsettlement;
VendTable vendtable;
VendTransOpen vendTransOpen;
DirPartyTable dirPartyTable;
Amount amountTrans, amountSettle;
AccountNum vendAcc;
Notes companies;
VendAccount vendAccount;
boolean vendexists;
container conCompanies= ['B01', 'B12'];
TransDate fromDate= 01\07\2016;
TransDate toDate= 30\9\2016;
while select crossCompany : conCompanies
DataAreaId, RecId, AccountNum, AmountMST, ExchAdjustment, settleAmountMST from vendtrans
order by vendtrans.AccountNum asc
where vendtrans.TransDate >= fromDate
&& vendtrans.TransDate <= toDate
join party from vendtable
where vendtable.AccountNum == vendtrans.AccountNum
join Name from dirPartyTable
where dirPartyTable.RecId == vendtable.Party
{
if(!vendAcc)
{
select settleamountMST from vendsettlement
where vendsettlement.TransRecId == vendtrans.RecId
&& vendsettlement.TransDate >= todate
&& vendsettlement.dataAreaId == vendtrans.dataAreaId ;
apAgingTmp.APAgingAmount += vendsettlement.settleamountmst + vendtrans.remainAmountMST();
apAgingTmp.AccountNum = vendtrans.AccountNum;
apAgingTmp.Name = dirPartyTable.Name;
apAgingTmp.CompanyId = vendtrans.dataAreaId;
vendacc = vendtrans.AccountNum;
}
else
{
select settleamountMST from vendsettlement
where vendsettlement.TransRecId == vendtrans.RecId
&& vendsettlement.TransDate >= todate
&& vendsettlement.dataAreaId == vendtrans.dataAreaId ;
if(vendAcc && (vendAcc != vendTrans.AccountNum))
{
select sum(AmountMST) from vendTransBalance group by vendTransBalance.AccountNum
where vendTransBalance.AccountNum == vendAcc
&& vendTransBalance.TransDate < fromDate;
apAgingTmp.APAgingAmount += vendTransBalance.AmountMST;
apAgingTmp.APAgingAmount += vendTransTmp.AmountMST;
if(apAgingTmp.APAgingAmount != 0.00)
apAgingTmp.insert();
vendacc = vendTrans.AccountNum;
apAgingTmp.APAgingAmount = 0.00;
}
apAgingTmp.APAgingAmount += vendsettlement.settleamountmst + vendtrans.remainAmountMST();
apAgingTmp.AccountNum = vendtrans.AccountNum;
apAgingTmp.Name = dirPartyTable.Name;
apAgingTmp.CompanyId = vendtrans.dataAreaId;
}
}
select sum(AmountMST) from vendTransBalance group by vendTransBalance.AccountNum
where vendTransBalance.AccountNum == vendAcc
&& vendTransBalance.TransDate < fromDate;
apAgingTmp.APAgingAmount += vendTransBalance.AmountMST;
if(apAgingTmp.APAgingAmount != 0.00)
apAgingTmp.insert();
}