Design Details: Code Examples of Changed Patterns in Modifications

This topic provides code examples to show changed patterns in dimension code modification and migration for five different scenarios. It compares the code examples in earlier versions to the code examples in Microsoft Dynamics NAV 2013.

Posting a Journal Line

Key changes are listed as follows:

  • Journal line dimension tables are removed.

  • A dimension set ID is created in the Dimension Set ID field.

Earlier Versions Microsoft Dynamics NAV 2013
ResJnlLine."Qty. per Unit of Measure" := 
  SalesLine."Qty. per Unit of Measure";
TempJnlLineDim.DELETEALL;
TempDocDim.RESET;
TempDocDim.SETRANGE(
  "Table ID",DATABASE::"Sales Line");
TempDocDim.SETRANGE(
  "Line No.",SalesLine."Line No.");
DimMgt.CopyDocDimToJnlLineDim(
  TempDocDim,TempJnlLineDim);
ResJnlPostLine.RunWithCheck(
  ResJnlLine,TempJnlLineDim);
ResJnlLine."Qty. per Unit of Measure" := 
  SalesLine."Qty. per Unit of Measure";
ResJnlLine."Dimension Set ID" := 
  SalesLine." Dimension Set ID ";
ResJnlPostLine.Run(ResJnlLine);

Posting a Document

When you post a document in Microsoft Dynamics NAV 2013, you no longer have to copy the document dimensions.

Earlier Versions Microsoft Dynamics NAV 2013
DimMgt.MoveOneDocDimToPostedDocDim(
  TempDocDim,DATABASE::"Sales Line",
  "Document Type",
  "No.",
  SalesShptLine."Line No.",
  DATABASE::"Sales Shipment Line",
  SalesShptHeader."No.");
SalesShptLine."Dimension Set ID”
  := SalesLine."Dimension Set ID”

Editing Dimensions from a Document

You can edit dimensions from a document. For example, you can edit a sales order line.

Earlier Versions Microsoft Dynamics NAV 2013
Table 37, function ShowDimensions:
TESTFIELD("Document No.");
TESTFIELD("Line No.");
DocDim.SETRANGE("Table ID",DATABASE::"Sales Line");
DocDim.SETRANGE("Document Type","Document Type");
DocDim.SETRANGE("Document No.","Document No.");
DocDim.SETRANGE("Line No.","Line No.");
DocDimensions.SETTABLEVIEW(DocDim);
DocDimensions.RUNMODAL;
Table 37, function ShowDimensions:
"Dimension ID" := 
  DimSetEntry.EditDimensionSet(
    "Dimension ID");

Showing Dimensions from Posted Entries

You can show dimensions from posted entries, such as sales shipment lines.

Earlier Versions Microsoft Dynamics NAV 2013
Table 111, function ShowDimensions:
TESTFIELD("No.");
TESTFIELD("Line No.");
PostedDocDim.SETRANGE(
  "Table ID",DATABASE::"Sales Shipment Line");
PostedDocDim.SETRANGE(
  "Document No.","Document No.");
PostedDocDim.SETRANGE("Line No.","Line No.");
PostedDocDimensions.SETTABLEVIEW(PostedDocDim);
PostedDocDimensions.RUNMODAL;
Table 111, function ShowDimensions:
DimSetEntry.ShowDimensionSet(
  "Dimension ID");

Getting Default Dimensions for a Document

You can get default dimensions for a document, such as a sales order line.

Earlier Versions Microsoft Dynamics NAV 2013
Table 37, function CreateDim()
SourceCodeSetup.GET;
TableID[1] := Type1;
No[1] := No1;
TableID[2] := Type2;
No[2] := No2;
TableID[3] := Type3;
No[3] := No3;
"Shortcut Dimension 1 Code" := '';
"Shortcut Dimension 2 Code" := '';
DimMgt.GetPreviousDocDefaultDim(
  DATABASE::"Sales Header","Document Type",
  "Document No.",0,
  DATABASE::Customer,
  "Shortcut Dimension 1 Code",
  "Shortcut Dimension 2 Code");
DimMgt.GetDefaultDim(
  TableID,No,SourceCodeSetup.Sales,
  "Shortcut Dimension 1 Code",
  "Shortcut Dimension 2 Code");
IF "Line No." <> 0 THEN
  DimMgt.UpdateDocDefaultDim(
    DATABASE::"Sales Line","Document Type",
    "Document No.","Line No.",
    "Shortcut Dimension 1 Code",
    "Shortcut Dimension 2 Code");
Table 37, function CreateDim()
SourceCodeSetup.GET;
TableID[1] := Type1;
No[1] := No1;
TableID[2] := Type2;
No[2] := No2;
TableID[3] := Type3;
No[3] := No3;
"Shortcut Dimension 1 Code" := '';
"Shortcut Dimension 2 Code" := '';
GetSalesHeader;
"Dimension ID" :=
  DimMgt.GetDefaultDimID(
    TableID,No,SourceCodeSetup.Sales,
    "Shortcut Dimension 1 Code",
    "Shortcut Dimension 2 Code",
    SalesHeader."Dimension ID",
    DATABASE::"Sales Header");

See Also

Concepts

Design Details: Dimension Set Entries
Dimension Set Entries Overview
Design Details: Searching for Dimension Combinations
Design Details: Table Structure
Design Details: Codeunit 408 Dimension Management