When on a Sales Order and releasing it to a prod order. I have code which would error if the Prod. BOM Version is blank. I've changed this to check if there is any BOM version on the item card, If no then don't error. However By doing this it's still creating a planned production order for the Sales order item with No Prod. BOM version, it shouldn't.
I need to basically state,
1) If there isn't a Prod. BOM version on the sales line, check to see if the item card has an Assebly BOM.
2) If the item does have an Assembly BOM, ERROR.
3) If the item doesn't have an assembly bom, don't error but don't continue to create a planned production order for that sales order line.
4) Carry on creating Planned production Orders for all over lines, normal process basically.
Here is the code so far.
IF recSalesLine.GET(
"Sales Header"."Document Type",
"Sales Header"."No.",
"Sales Line No.") THEN BEGIN
ProductionOrderHeader.VALIDATE("Due Date", recSalesLine."Requested Delivery Date");
Item.RESET;
Item.SETRANGE("No.", recSalesLine."No.");
Item.SETRANGE("Assembly BOM",Item."Assembly BOM"::No);
IF NOT Item.FINDFIRST THEN
ERROR(Text0006); // Check for a blank Version
END ELSE
ProductionOrderHeader.VALIDATE("Due Date", "Sales Header"."Requested Delivery Date");
Rest of code for creating prod order below this line.
Any and all feedback is appreciated!
0
Answers
Item.RESET;
Item.SETRANGE("No.", recSalesLine."No.");
Item.SETRANGE("Assembly BOM",Item."Assembly BOM"::No);
IF Item.FINDFIRST THEN BEGIN
ProductionOrderHeader.VALIDATE("Due Date", "Sales Header"."Requested Delivery Date");
Rest of code for creating prod order below this line.
This code would not give any errors and continue the process.
Ishwar Sharma
My Blogs: Dynamics Community Blog | Blogspot
Connect: Google + | Twitter