How to Dynamically generate DImension set ID using CAL Code?
chandrurec
Member Posts: 560
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.
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.
0
Comments
-
take a look at the G/L journals and use the method standard NAV uses rather than trying to reverse engineer it.David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
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);0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions