Thursday, July 16, 2015

Generate the Dimension Set ID using Dimension Tree Node Table

Hi,

By accidentally developer has forgot to set Temporary  = Yes for Record object of  Table 480 - "Dimension Set Entry" (In my case i have work on standard Save As Sales Document Test Report).

I have created record variable for table 480 - dimension set entry :
TempDimSetEntry - Record (Temporary = <No>)

I have execute the standard GetDimneisonSet function:
DimMgt.GetDimensionSet(TempDimSetEntry,"Dimension Set ID");

And if we have run this report using developer license than system has delete all the record from the dimension set entry tables (because we have forgot to set Temporary = Yes).

Suppose that this happen in production database of customer than it will give you big shock.

But relax it is not big issue at all. You can get the Dimension Set Entry deleted data back using the Dimension Tree Node Table.

Yes....That is true, Because i have already face this issue in production database and i have get back that deleted data in couple of hours.

OBJECT Report 90062 Generate Dimension Set ID
{
  OBJECT-PROPERTIES
  {
    Date=;
    Time=;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    Permissions=TableData 480=ri;
    ProcessingOnly=Yes;
    OnPostReport=BEGIN
                   Window.CLOSE;
                   MESSAGE('Done');
                 END;

  }
  DATASET
  {
    { 33027920;;DataItem;                    ;
               DataItemTable=Table481;
               DataItemTableView=SORTING(Parent Dimension Set ID,Dimension Value ID)
                                 WHERE(In Use=FILTER(Yes));
               OnPreDataItem=BEGIN
                               Window.OPEN(Text000);
                             END;

               OnAfterGetRecord=VAR
                                  DimensionSetEntry_lRec@33027921 : Record 480;
                                  LastID@33027922 : Integer;
                                BEGIN
                                  Window.UPDATE(1,"Dimension Set Tree Node"."Dimension Set ID");
                                  DimensionSetEntry_lRec.SETRANGE("Dimension Set ID","Dimension Set ID");
                                  IF NOT DimensionSetEntry_lRec.ISEMPTY THEN
                                    CurrReport.SKIP;

                                  TempDimSetTreeNode_lRecTmp.RESET;
                                  TempDimSetTreeNode_lRecTmp.DELETEALL;

                                  LastID := "Dimension Set Tree Node"."Parent Dimension Set ID";
                                  TempDimSetTreeNode_lRecTmp.Number := "Dimension Set Tree Node"."Dimension Value ID";
                                  TempDimSetTreeNode_lRecTmp.INSERT;
                                  WHILE LastID <> 0 DO BEGIN
                                    LastID := FindParentSetID(LastID);
                                  END;

                                  IF LastID = 0 THEN BEGIN
                                    TempDimSetTreeNode_lRecTmp.RESET;
                                    IF TempDimSetTreeNode_lRecTmp.FINDSET THEN BEGIN
                                      REPEAT
                                        DimensionValue_gRec.SETRANGE("Dimension Value ID",TempDimSetTreeNode_lRecTmp.Number);
                                        DimensionValue_gRec.FINDFIRST;
                                        DimensionSetEntry_lRec.INIT;
                                        DimensionSetEntry_lRec."Dimension Code" := DimensionValue_gRec."Dimension Code";
                                        DimensionSetEntry_lRec."Dimension Value Code" := DimensionValue_gRec.Code;
                                        DimensionSetEntry_lRec."Dimension Set ID" := "Dimension Set Tree Node"."Dimension Set ID";
                                        DimensionSetEntry_lRec."Dimension Value ID" := DimensionValue_gRec."Dimension Value ID";
                                        DimensionSetEntry_lRec.INSERT;
                                      UNTIL TempDimSetTreeNode_lRecTmp.NEXT = 0;
                                    END;
                                  END;
                                END;

               ReqFilterFields=Dimension Set ID }

  }
  REQUESTPAGE
  {
    PROPERTIES
    {
    }
    CONTROLS
    {
    }
  }
  LABELS
  {
  }
  CODE
  {
    VAR
      TempDimSetTreeNode_lRecTmp@33027920 : TEMPORARY Record 2000000026;
      DimSetEntry_gRec@33027922 : Record 480;
      DimensionValue_gRec@33027921 : Record 349;
      Window@33027923 : Dialog;
      Text000@33027924 : TextConst 'ENU=#1###############';

    PROCEDURE FindParentSetID@33027923(SetEntryNo@33027920 : Integer) : Integer;
    VAR
      DimSetTreeNode_lRec@33027921 : Record 481;
    BEGIN
      DimSetTreeNode_lRec.SETRANGE("Dimension Set ID",SetEntryNo);
      DimSetTreeNode_lRec.FINDLAST;
      TempDimSetTreeNode_lRecTmp.Number := DimSetTreeNode_lRec."Dimension Value ID";
      TempDimSetTreeNode_lRecTmp.INSERT;
      EXIT(DimSetTreeNode_lRec."Parent Dimension Set ID");
    END;

    BEGIN
    END.
  }
  RDLDATA
  {
  }
}


Please let me know if you find any issue with batch job.

No comments:

Post a Comment