Hi I created a class in which I use a SysQuery. The init looks like this:
void initQuery()
{
Query query = new Query();
QueryBuildDataSource qbdsOrders, qbdsOrderLines, qbdsInventTable, qbdsCustomers;
;
//Aufträge
qbdsOrders = query.addDataSource(tablenum(SalesTable));
qbdsOrderLines = qbdsOrders.addDataSource(tablenum(SalesLine));
qbdsOrderLines.joinMode(JoinMode::InnerJoin);
qbdsOrderLines.relations(true);
qbdsInventTable = qbdsOrders.addDataSource(tablenum(InventTable));
qbdsInventTable.relations(false);
qbdsInventTable.addLink(fieldnum(InventTable, ItemId), fieldnum(SalesLine, ItemId));
SysQuery::findOrCreateRange(qbdsOrders, fieldnum(SalesTable, CreatedDate));
SysQuery::findOrCreateRange(qbdsOrders, fieldnum(SalesTable, SalesStatus));
SysQuery::findOrCreateRange(qbdsOrders, fieldnum(SalesTable, CustAccount));
SysQuery::findOrCreateRange(qbdsOrders, fieldnum(SalesTable, SalesOriginId));
SysQuery::findOrCreateRange(qbdsOrderLines, fieldnum(SalesLine, SalesStatus));
//Kunden
qbdsCustomers = query.addDataSource(tablenum(CustTable));
SysQuery::findOrCreateRange(qbdsCustomers, fieldnum(CustTable, AccountNum));
SysQuery::findOrCreateRange(qbdsCustomers, fieldnum(CustTable, CreatedDate));
SysQuery::findOrCreateRange(qbdsCustomers, fieldnum(CustTable, LineDisc));
SysQuery::findOrCreateRange(qbdsCustomers, fieldnum(CustTable, Blocked));
SysQuery::findOrCreateRange(qbdsCustomers, fieldnum(CustTable, CountryRegionId));
SysQuery::findOrCreateRange(qbdsCustomers, fieldnum(CustTable, EndDisc));
SysQuery::findOrCreateRange(qbdsCustomers, fieldnum(CustTable, MOCTotalVolume));
queryrun = new SysQueryRun(query);
}
now I call 2 methods in the run-method of my class to work with the data.
method one wants to process the data from the custtable part of the query and the second method I use for the SalesTable,SalesLine and InventTable data.
CustTable returns with no values (even if they are in the table in my ax.
For SalesTable there is something found but for salesline I get a runtime error.
Here my code to get SaleTable, SalesLine and INventtable:
while(this.queryrun().next())
{
salesTable = this.queryrun().get(tableNum(SalesTable));
salesLine = this.queryrun().get(tableNum(SalesLine));
inventTable = this.queryrun().get(tableNum(InventTable));
*This post is locked for comments