Creating a Program in One Step
You can use the CRTBNDC and CRTBNDCPP Create Bound Program commands to create a program (*PGM object) in one step.
The Create Bound Program commands combine the steps of compiling and binding. Using them is the same as first calling the CRTCMOD or CRTCPPMOD Create Module command, then calling the Create Program (CRTPGM) command, except that the module created by the Create Module command step is deleted after the CRTPGM step.
To use the Create Bound Program commands, the source member must
contain a
main() function. Note: When a CRTPGM parameter
does not appear in the Create Bound Program command, the CRTPGM parameter
default is used. For example, the parameter ACTGRP(*NEW) is the default
for the CRTPGM command, and is used for the Create Bound Program command.
You can change the CRTPGM parameter defaults by using the Change Command
Defaults (CHGCMDDFT) command.
You can use the CRTSQLCI or CRTSQLCPPI command to start the ILE C compiler and create a program object. The SQL database can be accessed from an ILE C/C++ program if you embed SQL statements in the ILE C/C++ source.
Example:
- To create the program T1520ALP, using the source found in Figure 1, enter:
The options specified are:CRTBNDC PGM(MYLIB/T1520ALP) SRCFILE(QCPPLE/QACSRC) TEXT('Adds integers and prints characters') OUTPUT(*PRINT) OPTION(*SHOWINC *NOLOGMSG) FLAG(30) MSGLMT(10) CHECKOUT(*PARM) DBGVIEW(*ALL)- OUTPUT(*PRINT) - specifies that you want a compiler listing.
- OPTION(*SHOWINC *NOLOGMSG) - specifies that you want to expand include files in a compiler listing and not log messages in the job log.
- FLAG(30) - specifies that you want severity level 30 messages to appear in the listing.
- MSGLMT(10) — specifies that you want compilation to stop after 11 messages at severity level 30.
- CHECKOUT(*PARM) — shows a list of function parameters not used.
- DBGVIEW(*ALL) specifies that you want all three views and debug data to debug this program.
- To see the compiler listing, enter one of the following CL commands:
DSPJOBand then select option 4 (Display spooled files)WRKJOBand then select option 4 (Work with spooled files)WRKOUTQqueue-nameWRKSPLF
Select an option to see the compiler listing.
- To run the program enter:
CALL PGM(MYLIB/T1520ALP) - Type
aand press Enter. Type9and press Enter. Typeband press Enter. Type8and press Enter. Type+and press Enter.The interactive session is as shown:> a > 9 > b > 8 > + Characters are ab Sum of Digits is 17 Press ENTER to end terminal session.