Error with developing a report in AL code for Dynamics 365 BC

Hi eveyone,
I don’t know if this is the best place to ask this question. I’m developing a new report, and the issue is this.
This is how the datset is defined:

dataset
    {
        dataitem(Item;Item)
        {
           DataItemTableView=SORTING("No.");
           RequestFilterFields = "No.","Inventory Posting Group","Location Filter","Variant Filter" ;
           trigger OnPreDataItem() 
           begin
                Location.SETRANGE("Use As In-Transit",FALSE);

                               DialogWindow.OPEN(Text000 +Text001 +Text002);
                               //BETEASTD SaveFilters := TRUE;
                               SaveFilters := FALSE; //BETEASTD
           end;
           trigger OnAfterGetRecord()
           var
               ItemVariant: Record 5401;
           begin
           IF SaveFilters THEN BEGIN
                                    LocationFilter := GETFILTER("Location Filter");
                                    VariantFilter := GETFILTER("Variant Filter");
                                    SaveFilters := FALSE;
                                  END;
                                  SETFILTER("Location Filter",LocationFilter);
                                  SETFILTER("Variant Filter",VariantFilter);
                                  Location.SETFILTER(Code,GETFILTER("Location Filter"));

                                  IF ReplacePreviousSKUs THEN BEGIN
                                    StockkeepingUnit.RESET;
                                    StockkeepingUnit.SETRANGE("Item No.","No.");
                                    IF GETFILTER("Variant Filter") <> '' THEN
                                      StockkeepingUnit.SETFILTER("Variant Code",GETFILTER("Variant Filter"));
                                    IF GETFILTER("Location Filter") <> '' THEN
                                      StockkeepingUnit.SETFILTER("Location Code",GETFILTER("Location Filter"));
                                    StockkeepingUnit.DELETEALL;
                                  END;

                                  DialogWindow.UPDATE(1,"No.");
                                  ItemVariant.SETRANGE("Item No.","No.");
                                  ItemVariant.SETFILTER(Code,GETFILTER("Variant Filter"));
                                  CASE TRUE OF
                                    (SKUCreationMethod = SKUCreationMethod::Location) OR
                                    ((SKUCreationMethod = SKUCreationMethod::"Location & Variant") AND
                                     (NOT ItemVariant.FIND('-'))):
                                      BEGIN
                                        IF Location.FIND('-') THEN
                                          REPEAT
                                            DialogWindow.UPDATE(2,Location.Code);
                                            SETRANGE("Location Filter",Location.Code);
                                            [b]CreateSKU(Item,Location.Code,'');[/b]
                                          UNTIL Location.NEXT = 0;
                                      END;
                                    (SKUCreationMethod = SKUCreationMethod::Variant) OR
                                    ((SKUCreationMethod = SKUCreationMethod::"Location & Variant") AND
                                     (NOT Location.FIND('-'))):
                                      BEGIN
                                        IF ItemVariant.FIND('-') THEN
                                          REPEAT
                                            DialogWindow.UPDATE(3,ItemVariant.Code);
                                            SETRANGE("Variant Filter",ItemVariant.Code);
                                            [b]CreateSKU(Item,'',ItemVariant.Code);[/b]
                                          UNTIL ItemVariant.NEXT = 0;
                                      END;
                                    (SKUCreationMethod = SKUCreationMethod::"Location & Variant"):
                                      BEGIN
                                        IF Location.FIND('-') THEN
                                          REPEAT
                                            DialogWindow.UPDATE(2,Location.Code);
                                            SETRANGE("Location Filter",Location.Code);
                                            IF ItemVariant.FIND('-') THEN
                                              REPEAT
                                                DialogWindow.UPDATE(3,ItemVariant.Code);
                                                SETRANGE("Variant Filter",ItemVariant.Code);
                                               [b] CreateSKU(Item,Location.Code,ItemVariant.Code);[/b]
                                              UNTIL ItemVariant.NEXT = 0;
                                          UNTIL Location.NEXT = 0;
                                      END;
                                  END;    
           end;

        }
    }

As you an see, I have 3 calls to the “CreateSKU” procedure, and I have this error:

2018_07_27_09_36_11_Window.png

I’ve defined the procedure inside the requestPage like this:

But it seems I should define it in other place. Any hint?

Thank you very much

Your local procedures should be at the end, outside of the request page, directly after the “var” statement

Thanks Thomas, it worked! I’ve solved before adding the procedure to a codeunit, and calling to the codeunit, but your solution is perfect.

Thank you very much!!