When creating a Prod. order from a Sales Order it currently looks at the lines and error's if there is a Prod. Bom version missing. I need to alter this to allow for creating a prod. Order from the lines even if this bom version is blank for the remaining lines and store the lines which did have a prod order missing for use in a message etc..
Here is the code:
ProductionOrderHeader.VALIDATE(Status, ProductionOrderHeader.Status::Planned);
ProductionOrderHeader.VALIDATE("Source Type", ProductionOrderHeader."Source Type"::"Sales Header");
ProductionOrderHeader.VALIDATE("Source No.", "Sales Order No.");
ProductionOrderHeader.VALIDATE("No.");
ProductionOrderHeader.VALIDATE("Source Order", "Sales Order No.");
ProductionOrderHeader.VALIDATE(Quantity, Quant);
IF recSalesLine.GET(
"Sales Header"."Document Type",
"Sales Header"."No.",
"Sales Line No.") THEN BEGIN
ProductionOrderHeader.VALIDATE("Due Date", recSalesLine."Requested Delivery Date");
IF recSalesLine."Prod. BOM Version" = '' THEN // Check for a blank Version
ERROR(Text0006);
END ELSE
ProductionOrderHeader.VALIDATE("Due Date", "Sales Header"."Requested Delivery Date");
IF ProductionOrderHeader.INSERT(TRUE) THEN BEGIN
ProductionOrderApplyTemplate(ProductionOrderHeader, goptTemplate::Finished);
ProductionOrderApplyCustomerName(ProductionOrderHeader);
"PO No." := ProductionOrderHeader."No.";
ProductionOrderLine.INIT;
ProductionOrderLine.VALIDATE(Status, ProductionOrderLine.Status::Planned);
ProductionOrderLine.VALIDATE("Prod. Order No.","PO No.");
ProductionOrderLine.VALIDATE("Item No.",Item."No.");
ProductionOrderLine.VALIDATE(Quantity, Quant);
ProductionOrderLine.VALIDATE("Bin Code", InvSetup."Finished Bin Code");
ProductionOrderLine.VALIDATE("Sales Order No.", "Sales Order No.");
ProductionOrderLine.VALIDATE("Sales Order Line No.", "Sales Line No.");
ProductionOrderLine.INSERT(TRUE);
ProductionOrderPage.SETTABLEVIEW(ProductionOrderHeader);
ProductionOrderPage.SETRECORD(ProductionOrderHeader);
ProductionOrderPage.RUN;
END;
EXIT("PO No.");
END;
Any feedback will be appreciated!
*This post is locked for comments