Create a text file from AX

tpriyantpriyan Member Posts: 32
edited 2009-02-13 in Dynamics AX
Hi All,

How cani create a text file by using X++.

Thanks in advance

Comments

  • KivancKivanc Member Posts: 1
    static void Jobx(Args _args)
    {
    TextIO diskFile;
    Container c;
    ;
    c = [1, "My Text1", 2, "My text2"];

    diskFile = new TextIO("c:\\test1.txt", 'W');
    diskFile.outRecordDelimiter('\r\n');
    diskFile.writeExp(c);
    diskFile.writeExp(c);
    }
  • HarishHarish Member Posts: 172
    Hi,

    Here is a very simple Ax job -
     InventTrans     InventTrans;
    
        CommaIo         myFile;
    
        Counter         recCount;
        str             fileName;
        ;
    
        fileName = "C:\\AxaptaXXXX.txt";
    
        //Creating new file with write access
        myfile = new commaIO(filename, "w");
    
        //setting up
        myfile.outRecordDelimiter("\r\n");
        myfile.outFieldDelimiter(",");
    
        while select InventTrans
        {
            myFile.write(InventTrans.ItemId, InventTrans.inventDimId);
        }
    
        myFile.write('______________________');
    
        recCount = new SysDictTable(tablenum(InventTrans)).recordCount();
        myFile.write("Inserted " + int2str(recCount) + " Records");
    
        myfile = null;
    


    NOTE - it is intended to be purely as an example and nothing else.

    Regards,
    Harish Mohanbabu
    Long way to go before I sleep..
Sign In or Register to comment.