4

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.

mike
  • 1,233
  • 1
  • 15
  • 36
nearly_lunchtime
  • 12,203
  • 15
  • 37
  • 42

5 Answers5

13

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)

Todd Waldorf
  • 156
  • 5
1

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.

Chris Smith
  • 5,326
  • 29
  • 29
1

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.

Gustavo Rubio
  • 10,209
  • 8
  • 39
  • 57
0

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!

Jim V
  • 31
  • 6
0

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

FredericP
  • 1,119
  • 1
  • 14
  • 27