- Create the physical file T1520DD1, which
contains the audit log entries, by entering the following command:
CRTPF FILE(MYLIB/T1520DD1) SRCFILE(QCPPLE/QADDSSRC) MAXMBRS(*NOMAX)
- Note:
- Figure 53 shows the source code in T1520DD1.
- Create the CL program T1520CL1, which passes
parameters to the ILE C program T1520PG1 by entering the following
command:
CRTCLPGM PGM(MYLIB/T1520CL1) SRCFILE(QCPPLE/QACLSRC)
- Note:
- Figure 54 shows the source code in T1520CL1.
- Create the CL command prompt T1520CM1, which
collects data for item name, price, and quantity by entering the following
command:
CRTCMD CMD(MYLIB/T1520CM1) PGM(MYLIB/T1520CL1) SRCFILE(QCPPLE/QACMDSRC)
- Note:
- Figure 55 shows the source code in T1520CM1.
- Create the module T1520IC1, which provides the
main() function by entering the following command:
CRTCMOD MODULE(MYLIB/T1520IC1) SRCFILE(QCPPLE/Q CSRC) OUTPUT(*PRINT) DBGVIEW(*ALL)
Notes:
- Figure 56 shows the source code in T1520IC1.
- OUTPUT(*PRINT) specifies that you want a compiler
listing.
- The parameter DBGVIEW(*ALL) specifies that you want a root
source view and a listing view, along with debug data, to debug this
module. See Chapter 10, Working with Source Debug Sessions for information on debug views and debug data.
- Create the module T1520IC2, which calculates the tax and
formats the total cost for output, by entering the following command:
CRTCMOD MODULE(MYLIB/T1520IC2) SRCFILE(QCPPLE/QACSRC) OUTPUT(*PRINT)
DBGVIEW(*ALL)
Notes:
- Figure 57 shows the source code in T1520IC2.
- DBGVIEW(*ALL) specifies that you want a root source view and a
listing view, along with debug data to debug this module.
- Create the module T1520IC3, which updates the audit trail
in audit file T1520DD1, by entering the following command:
CRTCMOD MODULE(MYLIB/T1520IC3) SRCFILE(QCPPLE/QACSRC)
OUTPUT(*PRINT) DBGVIEW(*SOURCE) OPTION(*SHOWUSR)
Notes:
- Figure 58 shows the source code in T1520IC3.
- The DBGVIEW(*SOURCE) OPTION(*SHOWUSR) parameters specifies that
you want an include view containing the root source member, user include
files, and debug data to debug this module.
- The OPTION(*SHOWUSR) parameter expands the type definitions
generated by the compiler from the DDS source file MYLIB/T1520DD1,
as specified on the #pragma mapinc directive, into the compiler
listing and the include debug view.
- Create the module T1520IC4, which exports the
tax rate data, by entering the following command:
CRTCMOD MODULE(MYLIB/T1520IC4) SRCFILE(QCPPLE/QACSRC) OUTPUT(*PRINT)
OPTION(*XREF) DBGVIEW(*SOURCE)
Notes:
- Figure 59 shows the source code in T1520IC4.
- The OPTION(*XREF) parameter generates a cross reference table
containing the list of identifiers in the source code with the numbers of the
lines in which they appear. The table provides the class, length and
type of the variable taxrate. The class is an external
definition. The length is 2. The type is a constant
decimal(2,2). The use of this option in this example is for
illustrative purposes. Typically you use this option when there are
several variable references or executable statements.
- The DBGVIEW(*SOURCE) parameter creates a root source view and
debug data to debug this module. If you do not specify
DBGVIEW(*SOURCE), you can debug the modules that reference
taxrate, but you cannot display taxrate during that
debug session nor can you debug this module that defines
taxrate.
- Create a source physical file QSRVSRC, which
contains the binder language to export the procedure
write_audit_trail() from ILE Service Program T1520SP1,
by entering the following command :
CRTSRCPF FILE(MYLIB/QSRVSRC) MBR(T1520SP1)
- Note:
- Figure 60 shows the source code in MYLIB/QSRVSRC.
- Create the source physical file QASRVSRC,
which contains the binder language to export the data item taxrate,
from ILE service program T1520SP2, by entering the following
command:
CRTSRCPF FILE(MYLIB/QASRVSRC) MBR(T1520SP2)
- Note:
- Figure 61 shows the source code in MYLIB/QASRVSRC.
- Create the binding directory T1520BD1 in library
MYLIB and add the two service program names (T1520SP1
and T1520SP2) to it.
- To create the binding directory, enter the following command:
CRTBNDDIR BNDDIR(MYLIB/T1520BD1)
- To add the service program names, enter the following commands:
ADDBNDDIRE BNDDIR(MYLIB/T1520BD1) OBJ((MYLIB/T1520SP1 *SRVPGM))
ADDBNDDIRE BNDDIR(MYLIB/T1520BD1) OBJ((MYLIB/T1520SP2 *SRVPGM))
- Note:
- The service program names T1520SP1 and T1520SP2 can be
added even though the service program objects do not yet exist.
- Note:
- These instructions assume that the library MYLIB already
exists.
- Create the ILE C service program T1520SP1 from
module T1520IC3 and the binder source language in
QSRVSRC by entering the following command:
CRTSRVPGM SRVPGM(MYLIB/T1520SP1) MODULE(MYLIB/T1520IC3 MYLIB/T1520IC4)
SRCFILE(MYLIB/QSRVSRC) SRCMBR(*SRVPGM) BNDDIR(MYLIB/T1520BD1) DETAIL(*FULL)
Notes:
- Figure 58 shows the source code in T1520IC3 and Figure 59 shows the source code in
T1520IC4.
- Service program T1520SP1 needs both module T1520IC3
and module T1520IC4 because it exports the procedure
write_audit_trail to satisfy an import request for function
write_audit_trail in module T1520IC1, and the
write_audit_trail procedure uses the data item taxrate,
which is defined in module T1520IC4.
- Create the ILE C service program T1520SP2 from
module T1520IC4 and the binder source language in
QASRVSRC by entering the following command:
CRTSRVPGM SRVPGM(MYLIB/T1520SP2) MODULE(MYLIB/T1520IC4) SRCFILE(MYLIB/QASRVSRC)
SRCMBR(*SRVPGM) BNDDIR(MYLIB/T1520BD1) DETAIL(*FULL)
- Note:
- Service program T1520SP2 exports the data item taxrate
to satisfy an import request for variable taxrate in module
T1520IC2.
- Create the ILE C program T1520PG1 from
components T1520IC1 and T1520IC2 by entering the
following command:
CRTPGM PGM(MYLIB/T1520PG1) MODULE(MYLIB/T1520IC1 MYLIB/T1520IC2) ENTMOD(*ONLY)
BNDDIR(MYLIB/T1520BD1) DETAIL(*FULL)
Notes:
- Figure 56 shows the source code in T1520IC1 and Figure 57 shows the source code in
T1520IC2.
- Module T1520IC1 contains an import procedure request named
write_audit_trail, which matches an export request in
T1520SP1, using symbol write_audit_trail. The
binder matches:
- The import request from T1520IC1 for the procedure
write_audit_trail with the corresponding export from
T1520SP1
- The import request from T1520IC2 for the data item
taxrate with the corresponding export from T1520SP2
- The ENTMOD(*ONLY) parameter specifies that only one module from
the list of modules can have a PEP. An error is issued if more than one
module is found to have a PEP. If the ENTMOD(*FIRST)
parameter is used, the first module found from a list of modules that has a
PEP is selected as the PEP. All other modules with PEPs are
ignored.
- The default ACTGRP(*NEW) parameter is used to define a new
activation group. The program T1520PG1 is associated with a
new activation group. Service programs T1520SP1 and
T1520SP2 were created with activation group
*CALLER. These service programs become part of the callers
activation group using the resources of one activation group for the purposes
of developing one cooperative program. Service program
T1520SP1 and T1520SP2 are bound to the program being
activated. These service programs are also activated as part of the
dynamic call processing.
- Run the program T1520PG1:
- Note:
- Ensure that the library MYLIB is on the LIBL library list.
- Enter the command T1520CM1 and press F4 (Prompt).
- As you are prompted by T1520CM, type the following data:
Hammers
1.98
5000
Nails
0.25
2000
The output is:
+--------------------------------------------------------------------------------+
| 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 T1520DD1 is updated with the following
data:
SMITHE HAMMERS 0000000198500015 $11,385.00072893
SMITHE NAILS 0000000025200015 $575.00072893
- Note:
- Each entry is identified with the user's ID. In this case, SMITHE
was the user.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.