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 deepu93213,370 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
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
…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.
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
Logic issue
If there are 8 records empno is displayed 9 times
Why?
Also, better to code %eof(employee)
Why?
Phil
your correct Mr. Phil, but i got error on the %eof line
error is -> Parameter EMPLOYEE is not valid for built-in function %EOF.
Yes, %eof(EMP) <- file name not record format name
…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
…by rpg/400 program
And does it have to be RPG/400? Why not use RPG from this century?
Tom
Thanks Tom
The code samples shown responding to this question pass muster for RPG IV but are not RPG/400.
Phil
@Phil:
We know it often doesn’t really matter. But it’s disturbing how often it actually does.
Tom