Problems with new Batch Production Post Function

alsol
Member Posts: 243
Hello there,
A customer uses Swiss Production Module but does more assembling than real production. He asked me for a new function on the sales order which should be able to post all production orders related to the actual sales order. Of course this should be status driven, so a the end the production orders should be on Archived.
I developed this function and it work very well as long I have only one sales line with a production order. As soon I have more than one, the Post Production Codeunit comes up with an error when posting the second production order saying "Value Entry XYZ already exists".
This is the code I developed behind a button on the sales order form:
I tried it with several commits because it seems that the transaction in the first loop was not yet closed. If I do the same manually (the same Codeunits) it works.
Has anybody any ideas how to solve that?
Best regards
Felix
A customer uses Swiss Production Module but does more assembling than real production. He asked me for a new function on the sales order which should be able to post all production orders related to the actual sales order. Of course this should be status driven, so a the end the production orders should be on Archived.
I developed this function and it work very well as long I have only one sales line with a production order. As soon I have more than one, the Post Production Codeunit comes up with an error when posting the second production order saying "Value Entry XYZ already exists".
This is the code I developed behind a button on the sales order form:
ProdOrderHead.RESET; ProdOrderHead.SETRANGE("Sales Order No.","No."); ProdOrderHead.SETFILTER(Status, '<>Archived'); IF ProdOrderHead.FIND('-') THEN BEGIN IF NOT CONFIRM(Text50012,FALSE) THEN EXIT; REPEAT //Save No. of Production order and Rec ProdOrderNo := ProdOrderHead.Number; ProdOrderHead2 := ProdOrderHead; //Save current status ProdNewStatus := ProdOrderHead.Status; WHILE ProdNewStatus < 5 DO BEGIN ProdOrderHead2.RESET; ProdOrderHead2.GET(ProdOrderNo); //Set new status ProdNewStatus := ProdNewStatus + 1; //Post production if new status = Completed IF ProdNewStatus = ProdNewStatus::Completed THEN BEGIN IF ProdOrderHead."Remaining Qty." <> 0 THEN BEGIN ProdPost.PostProduction(ProdOrderHead2); END; END; //Reload record ProdOrderHead2.RESET; ProdOrderHead2.GET(ProdOrderNo); //Update status ProdOrderStatus. ChangeStatusArchived(ProdOrderHead2,ProdNewStatus); END; ProdOrderNo := ''; ProdOrderHead2.RESET; UNTIL ProdOrderHead.NEXT = 0; END ELSE BEGIN ERROR(Text50013); END;
I tried it with several commits because it seems that the transaction in the first loop was not yet closed. If I do the same manually (the same Codeunits) it works.
Has anybody any ideas how to solve that?
Best regards
Felix
0
Comments
-
You don't need the COMMIT. That is not the problem, but could create other problems.
Try this://Post production if new status = Completed IF ProdNewStatus = ProdNewStatus::Completed THEN BEGIN IF ProdOrderHead."Remaining Qty." <> 0 THEN BEGIN CLEAR(ProdPost); // I added this line ProdPost.PostProduction(ProdOrderHead2); END; END;
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions