Customized Planning Worksheet for Multiple Locations

KWevickKWevick Member Posts: 103
This keeps coming up with clients who have multiple locations within the same facility and want to do combined planning, so before we start the customization process I would like to know if anyone else has customized the planning worksheet to consider multiple locations as one during the PW regeneration? This is in a non-warehouse environment, however, there is tracking involved. In this case, it is not feasible to use SKU's as the supply paths are many-to-many. I know how NAV works and have implemented planning successfully at other clients with different environments, but unfortunately the business requirements are different with these clients.

Thanks for your help.
Karen

Comments

  • ara3nara3n Member Posts: 9,256
    Hello Karen.

    I had similar requirements a few years ago. The customer had several stores/location close by and they wanted MRP to run as one. So that it suggest transfers from one location to the other. Etc.

    I decided to not modify MRP. Instead my idea was to setup SKU and set replenishment method to Transfer from other location. That way I would loop through each location and suggest anything available from other locations. Afterwards I would set the planning resiliency to non on the created req lines. Afterwards update the SKU transfer from location code to a second location and run it for the second locations. Now this does increase the time by a lot. But it's much simpler modification. One new report.
    Modifying MRP is a major modification. Another option you could do is this. Nightly copy the database to separate db. Merge the locations into One. There is a download link on how to merge customers/location/vendor. viewtopic.php?f=5&t=15580

    Run MRP. It will create the Req lines. Export them from the db and import them into production. Very simple process.


    Here is the report I mentioned.
    OBJECT Report 50052 Calculate Requisition
    {
      OBJECT-PROPERTIES
      {
        Date=08/16/07;
        Time=[ 6:57:13 PM];
        Modified=Yes;
        Version List=NAVW14.00;
      }
      PROPERTIES
      {
        CaptionML=[ENU=Calculate Plan - Req. Wksh.;
                   ESM=Calcular plan - Hoja demanda;
                   FRC=Calculer planning - F. demande;
                   ENC=Calculate Plan - Req. Wksh.];
        ProcessingOnly=Yes;
        OnInitReport=BEGIN
                       OrderDate := TODAY;
                       ToDate := TODAY + 30;
                     END;
    
        OnPreReport=BEGIN
                      Counter := 0;
                      MaxDate:= 12319999D;
                      IF OrderDate = 0D THEN
                        ERROR(Text002);
                      IF ToDate = 0D THEN
                        ERROR(Text003);
                      PeriodLength := ToDate - OrderDate + 1;
                      IF PeriodLength <= 0 THEN
                        ERROR(Text004);
    
                      IF (Item.GETFILTER("Variant Filter") <> '') AND
                         (MfgSetup."Current Production Forecast" <> '')
                      THEN BEGIN
                        ForecastEntry.SETCURRENTKEY("Production Forecast Name","Item No.","Location Code","Forecast Date","Component Forecast");
                        ForecastEntry.SETRANGE("Production Forecast Name",MfgSetup."Current Production Forecast");
                        Item.COPYFILTER("No.",ForecastEntry."Item No.");
                        IF MfgSetup."Use Forecast on Locations" THEN
                          Item.COPYFILTER("Location Filter",ForecastEntry."Location Code");
                        IF ForecastEntry.FIND('-') THEN
                          ERROR(Text005);
                      END;
    
                      ReqLine.SETRANGE("Worksheet Template Name",CurrTemplateName);
                      ReqLine.SETRANGE("Journal Batch Name",CurrWorksheetName);
    
                      Window.OPEN(
                        Text006 +
                        Text007);
    
                      MySalesLine.COPYFILTERS(DummySalesLine);
                    END;
    
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table5700;
            DataItemTableView=SORTING(Item No.,Location Code,Variant Code);
            OnPreDataItem=BEGIN
                            IF RunMRPForLocation.Code = '' THEN
                              ERROR('Please select the current Location');
                            RunMRPForLocation.GET(RunMRPForLocation.Code);
    
                            SETFILTER("Location Code",'<>%1',RunMRPForLocation.Code);
                            tempReqLine.DELETEALL;
                          END;
    
            OnAfterGetRecord=VAR
                               ReservationEntry@1000000000 : Record 337;
                               ReservationEntry2@1000000001 : Record 337;
                             BEGIN
                               IF Counter MOD 10 = 0 THEN
                                 Window.UPDATE(1,"Item No.");
    
                               //S001 Start
                               MySalesLine.SETCURRENTKEY("Document Type",Type,"No.");
                               MySalesLine.SETRANGE("Document Type",MySalesLine."Document Type"::Order);
                               MySalesLine.SETRANGE(Type,MySalesLine.Type::Item);
                               MySalesLine.SETRANGE("No.","Item No.");
                               IF NOT MySalesLine.FINDFIRST THEN
                                 CurrReport.SKIP;
    
    
                               CLEAR(gSKU);
                               gSKU.SETRANGE("Item No.","Item No.");
                               gSKU.MODIFYALL("Replenishment System" ,"Replenishment System"::Purchase);
                               gSKU.MODIFYALL("Transfer-from Code",'');
    
    
                               IF (LastSKU."Item No." <> "Item No.") OR (LastSKU."Item No." <> '') THEN BEGIN
                                 LastSKU.SETRANGE("Item No.","Item No.");
                                 LastSKU.SETFILTER("Location Code",'<>%1',RunMRPForLocation.Code);
                                 LastSKU.FINDLAST;
                                 RunForAllLocation := TRUE;
                                 RunMRP;
                                 RunForAllLocation := FALSE;
                               END;
    
                               CLEAR(FromSKU);
                               FromSKU.GET(RunMRPForLocation.Code,"Item No.",'');
                               FromSKU.VALIDATE("Replenishment System" ,FromSKU."Replenishment System"::Transfer);
                               FromSKU.VALIDATE("Transfer-from Code","Location Code");
                               FromSKU.MODIFY;
    
    
                               ForSKU.GET("Location Code","Item No.","Variant Code");
    
                               RunMRP;
    
    
                               //S001 Start
                               //Split the Reqline by Order
                               gReqLine.RESET;
                               gReqLine.SETRANGE("Worksheet Template Name",  CurrTemplateName);
                               gReqLine.SETRANGE("Journal Batch Name",CurrWorksheetName);
                               gReqLine.SETRANGE("No.",Item."No.");
                               gReqLine.SETRANGE("Replenishment System",gReqLine."Replenishment System"::Transfer);
                               gReqLine.MODIFYALL("Planning Flexibility",gReqLine."Planning Flexibility"::None);
    
                               gReqLine.RESET;
                               gReqLine.SETRANGE("Worksheet Template Name",  CurrTemplateName);
                               gReqLine.SETRANGE("Journal Batch Name",CurrWorksheetName);
                               gReqLine.SETRANGE("No.","Item No.");
                               IF gReqLine.FIND('-') THEN REPEAT
                                 gCounter += 1;
                                 tempReqLine := gReqLine;
                                 tempReqLine."Line No." := tempReqLine."Line No." + gCounter;
                                 IF tempReqLine.INSERT THEN;
                               UNTIL gReqLine.NEXT = 0;
    
                               CLEAR(gReqLine);
                               gReqLine.SETRANGE("Worksheet Template Name",  CurrTemplateName);
                               gReqLine.SETRANGE("Journal Batch Name",CurrWorksheetName);
                               gReqLine.SETRANGE("No.",Item."No.");
                               gReqLine.SETFILTER("Location Code",'<>%1',FromSKU."Location Code");
                               gReqLine.SETRANGE("Replenishment System",gReqLine."Replenishment System"::Purchase);
                               IF gReqLine.FIND('-') THEN REPEAT
                                 ReservationEntry.SETCURRENTKEY("Source ID","Source Ref. No.","Source Type");
                                 ReservationEntry.SETRANGE("Source ID",gReqLine."Worksheet Template Name");
                                 ReservationEntry.SETRANGE("Source Batch Name",gReqLine."Journal Batch Name");
                                 ReservationEntry.SETRANGE("Source Ref. No.",gReqLine."Line No.");
                                 IF ReservationEntry.FIND('-') THEN REPEAT
                                    IF ReservationEntry2.GET(ReservationEntry."Entry No.",NOT ReservationEntry.Positive) AND
                                      gReqLine2.GET(ReservationEntry2."Source ID",ReservationEntry2."Source Batch Name",ReservationEntry2."Source Ref. No.")
                                      THEN BEGIN
                                      IF gReqLine2.Quantity > gReqLine.Quantity THEN BEGIN
                                        gReqLine2.VALIDATE(Quantity,gReqLine2.Quantity-gReqLine.Quantity);
                                        gReqLine2.MODIFY(TRUE);
                                      END ELSE
                                        gReqLine2.DELETE(TRUE);
                                   END;
                                UNTIL ReservationEntry.NEXT = 0;
                               UNTIL gReqLine.NEXT = 0;
                               IF LastSKU."Location Code" = "Location Code" THEN BEGIN
                                 CLEAR(FromSKU);
                                 FromSKU.GET(RunMRPForLocation.Code,"Item No.",'');
                                 FromSKU.VALIDATE("Replenishment System" ,FromSKU."Replenishment System"::Purchase);
                                 FromSKU.VALIDATE("Transfer-from Code",'');
                                 FromSKU.MODIFY;
                                 ForSKU.GET(RunMRPForLocation.Code,"Item No.",'');
                                 RunMRP;
                                 gReqLine.RESET;
                                 gReqLine.SETRANGE("Worksheet Template Name",  CurrTemplateName);
                                 gReqLine.SETRANGE("Journal Batch Name",CurrWorksheetName);
                                 gReqLine.SETRANGE("No.",Item."No.");
                                 gReqLine.SETRANGE("Replenishment System",gReqLine."Replenishment System"::Purchase);
                                 gReqLine.MODIFYALL("Planning Flexibility",gReqLine."Planning Flexibility"::None);
    
                                 SplitReqlines;
                               END;
    
                               //S001 End
    
                               COMMIT;
    
                               TempItemList := Item;
                               IF TempItemList.INSERT THEN;
                             END;
    
            OnPostDataItem=BEGIN
                             //FORM.RUNMODAL(FORM::"Requisition Lines",tempReqLine);
                           END;
    
            ReqFilterFields=Item No.;
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=12000;
                SectionHeight=846;
              }
              CONTROLS
              {
              }
               }
          }
           }
        { PROPERTIES
          {
            DataItemTable=Table37;
            DataItemVarName=DummySalesLine;
            OnPreDataItem=BEGIN
                            CurrReport.BREAK;
                          END;
    
            ReqFilterFields=Sell-to Customer No.,Item Category Code;
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=12000;
                SectionHeight=846;
              }
              CONTROLS
              {
              }
               }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=6380;
          Height=2420;
          SaveValues=Yes;
          OnOpenForm=BEGIN
                       MfgSetup.GET;
                       UseForecast := MfgSetup."Current Production Forecast";
                     END;
    
        }
        CONTROLS
        {
          { 1   ;TextBox      ;3410 ;0    ;1650 ;440  ;CaptionML=[ENU=Order Date;
                                                                  ESM=Fecha pedido;
                                                                  FRC=Date commande;
                                                                  ENC=Order Date];
                                                       SourceExpr=OrderDate }
          { 2   ;Label        ;0    ;0    ;3300 ;440  ;ParentControl=1 }
          { 3   ;TextBox      ;3410 ;550  ;1650 ;440  ;CaptionML=[ENU=Ending Date;
                                                                  ESM=Fecha final;
                                                                  FRC=Date fin;
                                                                  ENC=Ending Date];
                                                       SourceExpr=ToDate }
          { 4   ;Label        ;0    ;550  ;3300 ;440  ;ParentControl=3 }
          { 1000000000;TextBox;3410 ;1100 ;1700 ;440  ;CaptionML=ENU=Location Code;
                                                       SourceExpr=RunMRPForLocation.Code;
                                                       TableRelation=Location.Code }
          { 1000000001;Label  ;0    ;1100 ;3300 ;440  ;ParentControl=1000000000 }
        }
      }
      CODE
      {
        VAR
          Text002@1000 : TextConst 'ENU=The order date must be entered.;ESM=Debe introducir Fecha pedido.;FRC=La date de commande doit ˆtre saisie.;ENC=The order date must be entered.';
          Text003@1001 : TextConst 'ENU=The ending date must be entered.;ESM=Debe introducir Fecha final.;FRC=La date de fin doit ˆtre saisie.;ENC=The ending date must be entered.';
          Text004@1002 : TextConst 'ENU=The ending date must not be before the order date.;ESM=Fecha final no puede ser anterior a Fecha pedido.;FRC=La date de fin ne doit pas pr‚c‚der la date de commande.;ENC=The ending date must not be before the order date.';
          Text005@1003 : TextConst 'ENU=You must not use a variant filter when calculating MPS from a forecast.;ESM=No debe utilizar un filtro variante cuando calcule MPS desde una previsi¢n.;FRC=Vous ne devez pas utiliser un filtre variante ou casier lorsque vous calculez une commande PDP depuis une pr‚vision.;ENC=You must not use a variant filter when calculating MPS from a forecast.';
          Text006@1004 : TextConst 'ENU=Calculating the plan...\\;ESM=Calculando el plan...\\;FRC=Calculer le plan...\\;ENC=Calculating the plan...\\';
          Text007@1005 : TextConst 'ENU=Item No.  #1##################;ESM=Prod. n§  #1##################;FRC=N§ d''article  #1##################;ENC=Item No.  #1##################';
          ReqLine@1006 : Record 246;
          ActionMessageEntry@1007 : Record 99000849;
          ReqLineExtern@1008 : Record 246;
          PurchReqLine@1009 : Record 246;
          SKU@1010 : Record 5700;
          PlanningAssignment@1012 : Record 99000850;
          ForecastEntry@1015 : Record 99000852;
          MfgSetup@1018 : Record 99000765;
          TempItemList@1019 : TEMPORARY Record 27;
          InvtProfileOffsetting@1020 : Codeunit 99000854;
          CurrWorksheetType@1022 : 'Requisition,Planning';
          PeriodLength@1024 : Integer;
          CurrTemplateName@1025 : Code[10];
          CurrWorksheetName@1026 : Code[10];
          OrderDate@1027 : Date;
          ToDate@1028 : Date;
          MaxDate@1029 : Date;
          ReqWkshTemplateFilter@1030 : Code[50];
          ReqWkshFilter@1031 : Code[50];
          Counter@1032 : Integer;
          UseForecast@1014 : Code[10];
          ExcludeForecastBefore@1013 : Date;
          gReqLine@1000000001 : Record 246;
          gReqLine2@1000000006 : Record 246;
          gReqLine3@1000000007 : Record 246;
          gSKU@1000000002 : Record 5700;
          RunMRPForLocation@1000000003 : Record 14;
          Item@1000000005 : Record 27;
          tempReqLine@1000000008 : TEMPORARY Record 246;
          gCounter@1000000009 : Integer;
          LastSKU@1000000010 : Record 5700;
          FromSKU@1000000011 : Record 5700;
          ForSKU@1000000004 : Record 5700;
          SalesLine@1000000000 : Record 37;
          RunForAllLocation@1000000012 : Boolean;
          Window@1000000013 : Dialog;
          MySalesLine@1000000014 : Record 37;
    
        PROCEDURE SetTemplAndWorksheet@2(TemplateName@1000 : Code[10];WorksheetName@1001 : Code[10]);
        BEGIN
          CurrTemplateName := TemplateName;
          CurrWorksheetName := WorksheetName;
        END;
    
        PROCEDURE RunMRP@1000000000();
        VAR
          PurchReqLine2@1000000000 : Record 246;
        BEGIN
          CLEAR(Item);
          IF NOT RunForAllLocation THEN
            Item.SETRANGE("No.",FromSKU."Item No.")
          ELSE
            Item.SETRANGE("No.",LastSKU."Item No.");
          Item.FIND('-');
          IF NOT RunForAllLocation THEN
            Item.SETFILTER("Location Filter",'%1|%2',FromSKU."Location Code",ForSKU."Location Code");
    
    
          SKU.SETCURRENTKEY("Item No.");
          Item.COPYFILTER("Variant Filter",SKU."Variant Code");
          Item.COPYFILTER("Location Filter",SKU."Location Code");
    
          Item.COPYFILTER("Variant Filter",PlanningAssignment."Variant Code");
          Item.COPYFILTER("Location Filter",PlanningAssignment."Location Code");
          PlanningAssignment.SETRANGE(Inactive,FALSE);
          PlanningAssignment.SETRANGE("Net Change Planning",TRUE);
    
          CLEAR(ReqLineExtern);
          ReqLineExtern.SETCURRENTKEY(Type,"No.","Variant Code","Location Code");
          Item.COPYFILTER("Variant Filter",ReqLineExtern."Variant Code");
          Item.COPYFILTER("Location Filter",ReqLineExtern."Location Code");
    
          //S001 Start
          CLEAR(PurchReqLine);
          //S001 End
          PurchReqLine.SETCURRENTKEY(
            Type,"No.","Variant Code","Location Code","Sales Order No.","Planning Line Origin","Due Date");
          PurchReqLine.SETRANGE(Type,PurchReqLine.Type::Item);
          Item.COPYFILTER("Variant Filter",PurchReqLine."Variant Code");
          Item.COPYFILTER("Location Filter",PurchReqLine."Location Code");
          PurchReqLine.SETFILTER("Worksheet Template Name",ReqWkshTemplateFilter);
          PurchReqLine.SETFILTER("Journal Batch Name",ReqWkshFilter);
    
    
    
          Counter := Counter + 1;
    
          SKU.SETRANGE("Item No.",Item."No.");
          IF NOT SKU.FIND('-') THEN BEGIN
            IF (CurrWorksheetType = CurrWorksheetType::Requisition) AND
               (Item."Replenishment System" = Item."Replenishment System"::"Prod. Order") THEN
              CurrReport.SKIP;
            IF Item."Reordering Policy" = Item."Reordering Policy"::" " THEN
              CurrReport.SKIP;
          END;
    
          PlanningAssignment.SETRANGE("Item No.",Item."No.");
    
          ReqLine.LOCKTABLE;
          ActionMessageEntry.LOCKTABLE;
          PurchReqLine.SETRANGE("No.",Item."No.");
          //s001 Start
          //PurchReqLine.DELETEALL(TRUE);
          PurchReqLine2.SETRANGE("No.",Item."No.");
          PurchReqLine2.SETFILTER("Worksheet Template Name",ReqWkshTemplateFilter);
          PurchReqLine2.SETFILTER("Journal Batch Name",ReqWkshFilter);
          PurchReqLine2.SETRANGE("Planning Flexibility",gReqLine."Planning Flexibility"::Unlimited);
          PurchReqLine2.DELETEALL(TRUE);
          //S001 End
    
          //s001 Start
          ReqLineExtern.SETFILTER("Worksheet Template Name",ReqWkshTemplateFilter);
          ReqLineExtern.SETFILTER("Journal Batch Name",ReqWkshFilter);
          ReqLineExtern.SETRANGE("Planning Flexibility",gReqLine."Planning Flexibility"::Unlimited);
          //S001 End
          ReqLineExtern.SETRANGE(Type,ReqLine.Type::Item);
          ReqLineExtern.SETRANGE("No.",Item."No.");
          IF ReqLineExtern.FIND('-') THEN
           REPEAT
              ReqLineExtern.DELETE(TRUE);
            UNTIL ReqLineExtern.NEXT = 0;
    
          InvtProfileOffsetting.SetParm(UseForecast,ExcludeForecastBefore);
          InvtProfileOffsetting.CalculatePlanFromWorksheet(
            Item,
            MfgSetup,
            CurrTemplateName,
            CurrWorksheetName,
            OrderDate,
            ToDate,
            FALSE);
    
          IF PlanningAssignment.FIND('-') THEN
            REPEAT
              IF PlanningAssignment."Latest Date" <= ToDate THEN BEGIN
                PlanningAssignment.Inactive := TRUE;
                PlanningAssignment.MODIFY;
              END;
            UNTIL PlanningAssignment.NEXT = 0;
        END;
    
        PROCEDURE SplitReqlines@1000000002();
        VAR
          TempReqLine2@1000000002 : TEMPORARY Record 246;
          RsrvEntry@1000000001 : Record 337;
          RsrvEntry2@1000000000 : Record 337;
        BEGIN
          //split requision based on reservation line
          CLEAR(gReqLine);
          gReqLine.SETRANGE("Worksheet Template Name",  CurrTemplateName);
          gReqLine.SETRANGE("Journal Batch Name",CurrWorksheetName);
          gReqLine.SETRANGE("No.",Item."No.");
          CLEAR(TempReqLine2);
          IF gReqLine.FIND('-') THEN REPEAT
              IF NOT TempReqLine2.GET(gReqLine."Worksheet Template Name",gReqLine."Journal Batch Name",gReqLine."Line No.") THEN BEGIN
                TempReqLine2 := gReqLine;
                TempReqLine2.INSERT;
                CLEAR(RsrvEntry);
                RsrvEntry.SETCURRENTKEY("Source ID","Source Ref. No.","Source Type");
                RsrvEntry.SETRANGE("Source ID",gReqLine."Worksheet Template Name");
                RsrvEntry.SETRANGE("Source Batch Name",gReqLine."Journal Batch Name");
                RsrvEntry.SETRANGE("Source Ref. No.",gReqLine."Line No.");
                RsrvEntry.SETRANGE("Source Subtype",0);
                IF RsrvEntry.FIND('-') THEN REPEAT
                  IF (RsrvEntry.Quantity <> gReqLine.Quantity) THEN BEGIN
                    IF RsrvEntry2.GET(RsrvEntry."Entry No.",NOT RsrvEntry.Positive) AND
                      (RsrvEntry2."Source Type" = DATABASE::"Sales Line") AND
                      SalesLine.GET(RsrvEntry2."Source Subtype",RsrvEntry2."Source ID", RsrvEntry2."Source Ref. No.")
                    THEN BEGIN
                      CLEAR(gReqLine2);
                      gReqLine2 := gReqLine;
                      gReqLine2."Line No." := gReqLine."Line No." + (RsrvEntry."Entry No." MOD 100);
                      gReqLine2.Quantity :=  RsrvEntry.Quantity;
                      gReqLine2."Quantity (Base)" :=  RsrvEntry."Quantity (Base)";
                      gReqLine2."Original Quantity" := 0;
                      gReqLine2.VALIDATE("Order No.",SalesLine."Document No.");
                      gReqLine2.INSERT;
                      RsrvEntry."Source Ref. No." := gReqLine2."Line No.";
                      RsrvEntry.MODIFY;
    
                      SplitReservEntry(gReqLine,gReqLine2.Quantity,gReqLine2."Line No.");
    
                      TempReqLine2 := gReqLine2;
                      TempReqLine2.INSERT;
    
                      gReqLine.Quantity -=  RsrvEntry.Quantity;
                      gReqLine."Quantity (Base)" -=  RsrvEntry."Quantity (Base)";
                      gReqLine.VALIDATE("Order No.",SalesLine."Document No.");
                      gReqLine."Original Quantity" := 0;
                      gReqLine.MODIFY;
                  END;
                  END ELSE BEGIN
                    IF RsrvEntry2.GET(RsrvEntry."Entry No.",NOT RsrvEntry.Positive) THEN
                      IF (RsrvEntry2."Source Type" = DATABASE::"Sales Line") THEN BEGIN
                        gReqLine.VALIDATE("Order No.",RsrvEntry2."Source ID");
                        gReqLine.MODIFY;
                    END;
                  END;
                UNTIL RsrvEntry.NEXT = 0;
            END;
          UNTIL gReqLine.NEXT = 0
        END;
    
        PROCEDURE SplitReservEntry@1000000001(reqLine@1000000000 : Record 246;Qty@1000000001 : Decimal;NewLine@1000000002 : Integer);
        VAR
          ResrvEntry@1000000004 : Record 337;
          ResrvEntry2@1000000003 : Record 337;
          QtyApplied@1000000005 : Decimal;
          ReserEntry3@1000000006 : Record 337;
          LineNo@1000000007 : Integer;
        BEGIN
          ResrvEntry.SETCURRENTKEY("Source ID","Source Ref. No.","Source Type");
          ResrvEntry.SETRANGE("Source ID",reqLine."Worksheet Template Name");
          ResrvEntry.SETRANGE("Source Batch Name",reqLine."Journal Batch Name");
          ResrvEntry.SETRANGE("Source Ref. No.",reqLine."Line No.");
          ResrvEntry.SETRANGE("Source Subtype",1);
          IF ResrvEntry.FIND('-') THEN REPEAT
            IF Qty <> 0 THEN BEGIN
              IF ABS(ResrvEntry.Quantity) > Qty THEN BEGIN
                CLEAR(ReserEntry3);
                ReserEntry3.FINDLAST;
                LineNo := ReserEntry3."Entry No." + 1;
                CLEAR(ReserEntry3);
                ReserEntry3 := ResrvEntry;
                ReserEntry3.Quantity := ReserEntry3.Quantity + Qty;
                ReserEntry3."Quantity (Base)" :=  ReserEntry3."Quantity (Base)" + Qty;
                ReserEntry3."Entry No." := LineNo;
                ReserEntry3.INSERT;
                ResrvEntry2.GET(ResrvEntry."Entry No.",NOT ResrvEntry.Positive);
                CLEAR(ReserEntry3);
                ReserEntry3 := ResrvEntry2;
                ReserEntry3.Quantity := ReserEntry3.Quantity - Qty;
                ReserEntry3."Quantity (Base)" :=  ReserEntry3."Quantity (Base)" - Qty;
                ReserEntry3."Entry No." := LineNo;
                ReserEntry3.INSERT;
    
                ResrvEntry."Source Ref. No." := NewLine;
                ResrvEntry.Quantity := -Qty;
                ResrvEntry."Quantity (Base)" :=  -Qty;
    
                ResrvEntry.MODIFY;
                ResrvEntry2.Quantity := Qty;
                ResrvEntry2."Quantity (Base)" :=  Qty;
                ResrvEntry2.MODIFY;
                EXIT;
    
    
              END ELSE IF ABS(ResrvEntry.Quantity) = Qty THEN BEGIN
                ResrvEntry."Source Ref. No." := NewLine;
                ResrvEntry.MODIFY;
                EXIT;
    
              END ELSE IF ABS(ResrvEntry.Quantity) < Qty THEN BEGIN
                ResrvEntry."Source Ref. No." := NewLine;
                ResrvEntry.MODIFY;
                Qty -= ABS(ResrvEntry.Quantity);
              END;
            END;
          UNTIL ResrvEntry.NEXT = 0
        END;
    
        BEGIN
        END.
      }
    }
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • KWevickKWevick Member Posts: 103
    Thanks Rashed, :D
    That is helpful. We have been trying to avoid SKU maintenance for this customer, but it may be unavoidable. We'll just have to automate as much as possible. The copy to another db is probably a good choice for a different customer.

    Karen
  • ara3nara3n Member Posts: 9,256
    The user do not need to maintain the SKU. You can add code to the report to create and update the SKU and populate them based on Item.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.