Help needed for looping Sales Invoice Line!

Imaspal
Member Posts: 68
Hi Experts!
I have to get document numbers from a Sales Invoice Line -table (invoice numbers). I have to get numbers:
- that belong to a certain Customer,
- that consist (invoices) of certain group of Items.
These numbers I have to put for example in a String.
How can I do that? A code example would be very much awaited.
Yours,
IP
I have to get document numbers from a Sales Invoice Line -table (invoice numbers). I have to get numbers:
- that belong to a certain Customer,
- that consist (invoices) of certain group of Items.
These numbers I have to put for example in a String.
How can I do that? A code example would be very much awaited.
Yours,
IP
0
Comments
-
Hello Imaspal,
First thing very easy;SalesInvLine.RESET; SalesInvLine.SETRANGE("Sell-to Customer No.",CustomerNo); //Or maybe you want to set filter on Bill-to Customer No.? SalesInvLine.SETRANGE(Type,Type::Item); SalesInvLine.SETRANGE("No.",ItemNo); IF SalesInvLine.FINDSET THEN REPEAT //Looping through records.. UNTIL SalesInvLine.NEXT = 0;
If all you want is to place the document nos. in a string, then just add the following code when looping through records in Sales Invoice Line;IF ListOfDocNos = '' THEN ListOfDocNos := SalesInvLine."Document No." ELSE IF STRLEN(ListOfDocNos + ' ' + SalesInvLine."Document No.") < MAXSTRLEN(ListOfDocNos) THEN ListOfDocNos += ' ' + SalesInvLine."Document No.";
However, it could be that you'd want to use a temp table and then build records so that you can easily display a long list of document nos. in a report. If that's the case, then things get a little bit more complicated. You could use Comment Line as a temporary table to achieve this.
Here's some code that I've used myself to get a list of serial nos. associated with any given item.ItemLedgEntryTemp.RESET; IF ItemLedgEntryTemp.FINDSET THEN BEGIN LineNo := 0; DoInit := TRUE; REPEAT IF (STRLEN(CommentTemp.Comment + ' ' + ItemLedgEntryTemp."Serial No.") > MAXSTRLEN(CommentTemp.Comment)) OR (DoInit) THEN BEGIN LineNo += 1; CommentTemp.INIT; CommentTemp."Table Name" := CommentTemp."Table Name"::Item; CommentTemp."No." := "Sales Shipment Line"."No."; CommentTemp."Line No." := LineNo; CommentTemp.Date := TODAY; CommentTemp.Comment := ItemLedgEntryTemp."Serial No."; CommentTemp.INSERT; DoInit := FALSE; END ELSE BEGIN CommentTemp.Comment += ' ' + ItemLedgEntryTemp."Serial No."; CommentTemp.MODIFY; END; UNTIL ItemLedgEntryTemp.NEXT = 0; END;
0 -
Thank you for your exhaustive help. I'm very appreciated!
Yours,
IP0
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