We are runing V5R1 OS400, how do I write to CSV file
5 pts.
0
Q:
We are runing V5R1 OS400, how do I write to CSV file
We are trying to write a program that will take the output of a report, & put it on a CSV file. This file will the be sent via email to user(s). Please provide with steps to accomplish this including foldersetup, etc.
ASKED: Jul 14 2009  9:47 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
24540 pts.
0
A:
 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0
  • AddThis Social Bookmark Button
Have you tried cpytoimpf to a file with only one field defined for the entire record?

===================================================================================
1. Create a physical file (CRTPF) at least as wide as the spool file
2. copy the spool file (CPFSPLF) to the physical file
3. Create a .cvs file (CPYTOIMPF)

I don't think you'll like the outcome. Each row will be a long text field in column A of the spreadsheet if that's where you are going.

You probably will want to consider getting the data into a physical file with columns for the various data elements and using CPYTOIMPF on that.

Phil
Last Answered: Jul 15 2009  5:57 PM GMT by Philpl1jb   24540 pts.
Latest Contributors: Cunninjoe   310 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Hafwhit   630 pts.  |   Jul 16 2009  5:10PM GMT

I agree with Cunninjoe on the basic steps. If you are a programmer I would suggest you write a program to read the file that the spool file is copied into. You then can separate the elements you need from the rest of the data and place it into an external file. I have done this in the past for some reports that get generated by programs we do not control. I read the file and only selected the records that did not have the header information and then split this detail into separate fields and output this to an external file. You then could create a .csv file from this new file.

If the program that generates the spool file is one written by your staff then I would suggest a change to the program to generate the output file at the same time as the report. I have done this in the past to generate a text file to be sent via email to an outside party and also print the report for the inside personnel.

 

YuVa47   280 pts.  |   Jul 19 2009  8:53AM GMT

If you are not a programmer (or a programmer but…) you can try a very good none expensive software called SpoolFactory. For more info you can contact me (yudavago at 013 dot net)

 

Yorkshireman   3200 pts.  |   Jul 20 2009  3:27PM GMT

If you do, indeed, want to take the ‘output’ of a report, which is a 132 or 198 byte record length file, then just use Client access to download the spoolfile.

CPYSPLF to a physical file, and use the CA wizard to move the file.

If you mean that you want user to receive the data represented in the report, then throw away the ‘report’ and use client access to download the data as a CSV.

If your report is unruly, and is carrying out calculations and what all, then you will need to make it write to an externally described data file, then continue as above

Whatever you’re wanting to do, a more detailed specification will be needed for us to provide much help

 

WM   340 pts.  |   Aug 15 2009  1:37AM GMT

I believe there is a way to export data or reports into MS Excel via iSeries Access/CA and if I’m not wrong you can actually schedule the entire process via the PC. That is if your planning to import reports into Excel.

 

Yorkshireman   3200 pts.  |   Aug 18 2009  8:44AM GMT

WM is correct,

For many mamny years, you could use CA to transfer data into a format for a spreadsheet. Initially the ‘BIFF3′ format was used, more recently, the ubiquitous CSV (comma separated variable) file format has become more widespread.

If you use CA, then create a download manually and keep the specs in a FDF.

When you are happy with it, then construct a batch file / script / JCL command to run it from wherever.

As regards the CSV, they are simple to construct - especially so in RPGLE where string handling is now simpler. Wrap a quote around alphameric fields and put comma’s between fields. beware of embedded quotes in alpha fields.

 
0