Copying Dimension from Item ledger to Item Journal - NAV 2016

rnjbngrnjbng Member Posts: 82
I want to copy the dimensions from Item ledger entry to Item journal. How can I get a new Dimension set ID for the Item journal line. Below is the code I have.
itemledg.reset;
itemledg.setrange("Posting date",PostingDate);
if itemledg.findset then begin
DimSetEntry.reset;
Dimsetentry.setrange("dimension set ID",itemledg."dimension set id");
if dimsetentry.findset then begin
repeat
Newdimsetentry.reset;
Newdimsetentry.init;
Newdimsetentry.transferfields(dimsetentry);
newdimsetentry."dimension set id" := getdimensionsetid(dimentry); (Which does not work)
Newdimsetentry.insert;
until dimsetentry.next = 0;
end;
end;

Code highlighted just does not work. I just want to get a new dimension set ID for the Item journal line.

Any help is highly appreciated.

RJ.

Comments

  • davmac1davmac1 Member Posts: 1,283
    If you have the same dimensions then the dimension set id field in the item ledger should be all you need to copy to the item journal
  • vnhackvnhack Member Posts: 9
    1. Copy dimension to TempDimSetEntry

    OldDimSetID := "Dimension Set ID";
    DimMgt.GetDimensionSet(TempDimSetEntry,OldDimSetID); //obtain list of existing purchase order dimensions

    2. Insert new dimension to TempDimSetEntry
    .......
    3. Create new diemension set id
    NewDimSetID := DimMgt.GetDimensionSetID(TempDimSetEntry); //get new DimSetID

    IF OldDimSetID <> NewDimSetID THEN BEGIN
    "Dimension Set ID" := NewDimSetID; //assign new DimSetID
    DimMgt.UpdateGlobalDimFromDimSetID("Dimension Set ID","Shortcut Dimension 1 Code","Shortcut Dimension 2 Code");
    END;
  • rnjbngrnjbng Member Posts: 82
    Many..Many Thanks Vnhack.. works like a charm. Thanks for all your help.
Sign In or Register to comment.