× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



CPYF does not use RRN in the FROMNBR, it uses the 'logical' record number,
i.e. deleted records are ignored.

RTVMBRD's NBRCURRCD also uses the 'logical' record numbers.

My technique does work, albeit a strange thing to want to do.



Regards

Jeff Bull
iSeries Technical Consultant
NYCO Ltd - iSeries & AS/400 Automation Specialists
Tel: +44(0)20 8416 3778
Fax: +44(0)20 8416 3779
Mobile: +44(0)77 5692 3335
Email: jeff.bull@xxxxxxxxxx
Website: www.nyco.co.uk
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Michael Schutte
Sent: 11 September 2012 15:20
To: Midrange Systems Technical Discussion
Subject: Re: program to read pf in reverse order using cl/400 program

Using the number of records in the file and the position to keyword is not a
good solution. As everyone should know, the highest relative record number
might not match the total number of records because of deleted records. You
would need to add the number of deleted records to the number of current
records (this may have been mentioned and maybe I missed it so sorry if
that's true).

Open Query File will not work either... because if you specify *ASCEND or
*DESCEND you must specify the field names that it will be ordered by. You
cannot specify *FILE or *NONE as Key Field when using *ASCEND or *DESCEND.
You get this error message when you do...
CPD0072 List item value for parameter KEYFLD required.
Cause . . . . . : A required list item was not specified.
Recovery . . . : Specify the missing list item.

If you must read the file in reverse order in a CL program. I suggest you go
with the SQL insert into the QTEMP table. ORDER BY RRN(tablename) DESC

Or maybe create a RPGLE service program to read the file for you.

In the service program, you would create a procedure to position to end of
file.

CLEAR MYDS;
SETLL *END FILE;
RETURN;

Create another procedure to read previous and load the data into a global DS
for the RPGLE service program.
CLEAR MYDS;
READP FILE MYDS;
RETURN %EOF();

Create more procedures that will return the variables from MYDS that were
read into the DS.

1. Return MYDS.Field1;
2. Return MYDS.Field2;
3. Return MYDS.FIeld3;

Then in your CLLE program you could...

CALLPRC PRC(POSITIONTOENDOFFILE)
CALLPRC PRC(READPREVIOUSRECORD) RTNVAL(&EOF) DOWHILE (&EOF = '0')
CALLPRC PRC(GETFIELD1VALUE) RTNVAL(&FIELD1)
CALLPRC PRC(GETFIELD2VALUE) RTNVAL(&FIELD2)
CALLPRC PRC(GETFIELD3VALUE) RTNVAL(&FIELD3)
CALLPRC PRC(READPREVIOUSRECORD) RTNVAL(&EOF) ENDDO

When you compile the CLLE you must compile as a module, then use the CRTPGM
command to bound the CLLE module with the RPGLE service program.

On Mon, Sep 10, 2012 at 4:33 PM, Scott Klement
<midrange-l@xxxxxxxxxxxxxxxx>wrote:

Please post the file that you'd like to see in reverse order.

On 9/10/2012 1:06 PM, Rishi Seth wrote:
could you please send the code for the logic you have explained?

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


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

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.