Report Date Ranges

CannikinCannikin Member Posts: 72
edited 2004-05-27 in Navision Attain
Hello! I just found you guys and am hoping you can help me out. Our company purchased Navision 6 months and are still making all kinds of changes. I kind of got volunteered to be the "expert" as far as making forms and such. My background is in web design and development (SQL Server & ColdFusion along with JavaScript and Flash's ActionScript), so C/SIDE is a little foreign to me, but I'm warming up to it. :) I'm familiar with programming concepts and techniques, I'm just not fluent in the syntax yet.

We have a report right now (it may be a default one included with the product) called "Sales History" and it's report # 10157. For some reason it only shows 8 "units" worth of data (in our case units = months) and we'd like to show the past year.

I can't for the life of me find where in the code that everything is limited to 8. I can find the loop that goes through each month and gets sales totals, quantities, etc., but not anything that actually says "never go past 8."

I tried cheating and just adding columns for 9-12 and making the appropriate changes to the arrays that are being used, but I get an error saying "the indexing 10 in the array is outside of the permitted range."

Any help would be greatly appreciated!

Thanks,
Rob

Comments

  • arunarun Member Posts: 4
    Hi Rob
    From the error message it seems you need to check the size of the array...increase it to accomodate your req.
  • CannikinCannikin Member Posts: 72
    Hi arun, thanks for the reply! Where can I change the length of an array at?

    I can't figure out how C/AL handles Arrays ... there's nothing in the help about actually creating an array, just a couple functions for working with them. I see tons of ARRAYLEN() checking going on in the code, but I never see anything being assigned to an array or a length being assigned! There are only 2 main chunks of code in the Report:

    In the "Item" DataItem:
    PrintLine := FALSE;
    CLEAR(QuantitySold);
    CLEAR("$Sold");
    CLEAR("Profit%");
    CLEAR(QuantitySoldPRYR);
    CALCFIELDS("Bill of Materials");
    FOR i := 1 TO ARRAYLEN(QuantitySold) DO
      BEGIN
        SETRANGE("Date Filter",DateRange[i],DateRange[i + 1] - 1);
        CALCFIELDS("Sales (Qty.)","Sales (LCY)", "COGS (LCY)");
        IF "Sales (Qty.)" <> 0 THEN BEGIN
          QuantitySold[i] := "Sales (Qty.)";
          "$Sold"[i] := "Sales (LCY)";
          Profit := "Sales (LCY)" - "COGS (LCY)";
          IF "Sales (LCY)" <> 0 THEN BEGIN
            "Profit%"[i] := ROUND(Profit / "Sales (LCY)" * 100,0.1);
            PrintLine := TRUE;
          END ELSE
            "Profit%"[i] := 0;
          SETRANGE("Date Filter",PriorYRMin[i],PriorYRMax[i]);
          CALCFIELDS("Sales (Qty.)");
          QuantitySoldPRYR[i] := "Sales (Qty.)";
        END;
      END;
    
    IF (NOT PrintLine) AND (OnlyItemsWithSales) THEN
      CurrReport.SKIP;
    

    And then in a blank entry in the DataItem:
    CompanyInformation.GET;
    ItemFilter := Item.GETFILTERS;
    FOR i := 2 TO ARRAYLEN(DateRange) DO
      DateRange[i] := CALCDATE(TimeDivision, DateRange[i - 1]);
    FOR i := 1 TO ARRAYLEN(PriorYRMin) DO BEGIN
      PriorYRMin[i] := CALCDATE('-1Y',DateRange[i]);
      PriorYRMax[i] := CALCDATE('-1Y',DateRange[i + 1]) - 1;
    END;
    

    It looks like everything depends on the value of QuantitySold, however nothing is ever assigned to it! It gets CLEAR()'d and then immediately used again without anything happening in between. I have no idea what's going on. :(
  • SavatageSavatage Member Posts: 7,142
    you said your company has it for 6 months. Your not going to get any older info.

    - Anyway I have 8 columns too - it looks like it was basically set up that way because that is all the columns that will fit on the page.

    If you select the options tab you can change the length of period to 2M
    this will cover a whole year
  • StephenGStephenG Member Posts: 99
    Cannikin wrote:
    Hi arun, thanks for the reply! Where can I change the length of an array at?

    I can't figure out how C/AL handles Arrays ... there's nothing in the help about actually creating an array, just a couple functions for working with them. I see tons of ARRAYLEN() checking going on in the code, but I never see anything being assigned to an array or a length being assigned! There are only 2 main chunks of code in the Report:

    To Create or Amend an array you need to find the Global/Local Variable
    click on it's properties and set the Dimensions property to the number you want in the array. :)
    Answer the question and wait for the answer.
  • arunarun Member Posts: 4
    Hi Rob
    I believe the report should suffice your req. with the period option as suggested by savatage... customization warrants a closer look...u have to change the sections also to accomodate the extra col. u want...

    for ur array probs. u may increase the size by going to global/local variables and increasing the dimension at its properties..
  • CannikinCannikin Member Posts: 72
    Thanks for the replies guys!

    The customization is no problem, I've already got it in Landscape and have more than enough room for the extra columns. But they still want the report broken down per month, not per 2 months. :)

    There aren't any arrays in the Global/Locals variable list, that's what's got me stumped! I have no idea where this array is coming from. Unless one of these is an array and I just don't know it?

    salesreport.jpg
  • StephenGStephenG Member Posts: 99
    Hi

    If you go into the Global Variable list and click on each line, whilst on that line click on the Properties icon on the toolbar or key in Shift+F4, you will then see a list of three properties, the second one Dimensions is the number of dimensions in the array.

    The arrays mentioned in the code you posted are
    PriorYRMin
    PriorYRMax
    QuantitySold
    $Sold
    Profit%
    QuantitySoldPRYR
    DateRange

    I can not do a screen dump as you have because the report you are using is a US localised object.

    I hope this helps point you in the right direction
    Answer the question and wait for the answer.
  • CannikinCannikin Member Posts: 72
    Holy cow it worked!! How did you know those were Arrays? I didn't even know that variables had associated properties like that.

    Thanks for the help everyone! :)
  • sjansjan Member Posts: 16
    Actualy, you don't now that some variable is ARRAY. You make it as ARRAY if you put some value in Dimensions (in Variable Properties). :)
Sign In or Register to comment.