CREATETOTALS how does this work?

Hello! I'm trying to find out how this CREATETOTALS function work, but i had no success so far. I read the Aplication Developers Guide but i dodn't understand which fields does it read to make totals...
I got a homework to find out how a report that we use works. It uses CREATETOTALS function. Some of the Code looks like this:

--on predataitem (Item ledger Entry)

SETRANGE("Item No.",Item."No.");
SETFILTER("Variant Code",Item.GETFILTER("Variant Filter"));
SETFILTER("Location Code",Item.GETFILTER("Location Filter"));
SETFILTER("Global Dimension 1 Code",Item.GETFILTER("Global Dimension 1 Filter"));
SETFILTER("Global Dimension 2 Code",Item.GETFILTER("Global Dimension 2 Filter"));
IF EndDate <> 0D THEN
SETRANGE("Posting Date",0D,EndDate);

CurrReport.CREATETOTALS(QtyOnHand,RcdIncreases,ShipDecreases,Quantity);
CurrReport.CREATETOTALS(InvoicedQty, InvIncreases, InvDecreases, "Invoiced Quantity");
CurrReport.CREATETOTALS(
ValueOfQtyOnHand,ValueOfRcdIncreases,CostOfShipDecreases,CostPostedToGL,ExpCostPostedToGL);
CurrReport.CREATETOTALS(
ValueOfInvoicedQty,ValueOfInvIncreases,CostOfInvDecreases,
InvoicedValueEntry."Adjusted Cost",InvCostPostedToGL);

---on post data item

QtyOnHand := 0;
RcdIncreases := 0;
ShipDecreases := 0;
IF "Posting Date" < StartDate THEN BEGIN
QtyOnHand := Quantity;
END ELSE
IF ("Entry Type" IN
["Entry Type"::Purchase,"Entry Type"::"Positive Adjmt.","Entry Type"::Output])
THEN BEGIN
RcdIncreases := Quantity;
END ELSE BEGIN
ShipDecreases := -Quantity;
END

-------
in sections these variables are printed:InvoicedQty,ValueOfInvoicedQty,InvIncrease, ValueOfInvIncrease, InvDecrease, CostOfInvDecrease, InvCostPostedToGL


If anyone can help me unrattle this code i'd realy appriciate it. I just can't understand where does it collect the data from.

Thanks in advance

lp Prosen
Parents
No Data
Reply
  • One additional FYI.

    Once you have defined CREATETOTALS(MyVar,MyField) on a number of variables or fields, Navision Creates a new total variable for this element, and you can indent, so for example if you have
    Table1
    table2
    then you can place code to add totalas and subtotals. One Gotcha here is what triggers the Totaling function. I like to look at it as something like CALCFIELDS, where if you put the folw field on a report it automatically caclulates, but if you don't then you have to force a CALCFIELDS. Well with CREATETOTALS, if you invoke the field by putting it on the Report, then it is automatically included in the TOTALING. Also(OR) if you assign a value to that Field or Variable it is also summed. A small trick to force this, and make certain that the value is included in the sum, is to assign it to it self in the section. eg;

    Table1.OnAfterGetRecord
    //My code is here
    ...
    MyVar := MyVar;
    MyField := MyField;
    Table1.OnPostDataItem

    The only way to access the variables is after running through the records, so there is no way to manipulate or view the current totals. (Wouldn't it be nice to have a command like CurrentValue := Table1.TOTALS.MyVar;).

    I hope this provides more help than confusion.
Children
No Data
Related
Recommended