Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
How to FTP a Save File to IBMi
has no ratings.
Published: 11 Feb 2011
Revised: 24 Jan 2013 - 4108 days ago
Last viewed on: 24 Apr 2024 (20896 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

How to FTP a Save File to IBMi Published by: Bob Cozzi on 11 Feb 2011 view comments

How to FTP and Install a Save File (SAVF) to IBMi (AS/400)

© Copyright 2003-2009 by Robert Cozzi, Jr.

To upload a save file stored on a PC, Mac or other operating system to IBM i, you first need to extract he save file from its ZIP container (if applicable).

To extract a file from a ZIP file, use Windows Explorer, WinZip or StuffIt Expander on the Mac and extract the enclosed .FILE or .SAVF file stored in the ZIP file.

For illustration purposes, the library name we are restoring in this example is named COZTOOLS. The file COZTOOLS.SAVF is extracted from the Save File named COZTOOLS.ZIP in some cases your own file may have no extension or contain the .FILE extension. See the notes below if this is your situation.

If you would like to use the COZTOOLS save file as practice, you may download it from this link. Once downloaded, return to this page and continue.

Before transferring the save file to your IBM i system, a save file with the same name as the PC file (without the suffix) should exist on the target system.

If the PC file's extension is NOT .SAVF, then the target save file must exist before transfer to the IBM i system. If the PC file's extension is .SAVF the save file doesn't need to exist ahead of time, but if it does, it is cleared by the FTP upload process.

To create a save file, sign on to the IBM i system and go to a Command Entry display or command line window.

On the IBM i system run the following CL command to create a save file.

	CRTSAVF SAVF(QGPL/COZTOOLSRT)

If the FTP server is NOT running on your IBM i system, start it by issuing the following CL command:

	STRTCPSVR *FTP

On your PC (any PC operating system should work the same)

  • Start FTP and connect to the System i:
	FTP myhost.domain.com

Where myhost.domain.com is the name of the System i. Instead of a domain name the dotted IP address may be required.

  • Enter your FTP user ID and Password when prompted (it will be the same as your IBM i system User ID and Password).
  • On the PC, run the following FTP commands:
	quote site namefmt 1
	cd /qsys.lib/qgpl.lib

At this point the IBM i system naming convention is established and the QGPL library is set to the current library. If your save file is created in a different library, change to that library using the same syntax, above but replacing "qgpl.lib" with the name of your library. For example, if the library name is DEVCODE,  run "cd /qsys.lib/devcode.lib".

Now you need to determine where the save file is located on the PC. A good place to store this type of file is in a directory named C:\TEMP or something similar since shorter directory names are easier to enter into the FTP session.

If you haven't already done so, make sure the COZTOOLS.SAVF save file has been extracted from the corresponding .ZIP file and it is stored in a known directory on your PC.

If the PC file name ends with .FILE you may optionally rename it to xxxx.SAVF (for example: COZTOOLSRT.FILE to COZTOOLSRT.SAVF). Having the .SAVF extension tells the IBM i system to create a save file on the target. If a file extension of .FILE is detected, a regular database file is created and that will not be useful to the RSTOBJ or RSTLIB commands.

If however, a save file already exists on your IBM i system with the same base name, the system also recognizes that you are transferring a save file and behaves as you would expect.

The next step is to change the local directory on the PC to the one containing the COZTOOLSRT.SAVF file, for example if your save file is stored in c:\my documents\downloads then the following LCD (local change directory) command would be used:

	lcd "c:\my documents\downloads

Note the quote in front of the directory name. This is required only when a blank is embedded in one of the directories in the path name. Since "My Documents" contains a blank, we prefix the local path name with a " (quote).

Next you need to tell FTP to transfer the file "as is" or unmodified. FTP servers cal this "binary mode" transfer. If you skip this step the save file's data may be corrupted, or if FTP is already in binary mode, it may work. To be certain, you should run the FTP command BINARY in your PC FTP session:

Change FTP to binary mode:

	BINARY

Note there is an alias for the FTP BINARY command. Often you will see people run the IMAGE command instead of BINARY,  they produce identical results.

You are now ready to begin the transfer. Remember, save files are often large so it may take a moment or two to upload depending on your connection speed.

Enter the following FTP command to send the save file to the IBM i system:

	PUT coztoolsrt.savf 

NOTE: If the file is named COZTOOLSRT.FILE then issue the following FTP command:

	PUT coztoolsrt.file 

This command will start the transfer. Depending on the FTP software you are using, you may or may not see a status message indicating the progress. Also some GUI-based FTP clients won't replace the target file. Instead they issue a hidden FTP command that deletes the target file and then uploads/sends the new file to the target system. This will NOT work for save files if the PC file name does NOT include the .SAVF extension.

After a successful FTP transfer, you should end the FTP session.

Enter the following FTP command:

	QUIT

On some PC platforms, the BYE command is used instead of QUIT. If the QUIT command fails, issue the BYE command as follows:

	BYE

On the Host IBM i system:

Enter the following CL command to restore the library COZTOOLS onto your IBM i system:

	RSTLIB SAVLIB(COZTOOLS) DEV(*SAVF) SAVF(QGPL/COZTOOLSRT)

At this point the COZTOOLS library for IBM i has been restored onto your system.

Remember the following key points when FTP'ing a Save File from a PC to an IBM i system:

  1. Set the transfer mode to BINARY before beginning the transfer.
  2. Having the PC file name suffix set to .SAVF will make uploading and restoring easier.
  3. Create the save file on the IBM i system first, before the transfer to insure any file extension produces the expected results.

 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS