Friday, 9 January 2015

Simple way to import CSV File through X++

We have been importing excel file for such along time in ax. And i think this will be best example if you want to import the CSV file into AX through code.

void ImportTmpData()
{
    CommaIo          file;// = new commaIo(ItemFileName,'r');
    Container          con;
    Int                     counter;
    tmpImport        tmpImport;
    ;
   
   delete_from tmpImport;
    file = new CommaIo(fileName,'r');
    file.inRecordDelimiter("\r\n");
    file.inFieldDelimiter(",");

    if (file)
    {
        while(file.status() == IO_Status::OK)
        {
            con = file.read();
            counter++;
            if (con && counter >1)
            {
                tmpImport.field1                = conpeek(con,1);
                tmpImport.field2                = conpeek(con,2);
                 tmpImport.insert();
            }
        }
    }
}

Code to write a text file using X++

Many  time we came across situation to where we need to import data in text file.Here is a simple way to write the data into a text file.
static server void WriteTextFile(Args _args)
{ TextIo file; // Using the @ before the filename // enables us to use single path // delimiters. If you don't use it // you will have to write the path like this: FileName filename = @"c:\<<Filename.txt>>"; CarTable carTable; container con; FileIoPermission permission; #File ; try {
// Create the permission class
permission = new FileIoPermission(filename, #io_write);
// Add a request for permission before new TextIo()
permission.assert();
// Create the TextIo object
file = new TextIo(filename, #io_write);
if (!file)
throw Exception::Error;
// Specify the delimiters
file.outRecordDelimiter(#delimiterCRLF);
file.outFieldDelimiter(";");
// Loop through the data source
while select carTable
{
// Empty the container
con = connull();
// Set the data into the container
con += carTable.CarId;
con += carTable.CarBrand;
con += carTable.Mileage;
con +=carTable.Model;
con += carTable.ModelYear;
// Write the container to the file
file.writeExp(con);
}
}
catch(Exception::Error)
{
error("You do not have access to write the file to the
selected folder");
}
// Revert the access privileges
CodeAccessPermission::revertAssert();
}

Variable Symmetry has not been declared Compilation error in Ax 2012 R3

Variable Symmetry has not been declared Compilation error in Ax 2012 R3

Hello everyone,

I would like to share an information regarding Symmetry error in Microsoft Dynamics Ax 2012 R3 which come just after fresh installation . Error will be as below:

Variable Symmetry has not been declared. \Data Dictionary\Tables\PayrollEmployerTaxRegion\Methods\retrieveGNIS 12 retrieveGNIS Err:9
Variable Symmetry has not been declared. \Data Dictionary\Tables\PrlTmpGNIS\Methods\populatePrlTmpGNIS 13 populatePrlTmpGNIS Err:9
Syntax error. \Classes\PayrollCalculatePayStatementBenefits\classDeclaration 12 classDeclaration Err:9999
Syntax error. \Classes\PayrollCalculatePayStatementTaxes\classDeclaration 42 classDeclaration Err:9999
Variable Symmetry has not been declared. \Classes\PayrollSetup\refreshWorkerTaxRegionTaxes 25 refreshWorkerTaxRegionTaxes Err:9
Syntax error. \Classes\PayrollTaxCalculation\classDeclaration 7 classDeclaration Err:9999
Syntax error. \Classes\PayrollTaxEngineUtil\checkInTaxEngine 7 checkInTaxEngine Err:9999
Syntax error. \Classes\PayrollTaxEngineUtil\checkOutTaxEngine 7 checkOutTaxEngine Err:9999
Variable Symmetry has not been declared. \Classes\PayrollTaxEngineUtil\getGNISLocations 40 getGNISLocations Err:9
Variable Symmetry has not been declared. \Classes\PayrollTaxEngineUtil\getMunicipalities 39 getMunicipalities Err:9
Syntax error. \Classes\PayrollTaxEngineUtil\getPoliticalSubDivision 31 getPoliticalSubDivision Err:9999
Syntax error. \Classes\PayrollTaxEngineUtil\getPoliticalSubDivisionByTaxCode 20 getPoliticalSubDivisionByTaxCode Err:9999
Variable Symmetry has not been declared. \Classes\PayrollTaxEngineUtil\getSchoolDistricts 41 getSchoolDistricts Err:9
Variable Symmetry has not been declared. \Classes\PayrollTaxEngineUtil\getTaxEngineLocationCodeList 38 getTaxEngineLocationCodeList Err:9
Syntax error. \Classes\PayrollTaxEngineUtil\getTaxEngineVersion 10 getTaxEngineVersion Err:9999
Syntax error. \Classes\PayrollTaxEngineUtil\getTaxTableVersion 10 getTaxTableVersion Err:9999
Syntax error. \Classes\PayrollTaxEngineUtil\money2Real 11 money2Real Err:9999
Syntax error. \Classes\PayrollTaxEngineUtil\real2Hours 11 real2Hours Err:9999
Syntax error. \Classes\PayrollTaxEngineUtil\real2Money 11 real2Money Err:9999
Syntax error. \Classes\PayrollTaxEngineUtil\real2Rate 11 real2Rate Err:9999
Syntax error. \Classes\PayrollTaxEngineUtil\taxCalculation2TaxCode 11 taxCalculation2TaxCode Err:9999
Syntax error. \Classes\PayrollTaxTypeInitialization\classDeclaration 8 classDeclaration Err:9999

Scenario: 
After compiling the whole application if you get errors on tables and classes related with Standard payroll.
Then you need to follow below procedure to solve the compilation errors.

Solution:
Check whether the ste-net.dll related with payroll is available in both client and server bin.

Then in the AOT --> References node  right click and add a new reference.
click on browse and select the ste-net.dll and press ok.
Compile the classes where you are facing errors on symmetry.