Interview Questions

Wednesday, May 14, 2014

Another way to Copy data in text file in AX

static void DataToTxtFile(Args _args)
{
    TextIO file;
    container line;
    InventTable invenTable;
    #define.filename('d:\\items.txt')
    #File
    ;
    file = new TextIO(#filename, #io_write);
    if (!file || file.status() != IO_Status::Ok)
    {
        throw error("File cannot be opened.");
    }
    file.outFieldDelimiter(';');// for semicolon seperator
    while select invenTable
    {
        line = [invenTable.ItemId,invenTable.ItemName,invenTable.ItemGroupId];
        file.writeExp(line);
    }
}

No comments:

Post a Comment