ILE C/C++ Programmer's Guide


Instructions to Create the Sample Application

  1. 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.
  2. 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.
  3. 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.
  4. 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:
  5. 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:
  6. 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:
  7. 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:
  8. 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.
  9. 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.
  10. Create the binding directory T1520BD1 in library MYLIB and add the two service program names (T1520SP1 and T1520SP2) to it.
    1. To create the binding directory, enter the following command:
      CRTBNDDIR BNDDIR(MYLIB/T1520BD1)
      
    2. 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.
  11. 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:
  12. 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.
  13. 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:
  14. Run the program T1520PG1:
    Note:
    Ensure that the library MYLIB is on the LIBL library list.
    1. Enter the command T1520CM1 and press F4 (Prompt).
    2. 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.


[ Top of Page | Previous Page | Next Page | Table of Contents ]