Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Well, yes you could do it with SPLICE. But if you only have one record in file1, it would be easier to do it with DFSORT symbols like this:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file1
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
* Generate a DFSORT Symbol as follows:
* TARG,'yyyymmdd'
* where yyyymmdd is from input file1
INREC BUILD=(C'TARG,''',1,8,C'''',80:X)
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file2
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
* Use TARG symbol in INCLUDE statement
INCLUDE COND=(21,8,CH,EQ,TARG)
/*
If your situation is actually more complicated than that, then show a better example of the records in each input file and what you expect for output. Also, give the RECFM and LRECL of each input file.
The date values in file 1 is distinct, whilst the records in file 2 can occur multiple times for each date. So our results should look something like this:
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
It's not completely clear to me what you want. I'd like a better example so I don't waste time on something that doesn't give you what you want.
It appears the output records should contain the date, the field after the date from file1 and the fields before and after the date from file2. Is that right?
You said you wanted matching records, but you only show matching records for file2 in your example so I'm not sure that's what you actually want.
Please show a better example (all variations - relevant fields only) of the records in each input file and what you want for output. Show matching records and non-matching records. Show all of the output records you expect.
Also, please indicate the starting position, length and format of all relevant fields in the input records and output records.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
If your yyyymmdd value is comp-3 it's a 5-byte PD field. For that you need to use a +yyyymmdd constant rather than a 'yyyymmdd' constant. Here's a DFSORT job that will generate a +yyyymmdd constant. I assumed your PD field starts at position 21. Adjust as needed.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file1
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
* Generate a DFSORT Symbol as follows:
* TARG,+yyyymmdd
* where yyyymmdd is from input file1
INREC BUILD=(C'TARG,+',1,8,80:X)
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file2
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
* Use TARG symbol in INCLUDE statement
INCLUDE COND=(21,5,PD,EQ,TARG)
/*
I have a slightly different requirement here.
Control file will be having a single record with 6 values at defined positions. I need to split the input file into 6 files based on the control file record values. Share some thoughts on this?