Sales Statistics report with Shortcut Dimension 1 Code

Aravindh_NavisionAravindh_Navision Member Posts: 258
Hi Friends,

Am modifying the existing "Sales Statistics" report (Report ID: 112) to filter the report based on "Shortcut Dimension Code 1". Currently we can filter using "Global Dimension Code 1" and "Global Dimension Code 2" from "Customer" dataitem itself. I need to filter the "Shortcut Dimension Code 1" from Request form.
Declared variables: 
ShortcutDimCode1 - Code - 20
DefaultDim - Rec - "Default Dimension"
DimensionValue - Rec - "Dimension Value"

Actually what need to do is while clicking the ShortcutDimCode1 in request form, it look-ups "Dimension Value" form.
DimensionValue.SETFILTER(DimensionValue."Dimension Code", 'GEOSECTOR');
IF FORM.RUNMODAL(FORM::"Dimension Values",DimensionValue) = ACTION::LookupOK THEN BEGIN
  ShortcutDimCode1 := DimensionValue.Code;
END;

After selecting the Dimension Value in request form, the value should get filter with the "Dimension Value Code" field of "Default Dimension" table. Table ID field is always 18 (pointing Customer table).
Customer - OnPreDataItem()

DefaultDim.RESET;
DefaultDim.SETRANGE(DefaultDim."Dimension Value Code", ShortcutDimCode1);

IF DefaultDim.FINDFIRST THEN BEGIN
  REPEAT
    CustNo := DefaultDim."No.";
  UNTIL DefaultDim.NEXT = 0;
END;

Then it must display the corresponding Customers with the same Dimension Value Code.

I have mentioned the coding pieces that I did. I'm getting only 1 "Customer" of the "Dimension Value Code". But I need all the Customers to get displayed.

Can you please point out where I did mistake?

Thanks,
Aarvi.

Answers

  • Aravindh_NavisionAravindh_Navision Member Posts: 258
    Hi Guys !

    I have solved this issue by the following code. instead of doing it in Customer - OnPreDataItem(), i made the following code and solved this issue.

    Variables required..
    blCheck - boolean

    In Customer - OnAfterGetRecord()
    IF ShortcutDimCode1 <> '' THEN BEGIN
    CLEAR(blCheck);
    DefaultDim.RESET;
    DefaultDim.SETFILTER(DefaultDim."Dimension Value Code", ShortcutDimCode1);
    IF DefaultDim.FINDFIRST THEN BEGIN
      REPEAT
        IF Customer."No." = DefaultDim."No." THEN BEGIN
          blCheck := TRUE;
          ShortcutDimCodeValue := DefaultDim."Dimension Value Code";
    
          DimensionValue2.SETFILTER(DimensionValue2."Dimension Code",'GEOSECTOR');
          DimensionValue2.SETRANGE(DimensionValue2.Code,ShortcutDimCodeValue);
          IF DimensionValue2.FINDFIRST THEN
            ShortcutDimCodeValue1 := DimensionValue2.Name;
        END;
      UNTIL DefaultDim.NEXT = 0;
      codGeoSector := 'GEOSECTOR: ' + ShortcutDimCodeValue + ' - ' + ShortcutDimCodeValue1;
    END;
    
    IF blCheck = FALSE THEN
      CurrReport.SKIP;
    END;
    

    Hope the above code helps, if you need to do this type of report.

    Thanks,
    Aravindh
Sign In or Register to comment.