HOW WRITE AND RUN
A REXX PROGRAM
REXX is defined for the AS/400, isn't it? Can anyone point to a good reference for a non-AS/400 programmer who needs to acclimate to a new environment?
FRANK CLARKE: subject AS/400 in comp.lang.rexx 1999/02/05
In this chapter I will demonstrate how write and run small, simple, maybe useful program. But first you have to create the source database file for texts of programs.
Have a look at the following program DSPLIBF written in the Rexx language for the AS/400 environment. It directs the output from the DSPLIB command into the INFO file in the library MYLIB. The DSPLIB (Display Library) command displays the contents of one or more specified libraries and has syntax:
The parameter OUTPUT specifies whether the output from the command is shown at the requesting work station (*) or printed with the job's spooled output (*PRINT); * is the default.
The DSPLIBF program shows how CL commands are issued from a Rexx program. Commands are expressions which are passed to the current command environment. In this article comands (and later SQL statements) in programs are blue coloured. By default, Rexx submits commands to the CL command environment for processing. Words as DSPLIB and CHKOBJ are CL commands. The CHKOBJ (Check Object) command checks object existence; the CRTPF (Create Physical File) command creates a physical file or a table in SQL terminology with the length of rows 132 chars; the CPYSPLF (Copy Spooled File) command copies the specified spooled file, i.e. the last spooled file created by the DSPLIB command with the parameter OUTPUT(*PRINT) in the file INFO.
How do you write and run the DSPLIBF program? If you do not have a source file for texts of programs and library, type the Create Library (CRTLIB) command on an AS/400 command line and press Enter to create a library for your source file. For example:
Note: Ask the system administrator for a name of your library. In this article I will use the name MYLIB.
Type the Create Source Physical File (CRTSRCPF) command to create a source file for Rexx programs
Now you can create your first program. The WRKMBRPDM FILE(MYLIB/QREXSRC) command shows:
Press F6, i.e. Create.
The following entry display requests you to enter a name of a program (DSPLIBF) and its source type (REXX). You can attach a comment (Output from DSPLIB into the INFO file), too. Then use the Enter key to submit information.
Rewrite the text of the program DSPLIBF. Press the F3 key to end the editing.
Press the Enter key to confirm the saving of the source text on the Exit display. On the following Work with Members Using PDM display type a 16 in the option field, i.e. Run, and press the F4 key.
Type a name of a library to the parameters field. Press the Enter key for run of the program. Of course, the DSPLIBF program you can run immediately, hence press in previous step instead F4 the Enter key. The program will ask for a name of a library oneself.
Note: you can start the DSPLIBF program when you enter the STRREXSRC (Start REXX Procedure) command as well as:
STRREXPRC SRCMBR(DSPLIBF) SRCFILE(MYLIB/QREXSRC) PARM(MYLIB)
The following display shows information about the run of the program
The DSPPFM (Display Physical File Member) command shows the result on the screen
DSPPFM FILE(MYLIB/INFO)And there is a fragment of the screen:
since 1st January 2000, last changed 13th April 2018