-1

I am scratching my head trying to solve this issue.

I have a two subfiles. Basically what i'm trying to achieve is to select a record from the subfile with an option.

This will then call another program which is basically a copy of the previous program.

What im trying to achieve. Select the record I want and then call the next program which will display all the current records and omit the read record.

Refer to image below to see the subfile display First Subfile

Currently if I enter the second program it will enter an unspecified error as it reads the LF file at the last record.

The two programs are using the same LF file which is pointing to the same PF and also the same SDA subfile. The two programs are basically identicals but I've set conditions to omit it based on the accnumber. When that didnt work i tried using a counter which is the previous programs RRN. That didn't work as well. I'm at wits end right now.

FACCDLF5   UF A E           K DISK    
FSDAFUND   CF   E             WORKSTN 

This is my file declaration

C     PARMCUSTID    CHAIN(N)  ACCDLF5                                             
C                   IF        %FOUND()    
C     PARMCUSTID    DOWEQ     QCUSTCHK   
C                   EXSR      FETCH1               
C                   ADD       1             RRN    
C                   MOVE      RRN           RRN2   
C                   WRITE     DTLTTEL              



C     FETCH1        BEGSR                               
C                   MOVE      ACCNUMBER     SACCNUM1    
C                   READ      ACCDLF5                   
C                   MOVE      CUSTID        QCUSTCHK    
C                   ENDSR                               

Is there something im missing. If i do another solution By Passing the Parm of the RRN over to the second program Subsequently doing a code as shown below before performing the fetch it works, however it omits one record. Doing the original code as the previous program will encounter an error.

C*    RRN2          SUB       1             RRN2     
C                   IF        %FOUND()               
C     RRN           DOUEQ     RRN2                   

Anyone know why that is.. The chain is not locking the PF file... Its been 2 hours debugging and using every method i know at hand.

  • I'm having a hard time understanding what you are asking here. Please edit the question to provide clarity. First problem is in the title. it sounds as if you are trying to read the same subfile in two different programs. But a subfile is a display file object, and each program has it's own unique display file unless you override it with SHARE(*YES) did you do that? – jmarkmurphy Aug 28 '23 at 14:59
  • "I have a two subfiles. Basically what i'm trying to achieve is to select a record from the subfile with an option." Which subfile? This is ambiguous. Do you have one subfile with an option field, and one without? What do you mean by you want to select a record? Are you speaking as the user, or as the programmer? Are you trying to decide how to read the record that the user selected? – jmarkmurphy Aug 28 '23 at 15:06
  • I have a feeling that you are not telling us the real requirements, but rather your interpretation of how to achieve the requirements. It also looks like you have a number of issues going on here. Pick one problem and ask a clear question about that. Include information about what you have tried, what you expected to happen, and what the result or error messages were. – jmarkmurphy Aug 28 '23 at 15:13
  • I have two identical subfiles One is calling another subfile based on an option. The second subfile will receive the option, Pass the accountnumber as a parm and then the following subfile will do the same logic as the previous subfile but even if do a check to not write the accountnumber from subfile1 based on the check, the reading of the pf encounters an error. – Anchor Man Aug 28 '23 at 15:20
  • Are the records locked in the first program? what is the error? – jmarkmurphy Aug 28 '23 at 15:31
  • Both first subfile program and second subfile program are using Chain(n). However it is the same LF file. Is that why its locked. Maybe i should just add the accnumbers into a data array and substring it to fill my second subfile. That will be so counter intuitive though. – Anchor Man Aug 28 '23 at 15:44
  • What is the error? If you are using Chain(n), it shouldn't be locked. – jmarkmurphy Aug 28 '23 at 21:30
  • The code you posted does a `READ` _with LOCK_ in `FETCH1`, presumably at the end of the loop the first PGM locks the first record with key > `PARMCUSTID` and never frees it. So if the second PGM tries the same it must fail there. Am I wrong ? – nfgl Aug 29 '23 at 09:17

0 Answers0