Skip to main content

Notifications

Announcements

No record found.

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

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

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

    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.

  • Dynamics AX Profile Picture
    Dynamics AX 20 on at
    RE: I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

    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));
    }
    }
    }
    }
  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

    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
    Dynamics AX 20 on at
    RE: I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

    i tried

    still didn't got response from ftp server.

  • Dynamics AX Profile Picture
    Dynamics AX 20 on at
    RE: I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

    how i will run this code in ax 2012

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

  • Dynamics AX Profile Picture
    Dynamics AX 20 on at
    RE: I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

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

    still having issue.

    i am not getting any response from ftp server

  • Blue Wang Profile Picture
    Blue Wang on at
    RE: I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

    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
    Dynamics AX 20 on at
    RE: I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

    Yes

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

    please provide the X++ code  for the same

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: I want to read multiple comma delimiter file from ftp server and insert data into ax regular table

    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.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans