I think your code is in purchase line table. Please try something like this:-
IF (“Document Type”=“Document Type”::Order) THEN
BEGIN
IF Type=Type::Item THEN BEGIN
PurchHeader.RESET;
IF PurchHeader.GET(PurchHeader.“No.”,“Document No.”) THEN BEGIN
ItemVendor.RESET;
IF ItemVendor.GET(“Buy-from Vendor No.”,“No.”,“Variant Code”) THEN
Leadtime :=ItemVendor.“Lead Time Calculation”;
ExpOrder:=CALCDATE(Leadtime, PurchHeader.“Order Date”);
MESSAGE(Txt001,’%1’,ExpOrder); //Show check “Lead Time Calculation”
END;
END;
END;
Sorry, did not notice, there was an issue with the GET statement in my code. Please change it to
IF PurchHeader.GET(“Document Type”,“Document No.”) THEN BEGIN
Not saying that it would not work in all situations, but you do have a few more errors/problems in that code! Plus you could do it much simpler.
IF ("Document Type" <> "Document Type"::Order) OR (Type <> Type::Item) THEN EXIT;
IF NOT PurchHeader.GET("Document Type","Document No.") THEN EXIT;
IF NOT ItemVendor.GET("Buy-from Vendor No.","No.") THEN EXIT;
IF FORMAT(ItemVendor."Lead Time Calculation") = '' THEN EXIT;
ExpOrder := CALCDATE(ItemVendor."Lead Time Calculation",PurchHeader."Order Date");
MESSAGE(Txt001,'%1',ExpOrder);
The same basic principle as in all code. Test first, then execute.