Page 1 of 1

Multiple jobs writing to the same sequential file

PostPosted: Sat Jan 25, 2020 6:42 am
by t_bt2
Hello Everyone.

I have a three COBOL programs and want them to writing to a single sequential file simultaneously, as the programs run at the same time.

Is this possible? If so how can I accomplish this?

Thanks in advance for any help.

Re: Multiple jobs writing to the same sequential file

PostPosted: Sat Jan 25, 2020 8:56 am
by steve-myers
Yes, it is possible, but ... the odds are the output will be useless, for several reasons.
  1. There is no mechanism in z/OS data management to ensure the records will be interleaved in the manner I think you expect.
  2. In the event the output is directed to a data set on magnetic tape, the second and subsequent programs that attempt to open the data set while the first program has the data set open will be abnormally terminated.
  3. The end of data for the data set is established by the last program that closes the data set, even if other programs have sent more data to the data set.
  4. Because of the way z/OS writes data to disks, the slower program may well over write data that faster programs have written to the disk.

Re: Multiple jobs writing to the same sequential file

PostPosted: Sat Jan 25, 2020 12:53 pm
by willy jensen
Possible, yes, but complicated.
In assembler I would do something like
test/wait for some agreed-upon resource name then enqueue the resource
open the dataset with the EXTEND option (this allows allocation with disp=shr and still act as if disp=mod was specified)
write
close
dequeue the resource
You need the open and close to flush buffers.
This will be horribly inefficient, but should be safe. And I have no idea if enqueue/dequeue is avaiable for a COBOL program or if the EXTEND option can be used in a COBOL OPEN.
I will much recommend that the programs write to seperate datasets, with a timestamp so that they can be merged afterwards.

Re: Multiple jobs writing to the same sequential file

PostPosted: Sat Jan 25, 2020 2:13 pm
by t_bt2
Thank you both for your replies.

It sounds like having the the three programs write to the same sequential file at the same time is too risky. I'll go with the notion of writing to respective files then add an end of night step that merges the the files at the end of night..

Re: Multiple jobs writing to the same sequential file

PostPosted: Sat Feb 15, 2020 4:52 am
by chaat
If you have IBM BatchPipes installed, you can have multiple jobs write to the same named pipe and a single SORT COPY job reading from that named pipe and writing to an output file. I've not used BatchPipes recently so best to check the documentation.

Chuck Haatvedt