Can someone enlighten me on this code...

NavNab
NavNab Member Posts: 181
Dear all,

Can someone enlighten me to understand this code in standard report 295. The screenshot is from a NAV 2017 W1 database, but the code exists in all (2009 at least) old versions also.

jygeis0i4b1m.jpg

I can't see what is the purpose of assigning a value to a field just after/before a SETRANGE.

The same logic is used on other standard objects. For example Table 175, function ApplyStdCodesToPurchaseLines

Best Answers

Answers

  • NavNab
    NavNab Member Posts: 181
    Thanks both of you. Now I see clear.

    Although it is
    straightforward assignment

    It is still a disturbing manner to code. It would be simple and easy to understand if the code was:
    ...
    InsertInvLineFromShptLine(VAR SalesLine : Record "Sales Line",SalesHeader);
    ...
    SalesLine."Document Type" := SalesHeader."Document Type";
    SalesLine."Document No." := SalesHeader."No.";
    ...
    

    The way @ErictP explains it sounds like a nice trick: SETRANGE to FIND next Line No. and := for assigning values... but still disturbing :smiley:

    Anyway, it is a way of coding as another...
  • Slawek_Guzek
    Slawek_Guzek Member Posts: 1,692
    You will get used to it :wink:

    Slawek
    Slawek Guzek - www.yitron.co.uk
    Business Central, MS SQL Server, Wherescape RED;