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

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...