Wednesday, November 18, 2020

New RPG features for arrays

%list built in function and for-each operation code for arrays

The new Technology Refreshes, IBM i 7.4 TR3 and 7.3 TR9, has given us a couple of new additions to array handling in the RPG language.

The first is a Built in Function, %LIST, that allows me to fill an array in one statement, and introduced me to a concept I had not heard of in the RPG language before, a temporary array.

The other is an operation code, FOR_EACH, that allows me to read an entire array, one element at a time in a loop operation without having to condition the loop with the number of elements in the array.

Let me start with %LIST Built in Function.

Tuesday, November 17, 2020

Range test added to RPG

%range bif added to rpg

The latest Technology Refreshes, IBM i 7.4 TR3 and 7.3 TR9, have added something I have wanted for a long time added to the RPG programming language, the ability to test if a value is within a range. This has been achieved by the introduction of a new Built in Function, %RANGE, and a new operation code, IN.

The syntax is very similar to the Range test I use in SQL:

if <value or variable> in %range(<minimum value or variable> :
                                 <maximum value or variable>) ;

Let me get on with some simple examples. First with a date:

Friday, November 13, 2020

TR day! 7.4 TR3 and 7.3 TR9

ibm i 7.4 tr3 and 7.3 tr9 day

Today is an exciting day as the new Technology Refreshes, TR3 for IBM i 7.4 and TR9 for 7.3, are now available to download via PTF.

I wrote about what is in these when they were announced in October.

Links to the find the PTFs are:

I am now off to generate a support ticket to ask RZKH to load all of these PTFs. I can then start writing about all of the cool new stuff!

Wednesday, November 11, 2020

Entry plist in all free RPG

entry plist in totally free rpg

This post comes under the category of "I thought I had already written about this". I have written about calling programs with totally free RPG, and how to receive passed parameters to a RPG program with a main procedure, but I just forgot to write about how to receive parameters to a RPG program without a main procedure.

In fixed format RPG the entry parameter list would look like:

01 C     *entry        plist
02 C                   parm                    Parm

Now how do I do the same in free?

Wednesday, November 4, 2020

Getting "Run SQL scripts" to use the library list

change run sql scripts to use library list

Perhaps I am the only person who experienced this issue with my "Run SQL scripts", but I am going to share the solution I found.

I have to say "Run SQL scripts" is probably my favorite IBM i tool. I open it when I start my work day, and I use it all day to help me develop and test various SQL statements before I copy them into programs, procedures, or source members that I then create the objects from using the RUNSQLSTM command.

When the latest release of Access Client Solutions, ACS, was released I download the new install files, uninstalled the version of ACS I already had, and ran the install program to install it onto my PC. When it completed and I started to use "Run SQL scripts" again I found that I had to qualify the object, file, view, etc. name with the library. If I did not I always received the message telling me that the object was not found.

Wednesday, October 28, 2020

Getting the day of the week in a CL program using SQL

getting day of week in a cl program

The germ for this post came from a Facebook post I saw. The question was posed: Is it possible to retrieve the day of the week in a CL program? Multiple people suggested using a CEE API. Then came a reply that really interested me. This person said he had built a SQL View for this purpose.

It struck me as a creative approach to this scenario. SQL has a global variable CURRENT_DATE which contains, as the name suggests, the current date:



What kind of information would I want to know about today's date?

Wednesday, October 21, 2020

Using SQL to extract packed decimal from a flat file

sql interpret to extract packed decimal from strings

I have a two "flat" files that contain packed numeric fields. The first is a "header" that contains the file date, the number of records and the total of the amounts in the "detail" file. The "detail" file contains account information that I don't really care about. I need to validate the count from the "header" file to the data in the "detail" file.

When I look at the file using the Display Physical File Member command, DSPPFM, I can see the packed fields. They are where the funny characters are:




First     ??One  ?????¬*Testing
Second    ??Two  ???Ì°?*Testing

Wednesday, October 14, 2020

Which libraries did Jane create?

get the libraries owned by a specific user profile

I was asked how can I identify the libraries a person, in this example we will call her Jane, created? The person who asked the question was a self-confessed “newbie operator" who had been given some information by his employer's programmers, but doubted it was the most efficient way to get the data.

If I need to find out who created one library I would use the Display Object Description command, DSPOBJD.


The following screen would be shown, and I would just look at the “Created by user" field:

Wednesday, October 7, 2020

Using multiple SQL Sequences to update different record types

sql sequence to update file with unique sequence number for each record

There is a file, ACCTFILE, with a unique key of two fields:

  1. SEQUENCE:  A unique sequence number
  2. ACCTYPE:  Account type code
01 A                                      UNIQUE
02 A          R ACCTFILER
03 A            SEQUENCE       6P 0
04 A            ACCTYPE        2A
05 A          K SEQUENCE
06 A          K ACCTYPE

The Sequence is incremented every time a record is written to the file, i.e. there is only one record with each Sequence number. The Sequence is now in the 800,000s, and the concern is what will happen when happen when 999,999 + 1 happens?

This is when they asked me for advice.

Tuesday, October 6, 2020

7.4 TR3 and 7.3 TR9 announced

new technology refreshes 7.4 tr3 and 7.3 tr9 announced

The autumnal announcements have been made for new Technology Refreshes for the currently supported versions of the IBM i operating system:

  • IBM i 7.4 TR3
  • IBM i 7.3 TR9

The TRs include the same updates for Db2 for i (SQL), RPG, and open source.