We are runing V5R1 OS400, how do I write to CSV file

5 pts.
Tags:
AS/400 CSV
AS/400 import/export
CSV format
OS/400
V5R1
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.

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • hafwhit
    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.
    1,145 pointsBadges:
    report
  • YuVa47
    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)
    1,300 pointsBadges:
    report
  • Yorkshireman
    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
    5,580 pointsBadges:
    report
  • WM
    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.
    460 pointsBadges:
    report
  • Yorkshireman
    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.
    5,580 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following