I can confirm that the OPNQRYF as I presented it does work. The Cobol reads the file by the key I specified. My problem remains, that if the input file is externally defined with multiple fields, I have no way to determine within which field my desired sort position/length exists, so I can't simple use a position/length as in my example. Again, that works fine if the file has a single, long field. Also to reiterate, the file itself is not keyed. Perhaps we should not be using the term keyed, but rather emphasizing that I want to read the file, in Cobol, sorted by an arbitrary position/length known only at run time.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Dan Kimmel
Sent: Wednesday, September 25, 2013 9:48 AM
To: Midrange Systems Technical Discussion
Subject: RE: Sort input file by arbitrary position/length

Joel,

I think Jeff is right. Using OPNQRYF with COBOL sequential access, the records will be presented to the program in the order of the keys used in the OPNQRYF.

It has been a long time ago, but this is one of the techniques we used to make Sys/36 programs work on the AS400. Those RPG2 or COBOL programs had none of the key extensions. We converted the $GSORT specs to OPNQRYF and recompiled the original source. Programs read the files as if they were physically sequenced.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-
bounces@xxxxxxxxxxxx] On Behalf Of Stone, Joel
Sent: Wednesday, September 25, 2013 9:41 AM
To: Midrange Systems Technical Discussion
Subject: RE: Sort input file by arbitrary position/length

No I don't think that is accurate (but I have been wrong before :)

Your stmt is accurate ONLY if the file is described in the COBOL
source as "ORGANIZATION IS INDEXED" and "RECORD KEY IS ..."

The RPG equivalent of "K" in the right spot for a file spec.

But his COBOL pgm has the file defined WITHOUT a key, so I am pretty
sure it will read it in the arrival sequence REGARDLESS of any keys or overrides.




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

Joel,
By using the OVRDBF command with SHARE(*YES), the COBOL program will
read the file using the Access Path created by the OPNQRYF.



On Wed, Sep 25, 2013 at 10:24 AM, Stone, Joel <Joel.Stone@xxxxxxxxxx>
wrote:

Have you actually tried this? I don't think that this will work as
you are proposing.

When you run OPNQRYF, if creates the equivalent of a temp LF. When
COBOL
reads this temp LF, it will read it as a PF (assuming no changes to
the COBOL pgm to access C1BMNAM by key).

You would have to do CPYFRMQRYF after the OPNQRYF to order the
physical
data - then the COBOL pgm would read in the sequence that you desire.

If the requirement is to NOT touch the COBOL pgm, then the physical
data must be re-ordered. I would expect FMTDTA to be faster than
OPNQRYF/CPYFRMQRYF or any other method.

But, it is so simple to change the COBOL to read an indexed file.
Maybe there are other constraints which require no changes to the COBOL.

Another option is SQL to re-order the data.

I don't see how OPNQRYF or LF or any kind of index will get you there.




--
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.