iSeries copy file to IFS - CPYTOIMPF and CPYTOSTMF

How to copy physical file to IFS CSV file

The Copy To Import File (CPYTOIMPF) command copies an externally-described file to an import file. The term import file is used to describe a file created for purposes of copying data between heterogenous databases. The import file (TOSTMF or TOFILE parameter) will be called the to-file for this command.

Some of the specific functions that can be performed by the CPYTOIMPF command include the following:

  • Copying from an externally described physical file to the to-file (TOFILE or TOSTMF parameter).
  • Adding records to an existing to-file member or replace the contents of the to-file member (MBROPT parameter).
CPYTOIMPF FROMFILE(*LIBL/$file_name) TOSTMF($ifs_file_path) 

How to copy source physical file to IFS file

The Copy To Stream File (CPYTOSTMF) command copies either a database file member or a save file to a stream file. Optional conversion of the data and reformatting is performed when copying a database file member. This command cannot be used to copy to or from a database file member on a remote system. Any overrides in effect for the database file member or the save file are not used by this command.

From file member or save file (FROMMBR) option

Specifies the path name of the database file member or save file from which data is copied. When copying from a member, the file may be a source physical file or a program-described physical file. Source physical files with multiple data fields are not supported.

If the database file is a source physical file, the sequence number and date stamp are removed when the records are written to the stream file.
CPYTOSTMF FROMMBR('/qsys.lib/$your_lib.lib/$your_file.file/$file_mbr.mbr') 

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.