The data in the database had changed. I could see that.
But which part of the program had changed it?
I was investigating a program written in RPG, a programming language used on AS/400 and IBM i. What I wanted was a location marker that I could include in a record of its processing.
That record is called a log. Along with how the data changed, knowing which instruction was being executed would help narrow down where to look.
So I decided to pass a statement number—a number identifying a location in the source—to a separate program that recorded the log.
But explicitly setting the number at each calling location felt a little clunky. Could I obtain the current location automatically, in a neater way?
I discussed it with Kimiko-chan, the name I gave ChatGPT.
One candidate was the PSDS, a collection of information about a program’s status. It includes a field for a line number or statement number.
If that could tell me the current location, it might save me from supplying the numbers individually.
But when I wrote a test program and tried it, what came back was eight zeros.
00000000
That was not the place I was looking for. (Laughs.)
Was I missing a setting? Perhaps an option used when compiling—converting the program into an executable form—or a setting written in the source? I asked again, this time with my test result.
The discussion then focused on a distinction: information about where an error occurred, versus information about where a program is executing during its ordinary processing.
Having a field for a number does not, by itself, mean it contains the current location at the moment I need it.
At least with the approach I had tested, I had not obtained the number I wanted.
So I decided to proceed with the explicit approach: set the number at the logging point and pass it to the program that recorded the log.
Of course, supplying the number myself means paying attention to whether it still matches the location when the source changes. The maintenance work does not disappear.
But what I needed was a clue that would let me trace the processing later. The hope that a number might be available automatically was no substitute for that.
I consulted Kimiko-chan, ran the test myself, and chose a direction based on the value that came back. This time, that exchange led me to choose the slightly clunky option.
If even the location marker in my log gets lost, the person investigating it—me—will get lost too. (Laughs.)
Technical note: IBM’s ILE RPG documentation describes the PSDS as a mechanism for obtaining program exception/error information and defines positions 21–28 as a field for a line number or statement number. This article does not present that field as a guaranteed way to retrieve the current position during ordinary execution. Reference: IBM — Program Status Data Structure.