Hi,
I have wrote something in order to take dimension values from item card and update the item journals . It seems that I'm doing something wrong. I have the following but I have error that Dimension set 0 already exists. Can somebody help me please? I'm trying for hours and I can't solve it.
I have 3 global variables that are the following
DefaultDimension Record Default Dimension
DimensionsetEntry Record Dimension Set Entry
TempDimensionsetEntry Record Dimension Set Entry
and my programming code is this
DefaultDimension.RESET;
DefaultDimension.SETRANGE(DefaultDimension."Table ID",27);
DefaultDimension.SETRANGE(DefaultDimension."No.","Item Journal Line"."Item No.");
IF DefaultDimension.FIND('-') THEN
REPEAT
DimensionsetEntry.INIT ;
DimensionsetEntry."Dimension Set ID" := "Item Journal Line"."Dimension Set ID";
DimensionsetEntry."Dimension Code" := DefaultDimension."Dimension Code" ;
DimensionsetEntry."Dimension Value Code" :=DefaultDimension."Dimension Value Code";
TempDimensionsetEntry.RESET;
TempDimensionsetEntry.SETRANGE("Dimension Set ID",DimensionsetEntry."Dimension Set ID");
TempDimensionsetEntry.SETRANGE("Dimension Code",DimensionsetEntry."Dimension Code");
TempDimensionsetEntry.SETRANGE("Dimension Value Code",DimensionsetEntry."Dimension Value Code");
IF NOT TempDimensionsetEntry.FIND('-') THEN
DimensionsetEntry.INSERT;
UNTIL DefaultDimension.NEXT = 0;
0
Answers
trying this I have an error
Dimension set Entry already exists ....
can you help please?
2) if you are calling the code in a loop add a TempDimensionsetEntry.DELETEALL; at the end of the code
I not sure what you mean, please explain in more detail with example data
however if some lines have already values then I have an error that dimension set already exists
my code is
IF ("Item Journal Line"."Journal Template Name" = 'PHYS. INVE') AND
("Item Journal Line"."Journal Batch Name" = 'LOC220') THEN
BEGIN
DefaultDimension.RESET;
DefaultDimension.SETRANGE(DefaultDimension."Table ID",27);
DefaultDimension.SETRANGE(DefaultDimension."No.","Item Journal Line"."Item No.");
IF DefaultDimension.FIND('-') THEN
REPEAT
TempDimensionsetEntry.INIT ;
TempDimensionsetEntry."Dimension Set ID" := "Item Journal Line"."Dimension Set ID";
TempDimensionsetEntry."Dimension Code" := DefaultDimension."Dimension Code" ;
TempDimensionsetEntry."Dimension Value Code" :=DefaultDimension."Dimension Value Code";
TempDimensionsetEntry.INSERT(TRUE);
UNTIL DefaultDimension.NEXT = 0;
"Item Journal Line"."Dimension Set ID" := DimensionMgt.GetDimensionSetID(TempDimensionsetEntry);
"Item Journal Line".MODIFY(TRUE);
TempDimensionsetEntry.DELETEALL
END;
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!