ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Query regarding Subfiles in Cobol

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

  • Query regarding Subfiles in Cobol

    Hi guys, need a little bit of clarification on how subfiles are handled by the cobol compiler as I am more of a RPG person.

    Now heres how the flow is:-
    1.) Subfile records displayed
    2.) User takes option 2 against a record
    3.) A normal record format is displayed with more details
    4.) User takes F6 on this screen and a new subfile is displayed which has related information

    Now the problem I am facing is, once i return to the first subfile and try to do a rewrite on the subfile record, i get an error (Cobol File Status 24). This is only when i go to the second subfile and come back.

    I am guessing this is because I am trying to update a record which is no longer locked? The reason for me to go along these lines is that, in cobol we associate the subfile rrn field to the file rather than individual subfile record formats like in RPG. So this might have reset all the indicators and locks of the first subfile when I do my operations with the second one. Is this correct or the reason might be something else.

    Do let me know. If needed i can post the code but the person who has written this program has done an extremely good job of using GOTOs which is currently affecting the flow when we try to add in the new functionalities.

  • #2
    Re: Query regarding Subfiles in Cobol

    Agreed. If the multiple screens/subfiles are being handled in the same program, its very likely that your subfile RRN from the initial subfile is being lost or overwritten upon return from the second
    subfile's logic path.

    Simple solution is to create a variable of s9(5) to save the current RRN prior to executing any secondary screen logic. I do this often in complex maintenance screens...

    Terry

    Comment


    • #3
      Re: Query regarding Subfiles in Cobol

      Thanks a lot a Terry, I did exactly what you suggested and it worked. Basically used the relative key field to reposition back to the record and acquired the lock before doing the rewrite.

      @#%@#%@#%@#% i need to remember regarding this error for COBOL. Atleast RPG would tell me that am trying to update/delete without a prior read while all i got here was a file status 24 which indicates theres some boundary violation of some sort.
      Last edited by vikramx; April 1, 2009, 08:58 AM.

      Comment

      Working...
      X