Multi field Item filter for dataport - ?best way?

jbra
Member Posts: 32
Using a dataport, I am trying to export only items that are members of a specific Item Categories, Product Groups or Product Lines. Each of these are a separate field in our Item table.
To exclude those that I do not want I have written the following.
This works, but it's very slow. My actual list of categories and groups is much longer.
Do you have suggestions on a better way to get this done?
Thanks!
To exclude those that I do not want I have written the following.
Item - OnBeforeExportRecord() IF NOT ( ("Item Category Code"='1730') OR ("Item Category Code"='2110') OR ("Product Group Code"='241210') OR ("Product Group Code"='241212') OR ("Product Line Code"='28163201') OR ("Product Line Code"='28221002') OR ("Product Line Code"='28225002') ) THEN CurrDataport.SKIP;
This works, but it's very slow. My actual list of categories and groups is much longer.
Do you have suggestions on a better way to get this done?
Thanks!
0
Comments
-
I would have added a boolean field to the Item categories, Product codes etc. to mark them for export ( or not ), then check them on the fly in your dataport
if not ItemCategory.get("Item category code") then ItemCategory.Init ; if not Productcode.get("Product Group Code") then ProductCode.Init ; If not ProductLine.get("Product Line Code") then ProductLine.Init ; if not ( Itemcategory.export OR Productcode.export OR productline.export) then currdataport.skip ;
0 -
I would presume the speed would be the same.
Those records need to be evaluated with a filter or by your code..
0 -
mdPartnerNL wrote:I would presume the speed would be the same.
Those records need to be evaluated with a filter or by your code..
0 -
Using a dataport, I am trying to export only items that are members of a specific Item Categories, Product Groups or Product Lines. Each of these are a separate field in our Item table.
If you're only exporting a minority of the total records, you can avoid having to scan through the whole table by looking through each segment individually and combining them into a temp table:Item.MARKEDONLY(FALSE); Item.SETCURRENTKEY("Item Category Code"); //if available Item.SETFILTER("Item Category Code",'1730|2110'); IF Item.FINDSET THEN REPEAT Item.MARK(TRUE); UNTIL Item.NEXT = 0; Item.SETRANGE("Item Category Code"); Item.SETCURRENTKEY(""Product Group Code"); //if available Item.SETFILTER("Product Group Code",'241210|241212'); IF Item.FINDSET THEN REPEAT Item.MARK(TRUE); UNTIL Item.NEXT = 0; Item.SETRANGE("Product Group Code"); Item.SETCURRENTKEY("Product Line Code"); //if available Item.SETFILTER("Product Line Code",'28163201|28221002|28225002'); IF Item.FINDSET THEN REPEAT Item.MARK(TRUE); UNTIL Item.NEXT = 0; Item.SETRANGE("Product Line Code"); Item.SETCURRENTKEY("No."); Item.MARKEDONLY(TRUE); REPORT.RUN(123456,TRUE,TRUE,Item);
Depending on the number of items and groups, and categories, this could be a lot faster.
- Reinhard0
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