Sales Header Archive Deletion problem

ozenineozenine Member Posts: 19
Good Day,
I need a second opinion :)
Here is the code from the function that creates the SO Archive (Codeunit 5063):
StoreDocDim(
  DATABASE::"Sales Header",SalesHeader."Document Type",
  SalesHeader."No.",0,SalesHeader."Doc. No. Occurrence",SalesHeaderArchive."Version No.",
   DATABASE::"Sales Header Archive");
............
............
StoreDocDim(
    DATABASE::"Sales Line",SalesLine."Document Type",SalesLine."Document No.",
    SalesLine."Line No.",SalesHeader."Doc. No. Occurrence","Version No.",
     DATABASE::"Sales Line Archive");

Here is the function taht it calls:
StoreDocDim(TableId : Integer;DocType : Option;DocNo : Code[20];LineNo : Integer;DocNoOccurrence : Integer;VersionNo : Integer;NewTableID : Integer)
DocDim.SETRANGE("Table ID",TableId);
DocDim.SETRANGE("Document Type",DocType);
DocDim.SETRANGE("Document No.",DocNo);
DocDim.SETRANGE("Line No.",LineNo);
IF DocDim.FINDSET THEN
  REPEAT
    DocDimArchive.INIT;
    DocDimArchive.TRANSFERFIELDS(DocDim);
    DocDimArchive."Table ID" := NewTableID;
    DocDimArchive."Version No." := VersionNo;
    DocDimArchive."Doc. No. Occurrence" := DocNoOccurrence;
    DocDimArchive.INSERT;
  UNTIL DocDim.NEXT = 0;

So when it creates archives it enters dimensions in the Document Dimension Archive table

When you delete Sales Archive Header this code executes:
DocDimensionArchive.SETRANGE("Table ID",DATABASE::"Sales Header");
DocDimensionArchive.SETRANGE("Document Type","Document Type");
DocDimensionArchive.SETRANGE("Document No.","No.");
DocDimensionArchive.SETRANGE("Doc. No. Occurrence","Doc. No. Occurrence");
DocDimensionArchive.SETRANGE("Version No.","Version No.");
DocDimensionArchive.DELETEALL;
DocDimensionArchive.SETRANGE("Table ID",DATABASE::"Sales Line");
DocDimensionArchive.DELETEALL;

So the BUG is taht it does not delete the Archived Dimensions since it enters Doc. Dim with the table if of 5107 or 5108 and it tries to delete dimesions taht were attached to tables 36 and 37.

So I wanted to get second opinion on this before I fix that. It is just hard to believe taht this obvious bug was not corrected yet, or i am just looking at it in the wrong way.

Thanks
Oleg Zenine

Answers

  • kapamaroukapamarou Member Posts: 1,152
    :bug:
  • ayhan06ayhan06 Member Posts: 210
    ozenine wrote:
    Good Day,
    I need a second opinion :)
    Here is the code from the function that creates the SO Archive (Codeunit 5063):
    StoreDocDim(
      DATABASE::"Sales Header",SalesHeader."Document Type",
      SalesHeader."No.",0,SalesHeader."Doc. No. Occurrence",SalesHeaderArchive."Version No.",
       DATABASE::"Sales Header Archive");
    ............
    ............
    StoreDocDim(
        DATABASE::"Sales Line",SalesLine."Document Type",SalesLine."Document No.",
        SalesLine."Line No.",SalesHeader."Doc. No. Occurrence","Version No.",
         DATABASE::"Sales Line Archive");
    

    Here is the function taht it calls:
    StoreDocDim(TableId : Integer;DocType : Option;DocNo : Code[20];LineNo : Integer;DocNoOccurrence : Integer;VersionNo : Integer;NewTableID : Integer)
    DocDim.SETRANGE("Table ID",TableId);
    DocDim.SETRANGE("Document Type",DocType);
    DocDim.SETRANGE("Document No.",DocNo);
    DocDim.SETRANGE("Line No.",LineNo);
    IF DocDim.FINDSET THEN
      REPEAT
        DocDimArchive.INIT;
        DocDimArchive.TRANSFERFIELDS(DocDim);
        DocDimArchive."Table ID" := NewTableID;
        DocDimArchive."Version No." := VersionNo;
        DocDimArchive."Doc. No. Occurrence" := DocNoOccurrence;
        DocDimArchive.INSERT;
      UNTIL DocDim.NEXT = 0;
    

    So when it creates archives it enters dimensions in the Document Dimension Archive table

    When you delete Sales Archive Header this code executes:
    DocDimensionArchive.SETRANGE("Table ID",DATABASE::"Sales Header");
    DocDimensionArchive.SETRANGE("Document Type","Document Type");
    DocDimensionArchive.SETRANGE("Document No.","No.");
    DocDimensionArchive.SETRANGE("Doc. No. Occurrence","Doc. No. Occurrence");
    DocDimensionArchive.SETRANGE("Version No.","Version No.");
    DocDimensionArchive.DELETEALL;
    DocDimensionArchive.SETRANGE("Table ID",DATABASE::"Sales Line");
    DocDimensionArchive.DELETEALL;
    

    So the BUG is taht it does not delete the Archived Dimensions since it enters Doc. Dim with the table if of 5107 or 5108 and it tries to delete dimesions taht were attached to tables 36 and 37.

    So I wanted to get second opinion on this before I fix that. It is just hard to believe taht this obvious bug was not corrected yet, or i am just looking at it in the wrong way.

    Thanks
    Oleg Zenine
    i have come up with this bug 3 months ago and corrected by myself.
  • ozenineozenine Member Posts: 19
    Okie, so I will just fix it up myself then. Thanks
Sign In or Register to comment.