I have changed the code as you said :
IF "Purch. Inv. Header"."Order No." = '' THEN BEGIN
sumamt := 0;
"Purch. Inv. Line".GET("Purch. Rcpt. Line"."Document No.");
"Purch. Inv. Line".SETRANGE("Purch. Inv. Line"."Document No.","Purch. Rcpt. Line"."Document No.");
IF "Purch. Rcpt. Line"."Document No." = "Purch. Inv. Line"."Document No." THEN
REPEAT
sumamt := sumamt + "Purch. Inv. Line".Amount;
UNTIL "Purch. Inv. Line".NEXT = 0;
"Purch. Inv. Header".Amount := sumamt;
"Purch. Inv. Header".MODIFY;
END;
I am getting an error as:
Microsoft Dynamics NAV
---------------------------
The Purch. Inv. Line does not exist. Identification fields and values: Document No.='107128',Line No.='0'
---------------------------
OK
---------------------------