Ted Holt
Ted Holt is the senior technical editor at The Four Hundred and editor of the former Four Hundred Guru newsletter at Guild Companies. Holt is Senior Software Developer with Profound Logic, a maker of application development tools for the IBM i platform, and contributes to the development of new and existing products with a team that includes fellow IBM i luminaries Scott Klement and Brian May. In addition to developing products, Holt supports Profound Logic with customer training and technical documentation.
-
Submit a Prompted Command to Batch
August 31, 2005 Hey, Ted
If I put a question mark before a command name in a CL program and run the program interactively, the system prompts the command, allows me to fill in the blanks, and then executes the command. Is there a way to prompt the command, then send it to batch for execution?
–Mark
Yes, there’s an API for this sort of thing. First, here’s the type of code you’re running interactively.
? SAVOBJ MONMSG MSGID(CPF6801) EXEC(RETURN)
The system prompts the Save Object (SAVOBJ) command. If the user presses Enter, the system runs the command. However, if the user presses F3 or
-
A Speedier CHGPF
August 24, 2005 Hey, Ted
As a matter of policy, and to eliminate the CHGPF quirk you wrote about recently, I recreate all associated logical files when I change a physical file. I use a certain technique to make the conversion go faster.
I first use the Move Object (MOVOBJ) command to move the logical files to a temporary library. When the new logical file is recompiled into the original library, the access path will be shared and the compile will be done in a snap. Then, I delete the old logical file from the temporary library and I’m done.
Here are two more tips
-
Avoid Changed Default Values
August 3, 2005 Hey, Ted
After we upgraded to V5R3 from V5R2, the size of the logical files on our box appeared to have increased to 56 times their original size. The physical files had not grown any more than normal after day-to-day processing. After finally finding someone at IBM that knew something, we learned that IBM had changed the default value of the ACCPTH parameter of the Save Library (SAVLIB) command. This change caused the backups to take more space on the tape, leading us to believe that the size of the logical files had grown.
Under V5R2, the default value was ACCPTH(*NO). Under
-
Of Middle-Tested Loops
July 27, 2005 Hey, Ted
I recently came across the Recursion and the Alternatives story that you wrote, which gives an example of a program that explodes a bill of material. I noticed that in this program, you used the following statement:
DOW '1'
Can you explain what this means? I have been preaching the importance of readability in programs and this baffles me. It seems like it would be better to code something like DOW NOT %EOF(MYFILE). I am actually using a modified version of your “Chase” routine, but this DOW ‘1’ statement bugs me.
–Eric
This is not the sort of thing I
-
Use SQL to Easily Update Multi-Key Files
July 27, 2005 Hey, Ted
Updating a single record in a file that has a lot of key fields often requires SQL commands with complicated WHERE clauses. I use a technique with web applications that greatly simplifies the WHERE clause. I have never seen this technique published before, so I hope you can use it.
When I retrieve a record that will be updated through a Web browser, I select the relative record number along with the data.
SELECT RRN(MyFile) as storedRRN, MyFile.* FROM MyFile WHERE ENBBTYPE = 'COPY' and ENBBTCH# = 4062
When I update, I need only refer to the relative record number.
-
CHGPF Quirk
July 13, 2005 Hey, Ted
I increased the size of a character field in the DDS of a physical file and ran the Change Physical File (CHGPF) command to apply the change. I was surprised to find that the changed field remained unchanged in one of my logical files. Can you explain why?
–Michael
Until recently, I was under the impression that CHGPF recreates all logical files, but I was wrong. CHGPF only changes the logical files that share the record format of the physical file. This is documented in the Database Programming manual. (See Record format relationships between physical and logical database files.)
-
What Program Uses That File?
July 13, 2005 Hey, Ted
We would like to delete a logical file that we no longer need. We got a list of programs that used the file from our documentation tool and changed those programs to use a newer logical. However, the Display Object Description (DSPOBJD) command tells us that the file is still being used. How can we find the program or programs that are accessing the file?
–Bobby
I suggest you journal the physical file(s) over which the logical file is built. Specify OMTJRNE(*NONE), because you need the system to record opens and closes. The following commands create a journal and start
-
Remove Misleading Messages from Job Logs,
June 29, 2005 Hey, Ted
Take TwoI agree that removing handled messages from the job log is very helpful. One optimization would be to put the API call in its own procedure, as that API has many parameters. Because we are adding a call level, we need to adjust the CallStackCtr parameter to 1 instead of 0. That is, we want to remove the message sent to the caller of our procedure.
prmvExceptionMsg b export d pi d ApiErr ds d provided 10u 0 inz(%size(ApiErr)) d available 10u 0 inz d MsgInfo s 8a /free QMHRCVPM(MsgInfo: %size(MsgInfo): 'RCVM0100': '*': 1: '*EXCP' : *blanks :
-
Case-Insensitive Sorting and Record Selection with Query/400
June 22, 2005 Hey, Ted
Thanks for explaining how to ignore case when sorting and selecting records with SQL. Can you tell me how to do the same with Query/400?
–Ron
Sure. First, here’s a database file that we can query.
LASTNAME FIRSTNAME smith billy Smith Amos SMITH CHARLEY smith DICK Smith ELMO SMITH dan JONES Andy
The normal sort places lowercase letters before uppercase ones, like this:
LASTNAME FIRSTNAME smith billy smith DICK JONES Andy Smith Amos Smith ELMO SMITH dan SMITH CHARLEY
From the Define the Query panel, place a 1 (one) beside the Select collating sequence option and press Enter. If your
-
Fetch a Variable Number of Records with SQL
June 15, 2005 Hey, Ted
If you want to use a variable for the number of rows to fetch in an SQL query, there is an alternative to the FETCH FIRST n ROWS technique you presented recently in Four Hundred Guru. Here is some code from an SQLRPGLE program shell I have used since V5R1. It uses a cursor instead of placing the number of rows directly into the SELECT statement.
c/Exec SQL c+ Fetch from C1 for :NbrRows rows into :RtnDtaSet c/End-Exec
–Rick
Rick’s comment is in response to the last paragraph of the issue he refers to. His idea is to use