Create a definitoin for the file with DDS or create a table with SQL.
Then do a CPYF from the flat file to the defined file.
Use the FMTOPT(*NOCHK) on the CPYF command
Last Wiki Answer Submitted: November 12, 2009 2:10 pm by CharlieBrowne32,915 pts.
All Answer Wiki Contributors: CharlieBrowne32,915 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.
Please give some description of your “flat file”. Many of us think of them as “program-described” physical files with a single field. But some others would mean streamfiles in an IFS directory. What file do you have? Can you show examples of a couple rows?
ok then you’re on Charlie Browns solution
Describe a physical file with fields for the stuff in your flat file .. but all text since your flat file is all text. This file’s record should be at least the length of the flat file record and breaks out the fields you want to key on, key on those fields.
Compile the physical file
Then copy the flat file (CPFY) to the new file using the fmtopt *NOCHK.
Then you can use the new keyed file.
Phil
It only needs to use ‘text’ fields if the field positions contain text bytes. If positions contain packed values, then those positions need to be described as packed. If positions contain binary values, then the description should be binary.
The DDS for the new physical file needs to list definitions of the subfields of FLD1 according to how those positions actually exist. When the image-copy is done (i.e., *NOCHK) there won’t be any conversion. The new file should already have the appropriate definitions for whatever the data is.
Please give some description of your “flat file”. Many of us think of them as “program-described” physical files with a single field. But some others would mean streamfiles in an IFS directory. What file do you have? Can you show examples of a couple rows?
Tom
Flat is file with single field
like
A R RFMT
A FLD1
ok then you’re on Charlie Browns solution
Describe a physical file with fields for the stuff in your flat file .. but all text since your flat file is all text. This file’s record should be at least the length of the flat file record and breaks out the fields you want to key on, key on those fields.
Compile the physical file
Then copy the flat file (CPFY) to the new file using the fmtopt *NOCHK.
Then you can use the new keyed file.
Phil
It only needs to use ‘text’ fields if the field positions contain text bytes. If positions contain packed values, then those positions need to be described as packed. If positions contain binary values, then the description should be binary.
The DDS for the new physical file needs to list definitions of the subfields of FLD1 according to how those positions actually exist. When the image-copy is done (i.e., *NOCHK) there won’t be any conversion. The new file should already have the appropriate definitions for whatever the data is.
Of course, that will most likely be text…
Tom