CUSMAIN: RPG Source

Figure 198. Source for module CUSMAIN
     //****************************************************************
     // PROGRAM NAME:   CUSMAIN                                       *
     // RELATED FILES:  MAINMENU (DSPF)                               *
     // RELATED PGMS:   CUSMNT   (ILE RPG PGM)                        *
     //                 SCHZIP   (ILE RPG PGM)                        *
     //                 SCHNAM   (ILE RPG PGM)                        *
     // DESCRIPTION:    This is a customer main inquiry program.      *
     //                 It prompts the user to choose from one of the *
     //                 following actions:                            *
     //                 1.Maintain (add, update, delete and display)  *
     //                   customer records.                           *
     //                 2.Search customer record by zip code.         *
     //                 3.Search customer record by name.             *
     //****************************************************************

     Fmainmenu  cf   e             workstn indds(indicators)

      // Prototype definitions:
     D CustMaintain    pr                  extproc('CUSMNT')
     D SearchZip       pr                  extproc('SCHZIP')
     D SearchName      pr                  extproc('SCHNAM')

      // Field definitions:
     D indicators      ds
     D    exitKey                      n   overlay(indicators:3)
     D    maintainKey                  n   overlay(indicators:5)
     D    srchZipKey                   n   overlay(indicators:6)
     D    srchCustKey                  n   overlay(indicators:7)

      /free
           // Keep looping until exit key is pressed
           dow  '1';
              // Display main menu
              exfmt hdrscn;

              // Perform requested action
              if exitKey;
                 // Exit program
                 leave;

              elseif maintainKey;
                 // Maintain customer data
                 CustMaintain();

              elseif srchZipKey;
                 // Search customer data on ZIP code
                 SearchZip();

              elseif srchCustKey;
                 // Search customer data on customer name
                 SearchName();
              endif;
           enddo;

           *inlr = *on;
      /end-free


This module illustrates the use of the CALLB opcode. The appropriate RPG module (CUSMNT, SCHZIP, or SCHNAM) is called by CUSMAIN depending on the user's menu item selection.

To create the program object:

  1. Create a module for each source member (CUSMAIN, CUSMNT, SCHZIP, and SCHNAM) using CRTRPGMOD.
  2. Create the program by entering:

    CRTPGM PGM(MYPROG) MODULE(CUSMAIN CUSMNT SCHZIP SCHNAM) ENTMOD(*FIRST)

    Note:
    The *FIRST option specifies that the first module in the list, CUSMAIN, is selected as the program entry procedure.
  3. Call the program by entering:
    CALL MYPROG

The "main menu" will appear as in Figure 199.

Figure 199. Customer Main Inquiry prompt screen
   22:30:05                CUSTOMER MAIN INQUIRY                      9/30/94



    Press one of the following PF keys.

                     F3 End Job
                     F5 Maintain Customer File
                     F6 Search Customer by Zip Code
                     F7 Search Customer by Name














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