Hi All, We can read a file from a file folder and import the data into Navision. This is normally achievable by using dataport and providing the path in the filename property. (which is hardcoded ). However i do not want to use hardcoded file name , instead wants to read the available fiels in the specified file folder ( Only the folder name and path are fixed not the file name ) and also if there are ‘n’ no of files existing in the above folder then i have to read all the files one by one and import the data in each file into Navision. All we want to do is … read all the files put in this file folder and read one file by another and import the data into Navision thru dataport… Is this achievable in Navision using any File/System commands ? If so how ??? Is it possible to execute any shell program / dos commands directly from Navision to get this.?? Kindly help.
Try this Variables: Name DataType Subtype Length FileRec Record File MyDataport Dataport Import Multiple FileRec.setrange(Path, 'C:\mydir'; FileRec.SETRANGE(FileRec."Is a file", TRUE); IF FileRec.FIND('-') THEN REPEAT CLEAR(MyDataport); MyDataport.FILENAME := FileRec.Path+ '\' + FileRec.Name; MyDataport.RUNMODAL //You might want to move/delete the file here... UNTIL FileRec.NEXT = 0;
The dataport has to be UseReqForm=No and Import=Yes. We are running this in a form where the user sets the FileRec.Path filter using F7 so they can see the files they are about to import (the form’s source table is the File table). Stefan
Thanks stefan. our requirement is not a standalone… we are having multiple external systems which will pump the data into this folder (ofcourse each system will place the data into individual file and also identified folder ). We are activating the scheduler which runs automatically and imports all the data from the files residing in all the folders with some frequency. Each file will be stored in pre-identified folder. There is no manual intervention at all. If you need more clarification, pls feel free to ask.
I would not use dataports. Oce you resolve all the structure issues, and the file names, and the automation steps, you will then discover all the Dataport problems, like random table lockings, locking and dieing automations etc. THis loks liek a fairly large interface project, so start form scratch with a more solid technology base, that means - Raw Navision code with Files - C/Front - SQL - XML - the list goes on. You can make a reliable interface with dataports, but int he end the other technologies are more reliable and more stable, you will spend less overall time than the time you think you will save with dataports.
Srikanth, Further to David’s posting. If you are running on SQL then why not use the flexibility inherent in the product. A table in a SQL database can be updated in many ways and offers secure data management through it’s own security and Windows AD. Try to normalise the data that is being pushed at Navision and design an interface table that provides all you need. Then you can process that table.
thanks very much for your feedback david and jsr. however i believe its a little late from our side to reconsider this option of chanigng better technology. can you suggest/assist me that how can i overcome the potential problems with the dataports. from our end we atleast ensuring that the data import routine is not getting disturbing by taking all the data into intermediate tables and then doing the validation. now the main concern is : how can i read the files existing in a folder ?? is there a way to do so ?? kindly help me.
further to my mail, suppose if i use the other technologies, except C/front, where i can have some control on the validation issues. if i directly push the data into the sql tables using available options, then how can i perform the validations… does SQL automatically fire all the necessary validations… david… can u suggest something on this. regards
I think you can make a report / codeunit and fire that from the scheduler. In that report / codeunit you can add code like Stefan described. After getting a filename, run your dataport with it.
Yes as Petr say, thats the way to go. Seriously you will spend less development time if you start now from scratch than if you continue down the dead end that you are currently travelling. My first preference for this would be to create new dummy tables inSQL, and have a From running that moves the data to the correct forms, and performs the validations. Option 2 would be as above, but us an automation in CU 1 to trigger the updates and validations.
Check this link:
http://dynamicsuser.net/forums/t/49849.aspx
I was faced with a similar problem.
I now run a report that does all that I need and gives me freedom from Dataports.
All the error checking and subsequent validation can be done here.
Check the questions and then the answer.
The only thing remaining is to move the files to different folders dependent on the success of the process.
Still working on that.
Cheers,
Colin