Monday, 31 August 2015

Loop Numbering

GeneralLedgerEntry.VALIDATE("G/L AccountNo", '100');
// This corresponds to:
GeneralLedgerEntry."G/L AccountNo" := '100';
GeneralLedgerEntry.VALIDATE("G/L AccountNo");

Record.FIELDERROR(Field, [Text])

Name := Record.FIELDNAME(Field)

//loop numbering

WITH SquashJnlLine DO BEGIN
  IF EmptyLine THEN
    EXIT;

  SquashJnlCheckLine.RunCheck(SquashJnlLine,TempJnlLineDim);

  IF NextEntryNo = 0 THEN BEGIN
    SquashLedgEntry.LOCKTABLE;
    IF SquashLedgEntry.FIND('+') THEN
      NextEntryNo := SquashLedgEntry."Entry No.";
      NextEntryNo := NextEntryNo + 1;
    END;

    IF SquashReg."No." = 0 THEN BEGIN
      SquashReg.LOCKTABLE;
      IF (NOT SquashReg.FIND('+')) OR ... THEN BEGIN
        SquashReg.INIT;
        SquashReg."No." := SquashReg."No." + 1;
        ...
        SquashReg.INSERT;
      END;
    END;
    SquashReg."To Entry No." := NextEntryNo;
    SquashReg.MODIFY;

How To create a report which is based on a temporary table?



How To create a report which is based on a temporary table?

Author: Luc Van Dyck

When you normally create a report, it is based on one or more tables.
Sometimes you need to create a temporary table (eg. to combine or sort data) and you want that data to appear in a report. The problem is that you can't use a temporary table directly in the DataItem-property of the report. It only accepts "real" tables.

The solution for this is to use the virtual table Integer instead, and write code to simulate the OnAfterGetRecord-trigger.

OnPreDataItem()
FOR i := 1 TO 80 DO BEGIN
  tmpItem.INIT;
  tmpItem."No." := FORMAT(i);
  tmpItem.Description := 'Item description ' + FORMAT(i);
  tmpItem."Unit Price" := i * 1000;
  tmpItem.INSERT;
END;

tmpItem.RESET;
SETRANGE(Number,1,tmpItem.COUNT);                                            
                                               
OnAfterGetRecord()
IF Number = 1 THEN
  tmpItem.FIND('-')
ELSE
  tmpItem.NEXT;

When defining the layout of your report, you use this Integer-dataitem to place your headers and body's.
You can't use the Field Menu to place fields on your report: you have to type the name of your tmp-variable together with the fieldname (eg. tmpItem.Description).

The result is a normally looking report:

Export Budget

OBJECT Report 82 Export Budget to Excel
{
  OBJECT-PROPERTIES
  {
    Date=09/07/12;
    Time=12:00:00 PM;
    Version List=NAVW17.00;
  }
  PROPERTIES
  {
    CaptionML=[ENU=Export Budget to Excel;
               FRA=Exporter budget vers Excel;
               ESM=Exportar ppto. a Excel;
               ENC=Export Budget to Excel];
    ProcessingOnly=Yes;
    OnPreReport=BEGIN
                  DimSelectionBuf.CompareDimText(
                    3,REPORT::"Export Budget to Excel",'',ColumnDim,Text000);
                END;

  }
  DATASET
  {
    { 3459;    ;DataItem;                    ;
               DataItemTable=Table96;
               DataItemTableView=SORTING(Budget Name,G/L Account No.,Business Unit Code,Global Dimension 1 Code,Global Dimension 2 Code,Budget Dimension 1 Code,Budget Dimension 2 Code,Budget Dimension 3 Code,Budget Dimension 4 Code,Date);
               OnPreDataItem=VAR
                               BusUnit@1000 : Record 220;
                             BEGIN
                               IF GETRANGEMIN("Budget Name") <> GETRANGEMAX("Budget Name") THEN
                                 ERROR(Text001);

                               IF (StartDate = 0D) OR
                                  (NoOfPeriods = 0) OR
                                  (FORMAT(PeriodLength) = '')
                               THEN
                                 ERROR(Text002);

                               SelectedDim.RESET;
                               SelectedDim.SETRANGE("User ID",USERID);
                               SelectedDim.SETRANGE("Object Type",3);
                               SelectedDim.SETRANGE("Object ID",REPORT::"Export Budget to Excel");
                               i := 0;
                               IF BusUnit.FINDFIRST THEN BEGIN
                                 i := i + 1;
                                 BusUnitDimIndex := i;
                                 BusUnitDimCode := COPYSTR(UPPERCASE(BusUnit.TABLECAPTION),1,MAXSTRLEN(ColumnDimCode[1]));
                                 ColumnDimCode[BusUnitDimIndex] := BusUnitDimCode;
                               END;
                               IF SelectedDim.FIND('-') THEN
                                 REPEAT
                                   i := i + 1;
                                   IF i > ARRAYLEN(ColumnDimCode) THEN
                                     ERROR(Text003,ARRAYLEN(ColumnDimCode));
                                   ColumnDimCode[i] := SelectedDim."Dimension Code";
                                 UNTIL (SelectedDim.NEXT = 0) OR (i = 8);
                               NoOfDimensions := i;

                               FOR i := 1 TO NoOfPeriods DO BEGIN
                                 IF i = 1 THEN
                                   TempPeriod."Period Start" := StartDate
                                 ELSE
                                   TempPeriod."Period Start" := CALCDATE(PeriodLength,TempPeriod."Period Start");
                                 TempPeriod."Period End" := CALCDATE(PeriodLength,TempPeriod."Period Start");
                                 TempPeriod."Period End" := CALCDATE('<-1D>',TempPeriod."Period End");
                                 TempPeriod."Period No." := i;
                                 TempPeriod.INSERT;
                               END;

                               SETRANGE(Date,StartDate,TempPeriod."Period End");
                               TempBudgetBuf2.DELETEALL;
                               ExcelBuf.DELETEALL;
                             END;

               OnAfterGetRecord=BEGIN
                                  CLEAR(TempBudgetBuf1);
                                  TempBudgetBuf1."G/L Account No." := "G/L Account No.";
                                  TempBudgetBuf1."Dimension Value Code 1" := GetDimValueCode(ColumnDimCode[1]);
                                  TempBudgetBuf1."Dimension Value Code 2" := GetDimValueCode(ColumnDimCode[2]);
                                  TempBudgetBuf1."Dimension Value Code 3" := GetDimValueCode(ColumnDimCode[3]);
                                  TempBudgetBuf1."Dimension Value Code 4" := GetDimValueCode(ColumnDimCode[4]);
                                  TempBudgetBuf1."Dimension Value Code 5" := GetDimValueCode(ColumnDimCode[5]);
                                  TempBudgetBuf1."Dimension Value Code 6" := GetDimValueCode(ColumnDimCode[6]);
                                  TempBudgetBuf1."Dimension Value Code 7" := GetDimValueCode(ColumnDimCode[7]);
                                  TempBudgetBuf1."Dimension Value Code 8" := GetDimValueCode(ColumnDimCode[8]);
                                  TempBudgetBuf1.Date := CalcPeriodStart(Date);
                                  TempBudgetBuf1.Amount := Amount;

                                  TempBudgetBuf2 := TempBudgetBuf1;
                                  IF TempBudgetBuf2.FIND THEN BEGIN
                                    TempBudgetBuf2.Amount :=
                                      TempBudgetBuf2.Amount + TempBudgetBuf1.Amount;
                                    TempBudgetBuf2.MODIFY;
                                  END ELSE
                                    TempBudgetBuf2.INSERT;
                                END;

               OnPostDataItem=VAR
                                DimValue@1004 : Record 349;
                                BusUnit@1007 : Record 220;
                                Window@1000 : Dialog;
                                RecNo@1001 : Integer;
                                TotalRecNo@1002 : Integer;
                                Continue@1003 : Boolean;
                                LastBudgetRowNo@1005 : Integer;
                                DimensionRange@1006 : ARRAY [2,8] OF Integer;
                              BEGIN
                                Window.OPEN(
                                  Text005 +
                                  '@1@@@@@@@@@@@@@@@@@@@@@@@@@\');
                                Window.UPDATE(1,0);
                                TotalRecNo := GLAcc.COUNT;
                                RecNo := 0;

                                RowNo := 1;
                                EnterCell(RowNo,1,Text006,FALSE,TRUE,'',ExcelBuf."Cell Type"::Text);
                                EnterCell(RowNo,2,'',FALSE,TRUE,'',ExcelBuf."Cell Type"::Text);
                                EnterFilterInCell(GETFILTER("Budget Name"),FIELDCAPTION("Budget Name"));

                                GLSetup.GET;
                                EnterFilterInCell(GETFILTER("Business Unit Code"),FIELDCAPTION("Business Unit Code"));
                                IF GLSetup."Global Dimension 1 Code" <> '' THEN BEGIN
                                  Dim.GET(GLSetup."Global Dimension 1 Code");
                                  EnterFilterInCell(GETFILTER("Global Dimension 1 Code"),Dim."Code Caption");
                                END;
                                IF GLSetup."Global Dimension 2 Code" <> '' THEN BEGIN
                                  Dim.GET(GLSetup."Global Dimension 2 Code");
                                  EnterFilterInCell(GETFILTER("Global Dimension 2 Code"),Dim."Code Caption");
                                END;
                                GLBudgetName.GET(GETFILTER("Budget Name"));
                                IF GLBudgetName."Budget Dimension 1 Code" <> '' THEN BEGIN
                                  Dim.GET(GLBudgetName."Budget Dimension 1 Code");
                                  EnterFilterInCell(GETFILTER("Budget Dimension 1 Code"),Dim."Code Caption");
                                END;
                                IF GLBudgetName."Budget Dimension 2 Code" <> '' THEN BEGIN
                                  Dim.GET(GLBudgetName."Budget Dimension 2 Code");
                                  EnterFilterInCell(GETFILTER("Budget Dimension 2 Code"),Dim."Code Caption");
                                END;
                                IF GLBudgetName."Budget Dimension 3 Code" <> '' THEN BEGIN
                                  Dim.GET(GLBudgetName."Budget Dimension 3 Code");
                                  EnterFilterInCell(GETFILTER("Budget Dimension 3 Code"),Dim."Code Caption");
                                END;
                                IF GLBudgetName."Budget Dimension 4 Code" <> '' THEN BEGIN
                                  Dim.GET(GLBudgetName."Budget Dimension 4 Code");
                                  EnterFilterInCell(GETFILTER("Budget Dimension 4 Code"),Dim."Code Caption");
                                END;

                                RowNo := RowNo + 2;
                                HeaderRowNo := RowNo;
                                EnterCell(HeaderRowNo,1,FIELDCAPTION("G/L Account No."),FALSE,TRUE,'',ExcelBuf."Cell Type"::Text);
                                EnterCell(HeaderRowNo,2,GLAcc.FIELDCAPTION(Name),FALSE,TRUE,'',ExcelBuf."Cell Type"::Text);
                                i := 0;
                                ColNo := 2;
                                Continue := TRUE;
                                WHILE Continue DO BEGIN
                                  i := i + 1;
                                  IF i > 8 THEN
                                    Continue := FALSE
                                  ELSE
                                    IF ColumnDimCode[i] = '' THEN
                                      Continue := FALSE;
                                  IF Continue THEN BEGIN
                                    ColNo := ColNo + 1;
                                    IF i = BusUnitDimIndex THEN
                                      EnterCell(HeaderRowNo,ColNo,BusUnit.TABLECAPTION,FALSE,TRUE,'',ExcelBuf."Cell Type"::Text)
                                    ELSE BEGIN
                                      Dim.GET(ColumnDimCode[i]);
                                      EnterCell(HeaderRowNo,ColNo,Dim."Code Caption",FALSE,TRUE,'',ExcelBuf."Cell Type"::Text);
                                    END;
                                  END;
                                END;
                                IF TempPeriod.FIND('-') THEN
                                  REPEAT
                                    ColNo := ColNo + 1;
                                    EnterCell(HeaderRowNo,ColNo,FORMAT(TempPeriod."Period Start"),FALSE,TRUE,'',ExcelBuf."Cell Type"::Date);
                                  UNTIL TempPeriod.NEXT = 0;

                                COPYFILTER("G/L Account No.",GLAcc."No.");
                                IF GLAcc.FIND('-') THEN
                                  REPEAT
                                    RecNo := RecNo + 1;
                                    Window.UPDATE(1,ROUND(RecNo / TotalRecNo * 10000,1));
                                    RowNo := RowNo + 1;
                                    EnterCell(
                                      RowNo,2,COPYSTR(COPYSTR(PADSTR(' ',100),1,2 * GLAcc.Indentation + 1) + GLAcc.Name,2),
                                      GLAcc."Account Type" <> GLAcc."Account Type"::Posting,FALSE,'',ExcelBuf."Cell Type"::Text);
                                    EnterCell(
                                      RowNo,1,GLAcc."No.",GLAcc."Account Type" <> GLAcc."Account Type"::Posting,FALSE,'',ExcelBuf."Cell Type"::Text);
                                    IF (GLAcc.Totaling = '') OR (NOT IncludeTotalingFormulas) THEN BEGIN
                                      TempBudgetBuf2.SETRANGE("G/L Account No.",GLAcc."No.");
                                      IF TempBudgetBuf2.FIND('-') THEN BEGIN
                                        TempBudgetBuf1 := TempBudgetBuf2;
                                        EnterDimValues;
                                        IF TempPeriod.FIND('-') THEN;
                                        REPEAT
                                          IF (TempBudgetBuf1."Dimension Value Code 1" <>
                                              TempBudgetBuf2."Dimension Value Code 1") OR
                                             (TempBudgetBuf1."Dimension Value Code 2" <>
                                              TempBudgetBuf2."Dimension Value Code 2") OR
                                             (TempBudgetBuf1."Dimension Value Code 3" <>
                                              TempBudgetBuf2."Dimension Value Code 3") OR
                                             (TempBudgetBuf1."Dimension Value Code 4" <>
                                              TempBudgetBuf2."Dimension Value Code 4") OR
                                             (TempBudgetBuf1."Dimension Value Code 5" <>
                                              TempBudgetBuf2."Dimension Value Code 5") OR
                                             (TempBudgetBuf1."Dimension Value Code 6" <>
                                              TempBudgetBuf2."Dimension Value Code 6") OR
                                             (TempBudgetBuf1."Dimension Value Code 7" <>
                                              TempBudgetBuf2."Dimension Value Code 7") OR
                                             (TempBudgetBuf1."Dimension Value Code 8" <>
                                              TempBudgetBuf2."Dimension Value Code 8")
                                          THEN BEGIN
                                            RowNo := RowNo + 1;
                                            EnterCell(
                                              RowNo,1,GLAcc."No.",GLAcc."Account Type" <> GLAcc."Account Type"::Posting,FALSE,'',ExcelBuf."Cell Type"::Text);
                                            EnterDimValues;
                                            TempBudgetBuf1 := TempBudgetBuf2;
                                          END;
                                          TempPeriod.GET(0,TempBudgetBuf2.Date);
                                          EnterCell(
                                            RowNo,NoOfDimensions + 2 + TempPeriod."Period No.",
                                            FORMAT(TempBudgetBuf2.Amount,0,1),GLAcc."Account Type" <> GLAcc."Account Type"::Posting,
                                            FALSE,'#,##0.00',ExcelBuf."Cell Type"::Number);
                                          TempPeriod.NEXT;
                                        UNTIL TempBudgetBuf2.NEXT = 0;
                                      END ELSE BEGIN
                                        CLEAR(TempBudgetBuf2);
                                        EnterDimValues;
                                      END;
                                    END ELSE
                                      IF TempPeriod.FIND('-') THEN BEGIN
                                        REPEAT
                                          EnterFormula(
                                            RowNo,
                                            NoOfDimensions + 2 + TempPeriod."Period No.",
                                            GLAcc.Totaling,
                                            GLAcc."Account Type" <> GLAcc."Account Type"::Posting,
                                            FALSE,
                                            '#,##0.00');
                                        UNTIL TempPeriod.NEXT = 0;
                                      END;
                                  UNTIL GLAcc.NEXT = 0;
                                IF IncludeTotalingFormulas THEN
                                  HasFormulaError := ExcelBuf.ExportBudgetFilterToFormula(ExcelBuf);
                                Window.CLOSE;
                                LastBudgetRowNo := RowNo;

                                RowNo := RowNo + 200; // Move way below the budget
                                FOR i := 1 TO NoOfDimensions DO
                                  IF i = BusUnitDimIndex THEN BEGIN
                                    IF BusUnit.FINDSET THEN BEGIN
                                      DimensionRange[1,i] := RowNo;
                                      REPEAT
                                        EnterCell(RowNo,1,BusUnit.Code,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
                                        RowNo := RowNo + 1;
                                      UNTIL BusUnit.NEXT = 0;
                                      DimensionRange[2,i] := RowNo - 1;
                                    END;
                                  END ELSE BEGIN
                                    DimValue.SETRANGE("Dimension Code",ColumnDimCode[i]);
                                    DimValue.SETFILTER("Dimension Value Type",'%1|%2',
                                      DimValue."Dimension Value Type"::Standard,DimValue."Dimension Value Type"::"Begin-Total");
                                    IF DimValue.FINDSET(FALSE,FALSE) THEN BEGIN
                                      DimensionRange[1,i] := RowNo;
                                      REPEAT
                                        EnterCell(RowNo,1,DimValue.Code,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
                                        RowNo := RowNo + 1;
                                      UNTIL DimValue.NEXT = 0;
                                      DimensionRange[2,i] := RowNo - 1;
                                    END;
                                  END;

                                IF HasFormulaError THEN
                                  IF NOT CONFIRM(STRSUBSTNO(Text007,ExcelBuf.GetExcelReference(7))) THEN
                                    CurrReport.BREAK;

                                ExcelBuf.CreateBook(ExcelBuf.GetExcelReference(10));
                                ExcelBuf.SetCurrent(HeaderRowNo + 1,1);
                                ExcelBuf.StartRange;
                                ExcelBuf.SetCurrent(LastBudgetRowNo,1);
                                ExcelBuf.EndRange;
                                ExcelBuf.CreateRange(ExcelBuf.GetExcelReference(8));
                                IF TempPeriod.FIND('-') THEN BEGIN
                                  REPEAT
                                    ExcelBuf.SetCurrent(HeaderRowNo + 1,NoOfDimensions + 2 + TempPeriod."Period No.");
                                    ExcelBuf.StartRange;
                                    ExcelBuf.SetCurrent(LastBudgetRowNo,NoOfDimensions + 2 + TempPeriod."Period No.");
                                    ExcelBuf.EndRange;
                                    ExcelBuf.CreateRange(ExcelBuf.GetExcelReference(9) + FORMAT(TempPeriod."Period No."));
                                  UNTIL TempPeriod.NEXT = 0;
                                END;

                                FOR i := 1 TO NoOfDimensions DO BEGIN
                                  ExcelBuf.SetCurrent(HeaderRowNo + 1,i + 2);
                                  ExcelBuf.StartRange;
                                  ExcelBuf.SetCurrent(LastBudgetRowNo,i + 2);
                                  ExcelBuf.EndRange;
                                  ExcelBuf.CreateRange('NAV_DIM' + FORMAT(i));
                                  ExcelBuf.SetCurrent(DimensionRange[1,i],1);
                                  ExcelBuf.StartRange;
                                  ExcelBuf.SetCurrent(DimensionRange[2,i],1);
                                  ExcelBuf.EndRange;
                                  ExcelBuf.CreateValidationRule('NAV_DIM' + FORMAT(i));
                                END;

                                ExcelBuf.WriteSheet(
                                  PADSTR(STRSUBSTNO('%1 %2',GLBudgetName.Name,GLBudgetName.Description),30),
                                  COMPANYNAME,
                                  USERID);

                                ExcelBuf.CloseBook;
                                ExcelBuf.OpenExcel;
                                ExcelBuf.GiveUserControl;
                              END;

               ReqFilterFields=Budget Name,Business Unit Code,G/L Account No.,Global Dimension 1 Code,Global Dimension 2 Code,Budget Dimension 1 Code,Budget Dimension 2 Code,Budget Dimension 3 Code,Budget Dimension 4 Code }

  }
  REQUESTPAGE
  {
    PROPERTIES
    {
      SaveValues=Yes;
      OnOpenPage=BEGIN
                   ColumnDim := DimSelectionBuf.GetDimSelectionText(3,REPORT::"Export Budget to Excel",'');
                 END;

    }
    CONTROLS
    {
      { 1900000001;0;Container;
                  ContainerType=ContentArea }

      { 1900000002;1;Group  ;
                  CaptionML=[ENU=Options;
                             FRA=Options;
                             ESM=Opciones;
                             ENC=Options] }

      { 1   ;2   ;Field     ;
                  CaptionML=[ENU=Start Date;
                             FRA=Date d‚but;
                             ESM=Fecha inicio;
                             ENC=Start Date];
                  SourceExpr=StartDate }

      { 5   ;2   ;Field     ;
                  CaptionML=[ENU=No. of Periods;
                             FRA=Nombre de p‚riodes;
                             ESM=N§ de periodos;
                             ENC=No. of Periods];
                  SourceExpr=NoOfPeriods }

      { 3   ;2   ;Field     ;
                  CaptionML=[ENU=Period Length;
                             FRA=Base p‚riode;
                             ESM=Longitud periodo;
                             ENC=Period Length];
                  SourceExpr=PeriodLength }

      { 7   ;2   ;Field     ;
                  CaptionML=[ENU=Column Dimensions;
                             FRA=Axes colonne;
                             ESM=Dimensiones columna;
                             ENC=Column Dimensions];
                  SourceExpr=ColumnDim;
                  Editable=FALSE;
                  OnAssistEdit=BEGIN
                                 DimSelectionBuf.SetDimSelectionMultiple(3,REPORT::"Export Budget to Excel",ColumnDim);
                               END;
                                }

      { 10  ;2   ;Field     ;
                  CaptionML=[ENU=Include Totaling Formulas;
                             FRA=Inclure formules de calcul;
                             ESM=Incluir total f¢rmulas;
                             ENC=Include Totalling Formulas];
                  SourceExpr=IncludeTotalingFormulas }

    }
  }
  LABELS
  {
  }
  CODE
  {
    VAR
      Text000@1000 : TextConst 'ENU=Column Dimensions;FRA=Axes colonne;ESM=Dimensiones columna;ENC=Column Dimensions';
      Text001@1001 : TextConst 'ENU=You can only export one budget at a time.;FRA=Vous ne pouvez exporter qu''un budget … la fois.;ESM=S¢lo puede exportar un ppto. de una vez.;ENC=You can only export one budget at a time.';
      Text002@1002 : TextConst 'ENU=You must specify a Start Date, a No of Periods and a Period Length.;FRA=Vous devez sp‚cifier une date de d‚but, une base p‚riode et un nombre de p‚riodes.;ESM=Debe especificar fecha inicio, n§ de periodos y longitud periodo.;ENC=You must specify a Start Date, a No of Periods and a Period Length.';
      Text003@1003 : TextConst 'ENU=You can only select a maximum of %1 column dimensions.;FRA=Vous pouvez seulement s‚lectionner un maximum de %1 axe(s) colonne.;ESM=S¢lo puede seleccionar un m ximo de %1 dim. columnas.;ENC=You can only select a maximum of %1 column dimensions.';
      Text005@1004 : TextConst 'ENU=Analyzing Data...\\;FRA=Analyse des donn‚es...\\;ESM=Analizar Datos...\\;ENC=Analysing Data...\\';
      Text006@1005 : TextConst 'ENU=Export Filters;FRA=Exporter filtres;ESM=Exportar filtros;ENC=Export Filters';
      Text007@1006 : TextConst 'ENU=Some filters cannot be converted into Excel formulas. You will have to check %1 errors in the Excel worksheet. Do you want to create the Excel worksheet ?;FRA=Certains filtres ne peuvent pas ˆtre convertis en formules Excel. Vous devez rem‚dier aux erreurs rencontr‚es (%1) dans la feuille Excel. Souhaitez-vous cr‚er une feuille Excel ?;ESM=Algunos filtros no pueden convertirse en f¢rmulas de Excel. Tendr  que comprobar los errores %1 en la hoja de Excel. ¨Quiere crear la hoja de Excel?;ENC=Some filters cannot be converted into Excel formulas. You will have to check %1 errors in the Excel worksheet. Do you want to create the Excel worksheet ?';
      TempPeriod@1007 : TEMPORARY Record 2000000007;
      SelectedDim@1009 : Record 369;
      TempBudgetBuf1@1010 : TEMPORARY Record 371;
      TempBudgetBuf2@1011 : TEMPORARY Record 371;
      DimSetEntry@1012 : Record 480;
      GLSetup@1013 : Record 98;
      Dim@1014 : Record 348;
      GLBudgetName@1015 : Record 95;
      ExcelBuf@1016 : TEMPORARY Record 370;
      GLAcc@1017 : Record 15;
      DimSelectionBuf@1018 : Record 368;
      StartDate@1019 : Date;
      PeriodLength@1020 : DateFormula;
      NoOfPeriods@1021 : Integer;
      NoOfDimensions@1022 : Integer;
      i@1023 : Integer;
      RowNo@1024 : Integer;
      ColNo@1025 : Integer;
      ColumnDim@1026 : Text[250];
      ColumnDimCode@1027 : ARRAY [8] OF Code[20];
      HasFormulaError@1028 : Boolean;
      IncludeTotalingFormulas@1029 : Boolean;
      HeaderRowNo@1030 : Integer;
      BusUnitDimIndex@1008 : Integer;
      BusUnitDimCode@1031 : Code[20];

    LOCAL PROCEDURE CalcPeriodStart@1(EntryDate@1000 : Date) : Date;
    BEGIN
      TempPeriod."Period Start" := EntryDate;
      TempPeriod.FIND('=<');
      EXIT(TempPeriod."Period Start");
    END;

    LOCAL PROCEDURE GetDimValueCode@2(DimCode@1000 : Code[20]) : Code[20];
    BEGIN
      IF DimCode = '' THEN
        EXIT('');
      IF DimCode = BusUnitDimCode THEN
        EXIT("G/L Budget Entry"."Business Unit Code");
      DimSetEntry.SETRANGE("Dimension Set ID","G/L Budget Entry"."Dimension Set ID");
      DimSetEntry.SETRANGE("Dimension Code",DimCode);
      IF DimSetEntry.FINDFIRST THEN
        EXIT(DimSetEntry."Dimension Value Code");
      EXIT('');
    END;

    LOCAL PROCEDURE EnterCell@3(RowNo@1000 : Integer;ColumnNo@1001 : Integer;CellValue@1002 : Text[250];Bold@1003 : Boolean;UnderLine@1004 : Boolean;NumberFormat@1005 : Text[30];CellType@1006 : Option);
    BEGIN
      ExcelBuf.INIT;
      ExcelBuf.VALIDATE("Row No.",RowNo);
      ExcelBuf.VALIDATE("Column No.",ColumnNo);
      ExcelBuf."Cell Value as Text" := CellValue;
      ExcelBuf.Formula := '';
      ExcelBuf.Bold := Bold;
      ExcelBuf.Underline := UnderLine;
      ExcelBuf.NumberFormat := NumberFormat;
      ExcelBuf."Cell Type" := CellType;
      ExcelBuf.INSERT;
    END;

    LOCAL PROCEDURE EnterFilterInCell@5(Filter@1000 : Text[250];FieldName@1001 : Text[100]);
    BEGIN
      IF Filter <> '' THEN BEGIN
        RowNo := RowNo + 1;
        EnterCell(RowNo,1,FieldName,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
        EnterCell(RowNo,2,Filter,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
      END;
    END;

    LOCAL PROCEDURE EnterDimValue@7(ColDimIndex@1000 : Integer;DimValueCode@1001 : Code[20]);
    BEGIN
      IF ColumnDimCode[ColDimIndex] <> '' THEN BEGIN
        ColNo := ColNo + 1;
        EnterCell(RowNo,ColNo,DimValueCode,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
      END;
    END;

    LOCAL PROCEDURE EnterDimValues@6();
    BEGIN
      ColNo := 2;
      EnterDimValue(1,TempBudgetBuf2."Dimension Value Code 1");
      EnterDimValue(2,TempBudgetBuf2."Dimension Value Code 2");
      EnterDimValue(3,TempBudgetBuf2."Dimension Value Code 3");
      EnterDimValue(4,TempBudgetBuf2."Dimension Value Code 4");
      EnterDimValue(5,TempBudgetBuf2."Dimension Value Code 5");
      EnterDimValue(6,TempBudgetBuf2."Dimension Value Code 6");
      EnterDimValue(7,TempBudgetBuf2."Dimension Value Code 7");
      EnterDimValue(8,TempBudgetBuf2."Dimension Value Code 8");
    END;

    LOCAL PROCEDURE EnterFormula@8(RowNo@1000 : Integer;ColumnNo@1001 : Integer;CellValue@1002 : Text[250];Bold@1005 : Boolean;UnderLine@1006 : Boolean;NumberFormat@1003 : Text[30]);
    BEGIN
      ExcelBuf.INIT;
      ExcelBuf.VALIDATE("Row No.",RowNo);
      ExcelBuf.VALIDATE("Column No.",ColumnNo);
      ExcelBuf."Cell Value as Text" := '';
      ExcelBuf.Formula := CellValue; // is converted to formula later.
      ExcelBuf.Bold := Bold;
      ExcelBuf.Underline := UnderLine;
      ExcelBuf.NumberFormat := NumberFormat;
      ExcelBuf.INSERT;
    END;

    BEGIN
    END.
  }
  RDLDATA
  {
  }
}