Creating a Module for Source Debugging

In this example, you create an ILE RPG module object that you can debug using the source debugger. The module TRANSRPT contains a main procedure which drives the report processing. It calls the procedures in TRANSSVC to perform certain required tasks. The source for this module is shown in Figure 39.

To create a module object, type:

CRTRPGMOD MODULE(MYLIB/TRANSRPT)  SRCFILE(MYLIB/QRPGLESRC)
          DBGVIEW(*SOURCE)

The module is created in the library MYLIB with the same name as the source file on which it is based, namely, TRANSRPT. This module object can be debugged using a source view. For information on the other views available, see Preparing a Program for Debugging.

A compiler listing for the TRANSRPT module will be produced.

Figure 39. Source for TRANSRPT module
      *=================================================================*
      * MODULE NAME:    TRANSRPT
      * RELATED FILES:  TRNSDTA  (PF)
      * RELATED SOURCE: TRANSSVC (Transaction services)
      * EXPORTED PROCEDURE:  TRANSRPT
      *       The procedure TRANSRPT reads every tranasction record
      *       stored in the physical file TRNSDTA. It calls the
      *       subprocedure Trans_Inc which performs calculations and
      *       returns a value back.  Then it calls Prod_Name to
      *       to determine the product name.  TRANSRPT then prints
      *       the transaction record out.
      *=================================================================*
     FTRNSDTA   IP   E             DISK
     FQSYSPRT   O    F   80        PRINTER       OFLIND(*INOF)
      /COPY QRPGLE,TRANSP
      * Define the readable version of the product name like the
      * return value of the procedure 'Prod_Name'
     D    ProdName     S             30A
     D    Income       S             10P 2
     D    Total        S             +5      LIKE(Income)
      *
     ITRNSREC       01
      *  Calculate the income using subprocedure Trans_Inc
     C                   EVAL      Income = Trans_Inc(PROD : QTY : DISC)
     C                   EVAL      Total = Total + Income
      *  Find the name of the product
     C                   EVAL      ProdName = Prod_Name(PROD)
     OQSYSPRT   H    1P                     1
     O         OR    OF
     O                                           12 'Product name'
     O                                           40 'Quantity'
     O                                           54 'Income'
     OQSYSPRT   H    1P                     1
     O         OR    OF
     O                                           30 '----------+
     O                                              ----------+
     O                                              ----------'
     O                                           40 '--------'
     O                                           60 '------------'
     OQSYSPRT   D    01                     1
     O                       ProdName            30
     O                       QTY           1     40
     O                       Income        1     60
     OQSYSPRT   T    LR                     1
     O                                              'Total: '
     O                       Total         1

The DDS for the file TRNSDTA is shown in Figure 40. The /COPY member is shown in Figure 38.

Figure 40. DDS for TRNSDTA
     A*****************************************************************
     A* RELATED FILES:  TRNSRPT                                       *
     A* DESCRIPTION:    This is the physical file TRNSDTA. It has     *
     A*                 one record format called TRNSREC.             *
     A*****************************************************************
     A* PARTS TRANSACTION FILE -- TRNSDTA
     A          R TRNSREC
     A            PROD          10S 0       TEXT('Product')
     A            QTY            5S 0       TEXT('Quantity')
     A            DISCOUNT       2S 2       TEXT('Discount')


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