Problem Totaling a Report

xina_manxina_man Member Posts: 116
Hi there!

I'm having a problems calculating a value in a report.
In the report of purchase receipt line i want to calculate the amount of the "qty received not invoiced"... in the body section it's easy to do it (qty received not invoiced*unit price in the SourceExpr properties).
Now i want to create a total with the previously calculated field in the footer section...
Can anybody help me with that?

Many thanks

Answers

  • kinekine Member Posts: 12,562
    Use some new variable and the value save into it. In the source expression use the variable instead the expression. Than you can use the CurrReport.CREATETOTALS(myvariable) for creating automatic totals of the variable.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • xina_manxina_man Member Posts: 116
    kine wrote:
    Use some new variable and the value save into it. In the source expression use the variable instead the expression. Than you can use the CurrReport.CREATETOTALS(myvariable) for creating automatic totals of the variable.

    I'm not a C/AL programmer so I dont know the code for do that task. Is it possible to give me de code for this task?

    Thanks&Regards
  • xina_manxina_man Member Posts: 116
    xina_man wrote:
    kine wrote:
    Use some new variable and the value save into it. In the source expression use the variable instead the expression. Than you can use the CurrReport.CREATETOTALS(myvariable) for creating automatic totals of the variable.

    I'm not a C/AL programmer so I dont know the code for do that task. Is it possible to give me de code for this task?

    Thanks&Regards

    Problem Solved!!!
    Many Thanks
  • kinekine Member Posts: 12,562
    1) Create new global variable e.g. with name "ReceivedNotInvAmount" with type Decimal
    2) In the correc dataitem add code (expression is same as you are using in the section in SourceExpr) into OnAfterGetRecord
      ReceivedNotInvAmount := "qty received not invoiced" * "unit price";
    
    3) Add this code into OnBeforeDataItem
      CurrReport.CREATETOTALS(ReceivedNotInvAmount);
    
    4) Use the ReceivedNotInvAmount variable everywhere you want to print the amount. If it will be in Footer section, it will print the total.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • allendeallende Member Posts: 51
    - Define a global variable ex: MyGrandTotal
    - Write this code to "Purch. Rcpt. Line" DataItems OnAfterGetRecord Triggger

    Code:
    MyGrandTotal := MyGrandTotal + (qty received not invoiced*unitprice );

    - Add a text box to Purch.Rcpt.Line footer section
    - Write MyGrandTotal to text box's SourceExpr property
    - Run the report
Sign In or Register to comment.