0

我正在尝试在 AX 2012 中导入 csv-FILE(字段:名字、姓氏、出生日期、泽西号码)

class SYCImportData_Roster
{
}


public static void main(Args _args)
{
    SYCImportData_Roster    importData_Roster;
    ;

    importData_Roster = new SYCImportData_Roster();

    importData_Roster.run();
}


public void run()
{
    AsciiIo         rosterFile;
    SYCu17roster    u17RosterTable;
    FilenameOpen    filenameopen;
    container       records;
    int             totalRecords;
    #FILE
    ;

    filenameopen = this.dialog();

    rosterFile = new AsciiIo(filenameopen, #IO_READ);

    if ((!rosterFile) || (rosterFile.status() != IO_Status::Ok))
    {
        throw error("@SYC71");
    }

    rosterFile.inFieldDelimiter(#delimiterSemicolon);

    try
    {
        ttsBegin;
            while (rosterFile.status() == IO_Status::Ok)
            {
                records = rosterFile.read();

                if (!records)
                {
                    break;
                }

                totalRecords++;
                this.doForEach(records);
            }
        ttsCommit;
    }

    catch (Exception::Error)
    {
        if (rosterFile)
        {
            rosterFile.finalize();
            rosterFile = null;
        }
        throw error("@SYC70");
    }

    info(strFmt("@SYC52" + " = %1", totalRecords));

}

public FilenameOpen dialog()
{
    Dialog          dialog;
    DialogField     DF_dialogfield;
    FilenameOpen    filenameopen;
    #FILE
    ;

    dialog          = new Dialog("Kaderliste importieren");

    DF_dialogfield  = dialog.addField(extendedTypeStr(filenameopen));

    dialog.filenameLookupFilter(['csv' , '*' + #CSV, 'xlsx', '*' + #XLSX]);

    if (!dialog.run())
    {
        throw error("@SYC70");
    }

    filenameopen    = DF_dialogfield.value();

    return filenameopen;
}


private void doForEach(container _records)
{
    SYCu17roster        u17rosterTable;
    ;

    u17rosterTable.clear();

    u17rosterTable.FirstName    = conPeek(_records, 1);
    u17rosterTable.LastName     = conPeek(_records, 2);
    u17rosterTable.BirthDate    = conPeek(_records, 3);
    u17rosterTable.jerseyNumber = conPeek(_records, 4);

    u17rosterTable.insert();

}

我得到的错误:

执行代码时出错。转换函数的参数类型错误。堆栈跟踪 (C)\Classes\SYCimportData_Roster\doForEach - 第 10 行 (C)\Classes\SYCimportData_Roster\run- 第 35 行 (C)\Classes\SYCimportData_Roster\main- 第 8 行

我认为这与我的 csv 文件中 Birthdate 字段的方式有关。

例子:

汤姆;理查兹;28.02.1990;12

4

0 回答 0