local procedure OnAfterFunctionInsertItemJnlLine(var ItemJournalLine: Record "Item Journal Line")
var
TempDimensionSetEntry: Record "Dimension Set Entry" temporary;
DimesionManagement: Codeunit DimensionManagement;
DefaultDimension: Record "Default Dimension";
DimensionValue: Record "Dimension Value";
RecRef: RecordRef;
Location: Record Location;
Item: Record Item;
begin
If Item.Get(ItemJournalLine."Item No.") then begin
DefaultDimension.Reset();
DefaultDimension.SetRange("Table ID", Database::Item);
DefaultDimension.SetRange("No.", Item."No.");
if DefaultDimension.FindSet() then
repeat
DimensionValue.Get(DefaultDimension."Dimension Code", DefaultDimension."Dimension Value Code");
TempDimensionSetEntry.Init();
TempDimensionSetEntry.Validate("Dimension Code", DefaultDimension."Dimension Code");
TempDimensionSetEntry.Validate("Dimension Value Code", DefaultDimension."Dimension Value Code");
TempDimensionSetEntry."Dimension Value ID" := DimensionValue."Dimension Value ID";
TempDimensionSetEntry.Insert();
until DefaultDimension.Next() = 0;
end;
if Location.Get(ItemJournalLine."Location Code") then begin
DefaultDimension.Reset();
DefaultDimension.SetRange("Table ID", Database::Location);
DefaultDimension.SetRange("No.", Location.Code);
if DefaultDimension.FindSet() then
repeat
DimensionValue.Get(DefaultDimension."Dimension Code", DefaultDimension."Dimension Value Code");
TempDimensionSetEntry.Init();
TempDimensionSetEntry.Validate("Dimension Code", DefaultDimension."Dimension Code");
TempDimensionSetEntry.Validate("Dimension Value Code", DefaultDimension."Dimension Value Code");
TempDimensionSetEntry."Dimension Value ID" := DimensionValue."Dimension Value ID";
if TempDimensionSetEntry.Insert() then;
until DefaultDimension.Next() = 0;
end;
ItemJournalLine."Dimension Set ID" := DimesionManagement.GetDimensionSetID(TempDimensionSetEntry);
ItemJournalLine.Modify();
end;