Update records without looping : AL Code

Hi All

I have written code to update records from code but want to know if there is a better (faster) way rather than looping through each record as below. There may be a simpler code:

    var

        PurchaseHeader: Record "Purchase Header";

        IntLog: Record "Interaction Log Entry";

    begin

        PurchaseHeader.SetRange("Document Type", PurchaseHeader."Document Type"::Order);

        PurchaseHeader.SetRange(MY_Status2, PurchaseHeader.MY_Status2::" ");

        if PurchaseHeader.FindSet() then begin

            repeat

                IntLog.SetRange("Document No.", PurchaseHeader."No.");

                if IntLog.FindSet() then

                    repeat

                        PurchaseHeader.Validate(MY_Status2, PurchaseHeader.MY_Status2::SentToSupplier);

                        PurchaseHeader.modify(true);

                    until IntLog.Next() = 0;

            until PurchaseHeader.Next() = 0

        end

Related
Recommended