Optimization of codes on report

liizz
Member Posts: 125
Hi all,
I wish to reduce the codes as the only part which is changing in the SETRANGE is the Dimension Code part(highlighted in bold) and thus retrieving the corresponding Dimension Value Code from Posted Document Dimension table. This piece of code is being used on a report.
PostedDocDimension.SETRANGE("Table ID",110);
PostedDocDimension.SETRANGE("Document No.","Sales Shipment Header"."No.");
PostedDocDimension.SETRANGE("Dimension Code",'D');
IF PostedDocDimension.FINDFIRST THEN
GTxt[1]:=PostedDocDimension."Dimension Value Code";
PostedDocDimension.SETRANGE("Table ID",110);
PostedDocDimension.SETRANGE("Document No.","Sales Shipment Header"."No.");
PostedDocDimension.SETRANGE("Dimension Code",'L');
IF PostedDocDimension.FINDFIRST THEN
GTxt[2]:=PostedDocDimension."Dimension Value Code";
PostedDocDimension.SETRANGE("Table ID",110);
PostedDocDimension.SETRANGE("Document No.","Sales Shipment Header"."No.");
PostedDocDimension.SETRANGE("Dimension Code",'H');
IF PostedDocDimension.FINDFIRST THEN
GTxt[3]:=PostedDocDimension."Dimension Value Code";
Is there a possible way to optimize the codes as I am fetching from the same Table ID and Document No..
Please help me.
Thanks
Liizz
I wish to reduce the codes as the only part which is changing in the SETRANGE is the Dimension Code part(highlighted in bold) and thus retrieving the corresponding Dimension Value Code from Posted Document Dimension table. This piece of code is being used on a report.
PostedDocDimension.SETRANGE("Table ID",110);
PostedDocDimension.SETRANGE("Document No.","Sales Shipment Header"."No.");
PostedDocDimension.SETRANGE("Dimension Code",'D');
IF PostedDocDimension.FINDFIRST THEN
GTxt[1]:=PostedDocDimension."Dimension Value Code";
PostedDocDimension.SETRANGE("Table ID",110);
PostedDocDimension.SETRANGE("Document No.","Sales Shipment Header"."No.");
PostedDocDimension.SETRANGE("Dimension Code",'L');
IF PostedDocDimension.FINDFIRST THEN
GTxt[2]:=PostedDocDimension."Dimension Value Code";
PostedDocDimension.SETRANGE("Table ID",110);
PostedDocDimension.SETRANGE("Document No.","Sales Shipment Header"."No.");
PostedDocDimension.SETRANGE("Dimension Code",'H');
IF PostedDocDimension.FINDFIRST THEN
GTxt[3]:=PostedDocDimension."Dimension Value Code";
Is there a possible way to optimize the codes as I am fetching from the same Table ID and Document No..
Please help me.
Thanks
Liizz
0
Comments
-
What about:
PostedDocDimension.SETRANGE("Table ID",110); PostedDocDimension.SETRANGE("Document No.","Sales Shipment Header"."No."); PostedDocDimension.SETRANGE("Dimension Code",'D'); IF PostedDocDimension.FINDFIRST THEN GTxt[1]:=PostedDocDimension."Dimension Value Code"; PostedDocDimension.SETRANGE("Dimension Code",'L'); IF PostedDocDimension.FINDFIRST THEN GTxt[2]:=PostedDocDimension."Dimension Value Code"; PostedDocDimension.SETRANGE("Dimension Code",'H'); IF PostedDocDimension.FINDFIRST THEN GTxt[3]:=PostedDocDimension."Dimension Value Code";
0 -
No, this is not working when I apply your codes.0
-
Is there reason why you don't filter the Line No. ? Then you could use GET instead of filter.
Below code will not work if you have multiple records per Dimension Code.PostedDocDimension.SETRANGE("Table ID",110); PostedDocDimension.SETRANGE("Document No.","Sales Shipment Header"."No."); PostedDocDimension.SETFILTER("Dimension Code",'%1|%2|%3','D','L','H'); IF PostedDocDimension.FINDSET THEN REPEAT CASE PostedDocDimension."Dimension Code" OF 'D' : GTxt[1]:=PostedDocDimension."Dimension Value Code"; 'L' : GTxt[2]:=PostedDocDimension."Dimension Value Code"; 'H' : GTxt[3]:=PostedDocDimension."Dimension Value Code"; END; UNTIL PostedDocDimension.NEXT = 0;
Microsoft Certified IT Professional for Microsoft Dynamics NAV
Just a happy frood who knows where his towel is0
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