Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Production Order

Posted on by Microsoft Employee

Hi I have this code on the OnValidate Function. With the Set ranges at the start once I find the production order, when i try to find the prod order component, using the recprodorder."No." it's coming up blank in the debugger. How can I ammend this to find the right production order component? 

//FIND production Order
recProdOrder.RESET;
recProdOrder.SETRANGE("No.", "Source No.");
recProdOrder.SETRANGE("Item No.", "Item No.");

// Find Production Order Component for Production order
recProdOrderComponent.RESET;
recProdOrderComponent.SETRANGE("Prod. Order No.",recProdOrder."No.");//This isn't finding anything
// Check If Items found are Customer Specific
IF recProdOrderComponent.FINDFIRST THEN BEGIN
recProdOrderComponent.CALCFIELDS(FixedVariant);
IF recProdOrderComponent.FixedVariant THEN
ItemVariant.GET("Item No.","Variant Code");
//Check if variant is customer specific, and if it matches prod Order No.
IF ItemVariant.CALCFIELDS("Customer Specific") THEN
//Find the Production Order
recProdOrder.SETRANGE("No.", recProdOrderComponent."Prod. Order No.");
IF recProdOrder."Customer No." <> ItemVariant.Manufacturer THEN
ERROR(Text024);
END;

*This post is locked for comments

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Production Order

    Replace your code with this

    recProdOrder.RESET;

    recProdOrder.SETRANGE("No.", "Source No.");

    recProdOrder.SETRANGE("Item No.", "Item No.");

    IF recProdOrder.FINDFIRST THEN BEGIN

      // Find Production Order Component for Production order

      recProdOrderComponent.RESET;

      recProdOrderComponent.SETRANGE("Prod. Order No.",recProdOrder."No.");//This isn't finding anything

      // Check If Items found are Customer Specific

      IF recProdOrderComponent.FINDFIRST THEN BEGIN

        recProdOrderComponent.CALCFIELDS(FixedVariant);

        IF recProdOrderComponent.FixedVariant THEN BEGIN

          ItemVariant.GET("Item No.","Variant Code");

        //Check if variant is customer specific, and if it matches prod Order No.

          IF ItemVariant.CALCFIELDS("Customer Specific") THEN BEGIN

        //Find the Production Order

          IF recProdOrder."Customer No." <> ItemVariant.Manufacturer THEN

            ERROR(Text024);

         END;

       END;

     END;

    END;

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Production Order

    Hi

    You need to write the code in block using begin end

    As well as activate debugger and check

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Production Order

    Thanks, I've tried this but it's still not pickinh up any value for the

    recProdOrderComponent.SETRANGE("Prod. Order No.",recProdOrder."No."); line

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Production Order

    Put the breakpoint on that line, only when the breakpoint is hit, i.e. when the cursor is inside the loop that value will be shown to you in the debugger. If you are trying to lookup the value before the execution of the loop you will see the blank value.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Production Order

    Thank you, my confusion is.. How can I get this SETRANGE to work properly essentially.

    97.PNG

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Production Order

    recProdOrder.RESET;
    recProdOrder.SETRANGE("No.", "Source No.");
    recProdOrder.SETRANGE("Item No.", "Item No.");
    If recProdOrder.FINDFIRST THEN --->  You forgot this line 
    // Find Production Order Component for Production order
    recProdOrderComponent.RESET;
    recProdOrderComponent.SETRANGE("Prod. Order No.",recProdOrder."No.");//This isn't finding anything
    // Check If Items found are Customer Specific
    IF recProdOrderComponent.FINDFIRST THEN BEGIN
    recProdOrderComponent.CALCFIELDS(FixedVariant);
    IF recProdOrderComponent.FixedVariant THEN
    ItemVariant.GET("Item No.","Variant Code"); 
    //Check if variant is customer specific, and if it matches prod Order No.
    IF ItemVariant.CALCFIELDS("Customer Specific") THEN
    //Find the Production Order
    recProdOrder.SETRANGE("No.", recProdOrderComponent."Prod. Order No.");
    IF recProdOrder."Customer No." <> ItemVariant.Manufacturer THEN
    ERROR(Text024);
    END;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Production Order

    This is written on the Warehouse Activity Line table

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