Am I missing something or is ...

Am I missing something or is this code wrong? I was answering a question for Ziad, and was looking in the Explode BOM codeunits and came across this code, it is the same in both, the Sales and Purchase-Exploded BOM. FromDocDim.SETRANGE(“Table ID”,DATABASE::“Purchase Line”); FromDocDim.SETRANGE(“Document Type”,“Document Type”); FromDocDim.SETRANGE(“Document No.”,“Document No.”); FromDocDim.SETRANGE(“Line No.”,“Line No.”); ToDocDim.SETRANGE(“Table ID”,DATABASE::“Purchase Line”); ToDocDim.SETRANGE(“Document Type”,“Document Type”); ToDocDim.SETRANGE(“Document No.”,“Document No.”); DimMgt.CopyDocDimToDocDim(FromDocDim,TempDocDim); CLEAR(TempDocDim); FromDocDim.DELETEALL; Why would we fill the TempDocDim and then Clear it? Why would we Delete all the Dimensions from the calling Line? Strange[:I] We should not be DELETEALL on the FromDocDim, and CLEAR(TempDocDim) before we fill it. Is it a known bug or am I missing something? Version 4.00

quote:

Why would we fill the TempDocDim and then Clear it?
Originally posted by David Cox - 2006 Apr 24 : 05:22:32

The TempDocDim is used later to populate the dimensions for the created sales/purchase line if the user select to populate them using father dimensions: IF Selection = 1 THEN BEGIN ToSalesLine."Shortcut Dimension 1 Code" := "Shortcut Dimension 1 Code"; ToSalesLine."Shortcut Dimension 2 Code" := "Shortcut Dimension 2 Code"; ToSalesLine.MODIFY; ToDocDim.SETRANGE("Line No.",ToSalesLine."Line No."); ToDocDim.DELETEALL; IF TempDocDim.FIND('-') THEN BEGIN REPEAT ToDocDim.INIT; ToDocDim."Table ID" := DATABASE::"Sales Line"; ToDocDim."Document Type" := ToSalesLine."Document Type"; ToDocDim."Document No." := ToSalesLine."Document No."; ToDocDim."Line No." := ToSalesLine."Line No."; ToDocDim."Dimension Code" := TempDocDim."Dimension Code"; ToDocDim."Dimension Value Code" := TempDocDim."Dimension Value Code"; ToDocDim.INSERT; UNTIL TempDocDim.NEXT = 0; END; END;

quote:

Why would we Delete all the Dimensions from the calling Line?
Originally posted by David Cox - 2006 Apr 24 : 05:22:32

the calling line is the one that will be changed in a comment line, therefore it doesn’t need the dimensions.

quote:

quote:
Why would we fill the TempDocDim and then Clear it?
Originally posted by David Cox - 2006 Apr 24 : 05:22:32

The TempDocDim is used later to populate the dimensions for the created sales/purchase line if the user select to populate them using father dimensions: IF Selection = 1 THEN BEGIN ToSalesLine."Shortcut Dimension 1 Code" := "Shortcut Dimension 1 Code"; ToSalesLine."Shortcut Dimension 2 Code" := "Shortcut Dimension 2 Code"; ToSalesLine.MODIFY; ToDocDim.SETRANGE("Line No.",ToSalesLine."Line No."); ToDocDim.DELETEALL; IF TempDocDim.FIND('-') THEN BEGIN REPEAT ToDocDim.INIT; ToDocDim."Table ID" := DATABASE::"Sales Line"; ToDocDim."Document Type" := ToSalesLine."Document Type"; ToDocDim."Document No." := ToSalesLine."Document No."; ToDocDim."Line No." := ToSalesLine."Line No."; ToDocDim."Dimension Code" := TempDocDim."Dimension Code"; ToDocDim."Dimension Value Code" := TempDocDim."Dimension Value Code"; ToDocDim.INSERT; UNTIL TempDocDim.NEXT = 0; END; END;

quote:
Why would we Delete all the Dimensions from the calling Line?
Originally posted by David Cox - 2006 Apr 24 : 05:22:32

the calling line is the one that will be changed in a comment line, therefore it doesn’t need the dimensions.
Originally posted by navisi0ne - 2006 Apr 24 : 05:42:39

Ok I forgot about the Comment Line [:I], the code that Ziad wanted was a copyline function, so I showed him how to construct a line using the code from the Explode BOM codeunit, In this I did not use the DELETEALL as He wants to retain the Dimensions and Line Detail. Thanks