Help 2013r2 Trouble Upgrading UpdateDimensions function

itsandsllc
Member Posts: 13
Hello all I am working on my first upgrade to 2013 r2 that I have inherited and trying to upgrade a database with a lot of dimension based modifications, no documentation and the client has no clue about what has been done under the covers for them. I have just started with 2013 and only done one other upgrade at this time. I have my c/side solution development in nav 2013 and chapter 8 - Module Dimensions open but I am having some trouble understanding how I should use the new calls to upgrade the following code. I have searched and been trying for a few hours but I am not getting the same results as used to occur on NAV 5. I know this is surely trivial for some but any inputs would be much appreciated; I'm sorry to say that the majority of my experiance with dimensions has been in setup and reporting. I have been just fine adapting to other changes but could really use some help here.
#-o
Thanks in advance for any and all replys
Current Code ::
Function UpdateDimensions() is on table 38 Purchase Header and I have just about the same function on the lines; I should also mention the customer no. is the same as global dim 2. Thats why there is the call from the customer.
Vars:
Name | DataType | Subtype | Length
GeneralLedgerSetup | Record | General Ledger Setup
Customer | Record | Customer
DefaultDimension |Record | Default Dimension
DocumentDimension | Record | Used to be Document Dimension Table 357
Thanks again for any help.
#-o
Thanks in advance for any and all replys

Current Code ::
Function UpdateDimensions() is on table 38 Purchase Header and I have just about the same function on the lines; I should also mention the customer no. is the same as global dim 2. Thats why there is the call from the customer.
Vars:
Name | DataType | Subtype | Length
GeneralLedgerSetup | Record | General Ledger Setup
Customer | Record | Customer
DefaultDimension |Record | Default Dimension
DocumentDimension | Record | Used to be Document Dimension Table 357
ChangeDimensions() IF Customer.GET("Shortcut Dimension 2 Code") THEN BEGIN GeneralLedgerSetup.GET; DefaultDimension.SETRANGE("Table ID", 18); DefaultDimension.SETRANGE("No.","Shortcut Dimension 2 Code"); IF DefaultDimension.FINDFIRST THEN REPEAT IF DefaultDimension."Dimension Code" = GeneralLedgerSetup."Global Dimension 1 Code" THEN VALIDATE("Shortcut Dimension 1 Code", DefaultDimension."Dimension Value Code") ELSE IF DefaultDimension."Dimension Code" <> "Shortcut Dimension 2 Code" THEN IF DocumentDimension.GET(DATABASE::"Purchase Header","Document Type","No.",0,DefaultDimension."Dimension Code") THEN BEGIN DocumentDimension.VALIDATE("Dimension Value Code", DefaultDimension."Dimension Value Code"); DocumentDimension.MODIFY(TRUE); END ELSE BEGIN CLEAR(DocumentDimension); DocumentDimension.VALIDATE("Table ID",DATABASE::"Purchase Header"); DocumentDimension.VALIDATE("Document Type", "Document Type"); DocumentDimension.VALIDATE("Document No.", "No."); DocumentDimension.VALIDATE("Line No.", 0); DocumentDimension.VALIDATE("Dimension Code", DefaultDimension."Dimension Code"); DocumentDimension.VALIDATE("Dimension Value Code", DefaultDimension."Dimension Value Code"); DocumentDimension.INSERT(TRUE); END; UNTIL DefaultDimension.NEXT = 0; END;
Thanks again for any help.
0
Comments
-
Hi, you can take advantage from new dimension management in NAV 2013 where Document Dimension, Posted Document Dimension and so on are replace by a unique new table called Dimension Set Entry, whose primary key is an integer evaluated through DimensionManagement codeunit.
According to this I suggest to modify your function as follow:PROCEDURE UpdateDimensions@1101321000(); VAR Customer@1101321000 : Record 18; GeneralLedgerSetup@1101321001 : Record 98; DefaultDimension@1101321002 : Record 352; TempDimSetEntry@1101321005 : TEMPORARY Record 480; DimMgt@1101321004 : Codeunit 408; OldDimSetID@1101321003 : Integer; NewDimSetID@1101321006 : Integer; BEGIN IF Customer.GET("Shortcut Dimension 2 Code") THEN BEGIN GeneralLedgerSetup.GET; DefaultDimension.SETRANGE("Table ID", 18); DefaultDimension.SETRANGE("No.","Shortcut Dimension 2 Code"); IF DefaultDimension.FINDFIRST THEN REPEAT OldDimSetID := "Dimension Set ID"; DimMgt.GetDimensionSet(TempDimSetEntry,OldDimSetID); //Get existing purchase order header dimensions TempDimSetEntry.SETRANGE("Dimension Code",DefaultDimension."Dimension Code"); IF DefaultDimension."Dimension Code" = GeneralLedgerSetup."Global Dimension 1 Code" THEN VALIDATE("Shortcut Dimension 1 Code",DefaultDimension."Dimension Value Code") ELSE IF DefaultDimension."Dimension Code" <> "Shortcut Dimension 2 Code" THEN IF TempDimSetEntry.FINDFIRST THEN TempDimSetEntry.VALIDATE("Dimension Value Code", DefaultDimension."Dimension Value Code") ELSE BEGIN TempDimSetEntry.INIT; TempDimSetEntry.VALIDATE("Dimension Code", DefaultDimension."Dimension Code"); TempDimSetEntry.VALIDATE("Dimension Value Code", DefaultDimension."Dimension Value Code"); TempDimSetEntry.INSERT; END; UNTIL DefaultDimension.NEXT = 0; NewDimSetID := DimMgt.GetDimensionSetID(TempDimSetEntry); //Get new DimSetID, after existing dimensions are modified IF OldDimSetID <> NewDimSetID THEN BEGIN "Dimension Set ID" := NewDimSetID; MODIFY; //Synchronize shortcut and global dimensions with the dimension set DimMgt.UpdateGlobalDimFromDimSetID("Dimension Set ID","Shortcut Dimension 1 Code","Shortcut Dimension 2 Code"); END; END; END;
Hope it works fine, I'm in a hurry and I didn't test it :oops:* Daniele Rebussi * | * Rebu NAV Diary *0 -
Hey geordie thanks so much for your response =D> I really appreciate it. I’m mowing over the code and running some tests on it. I can see now how you changed the code around and really appreciate the inputs.
I will post back and let you know how the testing turns out.
Thanks again so much for the help0
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