Pages

Wednesday, June 28, 2023

Changes to the RPG Select operation code

In my RPG work I have been using the IF-ELSEIF operations code instead of Select groups for longer than I have been writing this web site. I preferred them as I could do the same as a Select operation code in less lines of code.

But then comes along two new RPG operation codes in the latest Technology Refreshes, IBM i 7.5 TR2 and 7.4 TR8, that are related to the Select operation code that might change my mind.

The two new RPG operation codes are:

  • WHEN-IS:  Used to compare the given value is equal to a value or variable
  • WHEN-IN:  Used to compare the given value is in a list or values, array, or in a range

Tuesday, June 27, 2023

Copying multiple IFS files into one output file

This us another post that came from a question I was asked by a reader of this blog. The question is:

I have multiple files in an IFS folder with similar names, each has a timestamp at the end of the file name to make them unique. How can I read all the files and write the contents into one file?

Fortunately there are two SQL Table Functions that can help me do this:

  • IFS_OBJECT_STATISTICS:  To make a list of the files
  • IFS_READ:  Read the contents of the files

The rest is pretty straightforward SQL and RPG.

Wednesday, June 21, 2023

35th anniversary of IBM i

There has been lots of publicity in the build up to today, and I thought I would add my thoughts on the 35th anniversary of IBM i. That is a little misnomer as the server that was launched on June 21, 1988, was called AS/400, IBM Application System/400, which ran the OS/400, Operating System/400, operating system. Over the intervening years both the server and the operating system have been enhanced to be so much more than AS/400 / OS/400, becoming a thoroughly modern server, IBM Power, and operating system, IBM i.

As this is an anniversary I am not going to talk about the future of IBM Power and IBM i, which is "golden", I am going to write about the history of this.

Tuesday, June 20, 2023

Getting Save File information with SQL

Added to our SQL "toolkit" with the latest round of Technology Refreshes, IBM i 7.5 TR2 and 7.4 TR8, were two Views and a Table function that helps me get information about Save Files, and their contents.

Prior to these if I wanted to know how many save files I have in my library I would use the Work Object PDM command, WRKOBJPDM:

WRKOBJPDM LIB(MYLIB) OBJTYPE(*FILE) OBJATR(*SAVF)

Wednesday, June 14, 2023

RPG %SPLIT now handles blank sub-strings

When it was introduced in IBM i 7.4 I thought the Split built in function, BiF, would be useful way to break apart a string into pieces. The one frustration I had with it was when two separators were next to one another %SPLIT would not regard it as an empty, or null, sub-string.

Let me jump straight into my RPG program to demonstrate how this works. Let me start with all the definitions, etc.

01  **free
02  dcl-s String varchar(100) inz('RED,,BLUE,,GREEN,,,BLACK') ;
03  dcl-s Piece char(10) ;
04  dcl-s Array char(10) dim(*auto:999) ;

Monday, June 12, 2023

It has been a decade!

Saturday was the tenth year anniversary of this web site. IMHO that is a remarkable milestone. I have seen other IBM i related web sites and YouTube channels come and go in that time, as people do not appreciate the effort it takes to research, write, and publish content on a regular basis. I am not sure how long I thought I would write, I guess it was until there was nothing more about IBM i to write about. Fortunately IBM has obliged and this decade has seen more additions and changes to our favorite operating system than any other. Long may it continue.

Wednesday, June 7, 2023

Mass insert into IFS file using IFS_WRITE

There are times when someone asks me a question I think is interesting enough to become a post here. This was the question that was the germ for this post:

How can I read a physical file and for each records, use the IFS_WRITE Function to write the [ IFS ] file?

The IFS_WRITE are really three SQL procedures that writes data to a file in the IFS:

  1. IFS_WRITE:  Write plain text to IFS file
  2. IFS_WRITE_UTF8:  Write UTF8 text
  3. IFS_WRITE_BINARY:  Write binary text

In the following examples I am going to use IFS_WRITE_UTF8 as I want the contents of the IFS file to be UTF8 compatible.