The following X++ code example uses the QueryFilter class to filter the result set from an outer join.
The QrySalesAndLines query joins the parent and child tables on an equality test between parent's primary key field and child's foreign key field. The following job adds another join filter criteria which tests whether the Quantity field equals 66.
static void krishh_QueryFilter(Args _args)
{
Query query2;
QueryBuildDataSource qbDataSource3;
QueryRun queryRun4;
{
Query query2;
QueryBuildDataSource qbDataSource3;
QueryRun queryRun4;
// Ax2012 class
QueryFilter qFilter7;
QueryFilter qFilter7;
SalesOrder recSalesOrder;
SalesOrderLine recSalesOrderLine;
SalesOrderLine recSalesOrderLine;
struct struct5;
struct5 = new struct
("int SalesOrderID;"
+ "date DateAdded;"
+ "str SalesOrderLineID;"
+ "int Quantity"
);
("int SalesOrderID;"
+ "date DateAdded;"
+ "str SalesOrderLineID;"
+ "int Quantity"
);
query2 = new Query("QrySalesAndLines");
qbDataSource3 = query2.dataSourceName("SalesOrderLine_1");
qbDataSource3 = query2.dataSourceName("SalesOrderLine_1");
qFilter7 = query2.addQueryFilter(qbDataSource3, "Quantity");
qFilter7.value("66");
qFilter7.value("66");
queryRun4 = new QueryRun(query2);
while (queryRun4.next())
{
recSalesOrder = queryRun4.getNo(1);
recSalesOrderLine = queryRun4.getNo(2);
while (queryRun4.next())
{
recSalesOrder = queryRun4.getNo(1);
recSalesOrderLine = queryRun4.getNo(2);
struct5.value("SalesOrderID", recSalesOrder.SalesOrderID);
struct5.value("DateAdded", recSalesOrder.DateAdded);
struct5.value("SalesOrderLineID", recSalesOrderLine.SalesOrderLineID);
struct5.value("Quantity", recSalesOrderLine.Quantity);
info(struct5.toString());
}
}
struct5.value("DateAdded", recSalesOrder.DateAdded);
struct5.value("SalesOrderLineID", recSalesOrderLine.SalesOrderLineID);
struct5.value("Quantity", recSalesOrderLine.Quantity);
info(struct5.toString());
}
}
No comments:
Post a Comment
Thanks for visiting my blog,
I will reply for your comment within 48 hours.
Thanks,
krishna.