Is there any way to create a new physical file(say PF2) with same structure/fields as in a logical file(say LF1, whose physical file is PF1). One way is to use CPYF to create PF2 from LF1 but I dont wan't any data to be copied from LF1 to PF2 (dont want to use clrpfm after copying data) Is there any option in cpyf like *nodata as in crtdupobj ? OR Any other option other than CPYF?
You should be able to use CPYF though it's not really designed for that purpose. For example, you specify an impossible condition such as INCCHAR(*RCD 1 *GT X'FF') so that no records will be copied. (There will never be a character with a hex value greater than x'FF'.) You can also use the SQL CREATE TABLE ... LIKE statement. -- Tom
Hi anup,
Please note LF will never contain any data. So even if you use CPYF command here, it will not copy any data from LF1 to PF2, Since LF1 dosen't contain any data of PF1. It will only have a view to PF1.
Although a LF doesn't contain data, it will reference dat in the PF. The CPYF command will copy data from the PF, but it will format data according to the LF definition.
.
The data will be copied even though it's not contained inside the LF. A LF is just like a SQL VIEW. It doesn't contain, but it does define the access to the data.
.
Tom
Sai4AS400, good that you're adding to the knowledge base.
As Tom said, if you copy a logical file you will be coping all the rows that are available to use through that logical. Since this request was to create a pf like the logical but without the data, Tom had recommended using the CPYF with a record selection rule that wouldn't succeed in finding any records.
Tom's recommendations from Nov 17, 2012 are accurate and complete.
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
Discuss This Question: 5  Replies