Problem solve Get help with specific problems with your technologies, process and projects.

The Lazy Coder: Fun with objects

Objects: You can organize them, work with them, display information about them and delete them. Andrew Borts shows you how easy it can be.

Wow! We're having some fun with these systems. They are truly objects of my appreciation! Now, since my wife tells me I shouldn't refer to anything as merely an "object," maybe we can clarify this.

Everything within OS/400 is an OBJECT of some sort, and depending on that object's TYPE, OS/400 performs different functions with that object. For instance, the program you run to print out your accounting report is an object -- of type program or *PGM. The data printed on the report is another object type, known as a *FILE. So, how do I organize these objects? That's easy. OS/400 groups those objects using an object known as a *LIBrary. (Note: *LIB is uppercase -- I'm getting you used to the way the type is formatted.)

Now I've got objects grouped within objects known as libraries. Wait a second -- when I write programs, the sources are grouped, too! Sure -- they are grouped within a special type of object known as a source physical file. That is STILL A FILE, just a specific type of file. This file has many MEMBERS within it. So, let's review: My files can have groupings as well. OS/400 isn't tricky; it's just CLEVER.

More Information

Now let's manage those objects.

"Hey," you say, "I lost an object!" What can you do? First, do you remember its name? OK, how about the first part of its name? (Hey, I work with really forgetful programmers sometimes.) WRKOBJ is an AMAZING command. The command structure of OS/400 is broken into verbs (or actions) and what you want to do. Each command, when you break it into its three-letter counterparts, becomes easy to remember or find because frankly these three-letter combinations (and sometimes four-letter) are the SAME for almost all the commands. Here are the verbs:

  • WRK -- I want to WORK with something
  • DSP -- I want to DISPLAY something
  • DLT -- I'm DELETING something

And the list goes on.

We know what we want to do -- work with something -- but what? Objects, which is shortened to OBJ. So WRKOBJ is our command of choice. Hey, wanna see ALL the WRK commands to see what ELSE you can work with? Type WRK* and hit enter on the command line. Groovy, but we still have our missing object.

The Work Object screen lets you look for the object with a wild card, or "*" (asterisk). (I hear some of you giggling.) So to find a lost object within your library list, simply type WRKOBJ STUF* and the system looks for the objects within your library list that start with STUF*.

OK, I've found my object. What else can I do? Well, let's display its description. That's a variation on a theme. So you want DSP (display something), OBJ (my Object), and now IBM adds a little more detail. They want you to retrieve the description, so a D gets added: DSPOBJD (display the object description). This command has interactive origins, so you can display this info using OUTPUT(*), print this info OUTPUT(*PRINT) or send the information to a file, so you can perform functions on it or OUTPUT(*OUTFILE).

Now when your boss says, "Hey! How large are all the files? We need to analyze this to see if we need more disk." You calmly tell him (or her) that it'll be six or seven hours. They say GREAT, then you go to your desk, perform the command DSPOBJD OUTPUT(*OUTFILE), tell it the file you'd like to capture this information in, and use Query to print out a summery that all files are taking up xxx space in bytes. You can examine the file summarizing for field ODOBSZ and total that little bunny up. Next, go to the coffee station, mix yourself up a cup of joe, catch up with your cube mate, surf the Web for another 10 minutes or so (so you don't return to your boss's office too quickly), print out your results (bolding titles for effect) and walk into your bosses office 20 minutes later with the results. Cool.

Next month look for an article about more advanced functions using OBJECTS. Until then, this is the Lazy Coder signing off. Remember -- don't work so hard!

About the author: Andrew Borts is webmaster at United Auto Insurance Group in North Miami, Fla. He is often a frequent speaker at COMMON and is past president of The Southern National Users Group, an iSeries-AS/400 user group based in Deerfield Beach, Fla.

Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.