Question

Is there an iSeries command to export the data in a table to CSV format?

I know about the Windows utilities, but since this needs to be run automatically I need to run this from a CL program.

Was it helpful?

Solution

You can use CPYTOIMPF and specify the TOSTMF option to place a CSV file on the IFS. Example: CPYTOIMPF FROMFILE(DBFILE) TOSTMF('/outputfile.csv') STMFCODPAG(*PCASCII) RCDDLM(*CRLF)

OTHER TIPS

If you want the data to be downloaded directly to a PC, you can use the "Data Transfer from iSeries" function of IBM iSeries Client Access to create a .CSV file. In the file output details dialog, set the file type to Comma Separated Variable (CSV).

You can save the transfer description to be reused later.

You could use a trigger. The iSeries Client Access software wont do since that is a windows application, what I understand is that you need the data to be exported each time that the file is written. Check this link to know more about triggers.

You are going to need FTP to perform that action. If your iSeries shop uses ZMOD/FTP your shortest solution is a few lines of code away -- 3 lines to be exact -- the three lines are to Start FTP, Put DBF, and finally, End FTP.

IF you don't use ZMOD/FTP: - You could use native FTP/400 to accomplish what you need to do, but it is quite involved!!! - you may probably need to use an RPGLE program to parse, format, and move, data into a "flatfile", then use native FTP/400 to FTP the file out - and yes, a CL will need as a wrapper!

You can do it all in one very simple CL program:

  • CPYTOIMPF the file TOSTMF -> the cvs file will be in the IFS
  • FTP the file elsewhere (to a server or a PC)

It works like a charm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top