TexAS400 Tutorial


Writing an RPG Print Program using DDS

This is the RPG program for writing a Print Report using DDS. At the bottom, you will see a sample of the report layout in the spool file.


 Columns . . . :    1  71            Edit                       USER000/QRPGSRC
 SEU==>                                                                 TUTR007
 FMT FX .....FFilenameIPEAF........L..I........Device+......KExit++Entry+A....U
        *************** Beginning of data *************************************
0001.00      FCUST    IF  E                    DISK                            
0002.00       *  The AS/400 includes a pre-defined printer file named QPRINT   
0003.00       *      Here, I use indicator 10 as the overflow indicator        
0004.00       *      That means that *IN10 will be *ON when the printed page   
0005.00       *      is full.                                                  
0006.00      FCUSW007 O   E             10     PRINTER                         
0007.00       *----------------------------------------------------------------
0008.00      C* Print the heading                                              
0009.00      C                     WRITEHDG1                                   
0010.00      C                     WRITEHDG2                                   
0011.00      C                     WRITEHDG3                                   
0012.00      C* Read the first record                                          
0013.00      C                     READ CUST                     90            
0014.00      C*                                                                
0015.00      C           *IN90     DOWEQ*OFF                                   
0016.00      C* See if the page is full. If so, print the heading.             
0017.00      C           *IN10     IFEQ *ON                                    
0018.00      C                     WRITEHDG1                                   
0019.00      C                     WRITEHDG2                                   
0020.00      C                     WRITEHDG3                                   
0021.00      C                     MOVE *OFF      *IN10                        
0022.00      C                     ENDIF                                       
0023.00      C* Print the detail                                               
0024.00      C                     WRITEDETAIL                                 
0025.00      C                     READ CUST                     90            
0026.00      C                     ENDDO                                       
0027.00      C*                                                                
0028.00      C                     MOVE *ON       *INLR                        
0029.00      C                     RETRN                                       
        ****************** End of data ****************************************


Once you have written the program, compile it using option 14.  After you have compiled the 
program, you want to call it and see what the report looks like.  To call the program, simply
type on the command line:  CALL PGM(USER000/TUTROO7)

Next, go to the Work Spool File (WRKSPLF), find the program, and key in a 5 to view the report.

This is what the report will look like:

  11192002                CUSTOMER ORDER REPORT             PAGE   0001 
                                                # OPEN     AMT OPEN     
  CUST #  CUSTOMER NAME                         ORDERS      ORDERS      
  001002  E LUMPKIN                                .00         0        
  001084  CHISOLM                                  .00         0        
  001105  HAGGINS                                  .00         0        
  001109  BYRD                                     .00         0        
  001168  ROMERO                                   .00         0        
  001177  POUNDS                                   .00         0        
  001183  HINTON                                   .00         0        
  001184  YANCEY                                   .00         0        
  001186  MCDOUGLE                                 .00         0        
  001202  DAVIS                                    .00         0        
  001208  TARVIN                                   .00         0        
  001214  GOOSEBERRY                               .00         0        
  001234  REID                                     .00         0        
  001239  COLBERT                                  .00         0          
  001259  BLACKMON                                 .00         0          
  001264  CRANFORD                                 .00         0          
  001266  DODSON                                   .00         0          
  001269  LENSON                                   .00         0          
  001274  JACKSON                                  .00         0          
  001284  TAPER                                    .00         0          
  001287  WILLIAMS                                 .00         0          
  001293  FEAZELL                                  .00         0          
  001294  MC CULLUM                                .00         0          
  001301  SMITH                                    .00         0          
  001303  MCGHEE                                   .00         0          
  001308  WALLACE                                  .00         0          
  001318  ROBINSON                                 .00         0          
  11192002                CUSTOMER ORDER REPORT             PAGE   0002    
                                               # OPEN     AMT OPEN        
  CUST #  CUSTOMER NAME                         ORDERS      ORDERS         
  001480  VALLIERE                                 .00         0           
  001480  BAILEY                                   .00         0           
  001485  POLLARD                                  .00         0           
  001492  JORDAN                                   .00         0           
  001502  EVERETT                                  .00         0           
  001504  HIGGINS                                  .00         0   
  001509  JONES                                    .00         0   
  001523  BENDER                                   .00         0   
  001539  BUDD                                     .00         0   
  001557  KINSEY                                   .00         0   
  001561   PILKINGTON                              .00         0   
  001579  HAWKINS                                  .00         0   
  001583  MOBBS                                    .00         0   
  001584  SELLERS                                  .00         0   
  001587  WALKER                                   .00         0   
  001591  SLACK                                    .00         0   
  001604  HINKLE                                   .00         0   
  001606  ALLEN                                    .00         0   
  001608  R MALONE                                 .00         0   
  001614  JACKSON                                  .00         0   
  

 

 

Back to Table of Contents   |   Main Page