RATE THIS ANSWER
+1
Click to Vote:
1
0
You can use SQL to CREATE TABLE
OR
If you have the database created ahead of time in another library, you can use CRTDUPOBJ.
------------------------------------------
If both PF1 and PF2 contain only the same six fields and you simply want to create a subset of the records then Create Duplicate Object of PF1 to PF2 (with DATA(*NO)) would get you the desired PF2. You could then write the appropriate records to PF2.
Depending on the data merge utility you are using you may also (in the above scenario) be able to simply add a temporary member to PF1 (called PF2), write the appropriate records to PF2, merge the data of this member into the spreadsheet, and then remove the member.
If the six fields of PF2 are a subset of the greater-than six fields found in PF1 and if the six fields are known in advance then you could create an appropriate (empty) file in advance (PF2_Model), use CRTDUPOBJ from PF2_Model to PF2, and then write the appropriate records to PF2.
If the six fields of PF2 are a subset of the greater-than six fields found in PF1 and the six fields are not known in advance (which I suspect is not the case as your intent is to merge the contents of PF2 into an existing spreadsheet) then you could either:
1. Use SQL Create Table and write the appropriate records to PF2
or
2. Write the appropriate DDS defining PF2 to a source file, create PF2 using the Create Physical File (CRTPF) command, and then write the appropriate records to PF2
In the above cases "write the appropriate records to PF2" may be the Copy File (CPYF) command if your selection criteria is simple enough, writing records from your CLP using CL for Files (CLF) commands such as Write Record using CLF (WRTRCDCLF), or some other mechanism.
As you can see, there is more than one way.
Bruce Vining
Last Answered:
Oct 8 2009 2:25 PM GMT by Bvining 
4885 pts.