Wednesday, November 26, 2014

Using Alias for longer field names


Update – December 17, 2014

Thanks to a PTF there is now a much easier way to use the ALIAS names in your RPG programs than the way described below.

Read Using aliases can be simple.


using alias in rpg

The ALIAS keyword in DDS has been around for many, many years. I first used it in a programming environment where most of other the programmers used Cobol. They explained that if I added a ALIAS keyword to any files I created then they could use the longer alias name rather than the field name. I have to admit that the ability to use a field or variable name that was longer than six characters greatly appealed to me. This was the days of RPGIII and I had to deal with field names like J4UEEC for "End user currency", rather than the alias END-USER-CURRENCY that the Cobol programmers could use (you have to use the underscore in the alias name and the Cobol compiler translate it to a dash). The other thing I was jealous of the Cobol programmers was the Data division being the only place to define program variables.

Wednesday, November 19, 2014

Data Areas in the all free RPG


I have a couple of communications asking about how to "correctly" code a data structure to receive the data from and update a data area in the latest, all free, RPG. One of person even sent me their code, which I will be using for the basis for my examples.

While I am not sure if there is just one "correct" way to do this I will be giving my version of the following three scenarios:

  1. Receive data from a data area into a data structure
  2. Update the data area with data from a data structure
  3. Equivalent of UDS

I am not going to describe the basics of how to code Data Structures in free format in this post, as I covered this in Defining variables in RPG all free.

Wednesday, November 12, 2014

Getting a list of files in IFS directory

directory folder list for ifs

I needed to make a job that would display a list of files in an IFS directory, allow a user to select one, copy contents of the file in the IFS directory to a file in the IBM i, and process the data. Always hearing the mantra KISS, Keep It Simple Simon, in my mind I searched for alternatives.

The person who taught me this mantra always made last the 'S' interchangeable between 'Simon' and 'Stupid', which left me thinking if I was being stupid? She always refused to elaborate.

I could use the 'Display Object links' DSPLNK, command. Alas, the output from this either display or print. If I output to print I could then copy the spool file to a physical file, and… that is unnecessarily complicated for something that should be simple.

Wednesday, November 5, 2014

More about subprocedures

subprocedures in modules

In my earlier post Subroutines versus Subprocedures I described some of the advantages of using subprocedures rather than subroutines. In it showed how you could use, what I call "open" subprocedures. An "open" subprocedure does not have a procedure interface specifications, therefore all of the variables defined in the main line/body are available in the subprocedures, and if you change the contents of one of those variables the changed value is seen in the main line/body.

The other type of subprocedure I call "closed". The subprocedure can be passed parameters and can return a single variable, which can be data structure with multiple subfields. A "closed" subprocedure is should be placed in a separate module, therefore, they are now available for multiple program to use. As the main line/body can only change the variables they pass to the subprocedure and the subprocedure can only return one pre-defined variable there is no accidentally changing to the values of the variables.

Many people commented on that post explaining the advantages of the "closed" subprocedure. I do agree and below I will describe how I code them and their advantages, including one potential gotcha.

Monday, November 3, 2014

Two user groups from France

I was recently browsing a French IBM i website when I found links to two User Groups in France:

They share at forum at

I have added these links to this site's IBM i user groups page. You will find a link to the user groups page at the top of every page of this website.

Are there other user groups/clubs in France or anywhere else in the world? If you know of any not on the user groups page please use the Contact form to send me their details.