Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

CommaTextIO occasionally writing empty file

Posted on by 115

Hello,

There is a process for our business that writes out order information to a csv file that is then FTP'd to a shipping company.  However, this process sometimes writes out an empty csv file when there should have been data.  I cannot figure out the problem with the code and was wondering if perhaps I was doing something obviously wrong?  _conRecords is a container of containers, where the containers hold the information such as item number, price, etc. 

fullFileName = HAExportFileHelper::createFileName(_filePath, _fileName, _extention);
fileIOPermission = new FileIOPermission(fullFileName, #io_write);
fileIOPermission.assert();
commaIoWrite = new CommaTextIo(fullFileName, #io_write, #ANSIEncoding);

commaIoWrite.outFieldDelimiter(_fieldDelimiter);
commaIoWrite.outRecordDelimiter(#delimiterCRLF);

conLength = conLen(_conRecords);

for (conIdx = 1; conIdx <= conLength; conIdx++)
{
commaIoWrite.write(conPeek(_conRecords, conIdx));
}

commaIoWrite = null;
CodeAccessPermission::revertAssert();
info(strFmt("Data has been exported to file %1.", fullFileName));

*This post is locked for comments

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: CommaTextIO occasionally writing empty file

    Hi AXGreenHorn,

    Are you using the same filename or are there some variables like date/time which is added to the filename? Have you reviewed the coding which compiles the container _conRecords? Have you also tried to use the debugger to find out more on this?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans