Tuesday, 16 July 2013

multi datasource lookup

public void lookup()
{
#define.seperator(‘, ‘)
SysTableLookup tablelookup;
QueryBuildRange qbr;
QueryRun qrun;
QueryBuildDataSource qbds1, qbds2;
QueryBuildLink qblink1;
Query q = new Query();
IPMPFBanks iPMPFBanks;
Name allPackIds;
;
tablelookup = SysTableLookup::newParameters(tableNum(BankAccountTable),this);
qbds1 = q.addDataSource(tableNum(BankAccountTable));
qbds2= qbds1.addDataSource(tableNum(IPMPFBanks));
qbds2.joinMode(JoinMode::InnerJoin);
qblink1 = qbds2.addLink(fieldNum(IPMPFBanks,PortfolioAccount), fieldNum(BankAccountTable, AccountNum));
qbds2.relations(true);
while select iPMPFBanks where iPMPFBanks.PortfolioID ==IPMPFComodityTable.PortfolioID
{
allPackIds += (iPMPFBanks.PortfolioAccount + #seperator);
}
qbds1.addRange(fieldNum(BankAccountTable,AccountNum)).value(allPackIds);//(queryValue(iPMPFBanks.PortfolioAccount));
qbds1.addOrderByField(fieldnum(BankAccountTable,AccountNum ));
qbds1.addOrderByField(fieldnum(BankAccountTable,AccountID ));
qbds1.addOrderByField(fieldnum(BankAccountTable,Name ));
qbds1.orderMode(OrderMode::GroupBy);
tablelookup.parmQuery(q);
//tablelookup.addLookupField(fieldNum(IPMPFBanks,PortfolioAccount));
tablelookup.addLookupfield(fieldNum(BankAccountTable,AccountNum));
tablelookup.addLookupfield(fieldNum(BankAccountTable, AccountID));
tablelookup.addLookupfield(fieldNum(BankAccountTable, Name));
tablelookup.performFormLookup();
}
/*public void lookup()
{
IPMPFBanks IPMPFBanks;
//IPMPFComodityTable IPMPFComodityTable;
SysTableLookup IPMPFBankslookup;
Query query = new Query();
IPMPFBanks iPMPFBanksloc;
String255 append;
QueryBuildDataSource qbdsIPMPFBanks;
// QueryBuildDataSource qbdsVendTable;
//QueryBuildDataSource qbdsDirpartyTable;
//QueryBuildRange qbrPortfolioID;
// VendTable Vendtable;
 IPMPFBankslookup = SysTableLookup::newParameters(tableNum(IPMPFBanks), this);
qbdsIPMPFBanks = query.addDataSource(tableNum(IPMPFBanks));
//qbdsIPMPortfolioMembers = query.addDataSource(tableNum(CustTable));
qbdsIPMPFBanks.addRange(fieldNum(IPMPFBanks,PortfolioID)).value(queryValue(IPMPFComodityTable.PortfolioID));
//qbdsIPMPortfolioMembers.addRange(fieldNum(CustTable,AccountNum)).value(queryValue(IPMPfInvestmentLines.PortfolioID));
IPMPFBankslookup.parmQuery(query);
IPMPFBankslookup.addLookupfield(fieldNum(IPMPFBanks,PortfolioAccount),true);
// IPMPFBankslookup.addLookupfield(fieldNum(IPMPFBanks,PortfolioID));
//IPMPFBankslookup.addLookupfield(fieldNum(BankAccountTable,AccountID),true);
//IPMpfmemberslookup.addLookupfield(fieldNum(CustTable,AccountNum),true);
//IPMpfmemberslookup.addLookupfield(fieldNum(IPMPortfolioMembers,IPMPortfolioMemberID),true);
IPMPFBankslookup.performFormLookup();
}*/


No comments:

Post a Comment