iSeries copy file from IFS - CPYFRMIMPF and CPYFRMSTMF

How to copy from IFS CSV file to physical file


The Copy From Import File (CPYFRMIMPF) command copies all or part of an import file to the TOFILE. The term import file is used to describe a file created for purposes of copying data between heterogeneous databases. The import file (FROMSTMF or FROMFILE parameter) is called the from-file for this command.


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

  • Copying a from-file to an externally-described physical file. The to-file must exist on the system before the copy can occur.
  • Limiting the range of records copied based on starting and ending relative record numbers.
  • Adding records to an existing file member or replace the contents of a receiving file member (MBROPT parameter).
CPYFRMIMPF FROMSTMF($ifs_file_path) TOFILE(*LIBL/$file_name) 
MBROPT(*REPLACE)  RCDDLM(*CRLF)  

How to copy from IFS file to source physical file


The Copy From Stream File (CPYFRMSTMF) command copies the data in a stream file to either a database file member or a save 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.


To file member or save file (TOMBR)

Specifies the path name of the database file member or save file to which data is copied. All directories in the path name must exist.

When copying to a save file, the save file will be created if it does not exist.

When copying to a database file member, the database file must exist. If the member does not exist, it is created. The file may be either a source physical file or a program-described physical file. Source physical files with multiple data fields are not supported.
CPYFRMSTMF FROMSTMF($ifs_file_path) TOMBR('/qsys.lib/$your_lib.lib/$your_file.file/$file_mbr.mbr') 
MBROPT(*REPLACE) STMFCODPAG(*PCASCII) ENDLINFMT(*CRLF) 

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.