Wednesday, July 30, 2008

Little Known feature of CPYFRMIMPF:

When we are importing delimited data to the iSeries, such as a comma-delimited spreadsheet or data from a Unix or Windows NT system, the CPYFRMIMPF command is a huge timesaver. But even with this command, we face problems about null data, errors or formatting problems. Many are not aware that the CPYFRMIMPF command is also capable of helping with some of those types of problems.

By default when the command is invoked, it shows only few of the options. But by taking more keys and show all parameters options, we can view all the available parameters for the command.

These are few options that are more useful.
Copy From Import File (CPYFRMIMPF)

Type choices, press Enter.

Decimal point . . . . . . . . . *PERIOD *PERIOD, *COMMA
Date format . . . . . . . . . . *ISO *ISO, *USA, *EUR, *JIS...
Time format . . . . . . . . . . *ISO *ISO, *USA, *EUR, *JIS, *HMS
Copy from record number:
Copy from record number . . . *FIRST Number, *FIRST
Number of records to copy . . *END Number, *END
Errors allowed . . . . . . . . . *NOMAX Number, *NOMAX
Error record file:
File . . . . . . . . . . . . . *NONE Name, *NONE
Library . . . . . . . . . . Name, *LIBL, *CURLIB
Member . . . . . . . . . . . . Name, *FIRST
Replace or add records . . . . . *ADD *ADD, *REPLACE
Replace null values . . . . . . *NO *NO, *FLDDFT
Replace null values prompt at the bottom of the screen can have the value *FLDDFT. If this is changed to *FLDDFT, then when it encounters a null field, it will replace the values in the TOFILE with something acceptable to the 400 (blanks for alphanumeric fields and zeros for numeric fields).
The date and time format fields can be used to format the TOFILE date and time fields, we tell this command the format of those fields and it will do a validity check to ensure that we are importing valid dates and times.
The error record file parameter can hold a file name. If a file name is specified in these fields, any error on the import will be copied to this file. If a file were to be specified with the defaults as shown in this example, the CPYFRMIMPF will import all the records it can but copy off the errors to a separate file for later analysis.

2 comments:

kelboy said...

nice work here ... keep em comming!!!!

kelboy said...

nice tips, thanks alot!!