NAV 2017

“Create New Dimension ID to import dimension values from buffer table”


Many questions in Microsoft forum about this topic: “How to generate new dimension ID from data (dimensions values for NAV login) existing on external tables ?”

Use standard NAV to achieve this, you can use standard NAV function DimMgt.GetDimensionSetID(Rec) to create New Dimension SET ID of function existing on UpgradeToolkit since NAV 2013.

Dimennsion config

Utilization of “DimMgt.GetDimensionSetID(TempDimSetEntry)” function

Elements:

Page “Edit Dimension Set Entries (480)”
Table “Dimension Set Entry (480)”

On Open Page
DimSetID := GETRANGEMIN(“Dimension Set ID”);
DimMgt.GetDimensionSet(Rec,DimSetID);

On Close Page
DimSetID := DimMgt.GetDimensionSetID(Rec);

Create New Dimension Set ID

//Variabiles
StazID :=0;
ImpID :=0;
RepID :=0;
Staz := BufferRegDim.Station;

//Loop on dimension values on buffer table
Example: we have dimensions values to import existing on external table: “BufferRegDim”

BufferRegDim.RESET;
BufferRegDim.SETCURRENTKEY(“Processed”);
BufferRegDim.SETRANGE(“Processe”,FALSE);

IF BufferRegDim.FINDSET THEN REPEAT
Line :=0;
ItemJournalLine2.RESET;
ItemJournalLine2.SETFILTER(“Journal Template Name”,’%1′,’ITEM’);
ItemJournalLine2.SETRANGE(“Journal Batch Name”, ‘MyTestBatch’);

IF ItemJournalLine2.FINDLAST THEN
Line := ItemJournalLine2.”Line No.”;

ItemJournalLine.”Journal Template Name” := ‘ITEM’;
etc. etc. etc.

//Example – extraction from Dimension Values – filter for “BufferRegDim.Stations”
DimensionValue.RESET;
DimensionValue.SETFILTER(DimensionValue.”Dimension Code”,’%1′,’STATIONS’);
DimensionValue.SETFILTER(DimensionValue.Code,’%1′,BufferRegDim.Stations);

IF DimensionValue.FINDFIRST THEN BEGIN
Imp := DimensionValue.”Dimension Father Valure”;
StazID:=DimensionValue.”Dimension Value ID”;

DimensionValue2.RESET;
DimensionValue2.SETFILTER(DimensionValue2.”Dimension Code”,’%1′,’PLANTS’);
DimensionValue2.SETFILTER(DimensionValue2.Code,’%1′,DimensionValue.”Dimension Father Valure”);
IF DimensionValue2.FINDFIRST THEN BEGIN
Rep := DimensionValue2.”Dimension Father Valure”;
ImpID:= DimensionValue2.”Dimension Value ID”;

DimensionValue3.RESET;
DimensionValue3.SETFILTER(DimensionValue3.”Dimension Code”,’%1′,’DEPARTS’);
DimensionValue3.SETFILTER(DimensionValue3.Code,’%1′,DimensionValue2.”Dimension Father Valure”);
IF DimensionValue3.FINDFIRST THEN BEGIN
RepID:= DimensionValue3.”Dimension Value ID”;
END;
END;
END;

//Creation of New”Dimensions Set ID”  : examples STATIONS and PLANTS

TempDimSetEntry.RESET;  TempDimSetEntry.”Dimension Code” := ‘STATIONS’;  TempDimSetEntry.”Dimension Value Code” := Staz;  TempDimSetEntry.”Dimension Value ID” := StazID;  TempDimSetEntry.INSERT;

//write to journal line
ItemJournalLine.”Dimension Set ID” := DimMgt.GetDimensionSetID(TempDimSetEntry);

TempDimSetEntry.”Dimension Code” := ‘PLANTS’;
TempDimSetEntry.”Dimension Value Code” := Imp;
TempDimSetEntry.”Dimension Value ID” := ImpID;
TempDimSetEntry.INSERT;

//write to journal line
ItemJournalLine.”Dimension Set ID” := DimMgt.GetDimensionSetID(TempDimSetEntry);

ItemJournalLine.INSERT;

Example of output

reg magaz

etc. etc.etc.

Annunci

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...