I need to compare two PS files and get the matching records from file 2 in output but one of the Input is CSV file. Input records looks something like below
Input1:
XXXXXXXXXXXXXXKKKKKKKKKKYYYYYYYYYY........
It's a FB file with LREC of 528 and key position is from 15 to 24. File1 will not have duplicates
Input2: It contains header in 1st row and then records
It's a FB file with LREC of 200. Key position is not fixed as it is csv file.File 2 may contain duplicates, I need to get those all duplicate records in output(if matching record is found in file1). of course it should exclude header record while comparing but in output I need header as in file 2.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
I've tested (lightly) with 80-byte records.
First step generates a "header" indicator in the position of the key of the fixed-layout file.
That dataset is the first IN1 dataset, with the main dataset concatenated to it.
The key for the variable-format file is inserted at the front of each record, in first 10 bytes.
The REFORMAT gets the data from the original variable-format record for each matched output record.
The file header does not have to be created, as it is forced to "match" through the inclusion of the header from the firs step.
Code:
//HDRGEN EXEC PGM=SORT
//SORTIN DD dsn=same input as main file, but only one record read, to get dcb info for output and overlay for the header to concatenate
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=&&HEADER,UNIT=SYSDA,SPACE=(TRK,1),DISP=(,PASS)
//SYSIN DD *
OPTION COPY,STOPAFT=1
OUTFIL OVERLAY=(15:C'ACTION ')
//MTCHFILE EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *