web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

(0) ShareShare
ReportReport
Posted on by 20

I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

i am trying this but i did not got any result.

please provide the X++ code  for the same

I have the same question (0)
  • Martin Dráb Profile Picture
    237,924 Most Valuable Professional on at

    Decompose the problem to individual pieces:

    • Getting a file from FTP
    • Reading a CSV file
    • Inserting data to a table

    Then think about what you know how to do and what you don't. For example, maybe you know how to insert data, but you don't know how to work with FTP.

    When you understand what actually need, you can use a search engine to find documentation, blog posts and forums threads on the right topic. If you don't find what you need, create a new thread (with an approriate name and tags) and explain your particular problem.

  • Dynamics AX Profile Picture
    20 on at

    Yes

    1. i am not able get file from ftp folder.

    please provide the X++ code  for the same

  • Blue Wang Profile Picture
    on at

    Hi M.G.Harran,

    Maybe these are helpful to you:

    daxbalakumaran.wordpress.com/.../

    www.atomicax.com/.../downloading-files-ftp-and-doing-something-them-d365fo

  • Dynamics AX Profile Picture
    20 on at

    i tried using this daxbalakumaran.wordpress.com/.../

    still having issue.

    i am not getting any response from ftp server

  • Dynamics AX Profile Picture
    20 on at

    how i will run this code in ax 2012

    www.atomicax.com/.../downloading-files-ftp-and-doing-something-them-d365fo

  • Dynamics AX Profile Picture
    20 on at

    i tried

    still didn't got response from ftp server.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Can you access the FTP server from the location where AX runs? You can try to access it via a web browser. Perhaps some firewall is blocking the access.

    In general, may I suggest that you share as much details about your situation as possible? This would help us to help you figure out what the problem could be, and hopefully solve the problem. The quality of the help that you will get is strongly linked to the quality of information that you share.

  • Dynamics AX Profile Picture
    20 on at

    Yes i am able to access the ftp server from the location where Ax is running

    code

    //in the code i am not getting response, refer the comment.

    private void getFTPDirFilesList()
    {
    container conFTPFilesDownload;
    ListIterator ftpFilesListIterator;
     
    // Marshaling .NET to X++
    ftpObject = System.Net.WebRequest::Create(ftpHostName);
    ftpWebRequest = ftpObject;
     
    if (ftpWebRequest)
    {
    ftpWebRequest.set_KeepAlive(false);
    ftpWebRequest.set_UsePassive(true);
    ftpWebRequest.set_UseBinary(true);
    ftpWebRequest.set_Timeout(ftpTimeOut);
    ftpWebRequest.set_Method(#ListDirectory);
    this.setFTPCredentials();
     
    ftpWebResponse = ftpWebRequest.GetResponse();
    //-------------code is not running after this line.----------------------------------// 
    if (ftpWebResponse)
    {
    ftpFilesList = new list(Types::String);
     
    // BP Deviation Documented
    ioStreamReader = new System.IO.StreamReader(ftpWebResponse.GetResponseStream());
     
    if (ioStreamReader)
    {
    strReadLine = ioStreamReader.ReadLine();
     
    while (!System.String::IsNullOrEmpty(strReadLine))
    {
    ftpFilesListIterator = new Listiterator(strsplit(strReadLine, '/'));
     
    while (ftpFilesListIterator.more())
    {
    conFTPFilesDownload += ftpFilesListIterator.value();
    ftpFilesListIterator.next();
    }
     
    ftpFilesList.addEnd(conPeek(conFTPFilesDownload, conlen(conFTPFilesDownload)));
    strReadLine = ioStreamReader.ReadLine();
    }
     
    ioStreamReader.Close();
    }
     
    if (ftpFilesList.empty())
    {
    warning (strfmt("No files available in %1", ftpHostName));
    }
    }
    }
    }
  • Martin Dráb Profile Picture
    237,924 Most Valuable Professional on at

    It sounds like GetResponse throws an exception, but you're not aware of it, because you forget to catch it. And you can't fix the problem without finding out what it is.

    Do the following; it should show the message from the exception (unless yoi call the code inside a transaction).

    try
    {
        ftpWebResponse = ftpWebRequest.GetResponse();
    }
    catch (Exception::CLRError)
    {
    	throw error(AifUtil::getClrErrorMessage());
    }

    By the way, please always use Insert > Insert Code (in the rich-formatting view). Unlike your code above, it preserves indentation, making code much easier to read.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans