Monday, July 4, 2011

RPG IV Examples

Welcome to my RPG examples Blog.  This is intended as a way for the common, real world RPG programmer to exchange programming examples, techniques and stories about work related problems and solutions.

Mostly you will find free format RPG (RPG IV) code.  These examples are for the ILE compilers. I no longer use subruotines but only procedures in a highly modular environment.

The days of programs with 8000 lines of code are gone forever.   We now create programs with a simple main program entry point to set the environment and then calls to multiple modules as necessary.

Consider the following code for the main entry point of program UPC060:

      * +-----------------------------------------------------------------+
      * + Program Id.......: UPC060                                       +
      * + Module...........:  UPC060                                      +
      * + Date Written.....: 09/25/2007                                   +
      * + Author...........: Daniel Batista                               +
      * + Platform.........: OS/400                                       +
      * + OS Version.......: V5R3M0 or Later                              +
      * + Description......: UPC Invoice Item Recoding Program.           +
      * +                       Program Main Entry Point Module.          +
      * +                                                                 +
      * + Compile Inst.....:                                              +
      * +    CRTRPGMOD  MODULE(lib/UPC060) SRCFILE(/QRPGLESRC)            +
      * +    CRTPGM PGM(lib/UPC060) BNDDIR(EDITBNDDIR) ACTGRP(QILE)       +
      * +       ALWLIBUPD(*YES)                                           +
      * +                                                                 +
      * + Message File.....: N/A                                          +
      * +    Prefix........:                                              +
      * +                                                                 +
      * + Service Programs Used:                                          +
      * +                                                                 +
      * +-----------------------------------------------------------------+
      * + Indicator Usage..:                                              +
      * +                                                                 +
      * +    Standard to All Interactive programs and modules:            +
      * +       35   = Subfile Next Changed Indicator                     +
      * +       36-38= Reserved for Subfile Usage (Available)             +
      * +       39   = FRCDTA Display Keyword                             +
      * +       40-48= Reserved for Program Wide (Non Session Dependend)  +
      * +       49   = Program called in Inquiry Mode                     +
      * +       88   = Color White for All Subfile Records                +
      * +                                                                 +
      * +    Specific to this module:                                     +
      * +       None                                                      +
      * +                                                                 +
      * +-----------------------------------------------------------------+
      * + Modification Log.:                                              +
      * +    09/25/2007:  Daniel Batista                                  +
      * +       - Created Original Version                                +
      * +                                                                 +
      * +-----------------------------------------------------------------+

      * -----------------> Compiler Directives <-------------------
     H Thread(*Serialize)                                                 
     H AlwNull(*USRCTL)                                                   
     H Copyright('Program UPC060. +                                       
     H           Copyright(c) DB Consulting. 2001-2008. +                 
     H           UPC Invoice Item Recoding. Main Entry Point Module.  +   
     H           Version 1.0. Version Date 11/01/2007.        ')          
                                                                          
                                                                          
                                                                          
      * ----------------> Data Definition Area <------------------        
      * --> Main Program Prototype                                        
     D/Copy UPC060_P                                                      
                                                                          
      * --> Subfile Driver Module                                         
     D/Copy UPC060M1_P                                                    
                                                                          
      * --> Prototype for UPC060C                                         
     D/Copy UPC060C_P                                                     
                                                                          
      * ----> Locally Defined Prototyped Functions and Procedures         
      * ------> Module Level Constants                                    
      * ------> Module Level Date, Time and TimeStamp Variables           
      * ------> Module Level Numeric Variables                            
                                                                          
      * ------> Module Level Character Variables                          
                                                                          
      * ------> Module Level Boolean Variables                            
     D True            S               N   Inz(*On)                       
     D False           S               N   Inz(*Off)                      
                                                                          
      * ------> Module Arrays                                             
      * ------> Module Level Data Structures                              
                                                                          
      * Main Program Interface Definition                                 
     D UPC060          PI                                                 
     D  piExitKey                     2A                                  
     D  piSortType                    1A   Const Options(*NoPass)         
                                                                          
      /Free                                                               
                                                                          
         // Set Program Overrides                                         
         UPC060C(True);                                                   
                                                                          
         // Calls Subfile Driver. Display All Files List                  
         If %Parms() >= 2;                                                
            UPC060M1(piExitKey: piSortType);                              
         Else;                                                            
            UPC060M1(piExitKey);                                          
         EndIf;                                                           
                                                                          
         // Remove Program Overrides                                      
         UPC060C(False);                                                  
                                                                          
         // End Program                                                   
         *InLr = True;                                                    
                                                                          
      /End-Free
                                                                                                          

2 comments:

  1. MESSETRABERT GEL | SINGLE-SMD GEL
    MESSETRABERT GEL. A Tantric Tantric titanium bars Tantric system with a titanium aura quartz special head for the most titanium mens rings part is found in Shingles. In this 2019 ford edge titanium for sale Tantric titanium 3d printer Tantric Tantric system,

    ReplyDelete

DirectSwift Directory URL Shack Web Directory