940 pts.
 Reading physical file in reverse order by rpg/400 program
Dear all,

How to read a physical file in reverse order by rpg/400 program,condition is there is not any key field in this file.

Thanks



Software/Hardware used:
AS/400
ASKED: December 29, 2011  5:23 AM
UPDATED: February 28, 2012  1:18 PM

Answer Wiki:
Hi 6r, You can set the Pointer at the End of file, using <b>SETGT</b> & <b>*HIVAL</b>. Use <b>READP</b> for reading the file in Reverse order. Pradeep.
Last Wiki Answer Submitted:  December 29, 2011  5:30 am  by  deepu9321   3,370 pts.
All Answer Wiki Contributors:  deepu9321   3,370 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

just simple coding for you.. follow this..

F emp if e disk -> declare my PF
C *hival setll employee -> set high value in pf record
C dow not %eof
C readp employee
C empno dsply
C enddo
C eval *inlr = *on

 3,740 pts.

 

Logic issue
If there are 8 records empno is displayed 9 times
Why?
Also, better to code %eof(employee)
Why?

Phil

 44,130 pts.

 

your correct Mr. Phil, but i got error on the %eof line

error is -> Parameter EMPLOYEE is not valid for built-in function %EOF.

 3,740 pts.

 

Yes, %eof(EMP) <- file name not record format name

 44,130 pts.

 

…read a physical file in reverse order by rpg/400 program,condition is there is not any key field…

If there is no key, how are you defining “reverse order”? Do you want them in the reverse order that records were added to the file? Do you want them in reverse order based on relative record number? Do you want to read them in reverse order of the values of fields in the file? (They don’t have to be “keys” to do that.) Or do you have a different definition? Each way can have a different method.

Tom

 107,995 pts.

 

…by rpg/400 program

And does it have to be RPG/400? Why not use RPG from this century?

Tom

 107,995 pts.

 

Thanks Tom
The code samples shown responding to this question pass muster for RPG IV but are not RPG/400.
Phil

 44,130 pts.

 

@Phil:

We know it often doesn’t really matter. But it’s disturbing how often it actually does.

Tom

 107,995 pts.