Wednesday, February 3, 2016

Journal information using SQL

joblog_info sql view

It is Monday morning and I receive an email from my superior asking about the journals on the production IBM i. How can there be so many? How many are active? How much space do they take up? How many are remote journals? I need a quick and easy way to get to information about the journals. There is a Retrieve Journal Information API I could use. Fortunately there is a SQL View, added in IBM i 7.2, that does the basically the same thing as the API, but it is a heck of a lot easier to get the information from.

Those of you who are regular readers of this blog will not be surprised to learn that the JOURNAL_INFO View is located in the library QSYS2. It contains a lot more information that I have been asked to provide. Rather than list all of the columns I am going to refer you to the relevant page in the IBM's KnowledgeCenter here.

Wednesday, January 27, 2016

Read an IFS file using RPG

read ifs rpg

I had a situation where I had a text file in an IFS folder and I needed to read its contents. I could have copied the file from the IFS into an IBM i library and then read it there, but I decided to investigate how I could read the file directly from the IFS using RPG. Fortunately there are three APIs which will allow me to do this.

First I need to give credit to a friend of mine, who wishes to remain anonymous, for providing a program that my example is based upon.

I created a text file using Windows' Notepad. At the end of each line I pressed Enter to create variable length records, see below, and copied the file to my folder in the IFS.

Monday, January 25, 2016

More proof IBM i 7.3 is coming

IBM i 7.3 7.2 TR4

On December 17 I found a reference to IBM i release 7.3 on an IBM website, you can see it here. This weekend I found further proof that a new release is coming.

In the IBM developerWorks website there are now sections for IBM i 7.3 and 7.2 TR4 enhancements, which were created on January 13.

Wednesday, January 20, 2016

Using SQL for object's statistics

object statistics dspobjd

I have mentioned in a previous post how you could find out pretty much anything you wanted to know about a file or SQL table by using the SQL View SYSTABLES. But what about other object types?

I have found the OBJECT_STATISTICS table function useful for most of the information I want to know about objects in a library. Table functions return columns in way that resembles getting columns from a View or Table.

OBJECT_STATISTICS has three parameters:

Wednesday, January 13, 2016

Retrieving the program's name in a CL program

sndpgmmsg rcvmsg

I have always had a standard that whatever output I produce from the IBM i I always put the program's name on it. This is very useful when a user brings me a screen print or report I can quickly go to the program they have a question about. Many years ago I found that some of my colleagues would copy my display and printer file code without bothering to change the name of the program "hard coded" on the file. To overcome this I code the program name as a field in the file, and I always retrieve the name of the program from within the program itself. In RPG the program name is a subfield in the Program Data Structure so it can be easily retrieved, for an example see the post Externally described Data Structures.

Wednesday, January 6, 2016

Finding record locks using SQL

sql record lock info

One of the new SQL Views introduced as part of IBM i 7.2 TR3 and 7.1 TR11 was one that allows us to check for record locks. Now I can execute a SQL query and return all of the jobs locking the file I inquired about. No longer do I need to use APIs or the CL command Display Member Record Locks, DSPRCDLCK.

The new View, RECORD_LOCK_INFO, is found in the library QSYS2. It returns one row of every lock in your IBM i. This is why I should be careful how I use this View. I am sure there are many thousands of record locks in any medium to large size applications at any one time, most of them are harmless as the record or row is locked, updated and released. Every once in a while something goes "bump" and a tries to lock a record/row that is already locked by another. An error message occurs and I have to work out what the lock is and how to release it, in a timely manner, before I get more record locks to the same record/row.

Friday, January 1, 2016

Happy New Year

At the start of a new year I am always filled with a feeling of excitement for what the new year will bring us, and a feeling of gratitude for all the good stuff that happened last year.

Last year's most popular posts covered a good variety of subjects:

  1. Change date from one format to another using SQL
  2. Char built in function added to CL
  3. IBM i 7.1 TR10 and 7.2 TR2 announced at Common
  4. Trim in CL and its Second Parameter
  5. Getting the number of rows affected by SQL statement

We also have the following IBM i anniversaries to look forward to in 2016:

Wednesday, December 30, 2015

Searching for strings in source files, using RPG

fully free rpg

In my previous post, Searching for strings in source files, I included a sample program written in CL. The day it was published I received a message asking me: "Could that all be written in RPGLE instead of CL?"

The answer is: of course it can be. I thought this would be a good excuse to show how I could write a RPGLE program to do this, which would include subjects I have written about before. The RPGLE program will function in the same way the CL one does. The program is passed three parameters:

Wednesday, December 23, 2015

Searching for strings in source files

find string pdm fndstrpdm

I was recently asked how it is possible to search all the source members in QCLSRC to find which program called a particular Cobol program. I am sure most of you reading this will immediately shout "Find string PDM!", and you are right.

I thought that this would be a good excuse to explain the Find String PDM command, FNDSTRPDM, to those who are not familiar with it. And I will then give an example CL program to show of how I could search one or all of the source files in a library, which is really a reminder of things I have written about before: SQL, do loop, subroutine, changing name of spool files.

Thursday, December 17, 2015

Is IBM i 7.3 already out?

I was looking for the latest PTFs for IBM i 7.2 TR3 when I found SE6395 for the RPG compiler. What caught my attention was not the fact that this was an APAR for fully free RPG, it was the releases, see below.


Click on image to see larger version

Does this mean that there are already PowerSystems servers running IBM i release 7.3 out there? Perhaps there are a few out there in the user community testing a new release. It begs the question: could this mean that a new release is imminent? We will just have to wait and see what 2016 brings.

You can see the page for this APAR on the IBM web site here.