View previous topic :: View next topic
Author
Message
vasantha.gl New User Joined: 23 Sep 2011Posts: 12 Location: Chennai
I have a input file(File1) and I want to generate sequence number in a output file(File3)
Starting number to generate the sequence number i need to get from other file(File2).
Can any one help me out to resolve this issue.
Back to top
xknight Active User Joined: 22 Jan 2008Posts: 117 Location: Liberty city
Hello,
Quote:
Can any one help me out to resolve this issue.
Post the I/P files (File 1,File 2) and O/P file (File 3) layout, only you could explain this better.
Also, ensure DFSORT is installed at your site.
Back to top
vasantha.gl New User Joined: 23 Sep 2011Posts: 12 Location: Chennai
File 1 Layout RECFM=FB,LRECL=80
File 2 Layout RECFM=FB,LRECL=80 sequence number Start is present at 10 position
File 3 Layout RECFM=FB,LRECL=80 generate sequence number at 10 position
sEQUENCE NUMBER IS ZD(LENGTH 6)
In Brief :
(get the sequence number from File2(10th position) and generate the next sequence numbers in File3(10th position))
we can Ignore File1 in picture.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
how many records are in file2 ?
Gerry
Back to top
vasantha.gl New User Joined: 23 Sep 2011Posts: 12 Location: Chennai
There are 12 records in the file2. Need to take Last record(12th) 10th position and start generating the sequence number in file3 10th position.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
try this
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD * File2
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY,SKIPREC=11
OUTREC BUILD=(C' OUTREC OVERLAY=(10:SEQNUM,6,ZD,START=',
10,6,ZD,ADD,+1,EDIT=(TTTTTT),C')',80:X)
/*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD * File1
1
2
3
/*
//SORTOUT DD SYSOUT=* File3
//SYSIN DD *
OPTION COPY
/*
// DD DSN=&&S1,DISP=(OLD,DELETE)
Gerry
Back to top
vasantha.gl New User Joined: 23 Sep 2011Posts: 12 Location: Chennai
Yes, The above code is working. Thanks a lot for your support.
But I have a Last change in this.
How can I write generated sequence number into File3 in 89th position(STEP0200 step).
Thanks in Advance
Back to top
vasantha.gl New User Joined: 23 Sep 2011Posts: 12 Location: Chennai
Thanks I got it.
By changing OUTREC to 86, i got what was expecting
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
this is another way of achieving the same, this time we extract the last record regardless of the number of records on input file.
Code:
//STEP0300 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
//*
//OUT DD DSN=&&S2,UNIT=SYSDA,SPACE=(TRK,(1)),DISP=(,PASS)
//TOOLIN DD *
SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST USING(CTL1)
//*
//CTL1CNTL DD *
OPTION COPY
OUTFIL BUILD=(C' OUTREC OVERLAY=(10:SEQNUM,6,ZD,START=',
10,6,ZD,ADD,+1,EDIT=(TTTTTT),C')',80:X)
//STEP0400 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1
2
3
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
/*
// DD DSN=&&S2,DISP=(OLD,DELETE)
Gerry
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
gcicchet,
I would suggest using reporting features TRAILER1 to pick the last record instead of subset as it would need 2 passes of data to get the last record.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
000101
000102
000103
000104
000015
000116
000107
000108
000109
000010
000111
000212
//SORTOUT DD DSN=&&S1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
OPTION COPY
INREC BUILD=(10,6,ZD,ADD,+1,EDIT=(TTTTTT))
OUTFIL REMOVECC,NODETAIL,BUILD=(80X),
TRAILER1=(' OPTION COPY',/,
' OUTREC OVERLAY=(10:SEQNUM,6,ZD,START=',1,6,C')')
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1
2
3
//SORTOUT DD SYSOUT=*
//SYSIN DD DSN=&&S1,DISP=SHR
//*
Back to top
Please enable JavaScript!