Wednesday, May 28, 2025

Increment a number held in a character field

The title is simplistic for what this post is really about. The question that was asked was:

I have a character field in a DDS physical file that is 20 characters long. There can be various numbers in that field of any length. I want to retrieve the value from the field, increment it by one, and update the field in the file.

If all the "numbers" in the field in the file were 20 characters long it would be easy, but as the "numbers" can be of different lengths it makes the problem more interesting.

First I need a file for this 20 character field. I decided to call it TESTFILE and the DDS code for it is:

01 A                                      UNIQUE
02 A          R TESTFILER
03 A            KEY            5A
04 A            FIELD1        20A
05 A          K KEY

Wednesday, May 21, 2025

SQL scalar function to break apart IFS path name

As part of the new new release, IBM i 7.6, and the latest Technology Refresh for IBM i 7.5, TR6, I can break apart an IFS path name into its parts:

  • File extension
  • File name
  • File prefix (file name without the file extension)
  • Path prefix (path without the file name)

This new SQL scalar function is called IFS_PATH, and it is found in the library SYSTOOLS.

Before I start with my examples I need to check if there are objects in the IFS I can use. This is a simple task using IFS_OBJECT_STATISTICS:

Wednesday, May 14, 2025

Selecting updated and deleted values when using SQL

Have you ever wanted to confirm that a SQL Update or Delete statement ran the way you expected?

In the new release, IBM i 7.6, I can do this using what IBM describes as:

  1. Selecting updated values
  2. Selecting deleted values

This was not added to the latest Technology Refresh for IBM i 7.5, TR6.

Tuesday, May 13, 2025

SELF default changes

While playing with the new release, IBM i 7.6, I noticed that the default for the SELF, SQL Error Logging Facility, SELFCODES global variable has changed.

When it first came out, IBM i 7.5 TR1 and 7.4 TR7, the default for the SELFCODES was null.

With IBM i 7.6 and 7.5 TR6 the default is '*NONE'.

Why the difference?

Both null and '*NONE' are acceptable as the default. The difference is that '*NONE' will stop SELF monitoring immediately. Null does not, only when new SQL 'jobs' start.

 CREATE OR REPLACE VARIABLE SYSIBMADM.SELFCODES VARCHAR(256) DEFAULT '*NONE' ;

This is another good enhancement to SELF.

Wednesday, May 7, 2025

Where on the subfile is the cursor

I was asked how is it possible to determine where the cursor is on a subfile when the F4 key is pressed.

I have written about the parts needed to achieve this in separate posts, and I thought it would be a good idea to put it all together into one new post.

What I would need is:

  1. A subfile program
  2. Determine when the F4 is pressed
  3. Retrieve the record format name
  4. Retrieve subfile relative record number, RRN, of the record the cursor is on
  5. Retrieve the name of the field the cursor is on in the subfile

First off, I need a subfile display file, a simple one. The code for a minimalist subfile could be:

Monday, May 5, 2025

IBM Performance documents updated for Spring 2025

Steve Will, IBM i Chief Technology Officer and Chief Architect, announced this week that new versions of the following documents had been updated by the IBM performance experts:

  • IBM i on Power - Performance FAQ – see here
  • IBM Power10 performance optimization for IBM i – see here

IMHO I think they both are worth checking out.