To get data from different companies, use
change company:
changecompany(''C') // c: company name
{
// code;
}
or
use queryframe work and add the company range as:
qr.allowCrossCompany(true);
qr.query().addCompanyRange('A');
qr.query().addCompanyRange(''B'');
for reference find the below code.
here I am filtering the PO which are invoice and received and also based on VendGroup
and fetching the data from purchline.
...................................................................................................................................................
public boolean fetch()
{
QueryBuildDataSource qbds,qbds1;
Query q = new Query();
QueryBuildRange qbr,qbr1,qbr2;
QueryRun qr;
container conCompanies = [ ''A", ''B'' ]; // you can assign the selected company
;
changecompany(''C'')
{
// code;
}
//or
qbds = q.addDataSource(tablenum(PurchTable));
qbds1 = qbds.addDataSource(tablenum(purchLine));
qbds.joinMode(joinmode::InnerJoin);
qbds1.relations(true);
qbr1 = q.dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable,VendGroup));
qbr1.value("HIRING");
qbr2 = q.dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable,DeliveryDate));
qbr2.value(queryValue(fromDate)+ '..'+ queryValue(toDate));
qbr = q.dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable,PurchStatus));
//qbr.value(enum2str((PurchStatus::Received) || (PurchStatus::Invoiced )));
qbr.value(strFmt('%1,%2', PurchStatus::Received,PurchStatus::Invoiced));
qr = new QueryRun(q);
qr.allowCrossCompany(true);
qr.query().addCompanyRange('A');
qr.query().addCompanyRange(''B'');
while(qr.next())
{
purchLine = qr.getNo(2);
element.send(purchLine);
}
}
return true;
}
No comments:
Post a Comment