Rishi, consider OPNQRYF with the KEYFLD parameter set at *DESCEND.

http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Fdbp%2Frbafoopnqf.htm

Here is an example they provide:
OPNQRYF FILE(ordfile) OPTION(*ALL)
QRYSLT('orddate=%range("840101" "841231") &
ordamt>100')
KEYFLD((ordamt *descend))

There are issues you will run into as you use this solution, but they are generally trivial once you re-read the manual.

On 9/10/2012 2:05 PM, Stone, Joel wrote:
Oops - this probably wont work - I think that OVRDBF only works once with RCVF. SQL should work to add a new field containing the RRN and then RCVF on that new field descending.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Stone, Joel
Sent: Monday, September 10, 2012 2:01 PM
To: 'Midrange Systems Technical Discussion'
Subject: RE: program to read pf in reverse order using cl/400 program

Rishi -

People rarely send the "exact code" on these tech forums. It makes it sound like you are asking others to do your work (or homework) for you, and people don't want to do that.

However, iseries developers do like to point people in the right direction.

That said, maybe you could try something like the following (although I have no idea if this will work)

Rtvmbrd filename NBRCURRCD (&rrn)

topOfLoop:
Ovrdbf filename POSITION(*RRN &rrn)
rcvf
Chgvar &rrn (&rrn - 1)
If (&rrn > 0) goto TopOfLoop


This is the most direct method I can think of. Using a less direct alternative, SQL or OPNQRYF would allow you to add a sequential # to each record, then RCVF the view in descending order.



-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Rishi Seth
Sent: Monday, September 10, 2012 10:56 AM
To: midrange-l@xxxxxxxxxxxx
Subject: program to read pf in reverse order using cl/400 program

Hi,

I want to read a physical file in reverse order using cl program condition
is there should not be any logical file
in this program.If somebody could please send the exact code for this then
it would really be helpful to understand the logic.

Thanks






Return to Archive home page | Return to MIDRANGE.COM home page