Ü CL program to read a database file and display its field’s value on the console & prompt every time before reading a new record from the file

 

 

 

Ø  Physical file used in the program = CUST

 


 Columns . . . :    1  71           Browse                       AMIT/QRPGLESRC
 SEU==>                                                                    CUST
 FMT PF .....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
        *************** Beginning of data *************************************
0001.00                                                                        
0002.00      A          R CUSTR                                                
0003.00      A            CSNBR          6A                                     
0004.00      A            CSNAME        10A                                    
0005.00      A            CS#OPN         5P 0                                  
0006.00      A            CS$OPN        10P 2                                   
        ****************** End of data ****************************************

 

 

 

Ø  CL Program

 

                                                  
 Columns . . . :    1  71           Browse                       AMIT/QRPGLESRC
 SEU==>                                                                READFILE
 FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 
        *************** Beginning of data *************************************
0001.00 PGM                                                                    
0001.01              DCL        VAR(&VAR1) TYPE(*CHAR) LEN(20)                 
0001.03              DCL        VAR(&REPLY) TYPE(*CHAR) LEN(1) +               
0001.04                           VALUE('N')                                   
0002.00              DCLF       FILE(AMIT/CUST)                                
0003.00 READ:                                                                   
0004.00              RCVF                                                      
0005.00              MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(END1))         
0005.02              CHGVAR     VAR(&VAR1) VALUE(&CSNBR||'       '|| +         
0005.03                         &CSNAME||'      '||+                           
0005.05                         ' ')                                           
0005.06              SNDUSRMSG  MSG('DO U WANT TO CONTINUE FILE READING') +    
0005.07                           MSGRPY(&REPLY)  VALUES('Y' 'N')              
0005.10                                                                        
0005.11              IF   (&REPLY='Y') DO                                       
0005.12              SNDUSRMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&VAR1) + 
0005.13                           MSGTYPE(*INFO)                               
0006.00              GOTO       CMDLBL(READ)                                   
0006.01              ENDDO                                                     
0006.02              ELSE  DO                                                  
0006.03              GOTO       CMDLBL(END2)                                   
0006.04              ENDDO                                                     
0007.00 END1:                                                                  
0008.00              SNDUSRMSG  MSG('THE END OF FILE IS REACHED')              
0008.01 END2:                                                                  
0009.00 ENDPGM                                                                 
        ****************** End of data ****************************************

         

 

 

 

OUTPUT

 

Below is the output that we get on the console.

 


DO U WANT TO CONTINUE FILE READING           
Y                                            
100001       AMI.                            
DO U WANT TO CONTINUE FILE READING           
Y                                             
100002       upi.                            
DO U WANT TO CONTINUE FILE READING           
Y                                            
100003       KUM.                            
THE END OF FILE IS REACHED                   

 

 

 

 











User Comments:



Subscribe

.  


Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy