HasAmount := HasAmount OR ("Qty. Shipped Not Invoiced" <> 0); SalesShptLine.InsertInvLineFromShptLine(SalesLine);
InsertInvLineFromShptLine(VAR SalesLine : Record "Sales Line") SETRANGE("Document No.","Document No."); TempSalesLine := SalesLine; IF SalesLine.FIND('+') THEN NextLineNo := SalesLine."Line No." + 10000 ELSE NextLineNo := 10000; IF SalesInvHeader."No." <> TempSalesLine."Document No." THEN SalesInvHeader.GET(TempSalesLine."Document Type",TempSalesLine."Document No."); IF SalesLine."Shipment No." <> "Document No." THEN BEGIN SalesLine.INIT; SalesLine."Line No." := NextLineNo; SalesLine."Document Type" := TempSalesLine."Document Type"; SalesLine."Document No." := TempSalesLine."Document No."; SalesLine.Description := STRSUBSTNO(Text000,"Document No."); SalesLine.INSERT; NextLineNo := NextLineNo + 10000; END;
Answers
You would need to have a look in the code down below ans see how the assigned data is used. 4 lines of code taken out of context almost never makes sense.
It could be used just to remember values of Document No. / Type to be used somewhere else. SETRANGE will only set the filter, without putting a value in the actual fields, so if you had used SETRANGE only and later want to have the "Document Type" assigned somewhere later you in the code would have to use IF EVALUATE(GETFILTER("DocumentType")) rather that straightforward assignment.
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
There is no FIND after the SETRANGE so the filer is not executed.
This object is passed in the next statements:
The SETRANGE is used to determine the next lineno.
(IF SalesLine.FIND('+') THEN)
And to set the values:
SalesLine."Document Type" := TempSalesLine."Document Type";
SalesLine."Document No." := TempSalesLine."Document No.";
Although it is
It is still a disturbing manner to code. It would be simple and easy to understand if the code was:
The way @ErictP explains it sounds like a nice trick: SETRANGE to FIND next Line No. and := for assigning values... but still disturbing
Anyway, it is a way of coding as another...
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03