Now, before you get all bent out of shape and point your grubby little index finger at me cackling “you called it an AS400 na-na-nu-na-naaah“, I do have a legitimate reason. It’s a shallow SEO based one (the grey haired brigade keep searching for “zip AS400 library”) but it’s legitimate.
I only used the wrong machine name in this blog title because I noticed that variations on “email AS400 library” and “ZIP AS400 library” keep appearing my website search logs. So, if people are searching for it, I can write an easy tip on how to do it. Obviously, since it’s not the 1990’s anymore, we will be using the IBM i Power System. The grandson of the AS400. Hopefully, one day, you lot will stop calling the IBM i System an AS400 – you filthy animals!
(anyone thats read my blogs knows I tend to rant about this, but today is a beautiful sunny warm summer morning, my iced coconut milk coffee is calming, my desert view is peaceful so please accept my apologies and lets get on with things)
We have a library on our AS400 IBM i System and we want to send it to another IBM i system using email. So, what is the best way to transfer SAVE FILES from IBM i Server to Another over the network?
Assuming you are an IBM I Fresher, or just not experienced with saving objects and restoring them on other machines, the concept behind it all is very simple.
- We can backup a library, an individual object, a collection of objects, some IFS stuff, just about anything we like into a *SAVF (Save File)
- This *SAVF is basically a big fat text file which can be sent to other IBM i Systems — but in this example we are going to use JAVA to squish it into a ZIP file before sending. Because transporting small things is quicker right?
- Then we can FTP to another IBM i Server… or copy to a Thumb Drive.. or email it… or attach it to a pigeons leg and fly it off somewhere. It’s up to you.
- When it gets to its destination we do the same thing in reverse – we un-squish it on the other end and restore it.
Save our stuff to a *SAVF
Lets do a simple example of just saving a library to a *SAVF:
CRTSAVF MYLIB/MYSAVF SAVLIB LIB('Library-to-be-saved') DEV(*SAVF) SAVF(MYLIB/MYSAVF) DTACPR(*YES)
This uses IBM i’s built-in compression and will make any save file a few percent smaller than standard.
Now we have the *SAVF in the smallest standard IBM i save file size… let’s squish it up even smaller.
ZIP the *SAVF — aka “Squish it”
We are going to use JAVA to squish that *SAVF into a *ZIP file. Of course this assumes Java installed on your IBM i Server as a licensed program.
Remember we can access that *SAVF using the IFS naming formats. ie: LIB(MYLIB/MYSAVF) can also be referenced as /QSYS.LIB/MYLIB.LIB/MYSAVF.FILE/MYSAVF.SAVF
The ZIP file will be an IFS object that lives in a directory and can be shared with your network or easily copy/pasted onto your PC
Lets assume we are creating the zip file in an IFS directory called MyIFSgubbbins
Of course you could use an existing directory (aka folder) if you wish. Now, from the 5250 Terminal Emulator you can simply ask Java to ZIP that *SAVF up for you.
The command is easy we say “use QSHELL” to run the “JAR” (Java compress — think “winzip”) and create a new zip file “/myIfsGubbins/myZippedStuff.zip” from the existing *SAVF at “/QSYS.LIB/MYLIB.LIB/MYSAVF.FILE”
STRQSH CMD('JAR -cf /myIfsGubbins/myZippedStuff.zip /QSYS.LIB/MYLIB.LIB/MYSAVF.FILE')
The Java “Jar” command basically creates a Java Jar file which is nothing more than a zip file. It’s transparent and real time compression is quick.
So, now you have a smaller ZIP file called myZippedStuff.zip that you can FTP, email, copy/paste or send by snail mail.
You can access this ZIP file using its IFS address of /myIfsGubbins/myZippedStuff.zip
You can email it from the command line or download it and have your wicked way with it:
SNDSMTPEMM RCP((email@example.com)) SUBJECT('This is a test email from IBM i V7R1') NOTE('<H1>This is the body of the email</H1> <p>I can enter things using HTML and format things in a most pretty way</p> <p><i>cool</i>') ATTACH(('/myIfsGubbins/myZippedStuff.zip' *OCTET *BIN)) CONTENT(*HTML)
If you are signed on using the wonderful IBM ACS then simply click the Integrated IFS Button and download the ZIP file to your PC:
Hope this is useful 🙂
Ps: stopping searching for “ZIP AS400 library” and search for “Zip IBM i Library” instead you numpty