zoukankan      html  css  js  c++  java
  • Using x++ code reading data from csv file format

    The following X++ code is tested in  Dynamics AX 2009 development environment!

    Wrote by : Jimmy Nov 24th 2010

    static void Jimmy_readCSVFieldFromAXCode(Args _args)
    {
        AsciiIo             asciiIo;
        FileIoPermission    perm;
        
        Test                Test;
        
        container           con;
        name                ItemId,Name;
        price               price;
        int                 i;
        
        #define.ExampleFile(@"c:\Book1.csv")
        #define.ExampleOpenMode("r")
        #define.FileDelimiter(",")
    ;
        // The AsciiIO.new method runs under code access permission.
        if(!WinAPI::fileExists(#ExampleFile))
            return;
        perm = new FileIoPermission(#ExampleFile,#ExampleOpenMode);
        if (perm == null)
            return;
      
        perm.assert();  // Code access permission scope starts here.
       
        asciiIo = new AsciiIo(#ExampleFile,#ExampleOpenMode);
        asciiIo.inFieldDelimiter(#FileDelimiter);
        
        if (asciiIo != null)
        {
            con = asciiIo.read();
            delete_from Test;
            while (asciiIo.status() == IO_Status::Ok)
            {
    
                ItemId  = conPeek(con,1);
                name    = conPeek(con,2);
                price   = conPeek(con,3);
    
                i++;
                ttsbegin;
                Test.clear();
                Test.ItemId = ItemId;
                Test.Name   = name;
                Test.Price2 = price;
                Test.doInsert();
                info(strfmt("%1 : %2,%3,%4",i,
                            Test.ItemId,
                            Test.Name,
                            num2str(price,1,2,1,2)));
    
                ttscommit;
                con = asciiIo.read();
            }
        }
        info(strfmt("total read %1 records [from %2]",i,#ExampleFile));
    }
    
    
    

  • 相关阅读:
    nsq 启动流程讲解
    nsq 初识
    【资料】http包接口和结构体
    http包详解 2
    http包详解 1
    openstack多节点部署运维
    一款简单实用的串口通讯框架(SerialIo)
    ~MySQL Perfect~
    linux创建用户设置密码
    linux安装tomcat且配置环境变量
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1886760.html
Copyright © 2011-2022 走看看