|
Hi, Vinay:
I would use the unix sort command for this.
Use CPYTOSTMF to put the file on the IFS. Then use QSH "sort" command.
Then use CPYFRMSTMF to put it back
For example:
CPYTOSTMF FROMMBR('/qsys.lib/mylib.lib/myfile.file/sortme.mbr')
TOSTMF('/tmp/sortme.in')
qsh cmd('sort -t x''1c'' -k2 < /tmp/sortme.in > /tmp/sorted.out')
CPYFRMSTMF FROMSTMF('/tmp/sorted.out')
TOMBR('/qsys.lib/mylib.lib/myfile.file/sorted.mbr')
Above will
take member SORTME of file MYLIB/MIFILE, put it onto the /tmp
directory, named sortme.in
sort /tmp/sortme.in by the second "key", where the keys are
separated by x'16'
producing /tmp/sorted.out
copy sorted.out inot member SORTED of MYLIB/MYFILE
Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"This is the most extraordinary collection of talent, of human knowledge,
that has ever been gathered together at the White House -- with the
possible
exception of when Thomas Jefferson dined here alone."
-- John F. Kennedy (to Nobel Prize winners)
I have a flat file, which has fields delimited by field separators and a2
character field tag. The actual fields are variable length, so not in afixed
position.thru
For example, my field separator is hex '1C' and the field tags are A1
A6.
Tag A1 denotes First name, A2 Last name, A3 Address Line 1, A4 AddressLine 2
etc.could
I want to sort by last name, which will be a variable length field, and
occur anywhere in the record (as the First name is also of variablelength).
It will always be enclosed between hex '1C'A2 and hex '1C' (it will neverbe
the first or the last field in the record).this
What would be the best way of doing this? (The only solution I have is to
write a program to create an intermediate file, with the Last Name as a
separate field).
The file is actually 4000 bytes and has about 18 million records, but
would be a one time effort.list To
TIA
Vinay
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,or
change list options,moment
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
to review the archives at http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.