Building a simple Query object

Example: Lot Available by Bin

Query:

Warehouse Entry Properties:

Bin Properties:

Bin Type Properties:

The dataset returned by Query, we only want the total quantity per combination of Location, Zone, Bin, Item, and Lot. For Column - Quantity in Warehouse Entry DataItem, set the Method Type column to Totals. The Method will default to Sum, and the columns above Quantity will be marked with Group By checked. This shows the grouping criteria for the aggregation of the Quantity field::

Now save and compile your query, give number and name to this query.

Run this Query: Output:

This query can be utilized internally in NAV 2013,15,16,17 as an indirect data source in a Page or a Report object. Although DataItems in Pages and Reports can only be database tables, we can define Query as a variable and then, use the Query dataset result to populate a temporary Sourcetable. In a page, we define the SourceTableTemporary property to Yes and then, load the table via the C/AL code located in the OnOpenPage trigger, or in a report that we might utilize as a virtual table, such as the Integer table, to step through the Query result. 

You can use this Query Object on any page, see below Example:

OnOpenPage Code:
OnOpenPage()
LotAvail.OPEN;
WHILE LotAvail.READ DO BEGIN
INIT;
// "Item No." := LotAvail.Item_No;
"Entry No." := LotAvail.Entry_No;
"Location Code" := LotAvail.Location_Code;
"Bin Code" := LotAvail.Bin_Code;
Quantity := LotAvail.Sum_Quantity;
INSERT;
END;

//OnOpenPage()
//queryCountTotal.OPEN;
//WHILE queryCountTotal.READ DO BEGIN
//INIT;
//myTotal :=queryCountTotal.Count_;
//queryCountTotal.CLOSE;
//END;

Important property to set for the page before use it: 

Output:

 

Enjoy! Query in Microsoft Dynamics NAV

Comments (1) -

203424 547530Sweet site  , super  pattern ,  rattling clean and use   friendly . 950797

Add comment