Sunday, October 26, 2014

Write Data to Text file from AX

// Write Data to Text file from AX

static void WriteTextfile(Args _args)
{
    CustTable   custTable;
    BinData     binData;
    TextBuffer  textBuffer;
    boolean     header;
    ;
    header = true;
    textBuffer = new TextBuffer();
    textBuffer.setText('');

    while select custTable
    {
        header = true;
        if (header)
        {
              textBuffer.appendText(strfmt("%1 - %2 \r\n",custTable.AccountNum,CustTable::find(custTable.AccountNum).name()));
              header = false;
        }
        textBuffer.appendText(strfmt('\t"%1","%2","%3","%4","%5","%6","%7","%8"\r\n',
                    custTable.AccountNum,custTable.AccountStatement,custTable.Currency,custTable.CashDisc,
                    custTable.DlvTerm,custTable.InvoiceAccount,custTable.CustGroup,custTable.DlvMode));
    }
    textBuffer.getText();
    binData = new BinData();
    binData.setStrData(textBuffer.getText());
    binData.saveFile(@"d:\ValidationFileGenerationTest.txt");

}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...