The CHGOBJOWN command has long been a sore spot for me. CHGOBJOWN has always lacked generic support--the ability to perform its function over multiple objects with one execution of the command. This capability has been needed since 1981 when IBM first shipped CPF, the predecessor to OS/400. Back in the days of Q38 Technical Journal, I wrote a generic version of this command, called CHGOWN, that was very popular and is still widely used today.
Let's look at the CHGOBJOWN command's four parameters:
- OBJ--A parameter that allows you to specify a qualified object name
- OBJTYPE--The type of object whose owner is to be changed
- NEWOWN--The user profile of the new object owner
- CUROWNAUT--A parameter that controls whether or not to revoke the existing object owner's authority
Most of us have used this command at one time or another, and many of us use it extensively. So why is it that, in the year 2003, the CHGOBJOWN command does not support a generic name on the OBJ parameter? This really frustrates me.
Look at the prompted CHGOBJOWN command listed in Figure 1. It illustrates effectively the same command that was shipped back in the early 1980s with System/38 CPF. The only thing that has changed is the CUROWNAUT parameter.
Early last year, I started to dig through my old issues of Q38, looking for my generic version of CHGOBJOWN. I discovered the library I stored these things in (it was called Q38LIB). I tried restoring it to an old AS/400 with OS/400 V3R7 running on it. This worked OK, considering Q38LIB had last been saved back in 1992. So I was relieved.
I then typed in my CHGOWN command and pressed F4. I was expecting to see the old prompt from the System/38 version of the command that I had written. But what I saw surprised me. What I saw was an actual OS/400 CL command named CHGOWN.
Figure 1: The CHGOBJOWN prompt (Click images to enlarge.)
When IBM added the new file systems to OS/400, such as the IFS, they created a set of commands that would work with those file systems. After all, they are nothing more than objects to the OS/400 system, so why not have object-based commands that do things to them?
Of course, a file stored on the IFS is stored in a directory structure. So the traditional OS/400 qualified object name of library/object would not fit that structure. So IBM created a series of CL commands that work pretty much like the traditional commands, except that they accept IFS directories and object names. In addition, they all accept those IFS object names generically.
As I looked at the CL command prompt listed in Figure 2, I thought, "Darn! Now, I'll have to come up with another name for the generic version of CHGOBJOWN." But after closer inspection, I noticed the first parameter of the command is OBJ (object). I thought this was interesting, so I tried typing in a QSYS file naming system object name, but using the IFS syntax. This was allowed for IFS file access from HLL programs, so why not through this command?
Figure 2: The generic CHGOWN prompt
So I typed the following into the OBJ parameter of the prompted command:
The QSYS file system may be represented on the machine as library/object or as /QSYS.LIB/LIBRARY.LIB/OBJECT.TYPE.
Of course, CL commands need to be aware of this alternate syntax, so rather than change every CL command on the system, IBM created several new CL commands to handle the IFS naming convention of the QSYS object system.
The CHGOWN command listed in Figure 2 illustrates one of these commands. The CHGOWN command has four parameters:
- OBJ-- A parameter that allows you to specify an object name in the IFS syntax
- NEWOWN--The user profile of the new object owner
- RVKOLDAUT--Revoke the old owner's authority (compare this parameter to the CUROWNAUT parameter of the CHGOBJOWN command)
- SYMLNK--When an IFS directory contains a symbolic link to an object, this parameter controls whether the command affects the symbolic link or the object to which the link refers.
The cool thing about CHGOWN is that the OBJ parameter supports generic IFS and QSYS object names. For example, to change the ownership of every object in the MYSTUFF library to QDFTOWN, the following command can be used:
Every object in the MYSTUFF library will have its owner changed to QDFTOWN. If CHGOBJOWN supported generic names, the equivalent version of that command would be as follows:
The IFS naming convention allows you to specify the object type generically, just like you would with the OBJTYPE parameter of a traditional CL command. Simply specify the object type following the asterisk, as follows:
The command listed above will change the owner of all the program objects in the MYSTUFF library, whereas the following command will change the owner of all the files in the MYSTUFF library whose names begin with INV.
I don't know how many commands like this IBM added to OS/400 over the years to work with files on the IFS and to allow them to cross over into the OS/400 object system. I ran a DSPOBJD to an outfile and then counted all the CL commands that had six or fewer characters in their name. Of course, this includes things like CPYF, DCL, CMD, GOTO, and several other CL commands. The total was over 400, so if only 25% of them work with both the IFS and the QSYS system, the generic versions of CL commands that you need may already be there.
Bob Cozzi has been programming in RPG since 1978. Since then, he has written many articles and several books, including The Modern RPG IV Language--the most widely used RPG reference manual in the world. Bob is also a very popular speaker at industry events such as COMMON and RPG World and is the author of his own Web site, www.rpgiv.com, and of the RPG ToolKit, an add-on library for RPG IV programmers.