Report Fetch

I want to make report which has datasource InventTrans and InventDim(as joinned DS)

I want to make 2 query

1 st one will search three fields trans refid , voucher and itemID if three of them are same it will get somefields
2nd one will search same thing but with different values then it will get some values again

then i will show them in a row.

I ve started with this fetch method but it is not correct and finished please help me.

public boolean fetch()

{

Query q = new Query(this.query());

QueryBuildDatasource qbd,qbdTrans;

QueryBuildRange qbr,qbrV,qbrItem;

Boolean ret;

QueryRUn qr;

InventTrans it;

qbd = q.dataSourceTable(tablenum(InventTrans));

qbr = sysquery::findOrCreateRange(qbd,fieldNum(InventTrans,TransRefId));

qbr.value(sysquery::range(TransRefId);

qbdTrans = q.dataSourceTable(tablenum(InventTable));

qbrV = sysquery::findOrCreateRange(qbd,fieldNum(InventTrans,Voucher));

qbrV.value(sysquery::value(Voucher));

qbrItem = sysquery::findOrCreateRange(qbd,fieldNum(InventTrans,ItemID));

qbrItem.value(sysquery::value(ItemId));

while select inventTrans group by transRefID, Voucher, ItemId

where inventTrans.TransRefId==inventTrans.ItemId &&

inventTrans.Direction==InventDirection::Issue

{

element.send(it.TransRefId);

}

qr = new QueryRun(q);

this.queryRun(qr);

ret = super();

return ret;

}