This example is an ILE version of the small transaction processing program OPM CL Example: Calling OPM, COBOL, and RPG Programs from an ILE C Program.
Figure 261. Basic Object Structure
This example consists of:
As shown in Figure 262, the CL and C programs are activated within a new activation group. The ILE CL program is created with the CRTPGM default for the ACTGRP parameter, ACTGRP(*NEW). The ILE C program is created with ACTGRP(*CALLER).
Figure 262. Integrated Language Environment Structure
The following steps show you how to:
CRTPF FILE(MYLIB/T1520DD2) SRCFILE(QCPPLE/QADDSSRC) MAXMBRS(*NOMAX)
Figure 263. T1520DD2 -- Source to Create Physical Files
|
This file contains the audit trail for the ILE C program T1520ICB.
CRTCLMOD MODULE(MYLIB/T1520CL3) SRCFILE(QCPPLE/QACLSRC)
CRTPGM PGM(MYLIB/T1520CL3) MODULE(MYLIB/T1520CL3) ACTGRP(*NEW)
Figure 264. T1520CL3 -- ILE CL Source to Pass Variables to an ILE C Program
|
This program passes the CL variables item name, price, quantity, and user ID by reference to an ILE C program T1520ICB. The Retrieve Job Attributes (RTVJOBA) command obtains the user ID for the audit trail. Arguments are passed by reference. They can be changed by the receiving ILE C program. The variable item_name is null ended in the CL program.
CRTCMD CMD(MYLIB/T1520CM2) PGM(MYLIB/T1520CL3) SRCFILE(QCPPLE/QACMDSRC)
Figure 265. T1520CM2 -- Source to Create a CL Command Prompt
|
You use this CL command to enter the item name, price, and quantity for the ILE C program T1520ICB.
CRTCMOD MODULE(MYLIB/T1520ICB) SRCFILE(QCPPLE/QACSRC)
Figure 266. T1520ICB -- ILE C Source to Call COBOL and RPG Procedures
|
Notes:
CRTCMOD MODULE(MYLIB/T1520ICC) SRCFILE(QCPPLE/QACSRC)
Figure 267. T1520ICC -- Source Code to Export Tax Rate Data
|
TAXRATE is exported from this module to ILE C, COBOL, and RPG procedures.
CRTCBLMOD MODULE(MYLIB/T1520CB2) SRCFILE(QCPPLE/QALBLSRC)
Figure 268. T1520CB2 -- ILE COBOL Source to Calculate Tax and Format Cost
|
Notes:
CRTRPGMOD MODULE(MYLIB/T1520RP2) SRCFILE(QCPPLE/QARPGSRC)
Figure 269. T1520RP2 -- ILE RPG Source to Write the Audit Trail
|
Notes:
The T1520SP3 service program exports taxrate. The export list is specified in T1520SP3 in QASRVSRC.
CRTSRVPGM SRVPGM(MYLIB/T1520SP3) MODULE(MYLIB/T1520ICC) +
EXPORT(*SRCFILE) SRCFILE(QCPPLE/QASRVSRC)
The T1520SP4 service program exports procedure T1520RP2. The export list is specified in T1520SP4 in QASRVSRC.
CRTSRVPGM SRVPGM(MYLIB/T1520SP4) MODULE(MYLIB/T1520RP2) +
EXPORT(*SRCFILE) SRCFILE(QCPPLE/QASRVSRC)
T1520ICB is considered the application's main program. It will run in the new activation group that was created when T1520CL3 was called.
CRTPGM PGM(MYLIB/T1520ICB) MODULE(MYLIB/T1520ICB MYLIB/T1520CB2) +
BNDSRVPGM(MYLIB/T1520SP3 MYLIB/T1520SP4) ACTGRP(*CALLER)
Type the following data into T1520CM2:
|
The output is as follows:
+--------------------------------------------------------------------------------+ | 5000 HAMMERS plus tax = $11,385.00 | | Press ENTER to end terminal session. | |> | | 2000 NAILS plus tax = $575.00 | | Press ENTER to end terminal session. | +--------------------------------------------------------------------------------+
The physical file T1520DD2 contains the following data:
SMITHE HAMMERS 0000000198500015 $11,385.00072893
SMITHE NAILS 0000000025200015 $575.00072893
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.