How to Dynamically generate DImension set ID using CAL Code?

chandrurecchandrurec Member Posts: 560
edited 2013-07-24 in NAV Three Tier
Hi all,

I am importing the data from excel . while importing from excel, I need to generate the dimension set id on the fly.So I have written the code like follows.


SalesSetup.GET;

SLSMS.RESET;
IF SLSMS.FINDSET THEN REPEAT
IF SL.GET(SLSMS."Document Type",SLSMS."Document No.",SLSMS."Line No.") THEN;
IF NOT DimValue.GET(SalesSetup."Intake ID",SLSMS."Intake ID") THEN BEGIN
DimValue.INIT;
DimValue.VALIDATE("Dimension Code",SalesSetup."Intake ID");
DimValue.VALIDATE(Code,SLSMS."Intake ID");
DimValue.INSERT(TRUE);
END;

IF NOT DimValue.GET(SalesSetup."Course Type",SLSMS."Course Type") THEN BEGIN
DimValue.INIT;
DimValue.VALIDATE("Dimension Code",SalesSetup."Course Type");
DimValue.VALIDATE(Code,SLSMS."Course Type");
DimValue.INSERT(TRUE);
END;

IF NOT DimSetEntryInsert.GET(SL."Dimension Set ID",SalesSetup."Intake ID") THEN BEGIN
DimSetEntryInsert.INIT;
DimSetEntryInsert."Dimension Set ID" := SL."Dimension Set ID";
DimSetEntryInsert.VALIDATE("Dimension Code",SalesSetup."Intake ID");
DimSetEntryInsert.VALIDATE("Dimension Value Code",SLSMS."Intake ID");
DimSetEntryInsert.INSERT(TRUE);
//MESSAGE(DimSetEntryInsert."Dimension Value Code");
END;
DimSetEntryInsert.VALIDATE("Dimension Value Code",SLSMS."Intake ID");
DimSetEntryInsert.MODIFY(TRUE);


IF NOT DimSetEntryInsert.GET(SL."Dimension Set ID",SalesSetup."Course Type") THEN BEGIN
DimSetEntryInsert.INIT;
DimSetEntryInsert."Dimension Set ID" := SL."Dimension Set ID";
DimSetEntryInsert.VALIDATE("Dimension Code",SalesSetup."Course Type");
DimSetEntryInsert.VALIDATE("Dimension Value Code",SLSMS."Course Type");
DimSetEntryInsert.INSERT(TRUE);
END;

DimSetEntryInsert.VALIDATE("Dimension Value Code",SLSMS."Course Type");
DimSetEntryInsert.MODIFY(TRUE);
DimSetEntryInsert.RESET;
DimSetEntryInsert.SETRANGE("Dimension Set ID",SL."Dimension Set ID");
IF DimSetEntryInsert.FINDSET THEN REPEAT
MESSAGE(DimSetEntryInsert."Dimension Code");
FinalDimSetEntry.COPY(DimSetEntryInsert);
UNTIL DimSetEntryInsert.NEXT = 0;

DimSetEntryInsert.GetDimensionSetID(FinalDimSetEntry);
//MESSAGE('%1',DimSetEntryInsert.GetDimensionSetID(FinalDimSetEntry));
UNTIL SLSMS.NEXT = 0;

But its not working properly. If anyone has any view on how to change the code to dynamically generate the dimension set id, please let me know.

Thanks in advance.

Regards,
chandru.

Comments

  • davmac1davmac1 Member Posts: 1,283
    take a look at the G/L journals and use the method standard NAV uses rather than trying to reverse engineer it.
  • KishormKishorm Member Posts: 921
    Basically what you need to do is copy the dimension values into a Temp Dimension Set Entry table (table 480) and then call GetDimensionSetID function in codeunit 408, e.g.

    "Dimension Set ID" := DimMgt.GetDimensionSetID(TempDimSetEntry);
Sign In or Register to comment.