How to post a transfer order using code

jorgito
Member Posts: 115
Hi all.
I have the following situation.
When the customer posts a Purchase Receipt, he need to create and post a Transfer Order for each line of the Receipt.
I tried inserting the following code in C90 for each line.
I also tried the following:
However, if there is an error while posting the Transfer Order, I get an error message but the Purchase Receipt gets posted.
I tried using the return value of the CODEUNIT.RUN, but I get a message saying that write transactions are not allowed.
How can I call the Transfer Post, so that if an error occurs, the whole procedure gets rolled back?
Thanx
Jorgito
I have the following situation.
When the customer posts a Purchase Receipt, he need to create and post a Transfer Order for each line of the Receipt.
I tried inserting the following code in C90 for each line.
CODEUNIT.RUN(CODEUNIT::"TransferOrder-Post Shipment", TransferHeader); CODEUNIT.RUN(CODEUNIT::"TransferOrder-Post Receipt", TransferHeader);
I also tried the following:
TransferPostShipment.RUN(TransferHeader); TransferPostReceipt.RUN(TransferHeader);
However, if there is an error while posting the Transfer Order, I get an error message but the Purchase Receipt gets posted.
I tried using the return value of the CODEUNIT.RUN, but I get a message saying that write transactions are not allowed.
How can I call the Transfer Post, so that if an error occurs, the whole procedure gets rolled back?
Thanx
Jorgito
0
Answers
-
Check this topic:
http://www.mibuso.com/forum/viewtopic.php?t=10025Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki,
Thanx for the solution.
It seems that Navision does not let you run a codeunit that performs a commit, while you are inside a transaction.
The way to solve this problem is:
In C5704 (TransferOrder-Post Shipment) and C5705 (TransferOrder-Post Receipt):
- Create a Boolean variable :blnDontUseCommit
- Create a functionDontUseCommit() blnDontUseCommit := TRUE;
- Change all COMMITs toIF NOT blnDontUseCommit THEN COMMIT;
and finaly you can run the codeunit usingCLEAR(TransferPostShipment); TransferPostShipment.DontUseCommit(); TransferPostShipment.RUN(TransferHeader);
Jorge0 -
jorgito wrote:It seems that Navision does not let you run a codeunit that performs a commit, while you are inside a transaction.
You can run a codeunit with a commit while already inside a transaction. The problem is that with the commit in the codeunit, the transaction is commited.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