ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Incorrect relative record number error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Incorrect relative record number error

    Please help! It has been years since I have looked at RPG programs and DDS, but I have to resolve an issue where an inquiry produces a CPF5021 error with the message of "Incorrect relative record number or field selection error". The code hasn't been touched in years, but there are records being added to the file that is being queried. The DDS looks similar to the following:

    Code:
    A                                      REF(ACCIDT) 	     
    A                                      PRINT 	           
    A                                      CF03 CF02 CF05 	  
    A          R CL14A                     SFL 	             
    A            AC        R        O  8  2REFFLD(CLACC#) 	  
    A                                      DSPATR(HI) 	      
    A            DTE            6Y 0O  8 12EDTCDE(Y) 	       
    A                                      DSPATR(HI) 	      
    A            TYPE      R        O  8 23REFFLD(CLACTY) 	  
    A                                      DSPATR(HI) 	      
    A            STAT      R        O  8 35REFFLD(CLSTAT) 	  
    A                                      DSPATR(HI) 	      
    A            DR        R        O  8 45REFFLD(DRVID) 	   
    A                                      DSPATR(HI) 	      
    A            TR        R        O  8 55REFFLD(TRACT) 	   
    A                                      DSPATR(HI) 	      
    A            TL        R        O  8 64REFFLD(TRLR) 	    
    A                                      DSPATR(HI) 	      
    A            ST        R        O  8 73REFFLD(CLST) 	             
    A                                      DSPATR(HI) 	               
    A            CH        R        O  8 78REFFLD(CLCHRG) 	           
    A                                      DSPATR(HI) 	               
    A          R CL14                      SFLCTL(CL14A) 	            
    A                                      SFLSIZ(0300) 	             
    A                                      SFLPAG(0014) 	             
    A  80                                  SFLCLR 	                   
    A  81                                  SFLDSP 	                   
    A  82                                  SFLDSPCTL 	                
    A  83                                  SFLEND 	                   
    A                                      OVERLAY 	                  
    A                                      CF01(25 'Help F-Key') 	    
    A                                      CSRLOC(ROW#       COL#  ) 	
    A            ROW#           3S 0H 	                               
    A            COL#           3S 0H 	                               
    A            JOBNAM        10A  O  1  2 	                         
    A                                      COLOR(BLU) 	               
    A            PGMNAM        10A  O  1 13 	                         
    A                                      COLOR(BLU) 	               
     A            CMNAME        30A  O  1 28 	                                 
     A                                      DSPATR(HI) 	                       
     A                                      DSPATR(UL) 	                       
     A                                  1 71DATE 	                             
     A                                      EDTCDE(Y) 	                        
     A                                      COLOR(BLU) 	                       
     A            USRNAM        10A  O  2  2 	                                 
     A                                      COLOR(BLU) 	                       
     A                                  2 28'  ACCIDENT INQUIRY BY DRIVER  ' 	 
     A                                      DSPATR(RI HI) 	                    
     A                                  2 71TIME 	                             
     A                                      COLOR(BLU) 	                       
     A                                  4  6'  Starting Driver:' 	             
     A            STCHAR         6A  B  4 25DSPATR(CS) 	                       
     A                                      DSPATR(HI) 	                       
     A                                      DSPATR(UL) 	                       
     A                                      CHECK(ER) 	                        
     A                                      COLOR(YLW) 	                       
     A                                  4 42'Enter Accident No.' 	             
     A                                      DSPATR(BL) 	                       
     A  55                                  DSPATR(ND) 	                          	 	
     A            WACC#          7A  B  4 61DSPATR(HI UL) 	                       	 	
     A                                      CHECK(RB) 	                           	 	
     A  55                                  CHECK(ER) 	                           	 	
     A N55                                  DSPATR(PC) 	                          	 	
     A  55                                  DSPATR(ND) 	                          	 	
    A                                  6  2'Acc. #      Date       Type    Sta- 	 	
    A                                      tus      Driver   Unit   Trailer   - 	 	
    A                                        St  Chrg' 	                         	 	
    A                                      COLOR(PNK) 	                          	 	
    A                                  7  2'------    --------   -------   ---- 	 	  
    A                                      ---      ------    ------  --------- 	 	  
    A                                        --  ----' 	                         	 	  
    A                                      COLOR(PNK) 	                        
    A          R CL14Z 	                                                       
    A                                      OVERLAY 	                           
    A                                      CF01(25 'Help F-Key') 	             
    A                                      CSRLOC(ROW#       COL#  ) 	         
    A            ROW#           3S 0H 	                                        
    A            COL#           3S 0H 	                                        
    A                                 23  2'F2=Accident Report  F3=Exit  F5=- 	
    A                                      Change Inquiry' 	                   
    A                                      COLOR(BLU)
    Here is the RPG:
    Code:
    FCL19DD  CF  E                    WORKSTN                              
    F                                              KINFDS CUSLOC           
    F                                        RRN   KSFILE CL14A            
    FACCIDTL3IF  E           K        DISK                                 
    ICOMPAN    E DS                                                        
    I            DS                                                        
    I                                        1  40 YYCOTX                  
    I                                        6  35 CONAME                  
    I           SDS                                                        
    I                                        1  10 PGMNAM                  
    I                                      244 253 JOBNAM                  
    I                                      254 263 USRNAM                  
    I           UDS                                                        
    I                                        5  11 WACC#                   
    I*                                                                     
    ICUSLOC      DS                                                        
    I                                    B 370 3710ROWCOL                  
    C           *NAMVAR   DEFN YYCOTXA   YYCOTX           Define YYCOTXA    
    C                     IN   YYCOTX                     Get YYCOTXA       
    C           *NAMVAR   DEFN           COMPAN           Company info      
    C                     IN   COMPAN                                       
    C                     MOVE CONAME    CMNAME                             
    C                     MOVE *BLANK    WACC#                              
    C                     MOVE '0'       *IN                                
    C                     SETOF                     U1U8                    
    C                     MOVE '1'       *IN55                              
    C           AGAIN     TAG                                               
    C                     Z-ADDRRN       HLDRRN                             
    C                     WRITECL14Z                                        
    C                     SETON                     8283  82 DSP SUBFIL     
    C           WHLP01    TAG                             Help Tag 01       
    C                     EXFMTCL14                       83 SUBFILE EN     
    C* Help Key Processing ----------------------------------               
    C           *IN25     IFEQ '1'                           |If = 1        
    C                     MOVEL'CL14    'HTFRMT              | Execute      
    C                     EXSR HELPSR                        | Help         
    C                     GOTO WHLP01                        | Subr.        
     C                     END                                |End         
     C                     Z-ADD0         ROW#                |Zero Row    
     C                     Z-ADD0         COL#                |and Col     
     C*-------------------------------------------------------             
     C                     SETOF                     8283                  
     C*                                                                    
     C   KC                SETOF                     U1                    
     C   KC                SETON                     LR                    
     C   KC                GOTO END                                        
     C   U1                SETON                     LR                    
     C   U1                GOTO END                                        
     C   KE                SETON                     U8                    
     C   KE                SETOF                     U1                    
     C   KE                SETON                     LR                    
     C   KE                GOTO END                                        
     C   KB                SETON                     U1                    
     C   KB                SETOF                     55                    
     C   KB                GOTO AGAIN                                      
     C*                                                                    
     C           STCHAR    IFNE HCHAR                                      
    C           STCHAR    OREQ *BLANK                                       
    C                     MOVE STCHAR    HCHAR   7                          
    C                     EXSR CLRSUB                                       
    C                     EXSR WRTSUB                                       
    C                     END                                               
    C                     GOTO AGAIN                                        
    C           END       TAG                                               
     *------------------------------------------------------------------*   
     * WRTSUB - BUILD SUBFILE DISPLAY RECORD                            *   
     *------------------------------------------------------------------*   
    C           WRTSUB    BEGSR                                             
    C           STCHAR    SETLLRCLACC                                       
    C           *IN61     DOUEQ'1'                                          
    C                     READ RCLACC                   61                  
    C           *IN61     IFEQ '0'                                          
    C                     MOVE CLACC#    AC                                 
    C                     Z-ADD0         JUILAN  70                         
    C                     MOVE *ZERO     DATEA   6                          
    C                     CALL 'DATCON'                                     
    C                     PARM CLADTE    JUILAN                             
    C                     PARM           DATEA                               
    C                     MOVE DATEA     DTE                                 
    C                     MOVE CLSTAT    STAT                                
    C                     MOVE DRVID     DR                                  
    C                     MOVE TRACT     TR                                  
    C                     MOVE TRLR      TL                                  
    C**DEL**              MOVE CLCITY    CTY                                 
    C                     MOVE CLACTY    TYPE                                
    C                     MOVE CLST      ST                                  
    C                     MOVE CLCHRG    CH                                  
    C                     MOVE '1'       *IN81            WRITE SUBFILE      
    C                     ADD  1         RRN                                 
    C                     WRITECL14A                    60                   
    C                     MOVE *BLANKS   DTE                                 
    C                     END                                                
    C                     END                                                
    C                     ENDSR                                              
     *------------------------------------------------------------------*    
     *   CLRSUB - CLEAR SUBFILE                                         *    
     *------------------------------------------------------------------*    
     C           CLRSUB    BEGSR                                             
     C                     MOVE '0'       *IN                                
     C                     MOVE '1'       *IN55                              
     C                     SETOF                     U1                      
     C                     Z-ADD0         RRN     40                         
     C                     Z-ADD0         HLDRRN  40                         
     C                     MOVE '1'       *IN80            CLEAR SUBFILE     
     C                     WRITECL14                                         
     C                     MOVE '0'       *IN80                              
     C                     ENDSR                                             
     C*--- Call Help Text Subroutine --------------------------              
     C* This subroutine calls the Help Text Driver Program    |              
     C           HELPSR    BEGSR                              |              
     C* Calculate Cursor Location from one binary field       |              
     C*      to two numeric fields                            |              
     C           ROWCOL    DIV  256       ROW#    30          |              
     C                     MVR            COL#    30          |              
     C                     MOVEL'CL19D   'HTPGM               |<--PGM        
     C                     MOVE ROW#      HTROW#              |              
     C                     MOVE COL#      HTCOL#              |              
    C* Call Window Help Subroutine                           |        
    C*      Pass Program Name, Format Name and Row#/Col#     |        
    C                     CALL 'WHDRVM'                      |        
    C                     PARM           HTPGM  10           |        
    C                     PARM           HTFRMT 10           |        
    C                     PARM           HTROW#  30          |        
    C                     PARM           HTCOL#  30          |        
    C                     ENDSR                              |        
    C*--------------------------------------------------------
    The subfile returns without issue if the inquiry is run for a driver code that begins with B; however, the first driver code that begins with an A issues the error. I thought perhaps the subfile size was not large enough and so increased it, but I still get the same error. I tried to do an ISDB on the program, but I did not see a problem with the RRN. Since the programs and file structures have not changed in years, this seems to be related to the number of records or records themselves in the file that is being queried (ACCIDTL3). Any help would be greatly appreciated. Thanks in advance!

  • #2
    Re: Incorrect relative record number error

    just a quick guess there are more than 9999 records in your file.
    once the rrn goes to 10000 then there are *zeros in the RRN and
    KAPOW!

    do a dspfd on the table to get total records.

    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Incorrect relative record number error

      bump..........
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: Incorrect relative record number error

        Yes, I looked at it again today, and there are more than 10,000 records in the file. As soon as the RRN gets to 10,000 it bombs! I increased the length of the RRN in the RPG, but as I understand it, 9999 is the limit for number of records in a subfile. Is there a way around this without deleting records from the file? Thanks!

        Comment


        • #5
          Re: Incorrect relative record number error

          There are a couple things you could do...
          1. make subfile size and subfile page both 14....
          then write code for pageup and pagedown......

          to accomplish this you must track the first and last record written using
          the keys to the file.

          then if the user uses pagedown then you take the 14 rrn on the page and setll
          on the file by that key...clear the subfile and load the next 14 records using read..

          if user uses pageup then you use key values from subfile in RRN 1 setgt by that key and first use readp to read up 14 records...clear the subfile....read 14 records and load the subfile again.


          2. write something llike this

          dow endscreen = 'N'
          exfmt subfilecontrol
          select
          when *in03
          endscreen = 'Y'
          when pagedown
          exsr $loadsfl
          endsl
          enddo

          $loadsfl
          if savrrn > *zeros
          eval rrn =savrrn
          endif

          do 14
          read myfile
          if not%eof(myfile)
          rrn +=1
          write subfile
          endif
          savrrn = rrn
          enddo


          I guess 3. could be

          if rrn < 9999

          eval rrn +=1
          write subfile
          endif
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: Incorrect relative record number error

            Thanks for your help! I took your option 3 as a quick change until I find out if any records can be omitted...and it worked without error! Yay. You are awesome! Thanks again!

            Comment


            • #7
              Re: Incorrect relative record number error

              Originally posted by Renee View Post
              Thanks for your help! ... Yay. You are awesome! Thanks again!
              Please do not feed the bear!
              "Time passes, but sometimes it beats the <crap> out of you as it goes."

              Comment

              Working...
              X