Thanks for the help Mr. Martin & Mr. Waed,
Actually the problem was with the datasource relations in the form as it had a wrong join with another table. I solved it. Now I need to use 3 tables in my form those are ProdJournalRoute, ProdTable & InventDim. I am trying to add some more filters in the form but it doesn't work as expected can you please help me to fix the issue in the below code and help me to simplify it. I am not much familiar with query range expressions when we have multiple datasources.
The form contains 3 tables ProdJournalRoute(1), ProdTable(2) (inner join with 1) & InventDim(Inner join with2).
[Form]
public class ProdReportingOverview extends FormRun
{
/// <summary>
///
/// </summary>
public void init()
{
super();
FromDate.dateValue(dateStartMth(today()));
Todate.dateValue(endMth(today()));
}
[DataSource]
class ProdJournalRoute
{
/// <summary>
///
/// </summary>
public void executeQuery()
{
QueryBuildDataSource qbds,qbds1,qbds2;
QueryBuildRange qbr,qbr1,qbr2;
qbds = this.query().dataSourceTable(tableNum(ProdJournalRoute));
qbds1 = qbds.addDataSource(tableNum(ProdTable));
qbds1.joinMode(JoinMode::InnerJoin);
qbds1.relations(true);
qbds2 = qbds1.addDataSource(tableNum(InventDim));
qbds2.joinMode(JoinMode::InnerJoin);
qbds2.relations(true);
qbds.clearDynalinks();
qbds.clearLinks();
qbr = qbds.addRange(fieldnum(ProdJournalRoute, TransDate));
qbr1 = qbds.addRange(fieldnum(ProdJournalRoute, Hours));
qbr1 = qbds.addRange(fieldnum(ProdJournalRoute, QtyGood));
qbr1 = qbds.addRange(fieldnum(ProdJournalRoute, QtyError));
qbr2 = qbds2.addRange(fieldnum(InventDim, InventLocationId));
qbr.value(queryRange(fromDate.datevalue(), toDate.dateValue()));
qbr1.value(strFmt('((Hours != %1) || (QtyGood != %2) || (QtyError != %3))'
,SysQuery::value('0'),SysQuery::value('0'),SysQuery::value('0')));
qbr2.value(Location.valueStr());
super();
}
}
[Control("Date")]
class FromDate
{
/// <summary>
///
/// </summary>
/// <returns></returns>
public boolean modified()
{
boolean ret;
ret = super();
ProdJournalRoute_ds.executeQuery();
return ret;
}
}
[Control("Date")]
class ToDate
{
/// <summary>
///
/// </summary>
/// <returns></returns>
public boolean modified()
{
boolean ret;
ret = super();
ProdJournalRoute_ds.executeQuery();
return ret;
}
}
[Control("String")]
class Location
{
/// <summary>
///
/// </summary>
/// <returns></returns>
public boolean modified()
{
boolean ret;
ret = super();
ProdJournalRoute_ds.executeQuery();
return ret;
}
}
}