Sql to nav page

sjen
Member Posts: 53
Hi,
I have a sql statement and my client runs this sql monthly basis and he decided that he wants this in nav. I created a temp page and a report for them to enter a date range(request page) then i want to display but I can't display the way I want.
for example here my sql statement
My solution is
I can do the rest but I cant filter properly. What am I missing? I am a beginner btw
I have a sql statement and my client runs this sql monthly basis and he decided that he wants this in nav. I created a temp page and a report for them to enter a date range(request page) then i want to display but I can't display the way I want.
for example here my sql statement
dbo.[Companyname$Purch_ Inv_ Line].No_ LIKE '122350%' OR dbo.[Companyname$Purch_ Inv_ Line].No_ LIKE '122370%' OR dbo.[Companyname$Purch_ Inv_ Line].No_ LIKE '7%')
My solution is
IF PurchInvLine.FINDSET THEN REPEAT IF (Type = Type::"G/L Account") AND ((COPYSTR("No.",1,6) IN ['122350', '122370']) OR // Problem is here I know. If I don't have anything here I can display everything (COPYSTR("No.",1,1) = '7')) BEGIN // Populate Temp Table // Rec := PurchInvLine; INSERT; END; UNTIL PurchInvLine.NEXT = 0; UNTIL PurchInvHeader.NEXT = 0;
I can do the rest but I cant filter properly. What am I missing? I am a beginner btw
0
Best Answers
-
Hi sjen,
why don't you filter in NAV?PurchInvLine.SETRANGE(Type,Type::"G/L Account"); PurchInvLine.SETFILTER("No.",'%1*|%2*|%3*',122350,122370,7); IF PurchInvLine.FINDSET(FALSE,FALSE) THEN BEGIN REPEAT // Populate Temp Table // Rec := PurchInvLine; INSERT; UNTIL PurchInvLine.NEXT = 0; END;
5 -
@sjen Between SETRANGE and SETFILTER you should always give priority to SETRANGE.
COPYSTR will anyhow you have to do looping and SETFILTER will save you from this so SETFILTER holds the priority.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/1
Answers
-
Hi sjen,
You can use the Linked Object for linking to SQL Server objects.
https://docs.microsoft.com/en-us/dynamics-nav/using-linked-objects
1 -
Hi sjen,
why don't you filter in NAV?PurchInvLine.SETRANGE(Type,Type::"G/L Account"); PurchInvLine.SETFILTER("No.",'%1*|%2*|%3*',122350,122370,7); IF PurchInvLine.FINDSET(FALSE,FALSE) THEN BEGIN REPEAT // Populate Temp Table // Rec := PurchInvLine; INSERT; UNTIL PurchInvLine.NEXT = 0; END;
5 -
Thank you Jan87,
This should do the trick. I will work on it. Thank you for your time.0 -
@sjen - Even what you have written will work with certain tweak but it will have an impact over performance , Why to do unnecessary loops if it can be saved by a filter right.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/1 -
but using a setfilter, doesn't it make run slower than copystr?0
-
@sjen Between SETRANGE and SETFILTER you should always give priority to SETRANGE.
COPYSTR will anyhow you have to do looping and SETFILTER will save you from this so SETFILTER holds the priority.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/1 -
Thank you for your time @RockWithNAV,
I started nav 3-4 months ago and I feel like I am learning a lot. I also have the best mentor at work. Thank you again!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