AS/400 Utilities


Here are some AS/400 utilities that you may find useful. We do assume that anyone interested in these commands has a certain amount of technical knowledge about the AS/400 and will be able to figure out most of the stuff here. Please feel free to contact Herb if you have any questions or comments.


Simple Command/CL program utilities

The source code for these utilities is stored as TEXT files and you can either download the source and use CPYFRMPCD to copy them into a source file or just CUT/PASTE the source right into a source member. Each component is stored as a text file (.txt extension) with the following naming convention:

Zxxxxxxxxx_ttt.txt
  • All of our commands start with Z.
  • xxxxxxxxx represents the command/program name.
  • ttt is the source type (cmd/clp).

This first block of utilities consists of a command and an associated CL command processing program (except for ZBRKMSGPGM, which is only a CL program). We will be adding further instructions to some of these commands but, for now, be aware that any of the RTV (retrieve) commands should include the ALLOW(*IPGM *BPGM) keyword on the CRTCMD.

ZBRKMSGPGM (Break message processing program)
Causes all break messages received by a work station to display in a message subfile at the bottom of the display without interrupting the current interactive job. zbrkmsgpgm_clp.txt (2622 bytes)

ZCHGUSRSPC (Change user space)
Allows the user to update the contents of a specific user space. The command allows specification of data to be placed in the user space and the starting position and length of the data. zchgusrspc_cmd.txt (1563 bytes)

zchgusrspc_clp.txt (3041 bytes)

ZCHKSBSACT (Check if subsystem is active)
This command can be used within any program to determine whether or not a particular subsystem is active. zchksbsact_cmd.txt (1030 bytes)

zchksbsact_clp.txt (2979 bytes)

ZCLRDTAQ (Clear data queue)
Clears contents of the specified data queue. Entries are removed from the queue but no resizing of the data queue is performed. zclrdtaq_cmd.txt (1043 bytes)

zclrdtaq_clp.txt (2741 bytes)

ZCRTUSRSPC (Create user space)
Create user space zcrtusrspc_cmd.txt (1508 bytes)

zcrtusrspc_clp.txt (3203 bytes)

ZRTVCURPGM (Retrieve current program name)
Retrieve current program name zrtvcurpgm_cmd.txt (1188 bytes)

zrtvcurpgm_clp.txt (2797 bytes)

ZRTVJOBSTS (Retrieve job status)
Retrieve job status zrtvjobsts_cmd.txt (2386 bytes)

zrtvjobsts_clp.txt (5922 bytes)

ZRTVPRVPGM (Retrieve previous program name)
Retrieve previous program name zrtvprvpgm_cmd.txt (1262 bytes)

zrtvprvpgm_clp.txt (2876 bytes)

ZRTVUSRSPC (Retrieve user space)
Retrieve user space zrtvusrspc_cmd.txt (1568 bytes)

zrtvusrspc_clp.txt (2846 bytes)

C program objects and source code

This next block of utilities is a little more complex. I do most of my AS/400 coding in C (because I don't have an RPG compiler and I'm NOT doing them in COBOL!) and these ones do have an associated C program. I realize that most AS/400 shops don't have a C compiler so I have also included a file that contains the compiled C program.

The programs are compiled under V3R1M0 and were then saved to a save file. I used my variation of CPYFRMSAVF (from QUSRTOOLS) to convert the save file to a physical file and then used CPYTOPCD to copy the physical file to shared folders. You will need to reverse the process in order to use the programs. Please see ZCPYSAVF (Copy from/to save file) for a better description of the process or to download code to build the utility.

ZADDREC (Add records to a file)
Add records to a file zaddrec_cmd.txt zaddrec_clp.txt zaddrec_c.txt addrec_exe.310

No Source

This next block of utilities has no source code because I wrote them in C a long time ago and don't have access to the source. Each command will consist of either 1 or 2 ZIP files that you can download. The first ZIP file (in the "ZIP File" column) will be created with the ZCPYSAVF (Copy from/to save file) utility and you will need to reverse the process in order to install the components on your system. The second ZIP file (in the "FTP File" column) contains a binary copy of the save file that was FTP'd onto a PC. If you have FTP installed and running on your AS/400 this may be a more desirable option for you. I will add more detailed instructions later but for now just create a save file on the AS/400 and FTP the unzipped version of this file right into it and use RSTLIB to restore the objects. If you want more details feel free to email Herb either at home or work.

ZEXECSQL (Execute SQL statement)
Execute SQL commands interactively or embed them in programs ZSQL.ZIP (46918 bytes)
ZWRKDTAQ (Work With Data Queues)
Work With Data Queues ZWRKDTAQ.ZIP (117765 bytes)
ZWRKDTAQ_FTP.ZIP (58885 bytes)