Rename problem.

We use Navision 4.0 ( I know…I’m a dinasour). I use the ‘rename’ function in dataports to rename and archive processed external files that we bring into our Nav Billing system. This works fine.

However, I’m writting a report object which will bring external files into our system without the ‘point and click’ required by our current dataport object. Everything works fine except for the archive process. I’ve pirated the code from our current dataport method. When the report code attempts the ‘rename’ function it returns an overflow error - ‘overflow under type conversion of text to code’.

The rename function requires old filename and new filename…both of these are defined as text (250 characters)…same as the dataport (which, as I said, works fine). Anybody know why the ‘rename’ report object is doing this?

Thank you,

Clueless in Connecticut

Hi,

This is an Ax forum. I will move yours to Nav thread. Next time, please post on the right thread [:)]

Best wishes,

Thank you…am new to the web site and am still getting my bearings. I just read thewelcoming email and realized that I had posted incorrectly. I jsut spent a bunch of time trying to find out how to contact someone to move and was unsuccessful.

Thank you for your help.

There are two RENAME-functions in NAV: one for files and one for records. Both might be called with RENAME only.
If a record is in focus, your RENAME will try to use the record-function. And according to your error-message I guess this is what happens.

So - try to use syntax FILE.RENAME(oldName, newName)…

That was the answer! Thank you very much, I appreciate your help.

Joe

I remember the first time I got that error, and how long it took to track it down.

when I used the rename function in the dataport, there was no problem and has worked flawlessly for years. Using the report object is a different animal…and when I narrowed this message to the rename statement, it puzzled me to no end. When I looked in the help I never saw the (file.) before the rename function, looked right past it. I’ve never used (file.) anything in any of the file processing I’ve done…that I can remember.

Anyway, I burned quit a bit of time trying a bunch of different things to make it work…finally threw in the towel and came to this website…I appreciate the help…

Hi,

I have gone through the above thread but I am getting very funny error message. Below is the simple code to rename a .csv file

InputFile DataType File

InputFile.CLOSE;
InputFile.Rename(‘C:\temp\HRM\HRM.CSV’,‘C:\temp\HRM\HRMBACKUP.CSV’);

Error ‘You have specified an unknown variable’

Rename

The same error message for function COPY. I am sure I have done some silly mistake but it has gone above my head.

My experience is with NAV 4.0

This is the code where I use rename in a dataport:

//-------------------------------------------------------------------------------------
// Archive the imported file to the IMPORT folder.
//
// If processing an imported file, do not prefice external filename with ‘IMPORTED_’
//
IF ‘IMPORTED_’ <> COPYSTR(FileName, EndOfPathPosition + 1, 9) THEN BEGIN
NewFileName := INSSTR(FileName, ‘Import\IMPORTED_’ + TextDate + ‘’, EndOfPathPosition + 1);
RENAME(FileName, NewFileName);
MESSAGE(‘Wrote %1 table records from %2 import lines in file \’ +
’ “%3”.\’ +
’ This file has been renamed with the prefix "IMPORTED
’ + TextDate + ‘_".’ ,
RecsWritten, ImportLines, FileName);
END ELSE
MESSAGE(‘Wrote %1 table records from %2 import lines in file \’ +
’ “%3”.’, RecsWritten, ImportLines, FileName);

This is how I use it in a report object:

800-Archive File()
//-------------------------------------------------------------------------------------
// Archive the imported file to the IMPORT folder.
//
// Preface the external filename with ‘IMPORTED_’ plus the RunID. The RunID will be used
//
//

NewFileName := FilePathHold + ‘Import\IMPORTED_’ + RunID + ‘_’ + FileData;
RENAME(ImportFileName, NewFileName);

as you can see, there is nothing prefacing the RENAME function.

Thanks Joe. It solved my problem.

I was checking on http://msdn.microsoft.com/en-us/library/dd338865.aspx and its nowhere mentioned that this function should be used directly.

Once again thank you very much.

Vijay

Vijay,

Glad to help.

I find Navision’s ‘online help’ only covers a portion of it’s functionality and it can be tough sleding when you need to do something that’s not there. I have yet to discover a comprehensive document that tells you how everything in Navision operates.

That’s why this website is such a good source when you hit a deadend. I’ve received help from other developers here a number of times when I was at wit’s end, so it’s nice to be able to reciprocate…

Good luck and take care,

Joe