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 27, 2010 - FOR Loop - Moving to free format shouldn't have barriers to entry. In this week's Tuesday Tip, Bob Cozzi shows how to migrate existing DO logic--and your own programming habits that use the DO opcode--to free format. The FOR opcode has been around for a long time, but a minority of RPG programmers use it. Watch this week's Tuesday Tip and see how it can help you.
  • June 13, 2010 - List Contents of Zip Files on i - Whether you create a .zip file on the PC, Mac, or right on an i system, you can view the contents of the .zip on the green screen of the i itself. In this week's Tuesday Tip, Bob Cozzi reviews how to create a .zip file on i and then illustrates the command available to list a directory of the files stored in a .zip, regardless of where it was created.
  • June 22, 2010 - Redirecting Files in RPG - Programmers have used Overriding Files on this platform since System/38 was first shipped in the early 1980s. Today, thousands--if not millions--of OVRDBF are needlessly consumed by POWER CPUs around the world. In this week's Tuesday Tip, Bob Cozzi shows how to be more ecologically conservative and avoid the OVRDBF CL command in favor of the better performing RPG IV File Redirection
  • June 8, 2010 - Using Data Structures for I/O in RPG IV - Improving performance is important to RPG IV programmers. Some of us mistakenly stopped using the RPG feature that improves performance on database I/O years ago when a new feature came onto the RPG scene. In this week's Tuesday Tip, Bob Cozzi illustrates the right way to reduce I/O overhead, particularly when a database file contains many fields.
  • May 25, 2010 - Ad Hoc Keylists in Free-Format RPG IV - Moving to free-format RPG IV syntax never seems to be straight forward. New and innovative features are seemingly hidden everywhere. One feature that many programmers don't realize is available is ad hoc keylists. Bob Cozzi discovered this lack of awareness during his recent RPG Skills Modernization Seminar, and describes the feature in this week's Tuesday Tip.
  • May 11, 2010 - Exporting Subprocedures from a Service Program - Exporting subprocedures is the art of making the subprocedures within a service program available to the outside world. Making this happen can be confusing. In this week's Tuesday Tip, Bob Cozzi shows how this two-step process works, and how it all ties together. .
  • April 27, 2010 - New (Financial) Functions in RPG IV - RPGOpen.com is an open-source project that Bob Cozzi started a few months ago. In this week's Tuesday Tip, Bob reviews the source code for a few new features he has added to RPGOPEN, including fnPMT to calculate a loan payment, min and max to determine the lowest and highest values from a list of numbers, and more.
  • April 13, 2010 - Declare Local Files in Subprocedures - A new i 6.1 feature in RPG IV lets you declare Files inside a subprocedure. While not perfect, it provides a huge advantage over declaring everything as a global file and trying to manage it that way. In this week's Tuesday Tip, Bob Cozzi shows how to declare and use Local Files in subprocedures in RPG IV.
  • March 23, 2010 - Conditional Code - Developers who want to modernize their RPG IV skills can't just move legacy coding requirements into the new expression syntax; you must also change the way you write code. In this week's Tuesday Tip, Bob Cozzi reviews Conditional Coding from the RPG II days, covering indicator controlled logic all the way up to today's best practices for free-format conditional logic.
  • March 9, 2010 - Create Qualified IFS Path Names - Trimming blanks from the end of an IFS file or path name isn't the only challenge to using the IFS. Inserting a forward slash to separate the file from the folder name also can be challenging. In this week's Tuesday Tip, Bob Cozzi demonstrates how to create properly qualified IFS path names.
  • February 23, 2010 - Trim Blanks from IFS and C APIs Made Easy - Using the IFS can lead to problems when trailing (or leading) blanks are included in the file or directory name. Many people use VARYING fields to circumvent this issue, while others wrap the value in %TRIMR. In this week's Tuesday Tip, Bob Cozzi shows a foolproof way to trim trailing blanks from parameters passed to any API-C, IFS, or even your own in-house interfaces-all without having to bother with VARYING or %TRIM.
  • February 9, 2010 - Display Program Version - Knowing what version of IBM i that your programs can run on is getting to be more and more important as we move beyond version 5.4 of the operating system. Program conversion is required to move to i 6.1 and the RPG compiler continues to support just n-2 for the target release parameter. If you're a software developer, this becomes even more important. In this week's Tuesday Tip, I introduce the DSPPGMVER command, which displays the earliest release that a program can be restored or run on, as well as whether the program needs to be re-encapsulated (i.e., converted) before you move it to 6.1 or later.
  • January 26, 2010 - Retrieve Julian Date - While writing my new book I tried to determine why anyone would need to use a Julian date. I couldn't really come up with a reason, but a colleague of mine suggested that people use it to retrieve the day of the year. That's right: February 1, 2010 is day 32. In this week's Tuesday Tip, I explain how to retrieve a Julian date from any Date variable, and in one line of code.
  • January 12, 2010 - MOVEA in Free Format - The MOVEA (move with array) operation code may not be supported in Free Format, but that doesn't stop Bob Cozzi from making it work anyway. This week's Tuesday Tip takes a page from Cozzi's upcoming book on free-format programming and illustrates two alternatives to MOVEA in free-format RPG IV.
  • December 22, 2009 - Modifying RDi Look and Feel - WDSC and now RDi ship with what I would categorize as a questionable choice of font colors. Bright red, really? In this week’s Tuesday Tip I show how to change the font family, color, and size inside RDi, and the same technique applies to WDSC.
  • December 8, 2009 - Delete IFS Files from within RPG IV - File upon file piles up on your IFS when you create PDF, XLS, CSV, HTML, and text documents to send to your users; not to mention all those EDI files you've received. In this week's Tuesday Tip, Bob Cozzi shows how to delete IFS files from within RPG IV--simply and easily without a lot of fuss.
  • November 24, 2009 - A Case for SQL: Part 2 - After the last episode of Tuesday Tips I received a number of emails and forum posts requesting information on using the CASE statement in SQL to create an ORDER BY clause with multiple "key fields." The original tip illustrated this technique with just one field. It can be complex to make it work with multiple ORDER BY values--unless you watch this week's episode of Tuesday Tips.
  • November 10, 2009 - Dynamic Order: A Case for SQL - It sure would be nice if IBM i applications gave users the ability to sort based on their needs at runtime rather than design time. In some cases, the order of data in a subfile or on a report was established more than a decade ago. In this week's Tuesday Tip, Bob Cozzi shows how to use embedded SQL to dynamically arrange the data brought into a program so that your end users can control how they receive it.
  • October 27, 2009 - Retrieve Display Size - In this week's Tuesday Tip, Bob Cozzi demonstrates how to retrieve the current "mode" of your display so that you can control whether you write a wide-screen format or normal format to the screen and keep it in its current state. The demonstration also features a second API that returns the number of rows and columns on the screen.
  • October 13, 2009 - MAINKWD: The Cool New IBM i 6.1 MAIN Keyword for RPG IV - With the introduction of new features to RPG IV in IBM i 6.1 came the MAIN keyword. This mysterious keyword lets you remove the RPG Logic Cycle overhead from your stand-alone programs, just like you can with Service Programs. But as always, there are options and coordinated efforts that need to be in place to make it work. In this week's Tuesday Tip, Bob Cozzi shows how to create a "LR-Free Zone" by getting rid of the RPG Cycle once and for all!
  • September 22, 2009 - %DEC Built-in Function Work-Around -Converting character values to numeric values with %DEC is quick and easy. However, you can't specify a variable for the resulting value's length and decimal positions without hard coding everything. In this week's Tuesday Tip, Bob Cozzi shows a work around that lets you avoid hard coding requirements with the %DEC built-in function.
  • September 8, 2009 - Naming Conflicts! What Naming Conflicts? - Naming conflicts traditionally have not been an issue in RPG. But as the language has evolved and more and more conventional language features have been introduced into RPG IV, so have naming conflicts. In this week's Tuesday Tip, Bob Cozzi shows what to watch out for when naming RPG IV variables and data structures and then a great work around when you have no choice in your naming conventions.
  • August 25, 2009 - Contemporary Transform Techniques - Transforming data is normally performed using a subroutine. But that's "so last century." Today, you should be using more contemporary techniques, well, techniques that have been around for at least 10 years. (Maybe it's time to start using them?) In this week's Tuesday Tip, Bob Cozzi illustrates a common programming task: He transforms data using a subroutine and then shows how to move that code to a subprocedure.
  • August 11, 2009 - Compatible Key Fields - Working with legacy applications usually means you'll also be working with legacy database files. These files occasionally have key fields in them that are different from those in more contemporary database files. For example, a legacy file might have a 10-position character field as its key, while most other files have the same field as a packed decimal value. In this week's Tuesday Tip, Bob Cozzi shows how to easily handle this situation in RPG IV using free format and a few simple functions.
  • July 28, 2009 - iComp - We've all had to compare two character fields while ignoring upper/lower case differences. If we had a third-party add-on library such as RPGLIB (rpglib.com), this kind of capability would be available to us every day. But what if we need something that is both efficient and available whenever and wherever we're coding. In this week's Tuesday Tip, Bob Cozzi introduces iComp() as a case-insensitive comparison function written with RPG IV, but leveraging the C runtime library. It's cool and easy to use.
  • July 14, 2009 - PackEven - Just before IBM announced RPG IV back in the mid-1990s, I was on the phone with IBM discussing the issue of even-length packed fields. Sure the new length notation on the Definition Specification solved the issue completely, but what about legacy code ported from RPG III? It still used from/to column notation to define fields. Sadly, there wasn't a way to use columnar notation in RPG IV to define even-length packed fields, so I made a suggestion as to how that feature could easily be implemented. Recently, I discovered that some RPG programmers have only worked in RPG IV and have never had to deal with RPG III; and they don't know this feature exists. In this week's Tuesday Tip, I explain the feature so that when your maintenance application assignment comes up, and you run across an even-length packed field in a data structure defined with from/to columns, well, you'll know what to do.
  • 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.

ProVIP Sponsors

ProVIP Sponsors