f.Open

Hi All,

I'm facing a little problem while creating an automatic dataport.
Everytime the dataport starts importing data he has to create (if the logfile doesn't exists already)a logfile that indicates the startdate, starttime, errors if they occur and endtime and date.
For this I use :

OnPreDataport
IF EXISTS ('C:\Log\Logfile.txt') THEN
BEGIN
file_LogError.WRITEMODE;
file_LogError.OPEN('C:\Log\Logfile.txt');
file_LogError.WRITE('BPCS'+' '+FORMAT(TODAY)+' '+FORMAT(TIME) +' '+':'+'Start importation');
END ELSE
BEGIN
file_LogError.TEXTMODE(TRUE);
file_LogError.CREATE('C:\Log\Logfile.txt');
file_LogError.WRITE('BPCS'+' '+FORMAT(TODAY)+' '+FORMAT(TIME)+' '+':'+'Start importation');
END;

OnPostDataport()
file_LogError.WRITE('No error');
file_LogError.WRITE(FORMAT("Import From Files".Source)+' '+FORMAT(TODAY)+' '+FORMAT(TIME)+' '+':'+'Stop importation');
file_LogError.CLOSE;

In the beginning he doesn't find a logfile, so he creates one and writes all the stuff down I asked.
It's an automatic dataport that is executed every hour and he always has to use the same logfile to write down the info.
So the second time he has to use the file.OPEN function. Here I get the message " Can not gain acces at C:\Log\Logfile.txt. Please check blablabla"
When I erase "file_LogError.CLOSE" in the OnPostDataport he passes by the file.OPEN part, even the write part and he does the importation. But when you check the logfile, he kept the created part and wrote nothing new.

What am I doing wrong???

Regards,
  • quote:
    Originally posted by sdegendt
    What am I doing wrong???



    The first thing you are doing wrong is that you are either posting your question in the wrong forum or that you are trying to use Attain/Financials code in Navision 3.x (character based version). Big Smile
  • > I'm facing a little problem while creating an automatic dataport.
    > Everytime the dataport starts importing data
    I Assume you're dealing with Application Server

    > In the beginning he doesn't find a logfile, so he creates one and writes all the stuff down I asked.
    I Assume you're looked in to test
    > It's an automatic dataport that is executed every hour and he always has to use the same logfile to write down the info.
    So the second time he has to use the file.OPEN function. Here I get the message " Can not gain acces at C:\Log\Logfile.txt. Please check blablabla"
    I assume you're looked out to see what happens

    I guess userrights of the server which runs the Application server will not have the right to access your logfile.



Related