'How to create a file with two entries in COBOL?

I have two files, the first one has the date and the second one has multiple registers. I want to create something like this:

Input File 1:

20200509

Input File 2:

0000001
0000002
0000003

Output

202005090000001
202005090000002
202005090000003

Thank u.



Solution 1:[1]

Build a record of two fields. I will not give you picture clauses. Read file one and populate field one. (end of field one stuff). Read file two and for each record, populate field two and write an output record.

Field one never changes?

Look into JOINKEYS (FILL?) if you get a moment and your shop has it.

And the record in File one should probably be a parameter.

Yes you will need to open and close the files, use filestat, and understand what a priming read is.

If you don't mind bad style and ANS COBOL c. 1972 see https://github.com/mckenzm/join2files/blob/main/stackex1.cbl

(No filestat, no exception (empty file) handling.)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1