Report - DataItem - sum calculation

andy76andy76 Member Posts: 616
Good morning,

I have created a new report with 4 dataitem indented

Manufacturer -> Item -> Purch. Inv. Line -> Purch. Inv. Header

In Purch.Inv. Line footer I show the totals of quantity and amount grouped by Type,No.,Item Category Code and it is ok.

I Item Group footer section grouped by Item Category Code I would like to show the totals for Item Category Code.

I inserted code in trigger Purch. Inv. Line, Footer (2) - OnPostSection()

as following

gTotQuantityManufNameICC := gTotQuantityManufNameICC + "Purch. Inv. Line".Quantity;
gTotQuantityManufName := gTotQuantityManufName + "Purch. Inv. Line".Quantity;
gTotQuantityGeneral := gTotQuantityGeneral + "Purch. Inv. Line".Quantity;

but the totals are wrong.
I think that all lines of Purch. Inv. Line are summed and not only the one displayed in Purch. Inv. Line, Footer...
How can I solve?

Thank you

Comments

  • andy76andy76 Member Posts: 616
    Similar problem happens if I insert the code to export in Excel in this section: Purch. Inv. Line, Footer (2) - OnPostSection()

    I wrote the code to export in Excel but all Purch. Inv. Line are export and not only the ones displayed in footer section that I want.

    Thank you
  • kapamaroukapamarou Member Posts: 1,152
    If you maintain some totals manually then you will need to zero them somewhere.

    In general I try to avoid maintaining totals manually because it gets complicated, especially if you are using TransHeader / TransFooter sections.

    Have you tried putting the following code in the Item - OnPreDataItem trigger?
    CurrReport.CREATETOTALS("Purch. Inv. Line".Quantity);
    
  • andy76andy76 Member Posts: 616
    Please read also my first reply to my message about export in excel.
    If we solve this, probably solve also the first one.

    Thank you very much
  • kapamaroukapamarou Member Posts: 1,152
    When you maintain the sum through code, you will need to clear it somewhere, because it will keep adding up. Your sum will not differ between the screen output and excel. Th issue is that your sum is wrong.

    I think you should try letting NAV calculate the sum. Otherwise you should clear the sum variables whenever the Item Category Code changes.
    andy76 wrote:
    I wrote the code to export in Excel but all Purch. Inv. Line are export and not only the ones displayed in footer section that I want.

    You should use something like this:
    IF CurrReport.SHOWOUTPUT THEN BEGIN
       OutputToExcel();
    END;
    
  • andy76andy76 Member Posts: 616
    I already tried the:

    IF CurrReport.SHOWOUTPUT THEN BEGIN
    OutputToExcel();
    END;

    in section Purch. Inv. Line, Footer (2) - OnPostSection() but i report are printed 4-5 lines and in Excel 1729....how is it possible?????
  • kapamaroukapamarou Member Posts: 1,152
    andy76 wrote:
    in section Purch. Inv. Line, Footer (2) - OnPostSection() but i report are printed 4-5 lines and in Excel 1729....how is it possible?????

    To help on this I think we'll need to know how you have coded your report. In which places do you have an ExportToExcel call? What sections have you used?
  • andy76andy76 Member Posts: 616
    The code to export in XLS is written in this section of the image.

    Thank you
Sign In or Register to comment.