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 BEGINStreamInTest.READTEXT(Buffer);// insert here your codeEND;MyFile.CLOSE();
MyFile is a File variable, StreamInTest is a InStream variable and Buffer is a text variable.
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!
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 BEGINStreamInTest.READTEXT(Buffer);// insert here your codeEND;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?
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 BEGINStreamInTest.READTEXT(Buffer);// insert here your codeEND;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.
Thanks,
How should i add my code just give a example.
hypothesize we need to import employees and we have a file lyke this
E00001Michael Red
E00002Bill Green
E00003Jim Black
the code will be like this:
MyFile.OPEN(FullFileName);MyFile.CREATEINSTREAM(StreamInTest);
WHILE NOT StreamInTest.EOS DO BEGINStreamInTest.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();
Answers
MyFile is a File variable, StreamInTest is a InStream variable and Buffer is a text variable.
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).
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
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.
How should i add my code just give a example.
hypothesize we need to import employees and we have a file lyke this
the code will be like this:
Emp is a record of Employee variable.
you're welcome