How to Add a Source Doc to a Warehouse Receipt..?

thetallbloke
Member Posts: 66
Hi guys,
On the Warehouse Receipt form (5768), under the Functions menu, there is an option to "Get Source Documents"..
From a code unit, I have a situation where I know what the document is that I want to add and its document type.. What I want to do, is run the "Get Source Documents" function, but skip the actual document selection bit of the process..
I've followed the code through to Code unit 5751 (Get Source Doc. Inbound), to the GetSingleInboundDoc function.. but it doesn't make sense to me...
There isn't anything obvious that says "read these lines from this source document and try to add them to the warehouse receipt"...
Have I followed the code wrong..??? is it done elsewhere..??? I'm at a loss..
Any help to point me in the right direction would be very much appreciated..
Thanks
On the Warehouse Receipt form (5768), under the Functions menu, there is an option to "Get Source Documents"..
From a code unit, I have a situation where I know what the document is that I want to add and its document type.. What I want to do, is run the "Get Source Documents" function, but skip the actual document selection bit of the process..
I've followed the code through to Code unit 5751 (Get Source Doc. Inbound), to the GetSingleInboundDoc function.. but it doesn't make sense to me...
There isn't anything obvious that says "read these lines from this source document and try to add them to the warehouse receipt"...
Have I followed the code wrong..??? is it done elsewhere..??? I'm at a loss..
Any help to point me in the right direction would be very much appreciated..
Thanks
.
I'm not crazy !!! Just ask my toaster...
.
I'm not crazy !!! Just ask my toaster...
.
0
Answers
-
Your code should looks something like this.
WhseReceiptHeader.get(YourWarehouseNo); GetSourceDocuments.SetOneCreatedReceiptHeader(WhseReceiptHeader); WhseRqst.setrange("source No.", YouPONumber); PurchaseLine.setrange("Document No.",YouPONumber); PurchaseLine.setrange("Document type",PurchaseLine."Document type"::Order); GetSourceDocuments.USEREQUESTFORM(FALSE); GetSourceDocuments.SETTABLEVIEW(WhseRqst); GetSourceDocuments..SETTABLEVIEW(PurchaseLine); GetSourceDocuments.RUNMODAL;
0 -
Thanks heaps Ara3n...!!!
I was able to take that code and modify it slightly to do exactly what I needed...
Tell me if I did something wrong... Basically, I'm passing in:-
ReceiptNo - Blank means 'create a new one' otherwise find the existing one.
-
DocumentNo (document to add to the receipt, PO/SRO/TRANS)
-
DocumentType
IF ReceiptNo = '' THEN BEGIN //Create a new ReceiptHeader WhseReceiptHeader.INIT(); WhseReceiptHeader.INSERT(TRUE); ReceiptNo := WhseReceiptHeader."No."; END ELSE BEGIN WhseReceiptHeader.SETRANGE("No.", ReceiptNo); END; GetSourceDocuments.SetOneCreatedReceiptHeader(WhseReceiptHeader); WhseRqst.SETRANGE("Source No.", DocumentNo); //YouPONumber); //0 - Purchase Order //1 - Purchase Return Order //2 - Sales Order //3 - Sales Return Order //4 - Transfer Order IF (DocumentType = 0) THEN BEGIN // 39 for PO/PRO WhseRqst.SETRANGE("Source Type", 39); PurchaseLine.SETRANGE("Document No.", DocumentNo); //YouPONumber); PurchaseLine.SETRANGE("Document Type", PurchaseLine."Document Type"::Order); // PurchaseLine.SETRANGE("Document type", PurchaseLine."Document Type"::"Return Order"); END ELSE BEGIN // 37 for SO/SRO WhseRqst.SETRANGE("Source Type", 37); SalesLine.SETRANGE("Document No.", DocumentNo); //YourSONumber); SalesLine.SETRANGE("Document Type", SalesLine."Document Type"::Order); END; GetSourceDocuments.USEREQUESTFORM(FALSE); GetSourceDocuments.SETTABLEVIEW(WhseRqst); IF DocumentType = 37 THEN GetSourceDocuments.SETTABLEVIEW(PurchaseLine) ELSE GetSourceDocuments.SETTABLEVIEW(SalesLine); GetSourceDocuments.RUNMODAL;
Actually, looking at the code now, I haven't catered for transfers, but I will do that shortly..
Thanks.
I'm not crazy !!! Just ask my toaster...
.0 -
I would change the code so that you don't hardcode table no.
Instead use Database::"Sales Line",
same for document type0 -
Thanks..
I will make those changes....
I'm not crazy !!! Just ask my toaster...
.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