Can someone enlighten me on this code...

NavNabNavNab 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

  • NavNabNavNab 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_GuzekSlawek_Guzek Member Posts: 1,690
    You will get used to it :wink:

    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.