How can i import a data to navision without the XmlPort

Mounika22
Member Posts: 18
I should Write a Code unit
0
Best Answer
Answers
-
You can write a custom codeunit or a custom report, open file and stream and read data from the stream. I prefer codeunit and i always use this example code:
MyFile.OPEN(FullFileName); MyFile.CREATEINSTREAM(StreamInTest); WHILE NOT StreamInTest.EOS DO BEGIN StreamInTest.READTEXT(Buffer); // insert here your code END; MyFile.CLOSE();
MyFile is a File variable, StreamInTest is a InStream variable and Buffer is a text variable.Giorgio Gandolfi0 -
You can use a dataport in the older versions. But those don't work with the NAS.
Something that works with all versions is a codeunit and using a FILE variable (and with the newer versions best use also a stream instead of reading/writing directly to the file-variable).Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Supremenerd88 wrote: »You can write a custom codeunit or a custom report, open file and stream and read data from the stream. I prefer codeunit and i always use this example code:
MyFile.OPEN(FullFileName); MyFile.CREATEINSTREAM(StreamInTest); WHILE NOT StreamInTest.EOS DO BEGIN StreamInTest.READTEXT(Buffer); // insert here your code END; MyFile.CLOSE();
MyFile is a File variable, StreamInTest is a InStream variable and Buffer is a text variable.
But in RTC you first need to copy the file to the server, correct?0 -
mdPartnerNL wrote: »Supremenerd88 wrote: »You can write a custom codeunit or a custom report, open file and stream and read data from the stream. I prefer codeunit and i always use this example code:
MyFile.OPEN(FullFileName); MyFile.CREATEINSTREAM(StreamInTest); WHILE NOT StreamInTest.EOS DO BEGIN StreamInTest.READTEXT(Buffer); // insert here your code END; MyFile.CLOSE();
MyFile is a File variable, StreamInTest is a InStream variable and Buffer is a text variable.
But in RTC you first need to copy the file to the server, correct?
I prefer to use shared folder (i.e. \\192.168.1.100\share\file.txt) but yes, generally you need to copy file on server.Giorgio Gandolfi0 -
Thanks,
How should i add my code just give a example.
0 -
above example is already given0
-
Thanks,
How should i add my code just give a example.
hypothesize we need to import employees and we have a file lyke thisE00001Michael Red E00002Bill Green E00003Jim Black
the code will be like this:MyFile.OPEN(FullFileName); MyFile.CREATEINSTREAM(StreamInTest); WHILE NOT StreamInTest.EOS DO BEGIN StreamInTest.READTEXT(Buffer); CLEAR(Emp); Emp.INIT(); Emp.VALIDATE("No.", COPYSTR(Buffer,1,6)); Emp.VALIDATE("First Name", COPYSTR(Buffer,7,20)); Emp.VALIDATE("Last Name", COPYSTR(Buffer,27,20)); Emp.INSERT(TRUE); END; MyFile.CLOSE();
Emp is a record of Employee variable.Giorgio Gandolfi0 -
Thank You for your kind reply0
-
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions