0
votes

i am trying to retrieve the difference of qty and qts shipped for a sales order. i am doing this through code.

setting range on sales line table fields and using findset does loop through all lines properly but while printing it gives the difference frm the last line.

clearing the variable is also not working.

i am new to NAV 2013 so not able to find out how to loop through all this lines so that it displays result properly.i tried using findfirst inside the if loop but no success.

1
can you post the code you have at present?BMac
CLEAR(Value); SalesLine.RESET; SalesLine.SETRANGE(SalesLine."Document No.","No."); IF SalesLine.FINDSET THEN REPEAT Value := SalesLine.Quantity - SalesLine."Quantity Shipped"; //MESSAGE('%1',Value); UNTIL SalesLine.NEXT =0;user4774487
"while printing it gives the difference frm the last line." What do you mean by "printing"?Daniel

1 Answers

0
votes

You need to add to "Value", not overwrite it. (use +=, not :=)

CLEAR(Value); 
SalesLine.RESET; 
SalesLine.SETRANGE(SalesLine."Document No.","No."); 
IF SalesLine.FINDSET THEN REPEAT 
  Value += SalesLine.Quantity - SalesLine."Quantity Shipped"; 
  //MESSAGE('%1',Value); 
UNTIL SalesLine.NEXT =0;