Using CLCRTPG to Create an MI Program
Assume that the source is in a member named MI01 in the source file MISRC,
which is created with a default record length (RCDLEN) of 92. The following
CLCRTPG CL program can be used to create an MI program called MI01. (An MI
program to call the Create Program (QPRCRTPG) API is developed in “Creating an
MI Version of CLCRTPG” on page 7-11.)
Note: All non-MI source examples are provided in CL, because CL is the one lan-
guage (other than REXX) that is standard on all AS/400 systems. Other
high-level languages (HLLs) could be used in place of the CL programs
(and in many cases would have been easier).
The following program reads a source file member into a program variable
(&MIPGMSRC) and then does a CALL to the QPRCRTPG API. This program has
many limitations (the major limitation is a program variable-size limit of 2000 bytes
for the source), but provides for a reasonably simple MI program creation scenario:
/ᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ/
/ᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ/
/ᑍ ᑍ/
/ᑍ Program Name: CLCRTPG ᑍ/
/ᑍ ᑍ/
/ᑍ Programming Language: CL ᑍ/
/ᑍ ᑍ/
/ᑍ Description: Create an MI program using the QPRCRTPG API. ᑍ/
/ᑍ ᑍ/
/ᑍ ᑍ/
/ᑍ Header Files Included: None ᑍ/
/ᑍ ᑍ/
/ᑍ ᑍ/
/ᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ/
PGM PARM(&SRCMBR)
DCLF FILE(MISRC)
DCL VAR(&SRCMBR) TYPE(ᑍCHAR) LEN(1)
DCL VAR(&MIPGMSRC) TYPE(ᑍCHAR) LEN(2)
DCL VAR(&MIPGMSRCSZ) TYPE(ᑍCHAR) LEN(4)
DCL VAR(&OFFSET) TYPE(ᑍDEC) LEN(5 ) VALUE(1)
DCL VAR(&PGMNAM) TYPE(ᑍCHAR) LEN(2) +
VALUE(' ᑍCURLIB ')
DCL VAR(&PGMTXT) TYPE(ᑍCHAR) LEN(5) +
VALUE('Compare two packed arguments and +
return larger')
DCL VAR(&PGMSRCF) TYPE(ᑍCHAR) LEN(2) +
VALUE('ᑍNONE')
DCL VAR(&PGMSRCM) TYPE(ᑍCHAR) LEN(1) VALUE(' ')
DCL VAR(&PGMSRCCHG) TYPE(ᑍCHAR) LEN(13) VALUE(' ')
DCL VAR(&PRTFNAM) TYPE(ᑍCHAR) LEN(2) +
VALUE('QSYSPRT ᑍLIBL ')
DCL VAR(&PRTSTRPAG) TYPE(ᑍCHAR) LEN(4) +
VALUE(X'1')
DCL VAR(&PGMPUBAUT) TYPE(ᑍCHAR) LEN(1) +
VALUE('ᑍALL ')
DCL VAR(&PGMOPTS) TYPE(ᑍCHAR) LEN(22) +
VALUE('ᑍLIST ᑍREPLACE ')
DCL VAR(&NUMOPTS) TYPE(ᑍCHAR) LEN(4) +
VALUE(X'2')
LOOP: RCVF
Chapter 7. Machine Interface Programming 7-5