View previous topic :: View next topic
Author
Message
Sammmy New User Joined: 30 Dec 2011Posts: 3 Location: AUstralia
Hi,
I was trying to add a sequence number to a file which has a Lrecl = 950.
I tried to use the restart parameter and later learnt that it has a limitation of Lrecl of 256.
Sample input record -
1-2-3-4-5 .... 948-949-950
AAAAAA .... A
AAAAAA .... A
BBBBBB .... B
1-2-3-4-5 .... 948-949-950
AAAAAA .... A 01
AAAAAA .... A 02
BBBBBB .... B 01
I was using a control card as below -
SORT FIELDS=(1,948,CH,A)
OUTFIL FNAMES=O1,OVERLAY=(949:SEQNUM,2,ZD,RESTART=(1,948))
Thanks...
Sam.
Can you please suggest me a alternate way ?
Back to top
sqlcode1 Active Member Joined: 08 Apr 2010Posts: 577 Location: USA
Sammmy,
See if below helps...
May be there is a better way, but the logic below is to use RESTART for the block of 256 bytes and assign sequence numbers. Later use these sequence numbers to make decision.
Code:
//STEP0001 EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=INPUT.FB950
//SORTOUT DD DSN=OUTPUT.FB950,
// DISP=(,CATLG,DELETE),
// UNIT=SYSDA
//SYSIN DD *
SORT FIELDS=(1,948,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(951:SEQNUM,8,ZD,RESTART=(001,256),
959:SEQNUM,8,ZD,RESTART=(257,256),
967:SEQNUM,8,ZD,RESTART=(513,256),
975:SEQNUM,8,ZD,RESTART=(769,180),
983:C'N')),
IFTHEN=(WHEN=(951,8,ZD,EQ,1,OR,
959,8,ZD,EQ,1,OR,
967,8,ZD,EQ,1,OR,
975,8,ZD,EQ,1),OVERLAY=(983:C'Y'))
OUTFIL IFTHEN=(WHEN=GROUP,BEGIN=(983,1,CH,EQ,C'Y'),PUSH=(949:SEQ=2)),
IFTHEN=(WHEN=INIT,BUILD=(1,950))
/*
//SYSOUT DD SYSOUT=*
//*
Thanks,
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
sqlcode1's solution is quite clever and only takes one pass. For simplicity, I would have used this OUTFIL statement:
Code:
OUTFIL IFOUTLEN=950,
IFTHEN=(WHEN=GROUP,BEGIN=(983,1,CH,EQ,C'Y'),PUSH=(949:SEQ=2))
FWIW, here's another DFSORT/ICETOOL solution. However, this one requires two passes:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (FB/950)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file (FB/950)
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
COPY FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
SORT FIELDS=(1,948,CH,A),EQUALS
OUTFIL FNAMES=T1,REMOVECC,
SECTIONS=(1,256,257,256,513,256,769,180,
HEADER3=(1:'***'))
/*
//CTL2CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'***'),
PUSH=(949:SEQ=2))
OUTFIL OMIT=(1,3,CH,EQ,C'***'),
OVERLAY=(949:949,2,ZD,SUB,+1,TO=ZD,LENGTH=2)
/*
Back to top
Sammmy New User Joined: 30 Dec 2011Posts: 3 Location: AUstralia
Thanks sqlcode1 and Frank... you Rock .. I will test them and update ...
Back to top
Please enable JavaScript!