Why do AL use record.Copy() instead of temporary tables

samantha73samantha73 Member Posts: 96
Hi All
I'm trying to understand Record.copy function in relation to order planning worksheet so I can extended and add other fields. for example below procedure:
local procedure InsertSalesLine(var UnplannedDemand: Record "Unplanned Demand")
    var
        UnplannedDemand2: Record "Unplanned Demand";
    begin
        with UnplannedDemand do begin
            UnplannedDemand2.Copy(UnplannedDemand);
            InitRecord(
              SalesLine."Line No.", 0, SalesLine."No.", SalesLine.Description, SalesLine."Variant Code", SalesLine."Location Code",
              SalesLine."Bin Code", SalesLine."Unit of Measure Code", SalesLine."Qty. per Unit of Measure",
              DemandQtyBase, SalesLine."Shipment Date");
            OnInsertSalesLineOnAfterInitRecord(UnplannedDemand, SalesLine);
            Reserve := SalesLine.Reserve = SalesLine.Reserve::Always;
            "Special Order" := SalesLine."Special Order";
            "Purchasing Code" := SalesLine."Purchasing Code";
            OnInsertSalesLineOnBeforeInsert(UnplannedDemand, SalesLine);
            Insert();
            Copy(UnplannedDemand2);
        end;
    end;
After running the code there is no data in "Unplanned Demand" table. So essensially this is a temp record. Why not using temp record like in reports and populate data?
Sign In or Register to comment.