10 January 2011

Working wtih Queries Query_Ex

1.Queries in Jobs
static void Query_Ex(Args _args)
{
Query q;
QueryRun qr;
QueryBuildDataSource qbd;
QueryBuildRange qbr;
SalesTable salesTable;;
q = new Query();
qbd = q.addDataSource(TableNum(salesTable));
qbr = qbd.addRange(FieldNum(salesTable,SalesId));
qbr.value("00078_036");
qr = new QueryRun(q);
while(qr.next())
{
SalesTable = qr.get(TableNum(salesTable));
info(salesTable.CustAccount);
}
}
---------------------------
2.Queries in Reports
In Report -> Fetch Method write the following code for Range

public boolean fetch()
{
boolean ret;

Query q;
QueryRun qr;
QueryBuildDataSource qbd;
QueryBuildRange qbr;
SalesTable salesTable;;

//ret = super();
q = new Query();
qbd = q.addDataSource(TableNum(salesTable));
qbr = qbd.addRange(FieldNum(salesTable,SalesId));
qbr.value("00078_036");//range value
qr = new QueryRun(q);
while(qr.next())
{
SalesTable = qr.get(TableNum(salesTable));
this.send(salesTable);
}
return true;
}
-----
Code for with out range
public boolean fetch()
{
boolean ret;

Query q;
QueryRun qr;
QueryBuildDataSource qbd;
QueryBuildRange qbr;
SalesTable salesTable;;

//ret = super();
q = new Query();
qbd = q.addDataSource(TableNum(salesTable));
qr = new QueryRun(q);
while(qr.next())
{
SalesTable = qr.get(TableNum(salesTable));
this.send(salesTable);
}

return true;
}
-------
Query Run with DS
DataSource added in report SalesTable
Report->Fetch()
public boolean fetch()
{
boolean ret;

QueryRun qr = new QueryRun(this);
;
//ret = super();

while(qr.next())
{
SalesTable = qr.getNo(1);// 1 refer the 1st datasource.
this.send(SalesTable );
}

No comments:

Post a Comment

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...