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 a 2
character field tag. The actual fields are variable length, so not in a
fixed
position.

For example, my field separator is hex '1C' and the field tags are A1 thru
A6.
Tag A1 denotes First name, A2 Last name, A3 Address Line 1, A4 Address
Line 2
etc.

I want to sort by last name, which will be a variable length field, and
could
occur anywhere in the record (as the First name is also of variable
length).
It will always be enclosed between hex '1C'A2 and hex '1C' (it will never
be
the first or the last field in the record).

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 this
would be a one time effort.

TIA
Vinay
--
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 thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.