Creating a NOMAIN Module

In this example you create an NOMAIN module object TRANSSVC using the CRTRPGMOD command and its default settings. TRANSSVC contains prototyped procedures that perform transaction services for procedures in other modules. The source for TRANSSVC is shown in Figure 37. The prototypes for the procedures in TRANSSVC are stored in a /COPY member, as shown in Figure 38.

  1. To create a module object, type:
    CRTRPGMOD MODULE(MYLIB/TRANSSVC)  SRCFILE(MYLIB/QRPGLESRC)

    The module will be created in the library MYLIB with the name specified in the command, TRANSSVC. The source for the module is the source member TRANSSVC in file QRPGLESRC in the library MYLIB.

    You bind a module containing NOMAIN to another module using one of the following commands:

    1. CRTPGM command
    2. CRTSRVPGM command
    3. CRTBNDRPG command where the NOMAIN module is included in a binding directory.
  2. Once it is bound, this module object can be debugged using a statement view. A compiler listing for the module is also produced.
  3. Type one of the following CL commands to see the compiler listing.
Figure 37. Source for TRANSSVC member
      *=================================================================*
      * MODULE NAME:    TRANSSVC (Transaction Services)
      * RELATED FILES:  N/A
      * RELATED SOURCE: TRANSRPT
      * EXPORTED PROCEDURES:  Trans_Inc  -- calculates the income
      *     for the transaction using the data in the fields in the
      *     parameter list.  It returns to the caller after all
      *     the calculations are done.
      *
      *     Prod_Name --  retrieves the product name based on the
      *     input parameter with the product number.
      *=================================================================*
      * This module contains only subprocedures; it is a NOMAIN module.
     H  NOMAIN
      *------------------------------------------------------------------
      * Pull in the prototypes from the /COPY member
      *------------------------------------------------------------------
      /COPY TRANSP
      *------------------------------------------------------------------
      * Subprocedure Trans_Inc
      *------------------------------------------------------------------
     P Trans_Inc       B                      EXPORT
     D  Trans_Inc      PI            11P 2
     D    ProdNum                    10P 0    VALUE
     D    Quantity                    5P 0    VALUE
     D    Discount                    2P 2    VALUE
     D  Factor         S              5P 0
      *
     C                   SELECT
     C                   WHEN      ProdNum = 1
     C                   EVAL      Factor = 1500
     C                   WHEN      ProdNum = 2
     C                   EVAL      Factor = 3500
     C                   WHEN      ProdNum = 5
     C                   EVAL      Factor = 20000
     C                   WHEN      ProdNum = 8
     C                   EVAL      Factor = 32000
     C                   WHEN      ProdNum = 12
     C                   EVAL      Factor = 64000
     C                   OTHER
     C                   EVAL      Factor = 0
     C                   ENDSL
     C                   RETURN    Factor * Quantity * (1 - Discount)
     P  Trans_Inc      E
      *------------------------------------------------------------------
      * Subprocedure Prod_Name
      *------------------------------------------------------------------
     P Prod_Name       B                      EXPORT
     D  Prod_Name      PI            40A
     D    ProdNum                    10P 0    VALUE
      *
     C                   SELECT
     C                   WHEN      ProdNum = 1
     C                   RETURN    'Large'
     C                   WHEN      ProdNum = 2
     C                   RETURN    'Super'
     C                   WHEN      ProdNum = 5
     C                   RETURN    'Super Large'
     C                   WHEN      ProdNum = 8
     C                   RETURN    'Super Jumbo'
     C                   WHEN      ProdNum = 12
     C                   RETURN    'Incredibly Large Super Jumbo'
     C                   OTHER
     C                   RETURN    '***Unknown***'
     C                   ENDSL
     P  Prod_Name      E
Figure 38. Source for TRANSP /COPY member

      * Prototype for Trans_Inc
     D  Trans_Inc      PR            11P 2
     D    Prod                       10P 0    VALUE
     D    Quantity                    5P 0    VALUE
     D    Discount                    2P 2    VALUE

      * Prototype for Prod_Name
     D  Prod_Name      PR            40A
     D    Prod                       10P 0    VALUE


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