mibuso.com

Microsoft Business Solutions online community
It is currently Wed Jun 19, 2013 1:18 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Optimization of codes on report
PostPosted: Wed May 16, 2012 12:08 pm 
Offline

Joined: Thu Dec 16, 2010 8:11 am
Posts: 97
Country: Bangladesh (bd)
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


Top
 Profile E-mail  
 
 Post subject: Re: Optimization of codes on report
PostPosted: Wed May 16, 2012 12:25 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Mon Nov 01, 2004 5:30 pm
Posts: 502
Location: Warnsveld
Country: Netherlands (nl)
What about:

Code: Select all
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";

_________________
Luc van Vugt, fluxxus.nl
Never stop learning
Van Vugt's dynamiXs
Dutch Dynamics Community


Top
 Profile  
 
 Post subject: Re: Optimization of codes on report
PostPosted: Wed May 16, 2012 12:51 pm 
Offline

Joined: Thu Dec 16, 2010 8:11 am
Posts: 97
Country: Bangladesh (bd)
No, this is not working when I apply your codes.


Top
 Profile E-mail  
 
 Post subject: Re: Optimization of codes on report
PostPosted: Thu May 17, 2012 4:29 am 
Offline

Joined: Mon Oct 24, 2011 2:58 am
Posts: 142
Location: Tokyo
Country: Japan (jp)
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.

Code: Select all
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 is


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: