Fetch method in report

public boolean fetch()
{
querybuildrange qbr;
QueryRun qr = new queryrun(this.query());// picks the current datasource available in the report
;

element.execute(1);

qbr = qr.query().datasourcetable(tablenum(Cust_Sales_Transaction)).addrange(fieldnum(Cust_Sales_Transaction,TransDate)).value(queryrange(From_Date,To_Date));

element.send(Cust_Sales_Transaction);
element.send(RBOStoreTable_1);
}

for the above code I am getting Operand types are not compatible with the operator error message. Please help me on this

Hi dhamodharan,

your code should be like this…The reason is u r assigning the value to QueryBuildRange Object…here i’m assigning the QueryBuildRange to qbr and then setting the value to qbr…

public boolean fetch()
{
querybuildrange qbr;
QueryRun qr = new queryrun(this.query());// picks the current datasource available in the report
;

element.execute(1);

qbr = qr.query().datasourcetable(tablenum(Cust_Sales_Transaction)).addrange(fieldnum(Cust_Sales_Transaction,TransDate));

qbr.value(queryrange(From_Date,To_Date));

element.send(Cust_Sales_Transaction);
element.send(RBOStoreTable_1);
}

Data cannot be accepted in query value so use the function date2str.If you want to know the syntax go to system documentation->functions->date2str in AOT.

Thanks Arun it works!!!

Hi,

you are adding a range, assigning value to the range and then assigning it to QueryBuildRange. See below

qbr = qr.query().datasourcetable(tablenum(Cust_Sales_Transaction)).addrange(fieldnum(Cust_Sales_Transaction,TransDate)).value(queryrange(From_Date,To_Date));

The return type of “value” is “str” which cannot be assigned to QueryBuildRange. you can directly use

qr.query().datasourcetable(tablenum(Cust_Sales_Transaction)).addrange(fieldnum(Cust_Sales_Transaction,TransDate)).value(queryrange(From_Date,To_Date));

Thanks,
Sasi

I am trying a build a report with data parameter… Find below the steps I have done…

I have added following tables in the datasource

RBOStoreTable
innerjoin RBOTransactionTable
innerjoin RBOTransactionSalesTrans

-------------------- Class Declaration---------------------
public class ReportRun extends RunbaseReportStd
{
DialogField fieldFromDate_Period;
DialogField fieldToDate_Period;
FromDate fromDate;
ToDate toDate;

#define.CurrentVersion(1)

#localmacro.CurrentList
fromDate,
toDate
#endmacro
}

-------------------Pack-------------------------------------
public container pack()
{
return [#CurrentVersion, #CurrentList];
}

------------------Unpack------------------------------------
public boolean unpack(container packedClass)
{
boolean _ret;
Integer _version = conpeek(packedClass,1);

switch (_version)
{
case #CurrentVersion:
[_version, #CurrentList] = packedClass;
_ret = true;
break;
default:
_ret = false;
}
return _ret;
}

-------------------Dialog-----------------------------------
public Object dialog(Object _dialog)
{
DialogRunbase dialog = _dialog;
;

dialog.addGroup("@SYS94817");
fieldFromDate_Period = dialog.addField(typeid(FromDate));
fieldToDate_Period = dialog.addField(typeid(ToDate));
fieldFromDate_Period.value(fromDate);
fieldToDate_Period.value(toDate);
return dialog;
}

------------------Get from dialog---------------------------
boolean getFromDialog()
{
;
fromDate = fieldFromDate_Period.value();
toDate = fieldToDate_Period.value();
return true;
}

--------------------Fetch-----------------------------------
public boolean fetch()
{
querybuildrange qbr;
QueryRun qr = new queryrun(this.query());// picks the current datasource available in the report
;

qr.query().datasourcetable(tablenum(RBOTransactionTable)).addrange(fieldnum(RBOTransactionTable,TransDate)).value(queryrange(fromDate,toDate));

element.send(RBOStoreTable);
element.send(RBOTransactionTable);
element.send(RBOTransactionSalesTrans);

return true;
}

While running the report I am getting blank… Please let me know what is wrong in the report…

Hi dhamodharan,

Try this one…

element.send(RBOStoreTable);
element.send(RBOTransactionTable);
element.send(RBOTransactionSalesTrans);

replace this code with

Super();

Dear Arun,

Parameter restriction is not working… I am running for particular date but report is printing for all the records…

Use

If(qr.next())

{

element.send(RBOStoreTable);

element.send(RBOTransactionTable);

element.send(RBOTransactionSalesTrans);

}

Blank report is coming…

Hi Dhamodharan,

Try with “while” instead of “if” in Kranthi’s code

Hi Arun,

Still blank report is coming…

use this

if(qr.next())

RBOStoreTable = qr.get(ablenum(RBOStoreTable ));

This function has not been declared. error message is coming…

Hi dhamodharan,

try this…

public boolean fetch()
{
querybuildrange qbr;
QueryRun qr = new queryrun(this.query());// picks the current datasource available in the report
;

qr.query().datasourcetable(tablenum(RBOTransactionTable)).addrange(fieldnum(RBOTransactionTable,TransDate)).value(queryrange(fromDate,toDate));

while(qr.next())
{

element.send(RBOStoreTable);
element.send(RBOTransactionTable);
element.send(RBOTransactionSalesTrans);

}

return true;
}

Still blank report is coming

I have typed it wrongly

RBOStoreTable = qr.get(tablenum(RBOStoreTable ));

Hi

I have changed the code as follows

public boolean fetch()
{
querybuildrange qbr;
QueryRun qr = new queryrun(this.query());// picks the current datasource available in the report
;
qr.query().datasourcetable(tablenum(RBOTransactionTable)).addrange(fieldnum(RBOTransactionTable,TransDate)).value(queryrange(fromDate,toDate));
while(qr.next())
{
RBOStoreTable = qr.get(tablenum(RBOStoreTable ));
RBOTransactionTable = qr.get(tablenum(RBOTransactionTable ));
RBOTransactionSalesTrans = qr.get(tablenum(RBOTransactionSalesTrans ));
element.send(RBOStoreTable);
element.send(RBOTransactionTable);
element.send(RBOTransactionSalesTrans);
}
return true;
}

now record is coming with parameter restriction…

but the porblem is header is repeating for all the lines…
I am expecting…

Store 1

TransactionID 1
Receipt1
Receipt2
Receipt3

TransactionID 2
Receipt1

TransactionID 3
Receipt1
Receipt2

Store 2

TransactionID 1
Receipt1
Receipt2

TransactionID 2
Receipt1
Receipt2

But report is printing like this

Store 1
TransactionID 1
Receipt1

Store 1
TransactionID 1
Receipt2

Store 1
TransactionID 1
Receipt3

Store 1
TransactionID 2
Receipt1

Store 1
TransactionID 3
Receipt1

Store 1
TransactionID 3
Receipt2

Store 2
TransactionID 1
Receipt1

Store 2
TransactionID 1
Receipt2

Store 2
TransactionID 2
Receipt1

Store 2
TransactionID 2
Receipt2

Please guide me on this

Can you able tell information about the design exactly what you are using - like your section groups and body etc.

this.query().dataSourceName(“your data source name”))).addrange(fieldnum(RBOTransactionTable,TransDate)).value(queryrange(fromDate,toDate));

use this instead of

qr.query().datasourcetable(tablenum(RBOTransactionTable)).addrange(fieldnum(RBOTransactionTable,TransDate)).value(queryrange(fromDate,toDate));

& use super();

instead of

while(qr.next())
{
RBOStoreTable = qr.get(tablenum(RBOStoreTable ));
RBOTransactionTable = qr.get(tablenum(RBOTransactionTable ));
RBOTransactionSalesTrans = qr.get(tablenum(RBOTransactionSalesTrans ));
element.send(RBOStoreTable);
element.send(RBOTransactionTable);
element.send(RBOTransactionSalesTrans);
}