Use Cpyf with fmtOpt *NOCHK
Phil
/////////////////////
Assuming that the flat file is
1. In a library on your AS/400
2. Fixed length fields
then
1. Create and compile the DDS which represents the data as fields
if first 30 are address, next 20 are city, next 10 are zip create those fields
at this point the fields probably are all text.
2. Use the CPYF command to copy the flat file to the fielded file.
Once you have it in a fielded file you may want to use RPG or SQL to convert some of the text fields to decimal.
Phil
Last Wiki Answer Submitted: May 15, 2009 7:00 pm by philpl1jb44,070 pts.
All Answer Wiki Contributors: philpl1jb44,070 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
Hi thanks for your response, but the flat file in my question has no fields defined, with only data in side it.Pl tell me how to create the PF with the data inside the flat file and to move the data to respective fields.Shall i need to write a CLP and a RPG program? pl clarify further…thanks
Phil’s answer is just what you need. You must create a physical file with the fields defined that make up the data in the flat file. So, for instance, your flat file has the 1st 30 characters which is an address and then the next 20 city, and so on and so forth. Each field must be defined in the order that it is in the flat file. Next, using the cpyf command you would tell it to copy from the flat file into the new file which you have created and use the parameter for fmtopt to be *nochk. This will bring the data from the flat file into the new field-defined file. That’s all you need. You could write a program to do the same thing but why waste your time when the copy file command will do it for you unless there are certain pieces of the flat file data that you don’t want in the new file.
Hi thanks for your response, but the flat file in my question has no fields defined, with only data in side it.Pl tell me how to create the PF with the data inside the flat file and to move the data to respective fields.Shall i need to write a CLP and a RPG program? pl clarify further…thanks
Phil’s answer is just what you need. You must create a physical file with the fields defined that make up the data in the flat file. So, for instance, your flat file has the 1st 30 characters which is an address and then the next 20 city, and so on and so forth. Each field must be defined in the order that it is in the flat file. Next, using the cpyf command you would tell it to copy from the flat file into the new file which you have created and use the parameter for fmtopt to be *nochk. This will bring the data from the flat file into the new field-defined file. That’s all you need. You could write a program to do the same thing but why waste your time when the copy file command will do it for you unless there are certain pieces of the flat file data that you don’t want in the new file.