Friday, October 27, 2023

Updated Power 10 performance guide published

On Wednesday Steve Will, IBM's CTO and Chief Architect for the IBM i operating system, announced on social media that an updated version of the "IBM Power 10 performance optimization for IBM i" had been published.

The timing could not have been better as the company I work for is installing their new Power 10 server next week.

I have read the guide and am impressed with all the advice that is offered.

You can reach the guide by using this link here.

Thursday, October 26, 2023

Renaming a CL procedure's name in a RPG program

One of my criticisms when using CL procedures in my RPG programs is that I had to use the name of the module. Sometimes the ten character name of the procedure, and module, was not descriptive enough for my sensibilities. I have discovered that a solution was provided in IBM i 7.2 that allows me to give my own name to CL procedures.

In this example what the code for the CL procedure is not necessary. All I need to know is that it will copy a file to a IFS folder. It has four parameters:

  1. Library the file is in
  2. File name
  3. Path name, directory and name the file will be called in the IFS
  4. A code returned from CL procedure to whatever called it

Wednesday, October 25, 2023

Calculating the sine, cosine, and tangent

I was asked what is the best way to calculate the sine for a number within a RPG program? I know my answer frustrated the person who asked as I replied with "It depends".

I can think of two scenarios that I would use different approaches for:

  1. Calculate the sine for a value in a file or table's field or column when "reading" the file or table
  2. Calculate the sine for a value calculated within a program

In my examples I am going to also show how to calculate the cosine and tangent too.

Wednesday, October 18, 2023

Using the time zone UDF I created in RPG

Yesterday I showed how to create a SQL User Defined Function, UDF, to return the current timestamp for another time zone.

Several people messaged me asking me how I would use this in a RPG program. Rather than answer them individually I thought would share my answer with you all.

I could think of two examples of when I would use the THEIR_TIMESTAMP UDF in a RPG program:

  1. I want to retrieve the timestamp from the UDF into a RPG variable, that I can then use elsewhere in the program
  2. Use it as part of an SQL Insert statement into a DDL Table or DDS file

Let me start with the first scenario: retrieving the timestamp from the UDF into RPG variables:

Tuesday, October 17, 2023

Determining the time zone with a user defined function

In a previous post I wrote about calculating the time in different places in my IBM i partition. I mentioned at the end of that post that I had created a User Defined Function, UDF, to perform that calculation for me. This post is to show you how I did that.

As I described in the previous post I can calculate the UTC by using the CURRENT_TIMEZONE special register:

UTC time = CURRENT_TIMESTAMP – CURRENT_TIMEZONE

It is not possible to know what other time zone's difference is from UTC without using a table to contain the following information:

Wednesday, October 11, 2023

More information about the Fall 2023 TRs

Information is still coming out about the Technology Refreshes announced yesterday.

Steve Will, Chief Architect for IBM i, gave his take on these in his "You and i" blog, you can read that here.

IBM has worked with COMMON North America to share two videos about these TRs:

You will need to register for both of these recordings. It requires a COMMON North America profile to do this, which is free to create.

I am still looking out for anything else I can find out about these TRs that I will share with you on this page.

Tuesday, October 10, 2023

Fall 2023 TRs announced

Today is the day that IBM has announced the Fall 2023 Technology Refreshes for the currently supported releases of IBM i, 7.5 TR3 and 7.4 TR9.

All the information about the TRs can be found on IBM website on the following on the following pages in IBM's websites:

Wednesday, October 4, 2023

Determining the time zone, and calculating the time in another country

I was asked if there is a way to calculate the current time in Japan, in an IBM i partition in the USA. To add to the complication in doing this the use of Daylight Savings Time, DST, has to be handled. Most places in the USA observe DST, not all other countries do.

Every IBM i partition has a set of system values that are related date and time. Two of these are particularly relevant here:

  • QTIMZON:  Time zone
  • QUTCOFFSET:  UTC offset, hours and minutes different from UTC. UTC the same as GMT, Greenwich Mean Time

I can retrieve these two system values with a SQL statement using the SYSTEM_VALUE_INFO View:

Wednesday, September 27, 2023

Deleting records from a file without the delete trigger executing

I have a file that has a "delete trigger" on it. I need to delete all of the records in the file without the "delete trigger" inserting data into its output file. How could I do that without removing the trigger from the file?

I am going to show you how.

Before I do I am going to need a file with data. I have created a file, TESTFILE, in my library, MYLIB, that has ten records in it:

Tuesday, September 26, 2023

Creating a spool file from a modern RPG program with no output specs or custom printer file

I am not sure if the title really describes what this post is about. The germ for this post came from an email I received from Elbert Cook. He asked me about emulating output specifications in a modern RPG program. Modern free format RPG does not support output specifications. I am pleased about this. I can get far more functionality and make changes many times faster by creating my own printer file than I would making changes to an output specification. Some have argued to me that printer files are too new for them to use, which is not true as I first used them when this operating system was OS/400 and it was running one of the releases of version 2.

Let me stress that what I describe in this post is NOT a case for creating something like output specifications. Use custom printer files.

There are times where I have created printed output from a program I was testing or developing that was so "down and dirty" I did not want to spend my time creating a printer file for. This post is based upon the methods I have used, and some examples from Elbert.

Thursday, September 21, 2023

Creating a spool file from a SQL Select

I was asked if it possible to create a spool file from the results of a SQL statement. It most certainly is! I have done it several times, and I was surprised I have not written about it here. I know I could do this with SQL embedded in RPG, but I wanted to do this not using RPG and have SQL do most of the work.

I have written about Query Management queries, QM queries, before. They are, basically, a compiled SQL statement. I execute them using the Start Query Management Query command, STRQMQRY. One of the parameters of the command is an option to *PRINT.

Before I show examples of QM queries I need a file of data to use. It will come to not surprise to you that I am going to use one called TESTTABLE. The source code for the Table is:

Wednesday, September 20, 2023

New functions added to assist with Boolean data type

The Boolean data type was introduced as part of IBM i 7.5, and does not work for lower releases.

With the last couple of Technology Releases, TRs, a number of SQL functions have been added to make using the Boolean data type easier. These are:

  • BOOLEAN:  Returns Boolean value for parameter
  • ISTRUE:  Returns "true" if the parameter is Boolean true, and if not returns "false" or null
  • ISFALSE:  Returns "true" if the parameter is Boolean false, and "false" or null if it is not
  • ISNOTTRUE:  Returns "true" if the parameter is not Boolean true, and returns "false" or null if not
  • ISNOTFALSE:  Returns "true" if the parameter is not Boolean false, and if not then "false" or null