Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Ambili S,
The following DFSORT JCL will give you the desired results.
I assumed that your input is FB recfm and 80 byte LRECL
You can use the WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) to retain the group of records like this:
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
USER1 COMPUTER MATHS
SCIENCE ECONOMICS
HISTORY BIOLOGY
USER2 HINDI GEOGRAPHY
MATHS HISTORY
ENG COMPUTER
USER3 HISTORY ENG
MATHS HINDI
//T1 DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) USING(CTL2)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'USER'),
PUSH=(81:ID=8,SEQ=8)),
IFTHEN=(WHEN=(1,80,SS,EQ,C'ENG'),OVERLAY=(97:C'Y'))
SORT FIELDS=(81,8,CH,A,97,1,CH,D)
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(97,1,CH,EQ,C'Y'),PUSH=(97:97,1))
OUTFIL FNAMES=T1,INCLUDE=(97,1,CH,EQ,C'Y')
//CTL2CNTL DD *
SORT FIELDS=(81,16,CH,A)
OUTFIL FNAMES=OUT,BUILD=(1,80)
/*
If you don't have the July, 2008 PTF installed, ask your System Programmer to install it (it's free).
For complete details on the new WHEN=GROUP and the other new functions available with PTF UK90013, see:
I am getting "STATEMENT DEFINE ERROR" while running the above JCL. I am able to use, ICETOOL and the INREC=WHEN syntax. But with WHEN=GROUP i am getting error.
I tried using FINDREP syntax to replace all 'User' to 'Name' .
I tried submitting the below JCL(as suggested by you above).
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
USER1 COMPUTER MATHS
SCIENCE ECONOMICS
HISTORY BIOLOGY
USER2 HINDI GEOGRAPHY
MATHS HISTORY
ENG COMPUTER
USER3 HISTORY ENG
MATHS HINDI
//T1 DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) USING(CTL2)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'USER'),
PUSH=(81:ID=8,SEQ=8)),
IFTHEN=(WHEN=(1,80,SS,EQ,C'ENG'),OVERLAY=(97:C'Y'))
SORT FIELDS=(81,8,CH,A,97,1,CH,D)
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(97,1,CH,EQ,C'Y'),PUSH=(97:97,1))
OUTFIL FNAMES=T1,INCLUDE=(97,1,CH,EQ,C'Y')
//CTL2CNTL DD *
SORT FIELDS=(81,16,CH,A)
OUTFIL FNAMES=OUT,BUILD=(1,80)
/*
This gave me the desired output. But in Substring when i tried with 'BIO' option instead of 'ENG' the output i obtained was same as the input.
I couldn't figure out what went wrong.
Also could you please throw more light on the OUTREC WHEN=GROUP syntax given above.