Wednesday, April 2, 2025

Easier way to check if member exists

Amended April 23, 2025:  To use CHKOBJ command.


I was asked: What is the easiest way to check if a member exists in a file?

They had been recommended to perform the check in a CL program, but wondered if there was a way to do the same in a RPG program.

In a "pre-SQL" world I would have used the Check Object command, CHKOBJ, in a CL program to check if the member exists. My program would look something like this:

Thursday, March 27, 2025

One thousand posts

Yesterday another milestone was reached for this website, its one thousandth post!

Personally I think this is a remarkable achievement, to have been able to provide you with information about IBM Power and IBM i for the past 11 years, 9 months, and 17 days.

I want to thank all of you for helping make this possible. Without your encouragement, via social media, email or in-person, this blog would not have become what it has.

Wednesday, March 26, 2025

For RPG program where can I see the path name?

This post is in answer to a question I was asked:

We have compiled an RPG program from an IFS location but we are unable to determine the source of the compilation. We attempted the DSPPGM command and APIs, but they only show the member location when the program is compiled from a library, not for the IFS.

All modern RPG programs contain modules, even if I used the CRTBDNRPG command to create the program object. In this example I have a program TESTRPG, that is in the library MYLIB, that I created using CRTBDNRPG.

Wednesday, March 19, 2025

MTI_INFO now includes member name

As part of the latest round of Technology Refreshes, IBM i 7.5 TR5 and 7.4 TR11, the MTI_INFO Table function was enhanced with the addition of the member or Table partition name the MTI was created over. I have to admit I was surprised this was not included when the Table function was first introduced.

The new column is called TABLE_PARTITION, it is the third column in the results, and is a VARCHAR of a maximum of 128 characters.

If I just wanted to view all of the MTIs in my partition I would use the following statement:

01  SELECT TABLE_SCHEMA,TABLE_NAME,FILE_NAME,
02         TABLE_PARTITION
03    FROM TABLE(QSYS2.MTI_INFO())
04   ORDER BY 1,2
05   LIMIT 5

Wednesday, March 12, 2025

New parameter added to Audit Data Mart procedure

Audit Data Marts were added to IBM i in the previous round of TRs, and in the latest round of TRs comes what I can think is a significant improvement.

IMHO Audit Data Marts are a big improvement in the way I can manage Audit journal data. It allows me to copy the data from the QAUDJRN journal into a series of Audit Data Mart Tables. Each Audit Data Mart Table contains the data for one particular audit journal entry types. I am not going to go into more detail about creating Audit Data Marts as I wrote, in detail, about how to use them in my post: Audit Journal Data Mart in October of last year.

An additional parameter was added to the procedure MANAGE_AUDIT_JOURNAL_DATA_MART that makes it possible to select the information when I create or reload the Audit Data Mart. It is the DATA_MART_FILTER parameter. With this I can add additional selection criteria, in SQL format, to the MANAGE_AUDIT_JOURNAL_DATA_MART statement. Up to a thousand characters can be entered. Be warned the statement entered here is not validated, therefore, if what you enter is not valid it will cause an SQL syntax error when the statement is executed.

Monday, March 10, 2025

RPGPGM.COM-unity reaches India

I handed out a lot of RPGPGM.COM-unity ribbons at last month's COMMON India conference in Pune.

You can see who I gave them to here.

And you can learn about what the RPGPGM.COM-unity is here.

Wednesday, March 5, 2025

Deleting all spool files with a certain form type

The idea for this post came from a question I was asked in a presentation last month. The more I think about the solution I developed I am of the opinion that many of you might find this useful.

The question was: Is there a way, using SQL, to delete all the spool files that have a particular form type?

I have been using the DELETE_OLD_SPOOLED_FILES SQL procedure to delete old spool files on my partition. Alas, the Procedure does not have a parameter for form type.

Another idea sprung to mind, I could use the OUTPUT_QUEUE_ENTRIES_BASIC SQL View to select the spool files I want to delete, and do the deleting in the same statement using the appropriate CL command in the QCMDEXC Scalar function. I am sure some of you are wondering why I picked OUTPUT_QUEUE_ENTRIES_BASIC View rather than OUTPUT_QUEUE_ENTRIES View. The "basic" version has less columns than the "full" version, which makes it faster to return results.

The crucial part of my design is that I must get the selection criteria correct when I use the OUTPUT_QUEUE_ENTRIES_BASIC.

Tuesday, March 4, 2025

Inaugural Common India a great success

Last week, Monday 24 – Wednesday 26 February, was a truly historic event. The first COMMON event in India. I was lucky to be invited to make some presentations at the event.

I was most impressed by the attendees' thirst for knowledge for the latest about the IBM Power server and the IBM i operating system. While helping at the registration desk I was surprised how many people recognized me and the other USA based IBM Champions who were attending the conference. I soon lost count of the number of times I was asked to appear in someone's selfie. There was a range of experience there, from people who has been working with IBM i for decades, to students who want to learn about whether this was an environment they could have a career in.


IBM Champions: Gajendar Tyagi, Simon Hutchinson, Ranga Deshpande,
Marina Schwenk, Nirmal Kumar Khatri, Charlie Guarino

Wednesday, February 26, 2025

Faster way to check authority to IFS object with SQL

I could already check my authorization to an object in the IFS using the IFS_OBJECT_PRIVILEGES SQL Table function. If I wanted to check if I was authorized to, let's say, read the object the Table function still takes time to retrieve columns of data even if I don't include them in my result set. A better approach would be if I can just check if I am authorized to an IFS object, and have a return code that indicates if I am authorized or not.

A new SQL scalar function, IFS_ACCESS, was added as part of the last round of Technology Refreshes, IBM i TR5 and 7.5 TR11, that does this, which makes the time taken to check if I am authorized a whole lot faster.

All of examples are going to use a stream file, *STMF, in my folder in the IFS. I can check who and what authorizations they have to the object by using the IFS_OBJECT_PRIVILEGES View:

Wednesday, February 19, 2025

Displaying the configuration status using SQL

I don't use the Work with Configure Status command, WRKCFGSTS, frequently, mostly to vary on and off devices and occasionally controllers. I know that others do, and I have been asked to provide information such as a list of all the controllers' status.

As part of the last round of Technology Refreshes, IBM i TR5 and 7.5 TR11, a new View was added that allows us to see the same information in a better way.

With the WRKCFGSTS I am limited with the data I can retrieve.

                  Work with Configuration Status (WRKCFGSTS)

Type choices, press Enter.
                                                            
Type . . . . . . . . . . . . . . CFGTYPE           
Configuration description  . . . CFGD         *ALL      
Output . . . . . . . . . . . . . OUTPUT        *     
Remote location  . . . . . . . . RMTLOCNAME    *NONE   
Range  . . . . . . . . . . . . . RANGE         *NET
Status . . . . . . . . . . . . . STATUS        *ALL      

The valid configuration types, CFGTYPE, are:

Wednesday, February 12, 2025

New SQL procedure to end multiple jobs

As part of the latest Technology Refresh, IBM i 7.5 TR5 and IBM i 7.4 TR11, comes a new SQL procedure easily end multiple jobs in one statement. This procedure is called END_JOBS, and it is found in the SYSTOOLS library.

This procedure has ten parameters, most of them will be familiar you if you know the End Job command, ENDJOB. The parameters are:

  • JOB_NAME_FILTER:  The unqualified job name, what I called the "short job name". If not given the default is *ALL.
  • CURRENT_USER_LIST_FILTER:  Up to ten user profiles, separated by a comma. The default is for all users.
  • SUBSYSTEM_LIST_FILTER:  Up to 25 subsystem names, separated by a comma. If not given them all subsystems are considered
  • END_OPTION:  Like the OPTION parameter in the ENDJOB command. The allowed values are CONTROLLED or IMMEDIATE. Controlled is the default.
  • END_CONTROLLED_DELAY:  Like the DELAY parameter of ENDJOB. If the END_OPTION in controlled then this is the number of seconds it waits before it ends the job.

Monday, February 10, 2025

I was today's years old when I learned...

In my 37 years of working with IBM midrange, and especially IBM i and its predecessors, I learned something new that has blown my mind.

Spool as in "spool file" is an acronym!

I have always thought that "spool" was the queue of spool files on an output queue. A long list of spool files would be like piece of thread from a spool of thread. It turns out my assumption is wrong.

I have Alan Seiden to thank for bringing this to my attention.

It turns out the definition of a "spool" is: