Basics of Fetch Method in Ax Report

this is my first post in this forum…expecting like me it will help freshers…

// #. A Fetch Method Override for A Date Range Data Retrival from Cust TRans Table as on …

public boolean fetch()

{

// 0. Declare Variables

QueryRun qr;

QueryBuildDatasource QueryBuildDatasource1;

QueryBuildRange rangeTransDate;

Boolean ret;

CustTable custTable;

CustTrans custTrans;

// 1. A QueryRun object called qr is initialized with the active query of the report,

qr = new QueryRun(element);

// 2. Get DAtaSource from current element query

QueryBuildDatasource1 = element.query().dataSourceTable(tablenum(CustTrans));

// 3. A range for the customer transaction date field is added to Datasource

rangeTransDate = QueryBuildDatasource1.addRange(fieldnum(CustTrans, transDate));

// 4. Actusl Date Range Value is added to qr

rangeTransDate.value(queryRange(systemdateGet() - daysBack, systemDateGet()));

// 5. The range is locked, so the user cannot change it.

rangeTransDate.status(RangeStatus::LOCKED);

// 6. The transaction date range is added to the caption of the report.

element.design().caption(strfmt("%1, %2", element.design().caption(), rangeTransDate.value()));

// 7. At this point, the query is looped. The standard loop of the query and the printout of the

// record is what the super() call in fetch() handles. Before the query is looped, there is a

// check to see whether the dialogs for the query and the report are called.These are the two dialogs which are wrapped by RunBaseReportStd

if (qr.prompt() && element.prompt())

{

// 8. query is looped

while (qr.next())

{

// 9. Within each loop, the tables CustTable and CustTrans are initialized.

// If no records are found, the loop breaks and the report ends.

// If a data source has changed, a new record is found

// and the record is printed using the send() method.

custTable = qr.get(tableNum(CustTable));

custTrans = qr.get(tableNum(CustTrans));

if (!custTable)

{

ret = false;

break;

}

// 10. Note the second parameter in the send() method.

// The second parameter defines the level of the record. CustTable is on the first level of the query and

// CustTrans is on the second level. This is important since, if it is not set correctly,

// auto sums will not be printed.

if (qr.changed(tableNum(custTable)))

{

element.send(custTable, 1);

}

if (qr.changed(tableNum(custTrans)))

{

element.send(custTrans, 2);

}

}

ret = true;

}

else

ret = false;

return ret;

}

// 11. ------Tactics of reports—

// In the fetch example, the query of the report was looped. The case could also be looping

// a WHILE statement, SELECT statement, or a combination of both. For each record

// looped in the query, you might want to select a record from a table which is not part of

// the query, or even build a temporary table to be printed. For each record to be printed,

// all you have to do is call the send() method

thnks

VERY INFORMATIVE POST…HELPFUL TO FRESHERS / NEW LEARNERS…KEEP POSTING LIKE WISE FOR DIFFERENT

METHODS USED IN REPORTS, FORMS

This is helpful, as the standard documentation does not go into this in enough detail. Very good post.

Hi,

Can you please post about the :

DIALOG & GETFROMDIALOG METHOD likeawise you have posted about the FETCH method ?

It is very clearly and helpful for freshers…

keep it up…

thanks