Hi Expects,
I have to find the inv amount using Inv line that has been invoiced using the reciept lines.
Can some one help me with the codeunit optimization.
the dataitem i choosed was:
Expanded Data Type Data Source Name Include Caption
1 DataItem Purch. Rcpt. Header <Purch. Rcpt. Header> No
0 Column "Purch. Rcpt. Header"."Buy-from Vendor No." VendorNo No
0 Column "Purch. Rcpt. Header"."No." GrnNo No
0 Column "Purch. Rcpt. Header"."Order No." PoNo No
0 Column "Purch. Rcpt. Header"."Order Date" PoDate No
0 Column "Purch. Rcpt. Header"."Document Date" GrnDate No
1 DataItem Purch. Rcpt. Line <Purch. Rcpt. Line> No
0 Column "Purch. Rcpt. Line".Quantity PoQuantity No
0 Column "Purch. Rcpt. Line"."Direct Unit Cost" * "Purch. Rcpt. Line".Quantity Amount No
0 Column "Purch. Rcpt. Line"."Quantity Invoiced" QtyInv No
1 DataItem Purch. Inv. Header <Purch. Inv. Header> No
0 Column "Purch. Inv. Header"."No." InvoiceNo No
0 Column "Purch. Inv. Header".Amount InvoiceAmount No
1 DataItem G/L Entry <G/L Entry> No
0 Column "G/L Entry".Amount PaymentAmount No
0 Column "G/L Entry"."Posting Date" PaymentDate No
0 Column "G/L Entry"."Document No." paymentDocNo No
Codeunit for this is:
Purch. Inv. Header - OnPreDataItem()
IF "Purch. Inv. Header"."Order No." = '' THEN BEGIN
sumamt := 0;
"Purch. Inv. Line".SETRANGE("Purch. Inv. Line"."Receipt No.","Purch. Rcpt. Line"."Document No.");
IF NOT "Purch. Inv. Line".GET("Purch. Rcpt. Line"."Document No.") THEN BEGIN
IF "Purch. Inv. Line"."Receipt No." = "Purch. Rcpt. 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".INSERT;
END;
END;
this shows an error as :
Microsoft Dynamics NAV
The Purch. Inv. Header does not exist. Identification fields and values: No.=''
OK
As i have to sum the values for showing the purchase tracker report I coulnt end up getting the result.
Thanks in advance.
0
Answers