Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Creating a Prod. Order

Posted on by Microsoft Employee

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

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Creating a Prod. Order

    Create two functions one to filter the sales line where Production BOM version is not blank which you will process and create production order and other function where Production BOM version is blank and you can pull what ever information you want from that line to the temp table or build the message to show it to the user, just use the MESSAGE box instead of Error show that it will not rollback the  process.

    Or COMMIT after your function, so that it will process the lines where production BOM version has value.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Creating a Prod. Order

    Thank you, how can I go about doing this first stage, i can't think how tackle it??

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Creating a Prod. Order

    you need to keep all your login in a codeunit onrun trigger and call the codeunit with each line of sales order.

    IF CODUNIT.RUN(SalesLine) THEN BEGIN

     you need to create either a table or so to store the failed saleslines here.

    END;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans