View previous topic :: View next topic
Author
Message
neopandya New User Joined: 02 Mar 2010Posts: 8 Location: Bangalore
Hi,
I have the below requirement to be performed using DFSORT.
Input File
Code:
----+----1----+--
IBMMAINFRAMES0106
IBMMAINFRAMES0508
Based on the value in positions (14,2) and (16,2) I need to cut a part of the string from (1,13)
Required Output File
Code:
----+----1----
IBMMAI
INFRAMES
Can someone tell me if this is possible using DFSORT?
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Are you saying that you want to use the value in 14,2 as the starting position and the value in 16,2 as the length?
If so, that would be:
01-06 -> IBMMAI
05-08 -> AINFRAME
so why do you show INFRAMES instead of AINFRAME?
Please do a better job of explaing what you're trying to do. Also, give the RECFM and LRECL of the input file.
Back to top
neopandya New User Joined: 02 Mar 2010Posts: 8 Location: Bangalore
Yes Frank, my mistake there
My expected output should have been as you mentioned -
Code:
----+----1----
IBMMAI
AINFRAME
LRECL = 17 and RECFM = FB (for input)
LRECL = 13 and RECFM = FB (for output)
And yes, the value in 14,2 is to be used as the starting position and the value in 16,2 is to be used as the length.
Back to top
Guest
Hi Neo,
Please find the jcl for your requirement:
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
IBMMAINFRAMES0106
IBMMAINFRAMES0508
//SORTOUT DD DSN=CARD.NEXT,DISP=OLD
//SYSIN DD *
OPTION COPY
OUTREC OVERLAY=(81:SEQNUM,3,ZD)
OUTFIL REMOVECC,NODETAIL,BUILD=(80X),
HEADER1(' INREC OVERLAY=(81:SEQNUM,3,ZD)',/,
' OPTION COPY',/,
' OUTREC IFTHEN=(WHEN=(81,3,CH,EQ,C''','AAA''','),',/,
' BUILD(1,80)),'),
SECTIONS=(81,3,
HEADER3=(' IFTHEN=(WHEN=(81,3,ZD,EQ,',81,3,'),',/,
' BUILD=(',14,2,',',16,2,')),'),
TRAILER3=('*')),
TRAILER1=(' IFTHEN=(WHEN=(81,3,CH,EQ,C''','AAA''','),BUILD=(1,80))')
/*
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
IBMMAINFRAMES0106
IBMMAINFRAMES0508
//SORTOUT DD SYSOUT=*
//SYSIN DD DSN=CARD.NEXT,DISP=SHR
Please let me know if your requirement is met.
Hope better suggestions would flow in
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10873 Location: italy
nice attempt
but the sort control statements of the first step
<build> an IFTHEN/BUILD for each and every record of SORTIN
nobody will care/notice if SORTIN contains very/very few records
but if the file is large ... ... !
even if the question looks academic, it is worth meditating anyway on the <best> solution
... <sort> on the <substring> start/length <build> the IFTHEN/BUILD only once for each <substring> start/length
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
devil13,
Here's an attempt to simplify your first sortcard.
Code:
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(81:SEQNUM,3,ZD)
OUTFIL REMOVECC,
HEADER1=(' OPTION COPY',/,
' INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,3,ZD)),'),
BUILD=(C' IFTHEN=(WHEN=(81,3,ZD,EQ,',81,3,C'),',80:X,/,
C' BUILD=(',14,2,C',',16,2,C')),'),
TRAILER1=(' IFOUTLEN=13')
But as enrico said already, it might not be the best approach when there are more input records.
Back to top
Guest
Enrico,
Thanks!! I strongly second your opinion. If the file is small then this can be used else its not the best approach
Arun,
Thanks for the new method. I am learning a lot from here
Rajesh,
You can use the function Subset of ICETOOL to attain this.
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=INPUT.TEST1,DISP=OLD
//OUT1 DD DSN=OUTPUT.TEST2,DISP=OLD
//TOOLIN DD *
SUBSET FROM(IN1) TO(OUT1) INPUT KEEP HEADER TRAILER
/*
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
devil13 wrote:
Rajesh,
You can use the function Subset of ICETOOL to attain this.
How does this relate to the topic!!!
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10873 Location: italy
Back to top
Guest
Yeah Enrico is right
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
I would suggest writing an E15 or E35 exit to do this. The exit could easily extract the starting position and length from each record , use them to extract the needed bytes, and pass them back to DFSORT for output. There's really no built-in functions for that kind of thing.
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
neopandya,
As Frank pointed out , an exit is the right way to do it. However your input LRECL is only 13 and hence the result can be achieved using a bunch of IFTHEN statements. The trick here is to pad the starting bytes with spaces to pick the values from middle. for ex if you want to pick the string from pos 5 for 8 bytes you pad out the first 4 bytes with spaces and then use JFY to shift to the left making the 5th byte as 1st byte. To know the number of spaces to be filled , just subtract 1 from the begin position. Once you get that then it is easy to build the output file like shown below.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
IBMMAINFRAMES0106
IBMMAINFRAMES0508
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(18:14,2,ZD,SUB,+1,EDIT=(TT))),
IFTHEN=(WHEN=(18,2,ZD,EQ,01),OVERLAY=(1:01X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,02),OVERLAY=(1:02X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,03),OVERLAY=(1:03X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,04),OVERLAY=(1:04X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,05),OVERLAY=(1:05X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,06),OVERLAY=(1:06X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,07),OVERLAY=(1:07X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,08),OVERLAY=(1:08X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,09),OVERLAY=(1:09X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,10),OVERLAY=(1:10X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,11),OVERLAY=(1:11X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,12),OVERLAY=(1:12X))
OUTREC IFOUTLEN=13,
IFTHEN=(WHEN=INIT,OVERLAY=(1:1,13,JFY=(SHIFT=LEFT))),
IFTHEN=(WHEN=(16,2,ZD,EQ,01),BUILD=(1,01)),
IFTHEN=(WHEN=(16,2,ZD,EQ,02),BUILD=(1,02)),
IFTHEN=(WHEN=(16,2,ZD,EQ,03),BUILD=(1,03)),
IFTHEN=(WHEN=(16,2,ZD,EQ,04),BUILD=(1,04)),
IFTHEN=(WHEN=(16,2,ZD,EQ,05),BUILD=(1,05)),
IFTHEN=(WHEN=(16,2,ZD,EQ,06),BUILD=(1,06)),
IFTHEN=(WHEN=(16,2,ZD,EQ,07),BUILD=(1,07)),
IFTHEN=(WHEN=(16,2,ZD,EQ,08),BUILD=(1,08)),
IFTHEN=(WHEN=(16,2,ZD,EQ,09),BUILD=(1,09)),
IFTHEN=(WHEN=(16,2,ZD,EQ,10),BUILD=(1,10)),
IFTHEN=(WHEN=(16,2,ZD,EQ,11),BUILD=(1,11)),
IFTHEN=(WHEN=(16,2,ZD,EQ,12),BUILD=(1,12)),
IFTHEN=(WHEN=(16,2,ZD,EQ,13),BUILD=(1,13))
//*
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Good one Kolusu.
Back to top
Please enable JavaScript!