Example 1: Change a physical file description and attributes

This example shows how to create a new physical file with the same name in a different library.

  1. Create a new physical file with a different record format in a library different from the library the old physical file is in. The name of the new file should be the same as the name of the old file. (The old physical file FILEPFC is in library LIBB and has two members, MBRC1 and MBRC2.)
    CRTPF FILE(NEWLIB/FILEPFC) MAXMBRS(2)...
  2. Copy the members of the old physical file to the new physical file. The members in the new physical file are automatically named the same as the members in the old physical file because TOMBR(*FROMMBR) and FROMMBR(*ALL) are specified.
    CPYF      FROMFILE(LIBB/FILEPFC) TOFILE(NEWLIB/FILEPFC)
              FROMMBR(*ALL) TOMBR(*FROMMBR)
              FMTOPT(*MAP *DROP) MBROPT(*ADD)
  3. Describe and create a new logical file in a library different from the library the old logical file is in. The new logical file name should be the same as the old logical file name. You can use the FORMAT keyword to use the same record formats as in the current logical file if no changes need to be made to the record formats. You can also use the Create Duplicate Object (CRTDUPOBJ) command to create another logical file from the old logical file FILELFC in library LIBB.
    CRTLF FILE(NEWLIB/FILELFC)
  4. Delete the old logical and physical files.
    DLTF FILE(LIBB/FILELFC)
    DLTF FILE(LIBB/FILEPFC)
  5. Move the newly created files to the original library by using the following commands:
    MOVOBJ OBJ(NEWLIB/FILELFC) OBJTYPE(*FILE) TOLIB(LIBB)
    MOVOBJ OBJ(NEWLIB/FILEPFC) OBJTYPE(*FILE) TOLIB(LIBB)