View previous topic :: View next topic
|
Author |
Message |
VivekKhanna
New User
Joined: 09 Feb 2009 Posts: 57 Location: India
|
|
|
|
Hi,
I have a flat file mentioned below:
Code: |
----+---10----+---20----+---30----+---40
A10000 AAAA
B20000 ASDA
A12000 25325
R25411 36365
S25454 23655
|
Now, the out required should contain only the 1st six columns of the input file, along with Sequence# in 1st column of the output file. The format of output file should be:
Code: |
----+---10----+---20----+---30----+---40
1A10000
2B20000
3A12000
4R25411
5S25454
|
I had tried using SORT, but only succeeded in get the output except Sequence#. The Sort Card used is:
Code: |
//STPSORT EXEC PGM=SORT
//SORTIN DD DSN=INPUT.FILE,DISP=SHR
//SORTOUT DD DSN=OUTPUT.FILE1,
// DISP=(NEW,CATLG,DELETE),
// DCB=*.SORTIN
//SYSIN DD *
SORT FIELDS = COPY
OUTFIL OUTREC=(1:1X'40',2:1,6,8:5X'40')
/*
|
I tried a no. of things, but didn't succeed in getting the Sequence#. Please guide. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
You need SEQNUM parameter of DFSort. I'm not connected to mainframes, however, please try this untested code:
Code: |
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:SEQNUM,1,ZD,2:1,6,40:X)
/* |
|
|
Back to top |
|
|
ChowHan
New User
Joined: 16 Oct 2009 Posts: 15 Location: India
|
|
|
|
What happens when the 10th record is reached ? I guess i will try this one out myself. |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
Quote: |
What happens when the 10th record is reached ? I guess i will try this one out myself.
|
You will need to decide how many bytes yu are going to use for the SEQNUM.
Also if the output file is 40 bytes long, you need to use this
Code: |
SORT FIELDS=COPY
OUTREC FIELDS=(SEQNUM,1,ZD,1,6,40:X)
|
Gerry |
|
Back to top |
|
|
VivekKhanna
New User
Joined: 09 Feb 2009 Posts: 57 Location: India
|
|
|
|
This was for a test purpose. Actual length of Sequence# is 8 bytes. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Ok, any other hiding fact?
For sequence# of length 8
Code: |
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:SEQNUM,8,ZD,9:1,6,40:X)
/* |
|
|
Back to top |
|
|
prem_ibm
New User
Joined: 15 Sep 2007 Posts: 31 Location: Chennai
|
|
|
|
Hi All,,
Need small clarity........suppose file lentgh is fixed as below
LRECL=40.
1)if i want to add sequence number(1 'minimum' to 8'maximum' digit) at the end of file OR at begining,...it will allow or thorugh error due to fixed length i.e 80.
2)If allow then what about our records which present on those columns....
i am very sorry if it looks minor doubt...but need proper answer.
Thank
Prem..... |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
If you start with RECFM=FB,LRECL=40 and pre-pend or append 8 bytes, DFSORT will give you an output file RECFM=FB,LRECL=48. If you want to have LRECL=80 output, put a blank in position 80 and DFSORT will oblige. If you put your SEQNUM starting in position 73, you would also get LRECL=80.
Garry. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
i am very sorry if it looks minor doubt...but need proper answer.
|
To get a proper answer, you must ask your question clearly, which you haven't done.
What exactly is it you want to do? What is the RECFM and LRECL of the input file? What do you want for the RECFM and LRECL of the output file? What exactly do you want the output file to look like? Do you want to create a new output file, or use an existing file for output?
Quote: |
2)If allow then what about our records which present on those columns.... |
Huh? I have no idea what this means. |
|
Back to top |
|
|
smijoss
Active User
Joined: 30 Aug 2007 Posts: 114 Location: pune
|
|
|
|
"If allow then what about our records which present on those columns...." -
Obviously you records will get shifted to right if you add seqnum to left.
if you want to keep the output file length fixed at 40, adjust you build parameter.
DFSORT will not THROW error. if you dont adjsust the Build in outrec it will change your output LRECL. |
|
Back to top |
|
|
|