I was updating a little RPG utility this morning to add some more detail to a spreadsheet it generated. Adding the Library Description will help the non-propeller heads who read this stuff. This is super easy to do with a single line of SQL added to your RPG program.
What is this spreadsheet you are waffling about? PS: Skip this paragraph if you don’t care about why I decided to add the description and just want to see how 🙂 This utility runs nightly and compares various libraries across the DEV, TST, QA and PROD environments looking for differences and generating an email with all the library names and a hash value for each library. If the hash values don’t match then we have a mismatched library on one of our machines. Just looking at a list of library names is fine for us propeller heads because we KNOW what the library names are and what application they are attached to. I was in a meeting where an executive asked “interesting spreadsheet, but how do we know what these library names are?” and the answer (with a straight face) was “ahhh, we know because of technical tribal knowledge”. I winced. Technical peeps often hide behind their desks, talking technobabble while forgetting that normal folks aren’t necessarily aware of the tribal language. But I digress…Me. waffling. I blame the double espresso.
In this example, the code is reading a file with two fields HSHLIB (the library name) and populating the HSHLIBDESC (the 50 character library description).
read filename; dow not %eof(filename); // now get the library description from the system catalog exec sql select SCHEMA_TEXT into :hshlibdesc from SYSSCHEMAS where SCHEMA_NAME = :hshlib; // now we have the library description in field "hshlibdesc' // so we can update the file or do whatever we want with it update filename; read filename; enddo;
In the old AS400 and iSERIES days we would have written a CL program just to do a DSPOBJD to an outfile and reading it, or maybe have called an IBM *API to get the info, but nowadays we can use the new IBM-i SQL facilities to grab the same info easily.
Simple code snippet – but hopefully will help any BM i novices out there
IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.
Don’t hardcode library names in your TURNOVER SQL source #youbigsilly
How to ZIP AS400 library and Email it
Funny Spam mail from Grill Insider
ILEditor connection problem with PUB400
IBM Rational Developer Ports
Upload a SAVF using IFS and IBM i Access Client Solutions (no FTP)
Using RPGLE to extract invoice numbers from an alpha string
How do we Check for Batch or Interactive in CLLE
Second Look: IBM RDi Extract Procedure Refactoring feature