Wednesday, February 22, 2023

Finding out if I am authorized to a function usage identifier

Function Usage Identifiers are a way to be authorized to a particular function, without having the authority changed on my user profile. I have found it is a lot easier to persuade the sys admins to grant me authority to the Function Usage Identifier for something, than it is to have my user profile changed.

In this post I am going to show ways you can find the Function Usage Identifiers, see which ones someone is authorized to, and finally have a way to check in a program whether or not you are authorized to one of the functions. Fortunately all of this can be achieved simply using SQL. What I will be using are:

Tuesday, February 21, 2023

Using SQL to get the first of the month for a date

I have used the LAST_DAY scalar function to return last day of the month many times. I was interested to see in IBM i 7.5 TR1 and IBM i 7.4 TR7 that a new matching scalar function was added, FIRST_DAY.

As the name suggests FIRST_DAY will return the fist day of the month of the date passed to the scalar function. For example:

01  VALUES FIRST_DAY(CURRENT_DATE) || ' thru ' || LAST_DAY(CURRENT_DATE)

I have used FIRST_DAY and LAST_DAY to return the first and last days of the month for the current date. Rather than have this information in two columns I have concatenated these together to produce one result. I know the SQL purist are going to criticize me as I have used the double pipe symbols ( || ) rather than CONCAT. They will, rightly, point out that this using the double pipe will not work on other Db2 platforms. As I will only ever run this code in an IBM i partition, I am not concerned by this lack of cross-platform compatibility.

Thursday, February 16, 2023

February 2023 Power announcement

On Valentine's day, February 14, Ken King, General Manager for IBM Power severs, published a blog describing the latest IBM Power announcements.

Not a lot about IBM i, but I am always interested to learn what is going on with the IBM Power server family of hardware and the operating systems it hosts.

You can read his blog, titled "Fueling Digital Transformation with IBM Power", here.

Wednesday, February 15, 2023

Discovering remote journals with SQL

I have an ongoing "battle" to keep the journals and their journal receivers under control in the IBM i partitions I am responsible for. Part of this has been to find and report on various features and functions of the journals. A recent addition to SQL, as part of IBM i 7.5 TR1 and 7.4 TR7, has been a View that returns results about the remote journals in a partition.

What is a remote journalling?

Remote journalling, in very simple terms, will send journal transactions to other partitions. I could use it to replicate changes made to file on the master partition to other partitions, and use those to update the remote files and keep all of the copies in synch.

Wednesday, February 8, 2023

Identifying profiles with disabled Netserver access

If you have users using your partition's IFS there are times when one of them manages to disable their access. In 2019 I wrote about how they can re-enable their access themselves using the QZLSCHSI API. What if I want to be more proactive and identify the profiles who already have disabled their IFS access?

Fortunately the information is attached to their user profile, but not in a place that I can get to with any of the User Profile commands, for example CHGUSRPRF. But I can use the SQL View USER_INFO. This View contains the column NETSERVER_DISABLED, if the User Profile has disabled their Netserver access then this column will contain 'YES'.

The statement I would use is:

Wednesday, February 1, 2023

Finding all the fields that contain certain characters

The germ for the idea for this post came from a question I saw in a Facebook Group. The question was how to identify records in a file where a particular field contains "special" characters, using SQL.

As the question was specially about a DDS file, I created a file, TESTFILE, with one field, FIELD1. I am not going to give the code for this file, just its contents. I would use the following SQL statement to list the contents of this file:

SELECT FIELD1 FROM TESTFILE

The results from this file are:

Wednesday, January 25, 2023

Finding a way to monitor for more than one message with RPG's monitor

Perhaps this title is a little misleading, I struggled to come up with something that adequately describe this scenario in the space allowed.

I was asked if there was an easy way when using a Monitor group to perform some kind of action if the message id starts with something like 'RNX12'.

Let me get start with my example RPG code:

Wednesday, January 18, 2023

Creating a User Index with SQL

When I wrote about a SQL procedure that allowed me to add data to a User Index, ADD_USER_INDEX_ENTRY, I created the User Index with the QUSCRTUI API. I received an email from an IBM employee telling me that there was a SQL procedure that would allow me to create the User Index.

I am going to do here is to create the same user index as I did with QUSCRTUI in that other post.

In this first example I am going to create the User Index with a fixed length entries of 100 bytes.

Wednesday, January 11, 2023

Getting an accurate count of characters in a variable RPG

Over recent years many of us are dealing with data in different character sets, not just the default CCSID of the partition we are using. The most common of these I encounter is UTF8.

UTF8 can contain double byte characters, which take two bytes for the character, as opposed to the standard single byte characters. If I am using a variable I have defined as UTF8 it is difficult to calculate the number of characters within, as the double byte characters result in an over count of the number of character present.

One of the additions to the RPG language as part of IBM i 7.5 Technology Refresh 1 and 7.4 TR7 are several things to make it possible to get a real character count from an UTF8 variable.

I am going to show several example programs to demonstrate how these new features work. Let me start with what I consider the most basic way, that is not bad thing I just me that IMHO the easiest. I am going to break this program into parts so it will be easy to explain what is happening. Let me start at the "top":

Wednesday, January 4, 2023

Procedure parameter option to convert data type

Another addition to RPG within the IBM i 7.5 TR1 and 7.4 TR7 updates was a new option in the OPTIONS parameter when defining the call to a procedure.

Previously if you passed, for example, a date to a procedure the parameter within the procedure's interface would have to be a date too. If the wrong data type was passed it would error.

The addition to the OPTIONS parameter is:

OPTIONS(*CONVERT)

Monday, January 2, 2023

Happy New Year 2023!

The old year is behind us, and I am always so hopefully and excited what the New Year will bring us all. Perhaps the new year will feel a bit more like the world returning to a kind of normal we have not seen for a couple of years.

In the IBM i world 2022 brought us:

What did you find interesting last year? These were the top five popular posts from 2022:

Wednesday, December 28, 2022

SQL View gives ability to see information about all commands

IMHO it has been problematic to get information about more than one IBM i command. The Display Command command, DSPCMD, will only output to display or print one command at a time. If I want to get information about more than one, or all, commands then I would need to use an API.

Fortunately with the fall 2022 Technology Refreshes, IBM i 7.5 TR1 and 7.4 TR7, comes a SQL View that contains all the information that the DSPCMD command does for all commands.

This new View, COMMAND_INFO, is simple to use. For example, if I want to list all the information about all the commands in this partition I could just use: