View previous topic :: View next topic
Author
Message
mishra New User Joined: 21 Feb 2007Posts: 3 Location: india
We have a scenario wherein there are a set of department IDs(maximum of 10 departments allowed) seperated by semicolon and followed by some data in the input file:
I/P file:
200;201 AAA
204;205;206;207 BBB
208 CCC
We need to write each of the department along with the info in separate lines as given below sorted on dept ID:
O/P file:
200 AAA
201 AAA
204 BBB
205 BBB
206 BBB
207 BBB
208 CCC
Are there any possiblities of achieving the above using only JCl sort instead of going for a separate EZT or REXX program?
Back to top
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006Posts: 6966 Location: porcelain throne
no, this is a syncsort forum,
there is a dfsort forum,
also in this forum (snycsort, CA-SORT)
but we have no specialists in JCL sort.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Recfm/lrecl of input and output?
Yes, it can be done.
Back to top
mishra New User Joined: 21 Feb 2007Posts: 3 Location: india
Both Input and output are FB format.
The input file length for the given example is 43 bytes (as multiple dept allowed dept filed length is 39 bytes+1 space+3 bytes) and the output LRECL will be 7.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Use the lack of seperator to determine how many records you want going out and where your other data is.
You'll need about 10 IFTHENs on OUTFIL so you can use the "/" slash-operator to output multiple records.
Back to top
Naish New User Joined: 07 Dec 2006Posts: 82 Location: UK
Have used OP's data and also assuming the fixed position of data separated by semicolon:
Code:
//STEP001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
200;201 AAA
204;205;206;207 BBB
208 CCC
123;122;121;120 DDD
000;111;222;333;444;555;666;777;888;999 EEE
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC PARSE=(%01=(STARTAFT=C' ',FIXLEN=3)),
BUILD=(1:1,43,45:%01)
OUTFIL IFOUTLEN=7,
IFTHEN=(WHEN=(4,1,CH,EQ,X'40'),
BUILD=(1:1,3,5:45,3)),
IFTHEN=(WHEN=(8,1,CH,EQ,X'40'),
BUILD=(1:1,3,5:45,3,/,
1:5,3,5:45,3)),
IFTHEN=(WHEN=(12,1,CH,EQ,X'40'),
BUILD=(1:1,3,5:45,3,/,
1:5,3,5:45,3,/,
1:9,3,5:45,3)),
IFTHEN=(WHEN=(16,1,CH,EQ,X'40'),
BUILD=(1:1,3,5:45,3,/,
1:5,3,5:45,3,/,
1:9,3,5:45,3,/,
1:13,3,5:45,3)),
IFTHEN=(WHEN=(20,1,CH,EQ,X'40'),
BUILD=(1:1,3,5:45,3,/,
1:5,3,5:45,3,/,
1:9,3,5:45,3,/,
1:13,3,5:45,3,/,
1:17,3,5:45,3)),
IFTHEN=(WHEN=(24,1,CH,EQ,X'40'),
BUILD=(1:1,3,5:45,3,/,
1:5,3,5:45,3,/,
1:9,3,5:45,3,/,
1:13,3,5:45,3,/,
1:17,3,5:45,3,/,
1:21,3,5:45,3)),
IFTHEN=(WHEN=(28,1,CH,EQ,X'40'),
BUILD=(1:1,3,5:45,3,/,
1:5,3,5:45,3,/,
1:9,3,5:45,3,/,
1:13,3,5:45,3,/,
1:21,3,5:45,3,/,
1:25,3,5:45,3)),
IFTHEN=(WHEN=(32,1,CH,EQ,X'40'),
BUILD=(1:1,3,5:45,3,/,
1:5,3,5:45,3,/,
1:9,3,5:45,3,/,
1:13,3,5:45,3,/,
1:17,3,5:45,3,/,
1:21,3,5:45,3,/,
1:25,3,5:45,3,/,
1:29,3,5:45,3)),
IFTHEN=(WHEN=(36,1,CH,EQ,X'40'),
BUILD=(1:1,3,5:45,3,/,
1:5,3,5:45,3,/,
1:9,3,5:45,3,/,
1:13,3,5:45,3,/,
1:17,3,5:45,3,/,
1:21,3,5:45,3,/,
1:25,3,5:45,3,/,
1:29,3,5:45,3,/,
1:33,3,5:45,3)),
IFTHEN=(WHEN=(40,1,CH,EQ,X'40'),
BUILD=(1:1,3,5:45,3,/,
1:5,3,5:45,3,/,
1:9,3,5:45,3,/,
1:13,3,5:45,3,/,
1:17,3,5:45,3,/,
1:21,3,5:45,3,/,
1:25,3,5:45,3,/,
1:29,3,5:45,3,/,
1:33,3,5:45,3,/,
1:37,3,5:45,3))
O/P:
Code:
200 AAA
201 AAA
204 BBB
205 BBB
206 BBB
207 BBB
208 CCC
123 DDD
122 DDD
121 DDD
120 DDD
000 EEE
111 EEE
222 EEE
333 EEE
444 EEE
555 EEE
666 EEE
777 EEE
888 EEE
999 EEE
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
You don't need all the columns, it makes it easier to read without them, but it'll do, Naish. Let's hope you get some thanks from the TS, even saved him the typing :-)
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
Naish,
Very good work indeed
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct,2010), you can now use the new RESIZE operator of DFSORT's ICETOOL to easily create larger records from smaller records, or smaller records from larger records.
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
200;201 AAA
204;205;206;207 BBB
208 CCC
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
209;111;222;333;444;555;666;777;888;999 000
//OUT DD SYSOUT=*
//TOOLIN DD *
RESIZE FROM(IN) TO(OUT) TOLEN(7) USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ENDBEFR=C' ',FIXLEN=40),%02=(FIXLEN=3)),BUILD=(%01,%02)),
IFTHEN=(WHEN=INIT,
PARSE=(%03=(ENDBEFR=C';',FIXLEN=3),%04=(ENDBEFR=C';',FIXLEN=3),
%05=(ENDBEFR=C';',FIXLEN=3),%06=(ENDBEFR=C';',FIXLEN=3),
%07=(ENDBEFR=C';',FIXLEN=3),%08=(ENDBEFR=C';',FIXLEN=3),
%09=(ENDBEFR=C';',FIXLEN=3),%10=(ENDBEFR=C';',FIXLEN=3),
%11=(ENDBEFR=C';',FIXLEN=3),%12=(ENDBEFR=C';',FIXLEN=3)),
BUILD=(%03,X,41,3,%04,X,41,3,%05,X,41,3,%06,X,41,3,%07,X,41,3,
%08,X,41,3,%09,X,41,3,%10,X,41,3,%11,X,41,3,%12,X,41,3))
OUTFIL FNAMES=OUT,OMIT=(1,3,CH,EQ,C' ')
//*
The output from this is
Code:
200 AAA
201 AAA
204 BBB
205 BBB
206 BBB
207 BBB
208 CCC
209 000
111 000
222 000
333 000
444 000
555 000
666 000
777 000
888 000
999 000
Back to top
Please enable JavaScript!