Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Help pls! Error re: update before read

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

  • Help pls! Error re: update before read

    Hello,
    I know I'm missing something very basic, but I'm completely stumped and have been reading everything I can find and have no other resources at the moment. The kicker is this program _used_ to run fine, so anytime I think I've found a reason for it to have failed, I can't see how it was then working originally.
    • File A is a one line file that is used for gathering header data & counts from..
    • File B which takes in a flat file of data with multiple record formats.
    • File A- four new fields added now
    • Program A gathers, parses and fills in File A with the header data as given
    • Program B processes the rest of record data, applies the changes as appropriate to the main account file
      And then (new now) should update File A with it's own gathered counts
    • Both are only used in their own process called on demand. No other users would be accessing them

    Everything compiles fine now, but the program errors out in ProgramA when it goes to update FileA with the error about trying to update a file before reading it. (sorry not at my desk to copy the exact wording)

    Basic code logic
    Code:
    FileA is an Update externally described file
    fileB is internally defined.
    
    Read FileA
    Clear *ALL FileA_Recordname
    
    Read FileB
       dowhile not EOF
          If first character is 'H'
               assign values from FileB into fields from FileA
          EndIf
       endDo
    
    Update FileA_RecordName
    When this started failing, I thought maybe the problem was the new fields in FileA that were not referenced at all in this program, so I added %fields(...) to list only the fields updated here, but still no luck.

    I feel like I'm missing some basic concept of reads & updates or file referencea (and I admit most of my 'education' has been self-inflicted in a very piecemeal situation-based focus only)...
    but if I needed another read for FileA now, how did it ever work in the past?
    I expected runtime errors once I started testing my changes, but I assumed they'd show up in ProgramB which does so much more work... Not this one.

    When the error appears, I know how to find the server job to see the job log, but I see no locks or anything that just jumps out at me like an incorrect library reference or such.

    If anyone can provide any guidance of how else to investigate this or another approach to researching this type of error, it would be just hugely appreciated.
    Thanks!
    Liz

  • #2
    Details updated/clarified

    Since I'm back to a location I could copy the exacts in..

    Error Message :
    Code:
    Message ID . . . . . . :   RNQ1221       Severity . . . . . . . :   99        
    Message type . . . . . :   Inquiry                                            
    Date sent  . . . . . . :   07/31/12      Time sent  . . . . . . :   17:01:32  
                                                                                  
    Message . . . . :   Update or delete in file FILEA without prior input     
      operation (C G D F).                                                        
    Cause . . . . . :   RPG procedure ACSCOUNT in program LIZLIBR/ACSCOUNT at     
      statement 103 tried to update or delete a record in file FILEA without a 
      previous input operation. The actual file is LIZLIBR/FILEA(FILEA).
    Code Logic Clarification:
    Code:
    FileA is an Update externally described file, no key.
    FileB is Input File, necessary fields defined in Input Specs, no key.
    
    Read FileA_RecordName
    Clear *ALL FileA_Recordname
    
    Read FileB
       dowhile not EOF(FileB)
          Select
              When RcdID = 'H'     //first letter of the record
                   assign values from FileB into fields from FileA
              When RcdID <> 'H'
                   Check the value of a single character 
                   add to relevant total count field from FileB of that type
          EndSL
          Read FileB
       EndDo
    
    Update FileA_RecordName
    
    InLR = On
    Alternate Ending:
    Code:
    Version 2:
    
       Update FileA_RecordName %fields([I]all altered in previous code[/I]);
    
    Version 3:
       Assign zero to the four new fields in FileA
       Update FileA_RecordName
    No luck with either..
    Thanks.

    Comment


    • #3
      Aaaand. I feel stupid/like hitting my computer with a brick.

      Basically the problem came down to FileA somehow getting completely emptied out (instead of the fields just clearing the values back to defaults), during one of my earlier test runs, I have to assume. So everything trying to read or update was coming up with nothing. And I just wasn't catching this angle.

      I added a group of lines that checked for opens and add a record if it was empty etc. Then returned the logic back to the original -Read,Clear..do stuff with FILEB.. Update FILEA- and it worked fine even on repetitions..

      So maybe this will help someone else down the road. Thank you anyway!

      Comment

      Working...
      X