Tuesday Tips

Get the Flash Player to see this player.

Got a question for Bob Cozzi about one of his Tuesday Tips? Have a suggestion for improving his solution? Want to recommend an alternative method? This is the place for discussing Bob's Tuesday Tips.
  • June 23, 2009 - Generic CL Commands--As far back as 1984 I started writing CL commands that performed the same task over multiple objects. It was my first attempt at adding generic support to certain commands that lacked it. Back then, most commands were not generic. Later, I wrote a CL command named GENSUP that performed any CL command on a generic list of objects or members. Today, IBM i includes generic commands for most functions. But some, such as a generic Change Object Owner (CHGOBJOWN) command and others, are still missing. With a little insight, you might find that there is a generic version of these commands already installed on your system. And the best part is that generic versions work with normal IBM i objects as well as IFS files and folders. In this week's Tuesday Tip, Bob Cozzi demonstrates.
  • June 9, 2009 - Create an FTP Script - FTP usage on IBM i is becoming pervasive. Nearly every shop needs to use FTP to transfer files. In this week's Tuesday Tip, Bob Cozzi shows how to create an FTP Script that lets you run FTP unattended in either batch jobs or interactively. You'll also find out how to save the FTP log in a source file member.
  • May 26, 2009 - Convert Date Values - Many people store their "date" values in numeric fields in their database files. In this week's Tuesday Tip, Bob Cozzi shows how to manage these dates by converting them in RPG IV to true Date data-types and then performing date arithmetic on them.
  • May 12, 2009 - Data Structure Templates - Since IBM i 5.1, developers have been able to simulate the concept of "Templates" in RPG IV through the use of QUALIFIED Data Structures. In this week's Tuesday Tip, Bob Cozzi reviews how to define these impromptu Templates and then shows you the new i 6.1 feature in RPG IV that lets you use real Data Structure Templates.
  • April 28, 2009 - SQL OPTION(s) Revisited - Recently, Bob Cozzi reviewed how to embed SQL options (PreProcessor options) into embedded SQL in RPG IV. He demonstrated how to insert a couple of SQL-away compiler parameters. In this week's Tuesday Tip, Bob revisits EXEC SQL SET OPTION and shows how to insert any compiler parameter, including DBGVIEW(*SOURCE), into your RPG IV (SQLRPGLE) source member.
  • April 14, 2009 - CL Compiler Options - It has been more than 12 years since IBM added to RPG IV the ability to insert Compiler options into the source code. This brought requests from all over the RPG world to do the same for CL and DDS. Sadly, the voices fell on deaf ears, until now. In this week's Tuesday Tip, Bob Cozzi shows how you can insert CL compiler parameters into CL source code--and it also works with CLP and ILE CL. (However, it still doesn't work for DDS.)
  • March 24, 2009 - Binder Language and Service Programs - If you've started creating service programs, you might have fallen into the EXPORT(*ALL) trap on the CRTSRVPGM command. But don't worry, because in this week's Tuesday Tip, Bob Cozzi shows how to create real binder language source from existing user-written service programs (or any service program, really) and then use it moving forward when re-creating those service programs. So check out this week's tip and get started doing things the right way with binder language and service programs.
  • March 10, 2009 - Workstation Time-Out - Even with the move to browser-enabled applications, readers have been asking about workstation time-outs at least once a month on Bob Cozzi's RPG World discussion forum. In this week's Tuesday Tip, Bob illustrates how to do workstation time-outs using Display File DDS and RPG IV. Now you can finally get that on-screen clock running just like in the opening of the television show 24.
  • February 24, 2009 - Mapping Database Arrays in RPG IV - Have you ever had repeating fields in a database and tried to map them into an array? It's very tricky, and until RPG IV it was cumbersome. Today, RPG IV can handle it with just a couple of lines of code. In this week's Tuesday Tip, Bob Cozzi shows how to easily map repeating database fields into a RPG IV array.
  • February 10, 2009 - IFS Directory List in RPG IV - The WRKLNK command is great, but it doesn't provide a way to send its list of IFS files to RPG. In this week's Tuesday Tip, Bob Cozzi shows how to build your own IFSDIR (List IFS Directory Entries) command and use it in RPG IV to produce and read a list of files in any IFS directory.
  • January 27, 2009 - Embedded SQL Compiler Options - For too long, prompting PDM option 14 to change the defaults of SQL RPG IV compilers has interfered with development. RPG IV solved this right out of the box by offering the compiler options embedded in the Header specification. But there is light at the end of the tunnel for those using the SQL RPG IV compilers. You can include embedded SQL compiler options in your source code, just like the RPG compiler options. But the syntax is, well, different. In this week's Tuesday Tip, Bob Cozzi shows how to add SQL Preprocessor/Compiler options to your source code, allowing you to avoid incorrectly compiling the code.
  • January 13, 2008 - Dynamic Web Page Content - Have you ever wondered how you can post periodic updates to your company's website without changing the HTML pages every single time? In this week's Tuesday Tip, Bob Cozzi demonstrates how to use CGI RPG as a Server Side Includes (SSI) program. SSI is a type of CGI RPG program that typically sends short posts into the middle of your web pages. Specifically, Bob illustrates a "Daily President's Message" example that retrieves the information from a file.
  • December 16, 2008 - Modern File Declaration - Since 2009 is almost upon us, you should consider declaring files in RPG IV the modern way. You can speed up processing by directly inserting your input fields into a data structure, or you can declare a physical and logical file in the same program and keep their fields distinctive. In this week's Tuesday Tip, Bob Cozzi shows his Modern RPG IV File Declaration techniques, which help make declaring files a snap.
  • December 9, 2008 - Convert Text to Numbers - Because developers are increasingly using web languages and XML with RPG IV, the need to move data from HTML and XML into RPG variables is pervasive. However, the RPG built-in functions often fall down on the job when anything other than perfect data is specified in them. In this week's Tuesday Tip, Bob Cozzi shows the steps to safely convert textual data, including blanks and empty values, to numeric data without runtime problems.
  • December 2, 2008 - Parsing XML in RPG IV - Parsing XML is becoming a requirement in many System i shops. If you are in a shop where i 5.4 has become the base release, you now have access to native XML parsing right from within RPG IV. In this week’s Tuesday Tip, Bob Cozzi illustrates how to parse XML that is stored in a field or IFS file using essentially one line of RPG IV code. No toolkits or add-on service programs are necessary.
  • November 25, 2008 - Read Data from a Web Browser into RPG IV - In a previous Tuesday Tip (Write to the Web browser from RPG IV--October 28) Bob Cozzi demonstrated how to write HTML and data to the web browser using nothing but RPG IV and the QtmhWrStout API. In this week's Tuesday Tip, Cozzi shows how to read the data that users have entered into a simple web page and store it in a System i DB2/400 database file.
  • November 18, 2008 - Faster Key Validation - Bob Cozzi was surprised to learn that over 80 percent of RPG IV programmers use the CHAIN opcode to verify the existence of a record in a database file. While this works, it's much slower than an alternative technique that Cozzi has used for many years. In this week's Tuesday Tip, Cozzi shows how to verify that a key exists in a database file without using the CHAIN opcode.
  • November 11, 2008 - Configure Your Web Server for CGI RPG - We've received many emails requesting a demonstration on how to run the CGIWrite example CGI RPG IV program. In this week's Tuesday Tip, Bob Cozzi illustrates the steps to configure your HTTP web server so that it will run the CGI RPG IV program from the library of your choosing.
  • November 4, 2008 - Use a Portion of an Array - Sorting an array or totaling the elements of one was an all-or-nothing feature in RPG IV until IBM loosened this long-standing restriction in IBM i versions 5.3 and later. In this week's Tuesday Tip, Bob Cozzi illustrates how to SORTA and XFOOT a portion of an array. That's right, no more preloading array with all 9s or *HIVALs before sorting. It's about time.
  • October 28, 2008 - Write to the Web Browser from RPG IV - Although several add-on service programs--RPG xTools, CGIDEV2, and eRPGSDK--make building web pages relatively easy from within RPG IV, it is still sometimes necessary to write directly to the web browser or respond to an SOA request without loading up one of those libraries. In this week's Tuesday Tip, Bob Cozzi shows how to write directly to the web browser and make it understand what you're about to write.
  • October 21, 2008 - Replace the DO Loop - When you move to free-format RPG IV, you might run into a few pieces of code that just don't convert. One goofy item is the DO opcode, which doesn't migrate well to free format. In this week's Tuesday Tip, Bob Cozzi demonstrates two techniques for migrating DO opcodes to free format. One is just as goofy as you might think; the other is pretty cool.
  • October 14, 2008 - Build True Date Values - We get so many emails asking about date conversion that we've gone back to the well for one more routine. In this week's Tuesday Tip, Bob Cozzi shows how to move non-date fields (no matter how crazy their format is) from the database to a true date data-type variable so you can use RPG IV's cool built-in date math. Whether the values are a CL date, three or four individual 2-digit fields, 7-digit packed, 8-digit zoned, or a 10-position character, you can convert them into true date fields.
  • October 7, 2008 - Keylists in Free Format - Programmers have always taken advantage of keylists in fixed-format RPG. But since free format became available, we've fumbled over the best place to locate fixed-format keylists in free-format code. In this week's Tuesday Tip, Bob Cozzi illustrates how to update legacy keylists with cool, new free-format equivalents.
  • September 30, 2008 - Writing to the IFS in RPG IV - So many Excel files, so little time. In this week's Tuesday Tip, Bob Cozzi shows how to create, open, and write from within RPG IV to a plain ASCII file on the IFS.
  • September 23, 2008 - Z-ADD With Truncate in /FREE - In traditional RPG syntax, the MOVE and Z-ADD opcodes (as well as all the Math opcodes) provide high-order truncation. This means that if you move a 10-digit number into a field that holds only nine digits, the compile truncates the leading (left-most) digit and pretends like nothing happened. However, in free format RPG, IBM avoided implementing high-order truncation and instead provided the option to turn it off in fixed format. Backwards implementation or not, programmers can't do high-order truncation in free format, causing tens of thousands of them to avoid moving to free format. In this week's Tuesday Tip, Bob Cozzi shows how to simulate high-order truncation in free format.
  • September 16, 2008 - Modernize Your *ENTRY/PLIST - Even though many RPG programmers have moved on to free format, using subprocedures, multiple modules, and/or service programs when creating applications, few have migrated their program's *ENTRY/PLIST to a "new" method introduced some 12 years ago. In this week's Tuesday Tip, Bob Cozzi shows step by step how to migrate legacy *ENTRY/PLIST for programs to a more modern style of prototypes and program parameter interface statements.
  • September 9, 2008 - The Right Side of Data - Comparing the last few characters in a field to a literal isn't a simple task. But RPG IV and SQL both have ways to make it easier (Well, it's easier in SQL, anyway). In this week's Tuesday Tip, Bob Cozzi illustrates how to compare a literal to the right side of your data.
  • August 26, 2008 - Local Global Variables - We've all heard of global and local variables. But when it's time to update the mainline Calcs of an existing application using clear, meaningful field names, having lengthy programs with lots of work fields can make it difficult. In this week's Tuesday Tip, Bob Cozzi demonstrates how to create your own set of global variables, regardless of their names, without worrying about name conflicts.
  • August 19, 2008 - Skipping Input Fields During Debug - Debugging code is critical. But it can get pretty annoying when the debugger hits a CHAIN or READ opcode and moves up to the Input specs, requiring you to step through each input field before returning to the Calc specs. In this week's Tuesday Tip, Bob Cozzi shows how to avoid such a time-consuming process.
  • August 12, 2008 - Boolean Operations in RPG IV - RPG indicators have virtually disappeared from new code. Still, you can assign the results of an express to an indicator field without using an IF statement. Bob Cozzi shows how in this week's Tuesday Tip.
  • August 5, 2008 - Extend RPG with SQL - Programmers know we can perform database operations with SQL in RPG. We also can extend the RPG language using SQL's vast library of functions. Bob Cozzi demonstrates how in this week's Tuesday Tip.
  • July 29, 2008 - Data Structures as Command Parameters - For years, RPG programmers have passed data structures as parameters. There's also an easy way to pass data structures from CL or Command Entry to RPG programs. Bob Cozzi demonstrates how in this week's Tuesday Tip.
  • July 22, 2008 - Qualified Object Names--The CL CALL command can make it a challenge to pass a qualified name, such as a file name, as a parameter to RPG programs. There's an easier way. Command definition source lets you easily define and pass qualified objects, including file names, to your programs. Bob Cozzi demonstrates how in this week's Tuesday Tip.
  • July 15, 2008 - Converting Non-Standard Date Formats - Users often have dates that are not in a standard format stored in database files or coming in from EDI or XML apps. A non-standard date format can cause a problem for RPG IV's built-in %DATE function. In this week's Tuesday Tip, Bob Cozzi shows how two date-oriented APIs help easily convert date values stored in virtually any format in non-date fields into standard date data types.
  • July 8, 2008 - More Indicator-Free Code - Using RPG indicators is taboo, to say the least. In this week's Tuesday Tip, Bob Cozzi shows how to eliminate the use of RPG indicators when the RPG code is processing display files. Cozzi introduced this simple, yet elegant technique more than 20 years ago in his original Modern RPG Language book and has revised and updated the technique to include the contemporary INDDS and INFDS data structures.

ProVIP Sponsors

ProVIP Sponsors