Search code examples
ibm-midrangerpgle

IBM i RPG Program not doing anything


The following code compiled under CRTBNDRPG but when running it is stuck on only 1 I/O.

All I hav to do is - all of our tables have order number as 8 but this one file has it as 10. So I am just creating the 2 fields i need one making it 8 and the other is ok as it is. ANy ideas why this little program doesn't take off?

FMFHHMH    IF   E             DISK                                    
F* output file                                                        
FMFHHMHPK  O  A E             DISK                                    
D*EXTSHP           S             13  6                                
D                                                                     
C                                                                     
C                   READ      MFHHMH                                  
C                   Dow       NOT %EOF(MFHHMH)                        
C                   iF        %found                                  
c                   MOVE      MHORDR        MHORDp                    
c                   MOVE      MHZONE        MHZONE                    
C                   WRITE     MFHHMHP                                 
C                   READ      mfhhmh                                  
C                   End                                               
C                   END                                               
C                   SETON                                        LR   

Solution

  • You have created an infinite loop where NOT %EOF is TRUE but %FOUND is FALSE.

    Note from the documentation for %FOUND that it does not reflect a status for a READ operation.

    The IF conditional is not needed in your code as the DOW loop is sufficient to guarantee you have a record.