ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Subfile Record Not Found error/ or SFLNXTCHG?

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

  • Subfile Record Not Found error/ or SFLNXTCHG?

    OK... Uncle already..

    I'm working on a program that gives an error message that says 'Subfile Record Not Found'. All of the research that I've done seems to indicate that this condition is usually caused by misuse of the READC Opcode in RPG. I can find nothing wrong with the way that the READC is coded compared to the way that it is recommended.

    So, I began to suspect the way that the SLFNXTCHG was coded. Initially, there were no indicators on it in the DDS, so I tagged an indicator to it, set it off before loading the subfile, and setting it back on on error conditions before update and so forth. This solved the problem of not getting that error, but simply because the program is treating it as though no changes are made to the subfile, and we bail out of the routine. This would suggest that the SFLNXTCHG indicator is not being turned on when a change is made.

    So, I took out all of the 'setoffs' of the indicator in the program, and debugged it. No help, still no indicator being turned on. What is puzzling me is how come the indicator is not comming on at all when I make a change to the screen? I have verified this via Debugs.

    Here is some of the code to chew on. NOTE: I cannot take blame/credit for it as I'm not the author of this program...I just got tapped to make a simple change to it!

    DDS...

    A 55 SFLNXTCHG

    Again...Originally, there was no indicator here..

    RPG...

    PHP Code:
    C     NEXTS1        BEGSR                                              
    C
    *                                                                     
    C                   MOVE      *OFF          UPFLG                      
    C                   MOVE      
    *ON           *IN40                      
    C     RRN1          IFGT      
    *ZEROS                                   
    C
    *                                                                     
    C                   MOVE      *OFF          *IN98                      
    C     
    *IN98         DOWEQ     *OFF                                     
    C     
    *IN03         ANDEQ     *OFF                                     
    C                   READC     BF607411                               98
    C     
    *IN98         IFEQ      *OFF                                     
    C
    ****               eval      *in55=*off                               
    C
    *    OPTN1         IFEQ      2                                        
    C
    *    OPTN1         OREQ      5                                        
    C                   
    if        (optn1 and apprv@ <> Approved        
    C                              
    and apprv@ <> SubApproval)              
    c                             or optn1 5                             
    C                   MOVE      MODE          HMODE                      
    C                   MOVE      
    *IN29         HIN29                      
    C                   Z
    -ADD     OPTN1         HOPTN1                     
    C                   Z
    -ADD     *ZEROS        OPTN1                      
    C                   UPDATE    BF607411                         
    C     HOPTN1        IFEQ      5                                
    C                   MOVE      
    *ON           *IN29              
    C                   MOVEL     
    'Display'     MODE               
    C                   
    ENDIF                                      
    C                   EXSR      SCRN02                           
    C                   MOVE      HMODE         MODE               
    C                   MOVE      HIN29         
    *IN29              
    C                   
    ENDIF                                      
    C     OPTN1         IFEQ      4                                
    C                   Z
    -ADD     OPTN1         HOPTN1             
    C                   Z
    -ADD     *ZEROS        OPTN1              
    C                   UPDATE    BF607411                         
    C
    Send a Status Message                                       
    C                   CALL      
    'MSX081CL'                       
    C                   PARM      '1'           MSSTS             1
    C                   PARM      MSG
    (2)        MSDTA           132
    C                   EXSR      DELETE                           
    C                   CALL      
    'MSX081CL'                       
    C                   PARM      '1'           MSSTS             1
    C                   PARM      MSG
    (3)        MSDTA           132
    C                   
    ENDIF                                     
    C                   If        OPTN1 and (apprv@ = Approved
    C                              
    or apprv@ = SubApproval)       
    C                   Z-ADD     OPTN1         HOPTN1            
    C                   EXSR      SR_AprvlUpd                     
    C                   
    Eval      OPTN1 0                       
    C                   UPDATE    BF607411                        
    C                   
    ENDIF                                     
    C*                                                            
    C                   ENDIF                                     
    C                   ENDDO                                     
    C
    *                                                            
    CRefresh the screen                                         
    C     UPFLG         IFEQ      
    *ON                             
    C                   EXSR      POSTS1                          
    C                   
    ENDIF                                     
    C*                                                            
    C                   ENDIF                                     
    C*                                                            
    C                   MOVE      *OFF          DLTFG1            
    C                   MOVE      
    *OFF          DLTFG2 
    C                   ENDSR 
    Probably more code than what is needed, and I removed that Setof of 55 as I just want to confirm that I'm not erroneously turning it off.

    Cheers! - BS

  • #2
    Re: Subfile Record Not Found error/ or SFLNXTCHG?

    <edit> sorry i had a miscount of if's ignore this.....*in98 gets set on when there are no more changed records to be read. The endif for the *in98 test is before OPTN1 = 4 test. (i think)
    If optn 4 or 6 were the last options taken before the last successful readc......BOOM.....< / edit >

    Best of Luck
    GLS

    BTW if you place your code between [ code] and [ / code ] (no spaces) markers it will actually be readable
    Last edited by GLS400; April 19, 2010, 08:57 AM.
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: Subfile Record Not Found error/ or SFLNXTCHG?

      Thanx GLS,

      I took your advice, but no cigar.. After further review, The ENDIF that is paired with the *in98 test is the one right before the ENDDO. Yeah, all of those IFs and such is what I first suspected and looked at.

      Thanks for the tip regarding [ code ] [/code] I'll use 'em.

      Testing..

      Code:
      2360.00 C     NEXTS1        BEGSR                                              
      2361.00 C*                                                                     
      2362.00 C                   MOVE      *OFF          UPFLG                      
      2363.00 C                   MOVE      *ON           *IN40                      
      2364.00 C     RRN1          IFGT      *ZEROS                                   
      2365.00 C*                                                                     
      2366.00 C                   MOVE      *OFF          *IN98                      
      2367.00 C     *IN98         DOWEQ     *OFF                                     
      2368.00 C     *IN03         ANDEQ     *OFF                                     
      2369.00 C                   READC     BF607411                               98
      2370.00 C     *IN98         IFEQ      *OFF                                     
      - - - - ------------ 39 data records excluded ---------------------------------
      2410.00 C*                                                                     
      2411.00 C                   ENDIF                                              
      2412.00 C                   ENDDO

      Comment


      • #4
        Re: Subfile Record Not Found error/ or SFLNXTCHG?

        Can you give the exact error code and message you are receiving, and which line is generating the error?

        The typical reasons for receiving a subfile record not found is because you are chaining to a non-existent record (ie, your subfile record number is set to zero or to a value higher than exists in the subfile) or you are chaining to a subfile record that was deleted. By seeing which line ( and opcode ) that generated the error, we will have a better idea of what failed.
        Michael Catalani
        IS Director, eCommerce & Web Development
        Acceptance Insurance Corporation
        www.AcceptanceInsurance.com
        www.ProvatoSys.com

        Comment


        • #5
          Re: Subfile Record Not Found error/ or SFLNXTCHG?

          Hi Michael,

          I do not know the exact statement that is causing the error, and that's a big reason that I've humbly submit this puzzle to the participants of this forum. In previous efforts, I've tried code to limit the number of READC executions to only be the number of actual records in the subfile. No help.

          The program is not hardhalting, so I do not get a dump that would tell us exactly where the error is, but it would have to be at that READC (right?). Here is some more information that might help us get to the bottom of it. What happens is that the subfile is displayed with one input capable field, an option, (ex. 2=change) I select a given record with a 2, and it works fine... I get to my subsequent change screens and such, but it when the subfile is redisplayed after the maintenance screens, THAT is when the error appears. (Maybe this is my problem.. We DON"T want to read the subfile at this point just redisplay it? Hmm... I'll investigate.)

          Anyway, the message is loaded/displayed in a message subfile at the bottom of the screen. It really doesn't *hurt* anything, but it bothers me, and I'd like to find and fix the cause of it. Does this info help?

          My change has absolutely nothing to do with this...Just trying to right a wrong that is currently in place. Famous last words, eh?

          Comment


          • #6
            Re: Subfile Record Not Found error/ or SFLNXTCHG?

            Oops... Nevermind what I said about 'redisplaying' the subfile... The problem occurs as it continues on thru the READC loop as I posted earlier. Sorry for the confusion... I've been looking at this for a long time...is it almost Friday?

            Comment


            • #7
              Re: Subfile Record Not Found error/ or SFLNXTCHG?

              here's your problem, the very first thing you do is update the subfile record from the READC, this releases the lock on the subfile record, then after you process the selected action, you try to UPDATE that subfile record again. remove this code (except for the IF condition i just added that so you would know what code i was referring to) and you will not get the error since the SFL record will still be locked for update.
              Code:
              C                   if        (optn1 = 2 and apprv@ <> Approved        
              C                              and apprv@ <> SubApproval)              
              c                             or optn1 = 5                             
              C                   MOVE      MODE          HMODE                      
              C                   MOVE      *IN29         HIN29                      
              C                   Z-ADD     OPTN1         HOPTN1                     
              C                   Z-ADD     *ZEROS        OPTN1                      
              C                   UPDATE    BF607411
              also i would change all of those frigging IF statements to a SELECT/WHEN.
              Code:
                                                   
              C                   MOVE      MODE          HMODE                      
              C                   MOVE      *IN29         HIN29                      
              C                   Z-ADD     OPTN1         HOPTN1                     
              C                   Z-ADD     *ZEROS        OPTN1                      
              C*                   UPDATE    BF607411              
              C                   SELECT           
              C     HOPTN1        WHENEQ      5                                
              C                   MOVE      *ON           *IN29              
              C                   MOVEL     'Display'     MODE               
              C*                                                         
              C                   EXSR      SCRN02                           
              C                   MOVE      HMODE         MODE               
              C                   MOVE      HIN29         *IN29              
              C                                                     
              C     OPTN1         WHENEQ      4                                
              C                   Z-ADD     OPTN1         HOPTN1             
              C                   Z-ADD     *ZEROS        OPTN1              
              C                   UPDATE    BF607411                         
              C* Send a Status Message                                       
              C                   CALL      'MSX081CL'                       
              C                   PARM      '1'           MSSTS             1
              C                   PARM      MSG(2)        MSDTA           132
              C                   EXSR      DELETE                           
              C                   CALL      'MSX081CL'                       
              C                   PARM      '1'           MSSTS             1
              C                   PARM      MSG(3)        MSDTA           132
              C                                                        
              C                   WHEN      OPTN1 = 6 and (apprv@ = Approved
              C                              or apprv@ = SubApproval)       
              C                   Z-ADD     OPTN1         HOPTN1            
              C                   EXSR      SR_AprvlUpd                     
              C                   Eval      OPTN1 = 0                       
              C                   UPDATE    BF607411                        
              C                   ENDSL
              then if you need to add more options the code is a) less cluttered, b) more efficient (with select as soon as a matching criteria is met it skips the other conditions and does not check them, with IF it evaluates EVERY condition even if the necessary processing has occurred). Also since you intend to do an update to the subfile record you only need to have a single UPDATE BF607411 after the ENDSL statement instead of having it in every WHEN block (same goes for the IF statements as well).
              I'm not anti-social, I just don't like people -Tommy Holden

              Comment


              • #8
                Re: Subfile Record Not Found error/ or SFLNXTCHG?

                Tom:

                I'm seeing only 1 update per option. Options 2 or 5/4/and 6 each do an update but are contained within an IF group.
                I'm thinking one of the called sub-routines is messing it up (subr02/delete/sr_aprvlupd/posts1) by either doing a second update or re-loading the subfile.

                I agree that a select and a single update would be a huge improvement.

                GLS
                The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                Comment


                • #9
                  Re: Subfile Record Not Found error/ or SFLNXTCHG?

                  Originally posted by birdschmitt View Post

                  The program is not hardhalting, so I do not get a dump that would tell us exactly where the error is, but it would have to be at that READC (right?).
                  I doubt the ReadC is causing the issue, as the program would not attempt to READC a subfile record that does not exist. It is likely occurring on an update or chain to the subfile.
                  Michael Catalani
                  IS Director, eCommerce & Web Development
                  Acceptance Insurance Corporation
                  www.AcceptanceInsurance.com
                  www.ProvatoSys.com

                  Comment


                  • #10
                    Re: Subfile Record Not Found error/ or SFLNXTCHG?

                    Originally posted by GLS400 View Post
                    Tom:

                    I'm seeing only 1 update per option. Options 2 or 5/4/and 6 each do an update but are contained within an IF group.
                    I'm thinking one of the called sub-routines is messing it up (subr02/delete/sr_aprvlupd/posts1) by either doing a second update or re-loading the subfile.

                    I agree that a select and a single update would be a huge improvement.

                    GLS
                    true...that just kinda proves my point. at a cursory glance (which was all i did...i know bad idea) all the IF blocks, etc. i didn't really see that was the case but that's my problem but i do agree that something has to be unlocking the subfile record prior to the update. it would be much less guesswork if we had the complete source to look at. (my fixed format skills are going out the window as well...after a few years of nothing but free-format i'm spoiled )
                    I'm not anti-social, I just don't like people -Tommy Holden

                    Comment


                    • #11
                      Re: Subfile Record Not Found error/ or SFLNXTCHG?

                      Thanks for all of your efforts, I trully appreciate them. Yeah, I know what y'all mean about those if structures and I figured I'd get dinged on it so was the reason for my earlier disclaimer. Just playing the hand that I'm dealt. Are you sure that you want to see the whole program? It gets no better!

                      Hopefully, this will help.. I'm using the '2' (optn1 = 2) option on the 1st subfile record, so it's executing that 1st 'if' group. I followed the code thru and did not find any instances of there being other processing to the subfile in question. However, and here's what I am most puzzled by, since that is the only subfile record that has truly changed, why does it continue to execute the READC over *all* of the records in the subfile? I would have expected that the second iteration of READC would have effectively resulted in an EOF condition, and *IN98 being set on.

                      Here may be another clue... Once time I did set the OPTN1 to '2' on the 1st and 3rd subfile records and hit 'enter'. It displayed the the detail data for the 1st item, and I made my changes, and entered through. Now, on to the next selected record. It displayed the detail screen for that item, but showed the 'SUBFILE RECORD NOT FOUND' error in the message subfile at the bottom of that detail screen! Real weird, but perhaps a clue?

                      BS

                      Comment


                      • #12
                        Re: Subfile Record Not Found error/ or SFLNXTCHG?

                        but showed the 'SUBFILE RECORD NOT FOUND' error in the message subfile at the bottom of that detail screen! Real weird, but perhaps a clue?
                        Sounds like it's your program's message not a system message. Look to see where that message is being processed!

                        Best of Luck
                        gls
                        GLS
                        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                        Comment


                        • #13
                          Re: Subfile Record Not Found error/ or SFLNXTCHG?

                          I would put the program in debug mode and step through it to see what condition, line number, and opcode is generating that message.
                          Michael Catalani
                          IS Director, eCommerce & Web Development
                          Acceptance Insurance Corporation
                          www.AcceptanceInsurance.com
                          www.ProvatoSys.com

                          Comment


                          • #14
                            Re: Subfile Record Not Found error/ or SFLNXTCHG?

                            Found the bug, and SQUASHED it!

                            As some of you have alluded to, the problem was in the processing of a different subfile, not the one where the error was shown. Long story short, there is a pop-up window which contains another subfile that appears under certain conditions. After this one is loaded, and the EXFMT is executed, the author of this code set up a loop to process the subfile that chained to the subfile and conditioned the DO on the indicator associated with the chain being off. So, if there were 10 records in the subfile, the RRN was incremented one more time after processing record 10, making it 11, and does the CHAIN. The chain is unsuccessful, indicator 70 set on and we're done with the loop. The problem is, that 11th chain is what throws the 'Subfile not found' error.

                            The solution is to consider the number of records in the subfile as part of the DO loop.

                            Thanks for all of your help! - BS

                            Comment

                            Working...
                            X