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 startthe SNADS subsystem using the commandSTRSBS QSNADS2. Ensure you are listed in the AS/400 directory by using theWRKDIRE *ALLcommand. For simplicity we will use QSECOFR / QSECOFR in theseexamples, but you will likely use your own user profile.3. Create the save file to contain the OS/400 objects withCRTSAVF FILE(QGPL/XFRSAVF)4. Place the OS/400 objects in the file using any of the save commandsincluding, but not limited to: SAVOBJ, SAVLIB, SAVDLO or SAVCFG5. Send the save file to yourself using the SNADS system withSNDNETF 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 fileCRTPF FILE(QGPL/XFRDTAF) RCDLEN(528)CRTPF FILE(QGPL/XFRDTAF) RCDLEN(528) MBR(*NONE)We specify MBR(*NONE) here so that we don't have problemslater with the RCVNETF and the default member name.Be sure to allow enough time for the SNADS transfer of the filewithin the AS/400 -- this can take a surprisingly long time insome cases, depending on system load.7. Receive the pending network file into a physical database fileRCVNETF FROMFILE(XFRSAVF) TOFILE(QGPL/XFRDTAF)orWRKNETF *ALLand using option 1 on the appropriate line item. Note we donot specify the member name in the TOMBR keyword on purpose.8. Now you can transfer the file XFRDTAF down to the PC. Be sureto specify "No Conversion" and create an FDF (field descriptionfile) so it can be uploaded later. Important entries inthe advanced transfer description are:From AS/400 lib/file(member) - QGPL/XFRDTAFTransfer to PC file - C:\SAVF.400PC file type - No ConversionOutput transferred file fmt - *NoneCreate PC File Desc. File - C:\SAVF.FDF9. If no longer needed, the save file and database file may bedeleted now.----------------------------------- Transfer to the AS/400 -----------------------------------In a similar fashion to moving files from the AS/400, transferringa save file from the PC to the 400 is nearly as simple, except forthe requirement of an FDF file for the upload step.1. First if the SNADS distribution system is not running, then startthe SNADS subsystem using the commandSTRSBS QSNADS2. Ensure you are listed in the AS/400 directory by using theWRKDIRE *ALLcommand. For simplicity we will use QSECOFR / QSECOFR in theseexamples, but you will likely use your own user profile.3. Create a physical file to receive the file from the PCCRTPF FILE(QGPL/XFRDTAF) RCDLEN(528)4. Upload the save file on the PC to the AS/400 using the FDFcreated during the download. Important entries inthe advanced transfer description are:Xfr to AS/400 lib/file(member) - QGPL/XFRDTAFFrom PC file name - C:\SAVF.400PC File Desc. File - C:\SAVF.FDFAS/400 object creation - replace member5. Send the data file to yourself using the SNADS system withSNDNETF 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 withCRTSAVF FILE(QGPL/XFRSAVF)Be sure to allow enough time for the SNADS transfer of the filewithin the AS/400 -- this can take a surprisingly long time insome cases, depending on system load.7. Receive the pending network file into a save fileRCVNETF FROMFILE(XFRDTAF) TOFILE(QGPL/XFRSAVF)orWRKNETF *ALLand using option 1 on the appropriate line item. Note we donot specify the member name in the TOMBR keyword on purpose.8. Restore the OS/400 objects from the file using any of therestore commands including, but not limited to: RSTOBJ, RSTLIB,RSTDLO or RSTCFG. For verification you can use theDSPSAVF FILE(QGPL/XFRSAVF)command to view the save file contents.9. When no longer needed, the save file and database file may bedeleted.----------------------------------- RPG conversion program -----------------------------------For those interested in creating their own conversion program, belowis 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 databasenames.0001.00 FIN IPE F 528 DISK0002.00 FOUT O F 528 DISK A0003.00 IIN NS 200004.00 I 1 256 PART10005.00 I 257 512 PART20006.00 I 513 528 PART30007.00 OOUT DADD 20NLR0008.00 O PART1 2560009.00 O PART2 5120010.00 O PART3 528