COMPILE — How to Compile on IBM i (Build Reference)

SteelFrame X operation manual  ·  ← back to Operation Manuals  ·  Sign On

This is the build reference for the SteelFrame X IBM i–compatible environment: for every AS/400 program and object type, the compile command, what it produces, and a minimal example — then the common combinations you meet in a real application (screen + program + database, batch reporting, service-program binding). It is written for two readers at once: the IBM i operator who just needs the verb, and the mainframe (z/OS) developer who knows COBOL/CICS/DB2/VSAM and wants the AS/400 equivalent — section A gives that mapping, and each combination in section C is labelled with the mainframe stack it replaces. All commands are entered on the command line after sign-on (or from CL); every recipe below uses verbs this environment actually supports.

Contents

A. For the Mainframe Reader: z/OS → IBM i Map ↑ top

If you come from z/OS, almost every technology you know has an IBM i equivalent — usually integrated into the operating system rather than sold as a separate product. This table is the spine of the whole manual; every row is expanded in sections B and C.

z/OS technologyIBM i equivalentCompile / create with
COBOL (batch & online)ILE COBOLCRTBNDCBL (or CRTCBLMOD+CRTPGM)
— (no direct z/OS peer)ILE RPG (RPGLE)CRTBNDRPG — the dominant business language on IBM i, the role COBOL plays on the mainframe
JCL (job control)CL — Control LanguageCRTBNDCL / CRTCLPGM; submit with SBMJOB
CICS + BMS mapsets5250 display files (DSPF)CRTDSPF — there is no CICS on IBM i; the interactive subsystem + DSPF are the transaction monitor and screen layer
VSAM (KSDS/ESDS)Keyed physical/logical filesCRTPF / CRTLF — there is no VSAM; native DB2-for-i files ARE the keyed data, accessed record-level from RPG/COBOL
DB2 (separate subsystem)DB2 for i (integrated)RUNSQLSTM for DDL; CRTSQLRPGI for embedded SQL — no BIND step, no plan/package management
Easytrieve / SAS (report & extract)RPG report pgm or SQLCRTSQLRPGI / RUNSQLSTM (see C.4)
IDMS + ADS/OnlineDB2 for i + RPG/COBOL + DSPFno network database on IBM i — relational replaces it (see C.5)
Natural + ADABASRPG/COBOL + DB2 for ino inverted-list DB / 4GL — 3GL + relational replaces it (see C.6)
HLASM (assembler)ILE modules / service programsCRTSRVPGM — assembler is not idiomatic on IBM i; the MI layer is below the covers and low-level work is done as bound ILE modules (see C.7)
The one-paragraph version: on IBM i the database, the transaction monitor, the security and the job system are all part of the operating system. So where a mainframe build has compile + link-edit + BIND + CICS table entries + JCL, an IBM i build is usually just: create the DDS files, compile the program, write a small CL to drive it. Everything lands in a library (the equivalent of a dataset-prefix/PDS world — e.g. MYLIB), and source lives as members in source physical files (QRPGLESRC, QCBLLESRC, QCLSRC, QDDSSRC) — the analogue of PDS members.

B. Single Object Types — Compile Each ↑ top

Convention used below: library MYLIB, source files per language (QRPGLESRC, QCBLLESRC, QCLSRC, QDDSSRC, QSQLSRC, QCMDSRC), member name = object name. Create a source file first if you need one: CRTSRCPF FILE(MYLIB/QRPGLESRC) RCDLEN(112).

B.1 ILE RPG (RPGLE) — CRTBNDRPG

The flagship language of the platform. One-step compile, source member → *PGM directly:

CRTBNDRPG PGM(MYLIB/CUSTRPT) SRCFILE(MYLIB/QRPGLESRC) SRCMBR(CUSTRPT)

Produces object CUSTRPT type *PGM in MYLIB; run it with CALL PGM(MYLIB/CUSTRPT). For multi-module programs use the two-step path (module then bind — the IBM i analogue of compile + link-edit):

CRTRPGMOD MODULE(MYLIB/CALCMOD) SRCFILE(MYLIB/QRPGLESRC) SRCMBR(CALCMOD)
CRTRPGMOD MODULE(MYLIB/MAINMOD) SRCFILE(MYLIB/QRPGLESRC) SRCMBR(MAINMOD)
CRTPGM    PGM(MYLIB/CUSTRPT) MODULE(MYLIB/MAINMOD MYLIB/CALCMOD)

B.2 RPG III / OPM RPG (RPG/400) — CRTRPGPGM

Legacy fixed-form RPG III source (columns, C-specs, indicators) compiles with the OPM compiler — still one step, still produces a *PGM:

CRTRPGPGM PGM(MYLIB/SIMPINV) SRCFILE(MYLIB/QRPGSRC) SRCMBR(SIMPINV)

(OPM COBOL likewise: CRTCBLPGM. New work should be ILE; the OPM verbs exist for the migrated estate.)

B.3 ILE COBOL — CRTBNDCBL

Same shape as RPG — one-step to *PGM, or module + bind:

CRTBNDCBL PGM(MYLIB/BILLPOST) SRCFILE(MYLIB/QCBLLESRC) SRCMBR(BILLPOST)
CRTCBLMOD MODULE(MYLIB/GLTOTMOD) SRCFILE(MYLIB/QCBLLESRC) SRCMBR(GLTOTMOD)
CRTPGM    PGM(MYLIB/GLTOTPGM) MODULE(MYLIB/GLTOTMOD)

COBOL reaches keyed database files through ASSIGN TO DATABASE- file control (record-level I/O — the VSAM idiom, see C.3) and screens through COPY DDS-ALL-FORMATS of a display file.

B.4 CL — Control Language (the JCL of IBM i) — CRTBNDCL

Where z/OS uses JCL decks, IBM i uses CL programs: compiled job-control that can test conditions, monitor for messages, override files and call programs. Compile to *PGM:

CRTBNDCL PGM(MYLIB/BILLCYCLE) SRCFILE(MYLIB/QCLSRC) SRCMBR(BILLCYCLE)

(CRTCLPGM is the OPM form — same result for plain CL.) A typical driver:

PGM
  OVRDBF FILE(INVOICE) TOFILE(MYLIB/INVOICE)
  CALL   PGM(MYLIB/BILLPOST)
  DLTOVR FILE(INVOICE)
ENDPGM

Run interactively with CALL, or as batch with SBMJOB CMD(CALL PGM(MYLIB/BILLCYCLE)) — SBMJOB is the “submit the JCL” of IBM i (see section D).

B.5 Physical file (DDS) — CRTPF

The base table: field layouts and (optionally) a key, defined in DDS. The AS/400 answer to both a VSAM cluster and a DB2 base table — the same object serves record-level I/O and SQL. Produces a *FILE (PF):

A          R CUSTR
A            CUSNBR         6P 0
A            CUSNAM        30A
A            CUSBAL         9P 2
A          K CUSNBR
CRTPF FILE(MYLIB/CUSTMAST) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTMAST)

B.6 Logical file (DDS) — CRTLF

An index / view / alternate key over one or more physical files (the alternate-index or DB2-view role). Produces a *FILE (LF):

A          R CUSTR                     PFILE(MYLIB/CUSTMAST)
A          K CUSNAM
CRTLF FILE(MYLIB/CUSTBYNAM) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTBYNAM)

Compile the PF before its LFs — a logical file cannot be created over a physical file that does not exist yet.

B.7 Display file (5250 screen) — CRTDSPF

The screen layer: record formats with fields, attributes, indicators and function keys, defined in DDS. This is the IBM i equivalent of a CICS BMS mapset — but there is no separate transaction monitor to define it to; the program simply opens the display file as WORKSTN and does EXFMT. Produces a *FILE (DSPF):

CRTDSPF FILE(MYLIB/CUSTMNTD) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTMNTD)

B.8 Printer file — CRTPRTF

Report layout in DDS (headings, detail lines, totals, skip/space). Produces a *FILE (PRTF); program output lands as a spooled file on an output queue:

CRTPRTF FILE(MYLIB/INVLIST) SRCFILE(MYLIB/QDDSSRC) SRCMBR(INVLIST)

B.9 Command definition — CRTCMD

Wrap a program in a first-class CL command with prompted, validated parameters (the polish of a real product). Produces a *CMD whose CPP (command-processing program) is your CL/RPG:

CRTCMD CMD(MYLIB/RUNBILL) PGM(MYLIB/BILLCYCLE) SRCFILE(MYLIB/QCMDSRC) SRCMBR(RUNBILL)

B.10 Modules, programs & service programs — CRTPGM / CRTSRVPGM

ILE separates compiling (source → *MODULE) from binding (modules → *PGM or *SRVPGM). A service program is a bound library of reusable procedures that many programs share — the closest AS/400 analogue to a callable assembler/utility service or a “copybook of logic”, resolved at bind time (bind-by-reference, so one fix updates every caller):

CRTRPGMOD MODULE(MYLIB/DATEMOD) SRCFILE(MYLIB/QRPGLESRC) SRCMBR(DATEMOD)
CRTSRVPGM SRVPGM(MYLIB/DATESRV) MODULE(MYLIB/DATEMOD) EXPORT(*ALL)
CRTPGM    PGM(MYLIB/CUSTRPT) MODULE(MYLIB/MAINMOD) BNDSRVPGM(MYLIB/DATESRV)

Callers reach the exports with a bound call (CALLB / prototyped CALLP in RPG, CALL ... USING of a bound entry in COBOL).

B.11 SQL — RUNSQLSTM and embedded SQL (SQLRPGLE)

DB2 for i is integrated — there is no separate DB2 subsystem, no BIND, no plan. Two build paths:

(a) SQL DDL as a script — put CREATE TABLE / VIEW / INDEX statements in a source member and run them; SQL tables and DDS physical files are the same kind of object underneath:

RUNSQLSTM SRCFILE(MYLIB/QSQLSRC) SRCMBR(CRTTBLS) COMMIT(*NONE)

(b) Embedded SQL in RPG — source type SQLRPGLE, compiled with the SQL precompiler+compiler in one verb. This replaces the mainframe precompile→compile→BIND chain entirely:

CRTSQLRPGI OBJ(MYLIB/AGERPT) SRCFILE(MYLIB/QRPGLESRC) SRCMBR(AGERPT) COMMIT(*NONE)
Embedded SQL in COBOL: the standard IBM i verb is CRTSQLCBLI. On SteelFrame X the ILE COBOL compiler accepts EXEC SQL ... END-EXEC inline, so an embedded-SQL COBOL member compiles with plain CRTBNDCBL (that is how the BILLIB/i aging report is built). SQL procedures/functions (SQL PL) are also created through RUNSQLSTM — see the SQL PL application manuals on the index page.

C. Combinations — the Mainframe Stacks, on IBM i ↑ top

Each recipe below names the z/OS stack it replaces, then gives the complete IBM i build in order. Rule of thumb for order: data first, screens second, programs third, CL last.

C.1 COBOL + CICS + BMS + DB2  →  ILE COBOL + DSPF + embedded SQL

Online transaction over the relational database. CICS and BMS both collapse into the display file; DB2 access is embedded SQL with no BIND step:

RUNSQLSTM SRCFILE(MYLIB/QSQLSRC) SRCMBR(CRTTBLS) COMMIT(*NONE)   /* tables      */
CRTDSPF   FILE(MYLIB/CUSTMNTD) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTMNTD) /* screen  */
CRTBNDCBL PGM(MYLIB/CUSTMNT) SRCFILE(MYLIB/QCBLLESRC) SRCMBR(CUSTMNT)  /* EXEC SQL inside */
CRTBNDCL  PGM(MYLIB/CUSTMCL) SRCFILE(MYLIB/QCLSRC) SRCMBR(CUSTMCL)     /* driver  */
CALL PGM(MYLIB/CUSTMCL)

(On a system with the standard SQL precompiler verbs, the COBOL step is CRTSQLCBLI OBJ(...) SRCFILE(...) SRCMBR(...) — same result.)

C.2 COBOL + CICS + BMS + VSAM  →  ILE COBOL + DSPF + keyed PF/LF

Online transaction over keyed records — VSAM becomes a keyed physical file with logical views, read/written record-level (READ/WRITE/REWRITE by key), no SQL anywhere:

CRTPF   FILE(MYLIB/CUSTMAST)  SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTMAST)
CRTLF   FILE(MYLIB/CUSTBYNAM) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTBYNAM)
CRTDSPF FILE(MYLIB/CUSTMNTD)  SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTMNTD)
CRTBNDCBL PGM(MYLIB/CUSTMNT)  SRCFILE(MYLIB/QCBLLESRC) SRCMBR(CUSTMNT)

C.3 COBOL + VSAM (batch)  →  ILE COBOL + keyed PF/LF

The classic batch update: keyed file maintenance with ASSIGN TO DATABASE-CUSTMAST, ORGANIZATION INDEXED file control — the direct VSAM-KSDS idiom:

CRTPF     FILE(MYLIB/CUSTMAST) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTMAST)
CRTLF     FILE(MYLIB/CUSTBYNAM) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTBYNAM)
CRTBNDCBL PGM(MYLIB/BILLPOST) SRCFILE(MYLIB/QCBLLESRC) SRCMBR(BILLPOST)
SBMJOB CMD(CALL PGM(MYLIB/BILLPOST)) JOB(BILLPOST)

C.4 Easytrieve + DB2 (report/extract)  →  SQLRPGLE or plain SQL

Easytrieve's role — a quick report or extract over the database — is filled on IBM i either by a small RPG report program with embedded SQL, or by a pure SQL script:

CRTPRTF    FILE(MYLIB/AGELIST) SRCFILE(MYLIB/QDDSSRC) SRCMBR(AGELIST)
CRTSQLRPGI OBJ(MYLIB/AGERPT) SRCFILE(MYLIB/QRPGLESRC) SRCMBR(AGERPT) COMMIT(*NONE)
CALL PGM(MYLIB/AGERPT)

…or, for a set-based extract with no program at all:

RUNSQLSTM SRCFILE(MYLIB/QSQLSRC) SRCMBR(AGEQRY) COMMIT(*NONE)

C.5 IDMS + ADS/Online  →  DB2 for i + RPG/COBOL + DSPF

Network database + dialog generator becomes relational database + compiled program + display file. Sets/records become tables with foreign keys (or PFs with join logical files); the ADS dialog becomes an RPG or COBOL program driving a DSPF. Build = C.1's recipe with CRTSQLRPGI (or CRTBNDRPG + CRTLF join views for the navigational parts).

C.6 Natural + ADABAS  →  RPG/COBOL + DB2 for i

4GL + inverted-list database becomes 3GL + relational. ADABAS descriptors (searchable fields) map to logical files / SQL indexes; Natural READ/FIND loops map to keyed RPG I/O or SQL cursors — use SQL (CRTSQLRPGI) for the set-based parts and record-level I/O (CRTBNDRPG over PF/LF) for the sequential ones. Build = C.3 or C.4 depending on which side dominates.

C.7 HLASM  →  ILE service program (assembler is not idiomatic here)

There is no assembler in normal IBM i practice — the machine interface (MI) sits below the covers and low-level, shared, performance-critical routines are written as ILE modules bound into a service program:

CRTRPGMOD MODULE(MYLIB/CVTMOD) SRCFILE(MYLIB/QRPGLESRC) SRCMBR(CVTMOD)
CRTSRVPGM SRVPGM(MYLIB/UTILSRV) MODULE(MYLIB/CVTMOD) EXPORT(*ALL)

C.8 COBOL + HLASM  →  ILE COBOL calling a bound service program

The classic “COBOL mainline calling an assembler subroutine” becomes an ILE COBOL module bound against the service program's exports (bound call — resolved at CRTPGM time, not runtime):

CRTCBLMOD MODULE(MYLIB/MAINMOD) SRCFILE(MYLIB/QCBLLESRC) SRCMBR(MAINMOD)
CRTPGM    PGM(MYLIB/MAINPGM) MODULE(MYLIB/MAINMOD) BNDSRVPGM(MYLIB/UTILSRV)

C.9 Any other combination — the general pattern

Whatever the stack, the build order is always the same:

  1. DDS objects first, in dependency order: PF → LF → DSPF / PRTF (CRTPF, CRTLF, CRTDSPF, CRTPRTF), or RUNSQLSTM for the SQL-defined data.
  2. Modules (CRTRPGMOD / CRTCBLMOD) for anything multi-module or shared.
  3. Bind into *PGM / *SRVPGM (CRTPGM, CRTSRVPGM) — or one-step CRTBNDRPG / CRTBNDCBL / CRTSQLRPGI for single-module programs.
  4. CL to orchestrate (CRTBNDCL) with OVRDBF for file redirection, then SBMJOB for the batch runs and optionally CRTCMD for a prompted front door.

D. Build Order & Batch (SBMJOB) ↑ top

Compiles themselves run interactively from the command line, but a full application build is usually a CL program — and long builds or batch cycles are submitted, exactly where a mainframe shop would submit JCL:

PGM  /* BUILDALL - full application build */
  CRTPF     FILE(MYLIB/CUSTMAST) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTMAST)
  CRTLF     FILE(MYLIB/CUSTBYNAM) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTBYNAM)
  CRTDSPF   FILE(MYLIB/CUSTMNTD) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUSTMNTD)
  CRTPRTF   FILE(MYLIB/AGELIST)  SRCFILE(MYLIB/QDDSSRC) SRCMBR(AGELIST)
  CRTBNDRPG PGM(MYLIB/CUSTMNT)   SRCFILE(MYLIB/QRPGLESRC) SRCMBR(CUSTMNT)
  CRTSQLRPGI OBJ(MYLIB/AGERPT)   SRCFILE(MYLIB/QRPGLESRC) SRCMBR(AGERPT) COMMIT(*NONE)
  CRTBNDCL  PGM(MYLIB/NIGHTCL)   SRCFILE(MYLIB/QCLSRC) SRCMBR(NIGHTCL)
ENDPGM
CRTBNDCL PGM(MYLIB/BUILDALL) SRCFILE(MYLIB/QCLSRC) SRCMBR(BUILDALL)
SBMJOB CMD(CALL PGM(MYLIB/BUILDALL)) JOB(BUILDALL)

Check results with WRKOBJ MYLIB/*ALL (does the object exist?), WRKSPLF (compile listings and reports), and WRKACTJOB / WRKSBMJOB for the submitted job. A failed compile leaves a message in the joblog (DSPJOBLOG) — the equivalent of reading the JES output.

E. Quick Command Table ↑ top

You wantCommandProduces
ILE RPG program (one step)CRTBNDRPG*PGM
ILE RPG module (for binding)CRTRPGMOD*MODULE
RPG III / OPM programCRTRPGPGM*PGM
ILE COBOL program (one step)CRTBNDCBL*PGM
ILE COBOL moduleCRTCBLMOD*MODULE
OPM COBOL programCRTCBLPGM*PGM
CL program (job control)CRTBNDCL / CRTCLPGM*PGM
Bind modules into a programCRTPGM*PGM
Service program (shared procedures)CRTSRVPGM*SRVPGM
Physical file (table / keyed data)CRTPF*FILE (PF)
Logical file (index / view)CRTLF*FILE (LF)
Display file (5250 screen)CRTDSPF*FILE (DSPF)
Printer file (report layout)CRTPRTF*FILE (PRTF)
Source physical fileCRTSRCPF*FILE (source)
Command definitionCRTCMD*CMD
Run SQL DDL / scriptRUNSQLSTMtables, views, indexes, SQL routines
Embedded-SQL RPG (SQLRPGLE)CRTSQLRPGI*PGM
Embedded-SQL COBOLCRTSQLCBLI ¹*PGM
Submit a batch jobSBMJOBbatch job on a job queue
Redirect a file for one jobOVRDBF(override, not an object)

¹ standard IBM i verb; on SteelFrame X, CRTBNDCBL compiles embedded EXEC SQL COBOL directly (see B.11).