Wednesday, July 24, 2024

Now possible to build SQL Alias over last member

The SQL Create Alias statement was enhanced in the latest round of Technology Refreshes, IBM i 7.5 TR4 and IBM i 7.4 TR10. Previously when you created a SQL Alias you had to give a specific member in the DDS Physical file. Now I can use *LAST to denote the most recent member in the Physical file, and what is really cool is if I add another member to the file the Alias will now use that member!

This will be clearer when I show my examples.

First I need a DDS physical file. I called this one MULTIMBR, and it is found in my library MYLIB.

 A          R RMULTIMBR
 A            FIELD        100A

I compiled the above DDS Physical file with the following command:

01  CRTPF FILE(MYLIB/MULTIMBR) SRCFILE(MYLIB/DEVSRC) MAXMBRS(*NOMAX)

Wednesday, July 17, 2024

List all object types using SQL

Have you ever wondered how many different types of objects there in IBM i? And what the types of objects are?

The latest Technology Refreshes give us a SQL View that contains that information, and we can query it to answer those questions.

The SQL View is called SYSTEM_OBJECT_TYPES, and it is found in the QSYS2 library. It has three columns:

  1. OBJECT_TYPE:  Object type
  2. TEXT_DESCRIPTION:  Description of what the object type is
  3. CATEGORY:  There are two categories:
    IFS - object is in the IFS
    LIBRARY - object resides in a library (not an IFS object)

Thursday, July 11, 2024

New functionality added to RPG's SND-MSG op code

Two years ago the Send Message, SND-MSG, operation code was added to RPG. In the latest round of Technology Refreshes a number of new options have been added to SND-MSG and the Target, %TARGET, built in function.

To oversimplify it SND_MSG consists to three parts:

  1. Type of message to send
  2. Message text or variable
  3. The target for the message, which is the %TARGET built in function, BiF. This is optional

For example:

 SND-MSG *INFO 'Message text goes here' %TARGET(*SELF)

Wednesday, July 10, 2024

Deleting old device definitions

Last month I wrote about a way to list all of the unused virtual devices in your partition. In response to the article I received a question: "Is there a way to then delete these devices, other than manually going through? One system I just did has over 5,000 devices...."

The answer, of course, is yes there is. Before I give my final result let me go through the steps I did to create a SQL script to delete the unused virtual devices.

I can identify the virtual devices using the Object Statistics SQL Table function. I do not want to repeat myself. For the details read my previous article.

I decide to create a Common Table Expression, CTE, as it was just "neater". In the first part of the statement I would create a virtual table of all the eligible virtual devices, and in the second I would delete them. To start with I just want to make sure I gather the data I expected, therefore, my first statement did not do any deleting.

Wednesday, July 3, 2024

Constant keyword added to RPG definitions

As part of the latest Technology Refreshes, IBM i 7.5 TR4 and 7.4 TR10, comes an addition to the variable and data structure definitions. It is now possible to use the constant keyword as part of those definitions to protect them from being changed.

Why would I want to do that?

There are times I want to use a variable, rather than a constant. It might be to contain a date. I would not want this to be changed, either on purpose or by accident.

Below is an example:

01  **free
02  dcl-s StartDate date inz(*sys) const ;
03  dsply StartDate ;
04  StartDate = d'2024-07-04' ;

Monday, July 1, 2024

July's presentations

This moth I have two events I will be talking at.

I will be the speaker of the July meeting of the Central Texas IBM i User Group, CTXiUG. This meeting is on Tuesday July 9 at 6:30 PM (CT. I will be talking about various ways I have used SQL on IBM i to keep partitions clean of old objects, etc.

You can register at the CTXiUG website here.


Later this month I will be attending and presenting at one of my favorite conference's, OCEAN user group's TechCon24. The conference is a four-day affair. The first day, Wednesday July 24, is online. I am presenting in person on the second and third days, Thursday July 24 and Friday July 25. On Saturday, July 27, is their day of workshops.

You can learn more about the best user group conference in the western USA at their TechCon24 website here. You can register for the event from the same page.

I hope to see you there. And if you are attending and you see me, please introduce yourself and say "Hi".


If you are a member of an IBM i Local User Group, LUG, and you would like me to talk to your group, use the contact form to reach me. We can then arrange a date and subject.

If you are a member of a LUG that is not listed on my LUG page, please contact me and send me your group's details.

Wednesday, June 26, 2024

Create an Excel spreadsheet from a CL program

It has been possible to create a Microsoft compatible Excel spreadsheet using SQL since the last Technology Refreshes. In my example I demonstrated how you could do this within a RPG program.

A few months have passed and I have been asked how to do the same within a CL program. With a minor change I will show it is possible.

Let me start by showing the code for this program:

Monday, June 24, 2024

RPGPGM.COM-unity ribbons in the UK

Last week I was at i-UG's i-Power2024 conference, in the United Kingdom. This gave me another opportunity to hand out some RPGPGM.COM-unity ribbons.

What is the RPGPGM.COM-unity? You will have to click on this link to learn what it means, and see who I gave ribbons to.

Friday, June 21, 2024

Happy birthday to IBM i

Today marks the 36th anniversary of the launch of the AS/400 server and the OS/400 operating system on June 21, 1988.

Over this time the server has evolved, with the change from CISC to RISC chips and the improvements in chip technology, to become the IBM Power server. The operating system has been rewritten several times to include the latest evolving technologies to become IBM i, which is not the only operating system that can run on a IBM Power server.

What we have today is not AS/400 and OS/400, even though everything we could with them we can do today with the modern server and operating system.

I think I did a good job describing this history last year, for the 35th anniversary. If you are interested in learning more what AS/400 was, and what it has become, read the story here.

Happy birthday IBM Power and IBM i! May you have many more!

Wednesday, June 19, 2024

Using SQL table function to lookup SQL codes

It has always been a bit of a bind to look up what a SQL codes means, to be able to discover what error or warning Db2 for i is giving me for a SQL statement I have executed. There is a message file, QSQLMSG, where I can convert the SQL code into a message id and then look in the message file for the message texts:

SQL code -501 = Message id SQL0501

DSPMSGD RANGE(SQL0501) MSGF(QSQLMSG)

With the technology refreshes for IBM i 7.5 TR3 and 7.4 TR9 comes a table function where I can pass it the SQL code, and the results include all the information I desire:

  • Message id
  • Message text
  • Second level message text