Showing posts with label Export. Show all posts
Showing posts with label Export. Show all posts

Friday, July 3, 2020

Data Export to Text file from Ax 2012 using X++

Hi guys, Today we see how data is exported to Text file(Notepad).

Write the below code in job. Do changes as per your requirement.

static void export_data(Args _args)
{
    #File
    CommaTextIo commaTextIo;
    FileIOPermission permission;
    Testing testing;    //my table
    str fileName = @"D:\Ax\test.txt"; // file path

    permission = new FileIOPermission(fileName,#io_write);
    permission.assert();

    commaTextIo = new CommaTextIo(fileName,#io_write);
    while select testing
    {
        commaTextIo.write(testing.AccountNum,testing.AccountName,enum2str(testing.PlayerType));
    }

    CodeAccessPermission::revertAssert();
    info("success");

Output:
        
                InfoLog



            Notepad


Keep Daxing !!

Just check below links for Export and Import process of Xml 

Thursday, July 2, 2020

Data Exporting to XML file using X++ in ax 2012



Welcome to Dynamics world.Today i would like to post Data export process.


Write this code in job and change according to your requirement.

static void exportingxml(Args _args)
{
    XmlDocument doc;
    XmlElement nodeXml;
    XmlElement nodeTable;
    XmlElement nodeId;
    XmlElement nodeName;
    XmlElement nodeCollectionType;
    XmlAttribute nodeType;    
    Testing testing ;

    #define.filename(@'D:\Ax\AnyNew.xml')
    doc = XmlDocument::newBlank();
    nodeXml = doc.createElement('xml');
    doc.appendChild(nodeXml);

    while select RecId,AccountName,AccountNum,PlayerType from testing
    {
    nodeTable = doc.createElement(tableStr(testing));
    nodeTable.setAttribute(fieldStr(testing, RecId),int642str(testing.RecId));
    nodeXml.appendChild(nodeTable);


    nodeName = doc.createElement(fieldStr(testing,AccountName));
    nodeName.appendChild(doc.createTextNode(testing.AccountName));
    nodeTable.appendChild(nodeName);

    nodeId = doc.createElement(fieldStr(testing,AccountNum));
    nodeId.appendChild(doc.createTextNode(testing.AccountNum));
    nodeTable.appendChild(nodeId);

    nodeCollectionType = doc.createElement(fieldStr(testing,PlayerType));
    nodeCollectionType.appendChild(doc.createTextNode(enum2str(testing.PlayerType)));
    nodeTable.appendChild(nodeCollectionType);

    }
    doc.save(#filename);
    info(strFmt('file is created', #filename));
}


Result in Info log:







Output:

                                                

Keep Daxing!!

For Import Process Refer to Below Link: