report Error

Hii EveryOne,

I wrote a code for a report which prints all transaction details.

But I didnt get any data in the report when i dragged it n placed in menu item.

This is my fetch code.

public boolean fetch()

{

Query q;

QueryBuildDataSource qbd,qbd2;

QueryBuildRange qbr;

QueryRun qr;

boolean printTotal = false;

;

q = new Query();

qbd = q.addDataSource(tablenum(VendTable));

qbd2 = qbd.addDataSource(tablenum(VendTrans));

qbd2.relations(true);

qbd2.joinMode(JoinMode::InnerJoin);

qbr = qbd.addRange(fieldnum(VendTable,AccountNum));

qbr.value(queryrange(fromDate,toDate));

qr = new QueryRun(q);

// if(qr.prompt())

// {

while(qr.next())

{

vendTable = qr.get(tablenum(VendTable));

vendTrans = qr.get(tablenum(VendTrans));

if(vendTrans.TransDate >= fromDate && vendTrans.TransDate <= toDate)

{

if (vendTable.AccountNum != vendTableAccount1)

{

vendTableAccount1 = vendTable.AccountNum;

if (subTotal || printTotal)

{

element.execute(3);

subTotal = 0;

printTotal = true;

}

accountNum = vendTable.AccountNum;

//vendorName1 = vendTable.Name;

element.execute(1);

}

}

transDate = vendTrans.TransDate;

amountMST = vendTrans.AmountMST;

purchId = vendInvoiceJour::findFromVendTrans(vendTrans.Invoice,vendTrans.TransDate,vendTrans.AccountNum).PurchId;

element.execute(2);

subtotal += vendTrans.AmountMST;

total += vendTrans.AmountMST;

}

//}

//}

element.execute(3);

//}

element.execute(4);

//}

return true;

}

AccountNum was added a range, but values provided were different(dates);

Use debugger to find if any problems exists

Hi Kranthi,

thanks for your reply,but i don’t have debugger ,can any one help me urgent

You need to install the debugger then debug the lines to check which values are being passed in the Fetch Method.

I noticed that you are using Programmable Sections so to return the data you need to either add Display Methods which return report data as variables, or else use the “element.send(vendTable)” to actually send the data to the report sections.

declare one more range qbr1 and change the code as shown below

qbr = qbd.addRange(fieldnum(VendTable,AccountNum));

qbr.value(queryrange(vendTableAccount1)); // vendTableAccount1 may be your variable that you are using in dialog to pass account number

qbr1 = qbd.addRange(fieldnum(VendTable,TransDate));

qbr1.value(queryrange(fromDate,toDate));

hope it may helps you…

It shows an error at the following line stating that wrong number of arguments were passed through this function.

qbr.value(queryrange(vendTableAccount1));

it needs the range…so it requires two arguments to be passed!

You need to send the fetched records to be displayed in the report where u haven’t done that.

Hi,

Below job will filter the transaction based on the account number and transaction date based on your input.

static void Job21(Args _args)
{
Query q;
QueryBuildDataSource qbd,qbd2;
QueryBuildRange qbr;
QueryRun qr;
boolean printTotal = false;
fromdate fromdate;
todate todate;
Vendtable vendtable;
vendtrans vendtrans;

;

q = new Query();
qbd = q.addDataSource(tablenum(VendTable));
qbr = sysquery::findOrCreateRange(qbd, fieldnum(VendTable,Accountnum));
qbr.value(“Vendor Account Num”);
qbd2 = qbd.addDataSource(tablenum(VendTrans));
qbd2.relations(true);
qbd2.joinMode(JoinMode::InnerJoin);
qbr = sysquery::findOrCreateRange(qbd2, fieldnum(Vendtrans,Transdate));
qbr.value(strFmt(’(Transdate >= %1)’, Date2strXpp(fromdate)) + ‘&&’ + strFmt(’(Transdate <= %1)’, Date2strXpp(todate)));

qr = new QueryRun(q);

while(qr.next())
{
vendTable = qr.get(tablenum(VendTable));
vendTrans = qr.get(tablenum(VendTrans));

// if(vendTrans.TransDate >= fromDate && vendTrans.TransDate <= toDate)
/Your above if condition is not required since query is filtering based on fromdate and todate./

}

}