How can read PF in reverse order (end to start) in CL pgm..
Answers were Sorted based on User's Feedback
Answer / shyam
Use OVRDBF Share(*yes)
Use the Openqry file by specified the values on opnqry file
Key field . . . . . . . . . . *NONE
Key field order . . . . . . . *DESCEND
now read file using RCVF command.
Is This Answer Correct ? | 26 Yes | 11 No |
Answer / kavitha
POSDBF (*END) points to last record, wont the RCVF command sets on EOF indicator?
Is This Answer Correct ? | 11 Yes | 7 No |
Answer / harkesh
you can read a physical file in DESENDING ORDER. You can
first sort the physical file in decending order through
OPNQRYF using KEYFLD. This will sort your PF in decending
order based on your key field and then do the RCVF on this
file.
But for this you first need to do OVRDBF on the file.
THIS IS ONLY THE WAY ON THE WE CAN READ PF IN REVERSE ORDER
BUT FOR THIS FILE SHOULD BE KEYED FILE.
ANOTHER WAY FOR THIS ON THE BASIS OF RRN. FIRST FIND OUT
TOTAL NO OF RECORD USING RTVMBRDSC COMMMAND IN CL PROGRAM.
THEN MOVE TOTAL NO TO RRN. THEN BY USING OVRDBF COMMAND SET
POINTER ON THE BASIS OF RRN. AND IN LOOP ON THE BASIS OF
RRN. LIKE
LOOP: OVERDBF FILENAME POINTER = &RRN
IF RRN NOT = 0
RCVF RCDFMTNAME.
RRN= RRN-1.
ELSE
ENDPGM
END-IF.
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / sumit gupta
We can not read a pf in reverse order in CL/CLLE. As POSDBF
only set the pointer to *START or *END and once you set it
to *END and then do the read operation, end of file will
reach and there is not such condition(MONMSG) through which
you can read the pf in reverse order.
you can read a physical file in DESENDING ORDER. You can
first sort the physical file in decending order through
OPNQRYF using KEYFLD. This will sort your PF in decending
order based on your key field and then do the RCVF on this
file.
But for this you first need to do OVRDBF on the file.
Is This Answer Correct ? | 9 Yes | 7 No |
Answer / suresh
Since the requirement is to Read from end to start, the
parameter *END should be provided to Position.
The statement should look like:
POSDBF OPNID(file name) position(*END)
Is This Answer Correct ? | 16 Yes | 15 No |
Answer / amit
See Opnqryf is the right answer. Use the keyfield as told
by others. But it is not necessary to overide the file.
Is This Answer Correct ? | 0 Yes | 0 No |
I have a PF(ABC)with no key fields. PF(ABC)have 2 fields (cusno and cusname). Please let me know how can i read the cusno = 1150 directly from PF in CL and RPG program(Without creating the LF and without reading the complete file and then compare 1150)
what is the difference between SETON RT & RETURN?
How to add 2 new fields in a file? How many ways are there in as400?
how do you use commitment control in rpg?
How to update selected fields from pf without using update opcode. How to read all member in Rpg-3,without using any cl command?
What is the purpose of Panel Groups?
please guys help me,I need to write a program that shows more than one way to display a subfile. Both views are of the same file but sorted differently and show different fields of the same file when the user presses a function key. send me code
Suppose my file has 10 fields and I want to make the 2nd field zeros in all records. And assume I have millions of records and I dont want to read each record and update the desired field with 0. Any other way to do this in one step operation?
Anybody know the difference of primary file and full procedural file
1. What is bound-by-call and bound-by-reference? 2. Where and why is *Nomain used? 3. What are the difficulties faced by programmers when using service programs? 4. Explain the different ways of parsing and compiling XML in iSeries.
how do u find whether a record is locked or not??
What is Multi Occurrence Data Structure(MODS)?