I'm able to save the UNPAIRED records to SORTOUT (this is what I want) using the following:
//SORT EXEC PGM=SORT,PARM='DYNALLOC=(SYSDA,255)'
//SORTMSGS DD SYSOUT=*
//SORTJNF1 DD DSN=FILE1,
// DISP=OLD,DCB=BUFNO=255
//SORTJNF2 DD DSN=FILE2,
// DISP=OLD,DCB=BUFNO=255
//SORTOUT DD DSN=FILEOUT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=(SYSDA,59),
// SPACE=(CYL,(500,100),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(25,4,A,115,20,A,135,4,A,140,4,A,5,20,A)
JOINKEYS FILE=F2,FIELDS=(5,4,A,9,20,A,29,4,A,33,4,A,37,20,A)
JOIN UNPAIRED,F2,ONLY
but I need to save the PAIRED records to a separate file. I tried the following statement but the PAIRED records don't get saved in my PAIRED file:
//SORT EXEC PGM=SORT,PARM='DYNALLOC=(SYSDA,255)'
//SORTMSGS DD SYSOUT=*
//SORTJNF1 DD DSN=FILE.F1,
// DISP=OLD,DCB=BUFNO=255
//SORTJNF2 DD DSN=FILE.F2,
// DISP=OLD,DCB=BUFNO=255
//SORTOUT DD DSN=FILE.SORTOUT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=(SYSDA,59),
// SPACE=(CYL,(500,100),RLSE)
//PAIRED DD DSN=FILE.PAIRED,
// DISP=(NEW,CATLG,DELETE),
// UNIT=(SYSDA,59),
// SPACE=(CYL,(500,100),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(25,4,A,115,20,A,135,4,A,140,4,A,5,20,A)
JOINKEYS FILE=F2,FIELDS=(5,4,A,9,20,A,29,4,A,33,4,A,37,20,A)
JOIN UNPAIRED,F2,ONLY
OUTFIL FNAMES=SORTOUT
OUTFIL FNAMES=PAIRED,SAVE
Edit 1: OP has mentioned (in the comments section of this answer), "I only want to keep the UNPAIRED records (F2 only) in my main SORTOUT dataset, and the PAIRED records (F2 only) in my PAIRED dataset." Paired records mean both F1 & F2. OP is basically looking for RIGHT JOIN. The SORT statements provided below are edited as per OP's requirement. Note that a
REFORMAT
statement is required unless aJOIN
statement with theONLY
operand is specified.You must use a method in Syncsort (which is called as indicator method in dfsort), to acheive what you're expecting. See below SORT statements.
where,
p
- The position value indicates the first byte of the field relative to the beginning of the input record.l
- The length value indicates the length of the field.Observe the
?
in theREFORMAT FIELDS
statement.Quote from Syncsort for z/OS Programmer's guide:
More details:
Hope this helps!