Assuming there's an easy way to get the list of fields in the input file, I believe I can do this with 2 mapped fields:

OPNQRYF FILE((METZ3410/PF2)) KEYFLD((*MAPFLD/ZIP)) +
MAPFLD((ONEBIGFLD 'pf2f1 *cat pf2f2 *cat +
pf2f3') (ZIP '%sst(onebigfld 133 5)')) +
OPNID(C1BMNAM) SEQONLY(*NO) OPNSCOPE(*JOB)

However, if any of the fields I'm concatenating are not strings, I'm thinking the offsets could change between the actual physical file and my concatenated representation, so the user-provided offset of 133, length of 5 might have shifted. In fact, I don't think I can simply concatenate numeric fields to a string.

Looks like I'm at a dead end. Unless I'm willing to make a copy of the input file, I don't see any way to sort it. If there were just a way to view the file as one long record regardless of its actual external description, I could do it with OPNQRYF.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Jeff Young
Sent: Wednesday, September 25, 2013 2:50 PM
To: Midrange Systems Technical Discussion
Subject: Re: Sort input file by arbitrary position/length

Try this:
1. Create a permanent physical file with the same format as your existing file, PLUS a number (10 should be good) of 32 byte (or longer if needed) fields that will be used for sorting.
2. Build the OPNQRYF command in a CL variable with the fixed parts as a constant, along with the FORMAT keyword to refer to your new file and the KEYFLD keyword sorting by the new fields in your format file. For the MAPFLD keyword, specify the sort field name and the value as %sst() .
ie: OPNQRYF FILE(MYFILE) FORMAT(MYFILE_S) QRYSLT(....) KEYFLD(KEY1 KEY2
KEY3) MAPFLD(
Then build your MAPFLD expression as another variable and concatenate the result into a string variable that you will pass to QCMDEXC to execute.
Then, in your OVRDBF command, specify the TOFILE keyword as the FORMAT file with SHARE(*YES).
This should give you what you want.

________________________________


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.