Export to CSV via report (NAV2015)

bRahms
Member Posts: 44
Hi,
My client doesn't have Xmlports in their licence, thus wants to export data in a CSV via Reports.
Can we create a report on the server, ProcessingOnly, that exports data without getting the error that the file is already open?
My client doesn't have Xmlports in their licence, thus wants to export data in a CSV via Reports.
Can we create a report on the server, ProcessingOnly, that exports data without getting the error that the file is already open?
OnPreDataItem=BEGIN tpath := 'C:\Users\User\Documents\'; tFilename := tpath + 'listing-'+ FORMAT(TODAY,0,'<day,2>-<month,2>-<year,2>')+ FORMAT(TIME, 0, '<hour,2><minute,2><second,2>') +'.' + 'csv'; CLEAR(fFileToExport); CLEAR(objFileSystem); CREATE(objFileSystem, TRUE, TRUE); IF NOT objFileSystem.FileExists(tFilename) THEN fFileToExport.CREATE(tFilename) ELSE BEGIN fFileToExport.TEXTMODE(TRUE); fFileToExport.OPEN(tFilename); END; CLEAR(objFileSystem); fFileToExport.TEXTMODE(TRUE); fFileToExport.WRITEMODE(TRUE); fFileToExport.WRITE(';;"Test Column 3"'); END; OnAfterGetRecord=BEGIN fFileToExport.WRITEMODE(TRUE); fFileToExport.TEXTMODE(TRUE); fFileToExport.WRITE('test 2'); END; OnPostDataItem=BEGIN CLEAR(fFileToExport); END; }Thanks in advance for your help
0
Best Answer
-
This functions:
fFileToExport.WRITEMODE(TRUE);
fFileToExport.TEXTMODE(TRUE);
should be used before File.OPEN is used to open the file. If you use this function on a file that is already open, then an error occurs.5
Answers
-
you can check if the file exists - if that is what you meanDavid Machanick
http://mibuso.com/blogs/davidmachanick/0 -
When running the above code (on server level), he gives the error that the action cannot be performed when the file is open.0
-
Is the DataItem this code is in the root DataItem? It must be.
If your file isn't open in another application check whether your OPEN gets called muliple times for some reason.
If that doesn't happen restart the service on your DEV Machine. Had that happen multiple times that NAV leaves files open for an eternity if you don't close them properly.
Austrian NAV/BC Dev0 -
Even a restart of the service gave me the same error.
The code is in the root dataitem.0 -
This functions:
fFileToExport.WRITEMODE(TRUE);
fFileToExport.TEXTMODE(TRUE);
should be used before File.OPEN is used to open the file. If you use this function on a file that is already open, then an error occurs.5 -
Correct
+ the fact that i didn't have to use the writemode function any longer.
Thanks for the help all.0
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