1,025 pts.
 AS400 – File
I wanted change a flat file as a keyed file.

What are all the ways there?



Software/Hardware used:
ASKED: November 12, 2009  10:24 AM
UPDATED: November 17, 2009  9:34 PM

Answer Wiki:
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  CharlieBrowne   32,915 pts.
All Answer Wiki Contributors:  CharlieBrowne   32,915 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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

 108,310 pts.

 

Flat is file with single field
like
A R RFMT
A FLD1

 1,025 pts.

 

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

 44,200 pts.

 

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

 108,310 pts.