SETCURRENTKEY Problems
Alkro
Member Posts: 115
I have readed old posts, but i don't find a solve...
This code:
TempILE --> Record - Item Ledger Entry
With this code, in TempILE, i have 134 records...
But when i add this:
Why? How can i apply filters with a secondary key, and then change to another key.
BR
This code:
TempILE --> Record - Item Ledger Entry
TempILE.SETCURRENTKEY("Entry Type","Item No.","Variant Code","Source Type","Source No.","Posting Date");
TempILE.SETRANGE(TempILE."Entry Type",TempILE."Entry Type"::Output);
TempILE.SETFILTER(TempILE."Source No.",ItemFilter);
TempILE.SETRANGE(TempILE."Posting Date",StartDate,EndDate);
IF TempILE.FIND('-') THEN BEGIN
.......
.......
With this code, in TempILE, i have 134 records...
But when i add this:
TempILE.SETCURRENTKEY("Entry Type","Item No.","Variant Code","Source Type","Source No.","Posting Date");
TempILE.SETRANGE(TempILE."Entry Type",TempILE."Entry Type"::Output);
TempILE.SETFILTER(TempILE."Source No.",ItemFilter);
TempILE.SETRANGE(TempILE."Posting Date",StartDate,EndDate);
IF TempILE.FIND('-') THEN BEGIN
TempILE.SETCURRENTKEY("Prod. Order No.","Prod. Order Line No.","Prod. Order Comp. Line No.","Entry Type");
I only have 72 records...Why? How can i apply filters with a secondary key, and then change to another key.
BR
0
Answers
-
You could copy the records in a new temporary table, and change the key.0
-
No need for temp table. Just do FINDFIRST after changing key.0
-
But Report is tooooooooo slow.Malajlo wrote:No need for temp table. Just do FINDFIRST after changing key.
For 5 days data, report is thinking about 2-3 minutes.TempILE.SETCURRENTKEY("Entry Type","Item No.","Variant Code","Source Type","Source No.","Posting Date"); TempILE.SETRANGE(TempILE."Entry Type",TempILE."Entry Type"::Output); TempILE.SETFILTER(TempILE."Source No.",ItemFilter); TempILE.SETRANGE(TempILE."Posting Date",StartDate,EndDate); TempILE.SETCURRENTKEY("Prod. Order No.","Prod. Order Line No.","Prod. Order Comp. Line No.","Entry Type"); IF TempILE.FINDFIRST THEN BEGIN .....
0 -
Remember that it doesn't matter in which order you put the SetRange and Setcurrentkey lines...the corresponding query will be built when you ask the DB for your records ( with a find or findfirst ), so in the above example the first setcurrentkey is totally wasted.Alkro wrote:
But Report is tooooooooo slow.Malajlo wrote:No need for temp table. Just do FINDFIRST after changing key.
For 5 days data, report is thinking about 2-3 minutes.TempILE.SETCURRENTKEY("Entry Type","Item No.","Variant Code","Source Type","Source No.","Posting Date"); TempILE.SETRANGE(TempILE."Entry Type",TempILE."Entry Type"::Output); TempILE.SETFILTER(TempILE."Source No.",ItemFilter); TempILE.SETRANGE(TempILE."Posting Date",StartDate,EndDate); TempILE.SETCURRENTKEY("Prod. Order No.","Prod. Order Line No.","Prod. Order Comp. Line No.","Entry Type"); IF TempILE.FINDFIRST THEN BEGIN .....
0 -
:SMBerger wrote:Remember that it doesn't matter in which order you put the SetRange and Setcurrentkey lines...the corresponding query will be built when you ask the DB for your records ( with a find or findfirst ), so in the above example the first setcurrentkey is totally wasted.
But, how can i apply filters with a key an then order with another key and the report not very slow????...0 -
The only viable way is to make a key that's usable for both ! which in your case would be :Alkro wrote:
:SMBerger wrote:Remember that it doesn't matter in which order you put the SetRange and Setcurrentkey lines...the corresponding query will be built when you ask the DB for your records ( with a find or findfirst ), so in the above example the first setcurrentkey is totally wasted.
But, how can i apply filters with a key an then order with another key and the report not very slow????...
Entry type, Source No., Posting Date, Prod. Order No. , Prod. Order Line No. , Prod. Order Comp. Line No.0 -
Problem is i want sort about "Prod. Order No.", and can have many Outputs in different dates.
Solved with copy all filtered records (Only "Prod. Order No.") to a own table with a temporary record and then this record order by "Prod. Order".
Thanks!0 -
Alkro, did you bother to read the very first reply to your question #-oSog wrote:You could copy the records in a new temporary table, and change the key.David Singleton0
-
Is the problem when anybody has many windows opened in Navigator...David Singleton wrote:Alkro, did you bother to read the very first reply to your question #-o
Excuse me (Sog)
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K 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
- 324 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
