Search This Blog

Thursday, February 13, 2014

Writing Data to Text File in AX 2009 & 2012

static void DataToTxt(Args _args)
{
     PurchTable   purchTable;
     BinData     binData;
     TextBuffer  textBuffer;
   
     ;

    textBuffer = new TextBuffer();
    textBuffer.setText('');

    while select purchTable
            where purchTable.PurchStatus == PurchStatus::Backorder
     {
        textBuffer.appendText(strfmt('%1\r',purchTable.PurchId));
        textBuffer.appendText(strfmt('%1\r',purchTable.PurchName));
        textBuffer.appendText(strfmt('%1\r\n',purchTable.PurchStatus));

     }
     textBuffer.getText();
     binData = new BinData();
     binData.setStrData(textBuffer.getText());
     binData.saveFile(@"C:\Users\ADeveloper1\Desktop\batch.txt");

}



No comments:

Post a Comment