Text File Export in AX


Below Sample provides exports errors in to text file. User can choose preferred location to save file.

static void ShyamTextFileExportErrors(Args _args)
{
    S_AxWmsErrorLog      errorLog;
    TextIO                  lclsTextIO;
    str                     s;
    date                    dt;
    Dialog                  dialog;
    DialogField             dfFileName;
    FileName                fileName;
    #File
    ;

    dialog = new Dialog("Choose the location to save the file");
    dfFileName = dialog.addField(extendedTypeStr(FilenameSave));
    dialog.filenameLookupFilter(["All files", #AllFiles]);

    if (dialog.run())
    {
            filename =  dfFileName.value();
    }

    lclsTextIO = new TextIO(filename,#io_write);

    while select errorlog
    {
     
            s = info::infoCon2Str(errorLog.InfologData);
            lclsTextIO.write(strfmt("%1;%2", errorlog.RefFileName,s));
     
    }
 info("done");
}

Comments