report using fetch

“The data source is not embedded within a (parent) data source.”

This is the error i get while trying to fetch a record from a table in report using fetch method without using datasource or querry in AOT.

How do i solve this error

the following is the fetch method which i have written in Report

public boolean fetch()
CarTable carTable1,carTable2;
QueryRun qr;
QueryBuildDatasource QueryBuildDatasource1;
qr = new QueryRun(element);
QueryBuildDatasource1 = element.query().dataSourceTable(tablenum(CarTable));
while (
if (qr.changed(tableNum(CarTable)))
carTable1 = queryRun.get(tableNum(CarTable));

while select carTable1 where carTable1.CarId == carTable2.CarId
return true;

I want to fetch records from just 1 table …i.e cartable display on report

Is it Nav or AX?

ax 2009

First of all, you use qr variable to iterate through results and queryRun variable to get table buffer. That’s obviously wrong.

And are you aware of that the statement QueryBuildDatasource1 = element.query().dataSourceTable(tablenum(CarTable)); does nothing useful?

sorry i was unaware of it …thanks a lot now how to i iterate with help of qr?

You already iterate through query results by while ( You need to call get() on the same object (i.e. qr, not on queryRun).

Thanks very much Martin…