IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to open the same file in two different programs ?


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
smvj007

New User


Joined: 19 Mar 2009
Posts: 1
Location: USA

PostPosted: Sat Apr 04, 2009 8:44 pm
Reply with quote

How to open the same file in two different programs in one execution ?

Here's the situation explained in more detail.

There are two programs, PGM1 and PGM2. PGM1 is in PLI version and PGM2 is in EPL/I version.

These two programs are executed in batch mode through a job.

PGM1 gets kicked off by the job and it opens the file FILE1 in OUTPUT mode and writes some records to the FILE1. After writing some records to the FILE1, without closing the file FILE1, the PGM1 calls PGM2 and PGM2 opens the FILE1 again in OUTPUT mode to write some recods. When the FILE1 is opened in PGM2, the records written to FILE1 by PGM1 are wiped off and FILE1 now has only records written by PGM2. There is no explicit CLOSE for the file FILE1 in PGM2. After PGM2 execution is over, the control goes back to PGM1. The job completes with S414-08 error code. It looks like the PGM1 is attempting to write some of the records to FILE1 stored in the BUFFER storage. It looks like the program is not able to locate the records stored in the buffer storage written by PGM1 and hence the job ends with completion code S414-08.

The description for S414-08 given as

S414 - 08 - FOR A QSAM DATA SET EITHER AN I/O ERROR OCCURRED WHILE
FLUSHING THE BUFFERS DURING CLOSE PROCESSING, OR A CLOSE WAS
ISSUED IN THE CALLER'S SYNAD ROUTINE.


I would like to know how to handle this situation where the same file is opened in both PGM1 and PGM2 and how to correctly get the records written into FILE1 by both program PGM1 and PGM2.

The file FILE1 is a sequential file and it's declared as

DCL FILE1 OUTPUT RECORD ENV(FB RECSIZE(133) CTLASA TOTAL);


The FILE1 in the job is declared as,

//FILE1 DD DSN=AAAA.DSN1.FILE1,
DISP=(NEW,PASS,DELETE),
DCB=(RECFM=FBA,LRECL=133,BLKSIZE=6118),
SPACE=(TRK,(1,5),RLSE),UNIT=TEMPDISK


Please let me know if further information is needed.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Apr 04, 2009 9:15 pm
Reply with quote

maybe:

jcl disp= mod
pgm1 open extend and close it before calling pgm2
pgm 2 open extend and close it before returning to pgm1

or you might get away with external that is used in cobol.

unfortunately, i don't know PL1, so don't know if you have an 'external' type ability
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Apr 05, 2009 8:06 am
Reply with quote

Hello,

Probably not what you'd prefer to hear, but as this process is new (i suspect), you might consider using a vsam file or a database table. . .
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sun Apr 05, 2009 10:16 am
Reply with quote

Quote:
I would like to know how to handle this situation where the same file is opened in both PGM1 and PGM2 and how to correctly get the records written into FILE1 by both program PGM1 and PGM2.
You don't -- you've got a faulty design here. Opening the same sequential file in two programs running at the same time and attempting to write records to the file from both programs is a sure recipe for file corruption and abends. A process redesign is in order. Open the file, write the records, close the file then let the other program at the file to do the same. Or you could use VSAM with share options (but plan on writing enqueue and dequeue logic as well to ensure the file isn't corrupted by your writes).

Writing records to a file is a form of serialization on the file: that's why VSAM shareoption 2 allows as many as desired to READ the file, but only ONE to write the file. Two processes both writing to the file violates serialization and unpredictable results, at best, will occur -- and abends or file corruption are likely.

REDESIGN THE PROCESS!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top