Novice Coding Question, Please Help

adamEthanadamEthan Member Posts: 104
Thanks for looking!

Nav 4.0 SP3

I have a very basic report that I created to detail the past shipping/invoice history of a customer, sorted by customer, then sales order no. then line items. I wanted to do this filtered on just a specific range of item numbers, so lines that were to GL or a different range were omitted.

This is what my Report Designer looks like:

Customer
__Sales Invoice Header
___Sales Invoice Line
_____ Integer ( Amounts )

And my code for each section looks like this:

( SIL = Sales Invoice Line Temp table )
Customer - OnAfterGetRecord()
TotalAmount := 0;
Sales Invoice Line - OnAfterGetRecord()
SIL.SETRANGE("Document No.","Document No.");
SIL.SETRANGE("Line No.","Line No.");

IF NOT SIL.FINDFIRST THEN
  BEGIN
    SIL := "Sales Invoice Line";
    SIL.INSERT;
  END
 ELSE
  BEGIN
    SIL.Amount :=
       SIL.Amount + Amount;
    SIL.MODIFY;
  END;
Amounts - OnPreDataItem()
Amounts.SETRANGE(Number,1,SIL.COUNT);

Amounts - OnAfterGetRecord()
IF Amounts.Number = 1 THEN
 SIL.FINDFIRST
ELSE
 SIL.NEXT;

TotalAmount := TotalAmount + SIL.Amount;

Since I have to wipe the "TotalAmount" Global each time a new customer is pulled, I'm having a hard time adding up all of the customers totals.

Can someone help so that I'd have a grand total?

Thanks a million..

-Adam

Answers

  • DaveTDaveT Member Posts: 1,039
    Hi Adam,

    Two ways to solve this - create a new variable for OverallTotal and add into it when you total TotalAmont or use the currreport.createtotals - this command is very usefull and will maintain total per group and an overall total even if the value is zero'd in the middle. Look at report 105 for a easy example

    Hope this helps.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • adamEthanadamEthan Member Posts: 104
    Thank you for the reply, and while I am home over the weekend I will certainly try this out on Monday and post my results.

    I'm familiar with the create totals aspect of the program, however I didn't know it would work when calculating variables etc.

    Thanks!

    -Adam
  • McClaneMcClane Member Posts: 40
    If you created a new key ("Sell-to Customer No.", SumIndexField Amount), it would be easier.

    Customer - OnAfterGetRecord:
    SalesInvoiceLine.SetRange("Sell-to Customer No.","No.");
    SalesInvoiceLine.calcsums(Amount);
    TotalAmount+=SalesInvoiceLine.Amount;
    
    If you dont´t want to create the key, you´ll have to add the Amounts line by line (if SalesInvoiceLine.find('-') then repeat .. until).
    All the other DataItems are not necessary.
  • adamEthanadamEthan Member Posts: 104
    Thanks for all the help! I got the report to function properly because of your assistance.

    Just one simple question though.

    How do I remove the tabs from the "report filter" screen? Currently it has all the tabs at the top for the different filtering, but I want to remove a few.

    Thanks!

    -Adam
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    edited 2008-07-28
    set the DataItemTableView property for the dataItem corresponding to the tab O:)
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • DenSterDenSter Member Posts: 8,305
    Set a sort order in the DataItemTableView property and make sure there are no fields specified in the ReqFilterFields property.
  • adamEthanadamEthan Member Posts: 104
    Thanks for the quick replies. I think I must have mistyped.

    I know how to remove the fields that could recieve filters, what I meant to type was that I don't know how to remove the tab altogether, like the "integer" tabs are completely unnecessary, etc.

    haha, sorry about that :(

    -adam
  • DenSterDenSter Member Posts: 8,305
    Maybe you didn't read my post:
    DenSter wrote:
    Set a sort order in the DataItemTableView property and make sure there are no fields specified in the ReqFilterFields property.
    The important bit being
    DenSter wrote:
    Set a sort order in the DataItemTableView
    If you specify a field in the ReqFilterFields property though, it will show the tab regardless of whether you set a sort order or not.
  • DenSterDenSter Member Posts: 8,305
    Detailed instructions:
    1 - Check the ReqFilterFields property. If this is already blank: good. If this has any value, remove it.
    2 - Set a sort order in the DataItemTableView property

    Now you should not have a tab for the dataitem any longer.
  • adamEthanadamEthan Member Posts: 104
    Thanks for the replies, I'm uncertain if you were being punchy or frank.

    I'm unfamiliar with the phrase that you so eloquently repeated, "set a sort order." Nothing is glaringly obvious when I view the properties of each table in the field you mentioned, as Integer tables have no viewable capabilities in these realms, but I'd rather avoid the confrontation and frustration and be on my way, report finished and all.

    Perhaps I should become a site supporter again.

    Thanks,

    -Adam
  • DenSterDenSter Member Posts: 8,305
    adamEthan wrote:
    I'm unfamiliar with the phrase that you so eloquently repeated, "set a sort order."
    Judged by the number of posts you have on mibuso I assumed you have more experience than it now appears that you do, so I'll be a little more elaborate. There are two things that determine whether the request form will show the dataitem. One is the sort order (which is determined by the selected key) and the requested filter fields. By selecting a key, you determine the sort order of the dataitem. The DataItemTableView property is used to set the view in the source table of the dataitem, in whith you can select a key (otherwise known as 'set a sort order'), the ReqFilterFields is used to specify the default fields to present to the user for filtering.

    Since you wrote that you are familiar with these properties, I assumed that you would know where to find it. You obviously did not find where you can select the sort order for the Integer dataitem.
    adamEthan wrote:
    Nothing is glaringly obvious when I view the properties of each table in the field you mentioned, as Integer tables have no viewable capabilities in these realms
    That comment makes me think that you did not understand my suggestion, dismissed it and you didn't even take the time to look around in there. Let me tell you exactly how to get there.
    Open your report in design, put the cursor on the integer dataitem, and open the properties page. Scroll down to the DataItemTableView property and click the ellipsis button (that's the little button with the 3 dots on it, and you can also press Shift+F2), which opens the 'table view' dialog box. In the 'Key' field, click the lookup button (that's the one with the arrow pointing upward), and you will see the Integer Key List, from which you can select the Number field as the key, which sets the sort order of the dataitem to the number field of the virtual Integer table.

    I've told you the same thing in three different ways, and you keep telling me that it is not what you need. If this still confuses you, please tell me what it is exactly that you don't understand, and I will try to help you.
  • adamEthanadamEthan Member Posts: 104
    DenSter,

    My coworkers and I got a laugh out of your comical response when you needed to slow it down for me, yet the information you provided did indeed help in finally "finishing" this report. Best of all, everyone at my company is very pleased with the effort, as they found the report to be very useful and extremely beneficial to their daily activities. I couldn't have done it without you! Thanks!

    All the best :D

    -Adam
  • DenSterDenSter Member Posts: 8,305
    adamEthan wrote:
    your comical response
    I wasn't trying to be funny. You obviously had trouble understanding what I suggested twice before, and since you did not specify what it was exactly that you didn't understand (you told me you understand the properties I described, yet you did not know where to set the sort order) I figured might as well be as elaborate as I can. :-k

    Good to hear you got that to work, well done.
Sign In or Register to comment.