Trilobyte Software Systems

Moving AS/400 Save Files (*SAVF)

This technical note provides a simple solution for moving AS/400 save files (*SAVF) to and from the AS/400 using the Synapse WinTran file transfer.



The OS/400 save file is a special object on the AS/400 that can be used to preserve other OS/400 objects (physical and logical files and program objects to mention a few) for archival purposes and/or for transfer to another AS/400. Because of the nature of an object- oriented system where commands are designed to work with, and only with, objects of certain types some "non-blessed" operations can be difficult or impossible to accomplish.

Unfortunately for many AS/400 users connected via PC's, the file transfer interfaces provided by OS/400 do not support transfer to or from the OS/400 save file. At first blush this would appear to be an oversight of IBM's, but since this restriction has existed for so many releases the restriction must instead be viewed as a process that IBM does not want their users performing.

We won't debate IBMs reasons here, but for those that have needs for moving objects to and from their AS/400s, we provide this technical note to assist them. The base concept is to "convert" the save file to a standard physical database file to allow the data to be exported to the PC, and the reverse to restore the data to the target AS/400. Because of the importance of ensuring that data and programs imported to the AS/400 have not been tampered with, there are several verifications performed on save file data during the restore process. It is very important that the save file contents be preserved exactly as they originally existed, or the transfer effort will be wasted and the target AS/400 will reject any restore attempts.

There are several paths to circumvent the save file import and export difficulties. If you have the ability to write a simple program, then create a program that can read 528 byte records from one file and write the records to an output file. In RPG that should be a dozen lines or less, with just a few lines of CL to provide the file overrides (sample source is provided at the bottom of this technical note). The same program can be used in converting the save file to a database file, or from the database file to the save file -- the CL overrides would specify the input and output file names. Just write a program to sequentially read 528 byte records from the input until EOF and write them in order to the target file that was created with the same record length. No other manipulation should be done to the file.

For those who lack the HLL compiler or ability to write a program, you can use the OS/400 facilities to migrate the file for you. This second techique makes use of the fact the OS/400 send/receive network file commands can read and write to save files as well as standard database files.

Remember that any objects transferred via these save files must abide by all OS/400 save/restore restrictions (release portability and such). Another restriction is that the current maximum for a Send Network file is approximately 2 Gigabytes.

 
 
    --------------------------------
    --- Transfer from the AS/400 ---
    --------------------------------
 
    1. First if the SNADS distribution system is not running, then start 
       the SNADS subsystem using the command
            STRSBS QSNADS
 
    2. Ensure you are listed in the AS/400 directory by using the 
            WRKDIRE *ALL 
       command.  For simplicity we will use QSECOFR / QSECOFR in these 
       examples, but you will likely use your own user profile.
 
    3. Create the save file to contain the OS/400 objects with 
            CRTSAVF FILE(QGPL/XFRSAVF)
 
    4. Place the OS/400 objects in the file using any of the save commands 
       including, but not limited to: SAVOBJ, SAVLIB, SAVDLO or SAVCFG
 
    5. Send the save file to yourself using the SNADS system with 
            SNDNETF FILE(QGPL/XFRSAVF) TOUSRID((QSECOFR QSECOFR))
       again you can replace QSECOFR with your own profile.
 
    6. Create a physical file to receive the "migrated" save file 
            CRTPF FILE(QGPL/XFRDTAF) RCDLEN(528)
            CRTPF FILE(QGPL/XFRDTAF) RCDLEN(528) MBR(*NONE)
       We specify MBR(*NONE) here so that we don't have problems 
       later with the RCVNETF and the default member name.
 
    Be sure to allow enough time for the SNADS transfer of the file 
    within the AS/400 -- this can take a surprisingly long time in 
    some cases, depending on system load.
 
    7. Receive the pending network file into a physical database file 
            RCVNETF FROMFILE(XFRSAVF) TOFILE(QGPL/XFRDTAF)
                or
            WRKNETF *ALL 
       and using option 1 on the appropriate line item.  Note we do 
       not specify the member name in the TOMBR keyword on purpose.
 
    8. Now you can transfer the file XFRDTAF down to the PC.  Be sure 
       to specify "No Conversion" and create an FDF (field description 
       file) so it can be uploaded later.  Important entries in 
       the advanced transfer description are:
            From AS/400 lib/file(member) - QGPL/XFRDTAF
            Transfer to PC file          - C:\SAVF.400
            PC file type                 - No Conversion
            Output transferred file fmt  - *None
            Create PC File Desc. File    - C:\SAVF.FDF
 
    9. If no longer needed, the save file and database file may be 
       deleted now.
 
 
    --------------------------------
    --- Transfer to the AS/400 ---
    --------------------------------
 
    In a similar fashion to moving files from the AS/400, transferring 
    a save file from the PC to the 400 is nearly as simple, except for 
    the requirement of an FDF file for the upload step.
 
    1. First if the SNADS distribution system is not running, then start 
       the SNADS subsystem using the command
            STRSBS QSNADS
 
    2. Ensure you are listed in the AS/400 directory by using the 
            WRKDIRE *ALL 
       command.  For simplicity we will use QSECOFR / QSECOFR in these 
       examples, but you will likely use your own user profile.
 
    3. Create a physical file to receive the file from the PC
            CRTPF FILE(QGPL/XFRDTAF) RCDLEN(528)
 
    4. Upload the save file on the PC to the AS/400 using the FDF 
       created during the download.  Important entries in 
       the advanced transfer description are:
            Xfr to AS/400 lib/file(member) - QGPL/XFRDTAF
            From PC file name              - C:\SAVF.400
            PC File Desc. File             - C:\SAVF.FDF
            AS/400 object creation         - replace member
 
    5. Send the data file to yourself using the SNADS system with 
            SNDNETF FILE(QGPL/XFRDTAF) TOUSRID((QSECOFR QSECOFR))
       again you can replace QSECOFR with your own profile.
 
    6. Create the save file to contain the OS/400 objects with 
            CRTSAVF FILE(QGPL/XFRSAVF)
 
    Be sure to allow enough time for the SNADS transfer of the file 
    within the AS/400 -- this can take a surprisingly long time in 
    some cases, depending on system load.
 
    7. Receive the pending network file into a save file 
            RCVNETF FROMFILE(XFRDTAF) TOFILE(QGPL/XFRSAVF)
                or
            WRKNETF *ALL 
       and using option 1 on the appropriate line item.  Note we do 
       not specify the member name in the TOMBR keyword on purpose.
 
    8. Restore the OS/400 objects from the file using any of the 
       restore commands including, but not limited to: RSTOBJ, RSTLIB, 
       RSTDLO or RSTCFG.  For verification you can use the 
            DSPSAVF FILE(QGPL/XFRSAVF)
       command to view the save file contents.
 
    9. When no longer needed, the save file and database file may be 
       deleted.
 
 
    --------------------------------
    --- RPG conversion program ---
    --------------------------------
 
    For those interested in creating their own conversion program, below 
    is sample code of a simple RPG program to read and write the records.
    Use CL to override the IN/OUT file names to the OS/400 database 
    names.
 
    0001.00      FIN      IPE F     528            DISK                       
    0002.00      FOUT     O   F     528            DISK                      A
    0003.00      IIN      NS  20                                              
    0004.00      I                                        1 256 PART1          
    0005.00      I                                      257 512 PART2          
    0006.00      I                                      513 528 PART3          
    0007.00      OOUT     DADD     20NLR                                      
    0008.00      O                         PART1    256                       
    0009.00      O                         PART2    512                       
    0010.00      O                         PART3    528