
Copy Database File to IFS Stream File (CPYTOIFSF) Command
What It Does
This command copies source or database file members into the
Integrated File System.
The data is always converted into ASCII. It may be copied as is, or the
fields may be organized as comma-separated values.
How It Works
The implementation uses the IBM-supplied CPYTOIMPF command to copy the data
into the IFS and to perform the CSV formatting. The CPY command is then used
to convert the resulting stream file to ASCII.
An intermediate file is created in /tmp in the IFS, and deleted before the
command returns (even if errors occur).
Syntax
+-*LIBL/--------+
>>--CPYTOIFSF--FROMFILE(--+---------------+--file-name--)--------->
+-*CURLIB/------+
+-library-name/-+
>--+--------------------------+---TOPATH(--'object-path-name'--)-->
+-MBR(--+-*FIRST------+--)-+
+-member-name-+
>--+----------------------------+--+---------------------------+-->
+-OPTION(--+-*NOREPLACE-+--)-+ +-FORMAT(--+--*CSV----+--)--+
+-*REPLACE---+ +--*FIXED--+
>--+------------------------+--><
+--EOL(--+--*DOS---+--)--+
+--*UNIX--+
Examples
Example 1: Copy a database file for use in a DOS/Windows spreadsheet program
CPYTOIFSF FROMFILE(ARLIB/REVENUE) MBR(JANUARY)
TOPATH('/home/revenue.csv') OPTION(*REPLACE)
FORMAT(*CSV) EOL(*DOS)
Example 2: Copy a source member for editing in UNIX
CPYTOIFSF FROMFILE(QGPL/TOOLS) MBR(CPYTOIFSF)
TOPATH('/home/src/cpytoifsf.cmd') OPTION(*REPLACE)
FORMAT(*FIXED) EOL(*UNIX)
(This brief documentation is available as
CPYTOIFSF.RTF.)
Terms of Use
Permission is hereby granted to use this copyrighted material in any
manner you wish, under the condition that the copyright, author, and
contact information is not altered or removed.
Installation Instructions
You can use this procedure if your system is at V4R3M0 or later.
If you have an earlier version of OS/400, you can download
this self-extracting archive
(94,561 bytes) of the source code instead, and compile it yourself.
Download the V4R3M0 save file from
ftp://ftp.binarytool.com/pub/as400/CPYTOIFSF.SAV
(139,392 bytes), and place it into QGPL (or wherever you prefer) on your iSeries.
Restore the objects from the save file into QTEMP:
RSTOBJ OBJ(*ALL) SAVLIB(QTEMP) DEV(*SAVF) SAVF(QGPL/CPYTOIFSF)
Move the command and its processing program to a library usually on your library list.
Again, use a library that is appropriate for your site.
MOVOBJ OBJ(QTEMP/CPYTOIFSF) OBJTYPE(*CMD) TOLIB(QGPL)
MOVOBJ OBJ(QTEMP/CPYTOIFSF) OBJTYPE(*PGM) TOLIB(QGPL)
Copy the source members to somewhere appropriate.
CPYF FROMFILE(QTEMP/QCMDSRC) TOFILE(QGPL/QCMDSRC)
FROMMBR(CPYTOIFSF) TOMBR(*FROMMBR)
MBROPT(*REPLACE)
CPYF FROMFILE(QTEMP/QCLSRC) TOFILE(QGPL/QCLSRC)
FROMMBR(CPYTOIFSF) TOMBR(*FROMMBR)
MBROPT(*REPLACE)
Clean up.
DLTF FILE(QGPL/CPYTOIFSF)
Future Improvements
Please send improvements or suggestions to the author for incorporation into
subsequent versions of this software.
Thanks, and enjoy!
|