View previous topic :: View next topic
Author
Message
saranyan_j New User Joined: 24 May 2006Posts: 7
Hello experts,
We use product DFSORT at our installation and I'm assuming that its quite possible through it.
I have the following input file
Code:
0000000000111111
1223456789123456
----------------
IDEN DATE REST
----------------
ABCD20100810X111
ABCD20100811Y111
ABCD20100710Z111
ZGFG20100810R111
ABCD20100110R111
XXXX20100810R111
YYYY20100810R111
YYYY20100710R111
I would like to put the least value of DATE (Colum 5-13) in all records containing similar IDEN(colum 1 - 4 ).
Further more I would like to make this change only for IDEN=ABCD
The output file should be like this
Code:
ABCD20100110R111
ABCD20100110X111
ABCD20100110Y111
ABCD20100110Z111
XXXX20100810R111
YYYY20100710R111
YYYY20100810R111
ZGFG20100810R111
Many thanks in advance
Saran
Back to top
sqlcode1 Active Member Joined: 08 Apr 2010Posts: 577 Location: USA
Saran,
What is the LRECL and RECFM of the input file? Is this already sorted by IDEN(colum 1 - 4 )?
Thanks,
Back to top
saranyan_j New User Joined: 24 May 2006Posts: 7
The file is FB with LREC of 16. It is not sorted by IDEN.
Back to top
sqlcode1 Active Member Joined: 08 Apr 2010Posts: 577 Location: USA
saranyan_j
Because your input is not already sorted and you want final output sorted by 12-16 ASC as well (or atleast that's what you show). I can't think of a solution with single pass.
Code:
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABCD20100810X111
ABCD20100811Y111
ABCD20100710Z111
ZGFG20100810R111
ABCD20100110R111
XXXX20100810R111
YYYY20100810R111
YYYY20100710R111
/*
//SORTOUT DD DSN=&&TEMP,DISP=(,PASS),SPACE=(CYL,(5,5),RLSE)
//SYSIN DD *
SORT FIELDS=(1,4,CH,A,5,8,CH,A)
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(17:SEQNUM,8,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=GROUP,BEGIN=(17,8,ZD,EQ,1),PUSH=(25:5,8))
OUTFIL IFTHEN=(WHEN=(1,4,CH,EQ,C'ABCD'),
BUILD=(1,4,25,8,13,4)),
IFTHEN=(WHEN=NONE,
BUILD=(1,16))
/*
//STEP02 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&TEMP,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,16,CH,A)
/*
Thanks,
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Saran,
Here's an easier way to do what you asked for with DFSORT:
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file1 (FB/16)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,4,CH,EQ,C'ABCD')
OUTFIL REMOVECC,NODETAIL,BUILD=(80X),
TRAILER1=('TARG,''',MIN=(5,8,ZD,TO=ZD,LENGTH=8),'''')
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file1 (FB/16)
//SORTOUT DD DSN=... output file (FB/16)
//SYSIN DD *
INREC IFTHEN=(WHEN=(1,4,CH,EQ,C'ABCD'),
OVERLAY=(5:TARG))
SORT FIELDS=(1,16,CH,A),EQUALS
/*
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
Unless I am missing something, can't it be done in just 1 pass?
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABCD20100810X111
ABCD20100811Y111
ABCD20100710Z111
ZGFG20100810R111
ABCD20100110R111
XXXX20100810R111
YYYY20100810R111
YYYY20100710R111
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,16,CH,A),EQUALS
OUTREC IFOUTLEN=16,
IFTHEN=(WHEN=INIT,OVERLAY=(17:SEQNUM,8,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'ABCD',AND,17,8,ZD,EQ,1),
END=(1,4,CH,NE,C'ABCD'),PUSH=(26:5,8)),
IFTHEN=(WHEN=(1,4,CH,EQ,C'ABCD'),OVERLAY=(5:26,8))
//*
Back to top
sqlcode1 Active Member Joined: 08 Apr 2010Posts: 577 Location: USA
Kolusu,
I ran your job and got below output but OP's expected output was sorted on last 4 bytes as well. That's why I thought of another pass to resort the file.
SINGLE PASS OUTPUT
Code:
ABCD20100110R111
ABCD20100110Z111
ABCD20100110X111
ABCD20100110Y111
XXXX20100810R111
YYYY20100710R111
YYYY20100810R111
ZGFG20100810R111
OP's expected output was
Code:
ABCD20100110R111
ABCD20100110X111 --> THIS APPEARS 3RD IN SINGLE PASS SOL.
ABCD20100110Y111 --> THIS APPEARS 4TH IN SINGLE PASS SOL.
ABCD20100110Z111
XXXX20100810R111
YYYY20100710R111
YYYY20100810R111
ZGFG20100810R111
Thanks,
Back to top
saranyan_j New User Joined: 24 May 2006Posts: 7
Dear Experts,
Thanks again for your reply, all the above worked just fine.
Howevere I opted to use the one with the single pass since the order of records in the O/P were not important.
Thx,
Saran
Back to top
Please enable JavaScript!